This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: email.message : get_payload args's documentation is confusing
Type: behavior Stage:
Components: Documentation Versions: Python 3.0, Python 3.1, Python 2.7, Python 2.6
Status: closed Resolution: postponed
Dependencies: Superseder:
Assigned To: georg.brandl Nosy List: georg.brandl, r.david.murray, trolldbois
Priority: normal Keywords:

Created on 2009-05-06 23:45 by trolldbois, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg87353 - (view) Author: Loic Jaquemet (trolldbois) Date: 2009-05-06 23:45
From documentation :

get_payload([i[, decode]])

"With optional argument i,[..] If the payload is a string (i.e.
is_multipart() is False) and i is given, a TypeError is raised."


"Optional decode is a flag [..] When True and the message is not a
multipart, the payload will be decoded if this header’s value is
quoted-printable or base64. [..]"

Now the bug : 
On a non-multipart b64 email,
how can the second-level-option "decode" be used, when using
first-level-optional 'i' throws an exception...

Two fixes possible : 
a) code fix
b) documentation fix
msg87355 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-05-07 01:46
The answer is that you do msg.get_payload(decode=True).  The doc needs
to be changed over to use keyword argument specification syntax, which I
think would make that obvious.
msg87372 - (view) Author: Loic Jaquemet (trolldbois) Date: 2009-05-07 12:15
Ok, I understand.

+ -> I need to learn python 
msg87373 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-05-07 13:09
No fault of yours, it's a real doc bug.  I've been programming in python
since 1997 or so, and I had to read the source code to figure it out
when I went to use get_payload a couple months ago.  That's why your bug
report caught my eye.  And even then I misremembered the answer and had
to look at the source code again to get it right.
msg87965 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-05-17 08:32
Will be fixed along with all other such instances.
Date User Action Args
2022-04-11 14:56:48adminsetgithub: 50201
2009-05-17 08:32:26georg.brandlsetstatus: open -> closed
resolution: postponed
messages: + msg87965
2009-05-07 13:09:51r.david.murraysetmessages: + msg87373
2009-05-07 12:15:51trolldboissetmessages: + msg87372
2009-05-07 01:46:35r.david.murraysetnosy: + r.david.murray

messages: + msg87355
versions: - Python 2.5, Python 2.4
2009-05-06 23:47:05trolldboissetversions: + Python 2.5, Python 2.4, Python 3.0, Python 3.1, Python 2.7
2009-05-06 23:45:20trolldboiscreate