[issue14740] get_payload(n, True) returns None

R. David Murray report at bugs.python.org
Mon May 7 15:57:48 CEST 2012


R. David Murray <rdmurray at bitdance.com> added the comment:

Thanks for the report and patch suggestion, but...

This is actually the way it is designed to work.  get_payload(i) returns the ith element of a multipart payload.  Your workaround is in fact the correct way to do this operation.  decode=True is documented to return None if is_multipart is True.

You will note that if decode=False, you get back the Message sub-object, not a string.  Since decoding a Message object (as opposed to its payload) is not a meaningful operation, None is returned for decode=True.  Arguably we should raise a TypeError or ValueError instead, but we don't for historical reasons.

----------
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> closed

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14740>
_______________________________________


More information about the Python-bugs-list mailing list