[issue27397] email.message.Message.get_payload(decode=True) raises AssertionError that "should never happen"

R. David Murray report at bugs.python.org
Fri Jul 29 10:09:16 EDT 2016


R. David Murray added the comment:

Returning the undecoded payload is a good idea.  Let's go with that.

The email module, unlike most stdlib packages, has a mandate that the parser should never raise an error.  Instead we do our best to guess (very unlike everything else in python!) and note 'defects' in the message.  The reason this is the case is Postel's Law, which has become one of the guiding principles in dealing with email over the years: "be conservative in what you do, and generous in what you accept".  So, the generator will raise errors (if the original input didn't come from the parser), but the parser will not, if at all possible.

(For those who want aggressive error checking, python3 the 'raise_on_defect' policy setting.)

For the versions, we use that field to indicate which versions the bug will get fixed in, which is why I removed 3.4.

----------
versions:  -Python 3.4

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


More information about the Python-bugs-list mailing list