[issue7143] get_payload(decode=True) eats last newline

R. David Murray report at bugs.python.org
Mon Jan 11 02:47:22 CET 2010


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

The behavior you object to is in fact correct per RFC 2046, 5.5.1:

   The boundary delimiter MUST occur at the beginning of a line, i.e.,
   following a CRLF, and the initial CRLF is considered to be attached
   to the boundary delimiter line rather than part of the preceding
   part.

So in your example message your attatched file does not in fact have a final newline.  Note that you do not get a newline regardless of whether decode is true ('p' is the part extracted from your sample message):

>>> p.get_payload()
'MTIzCg=='
>>> p.get_payload(decode=True)
'123'

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

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


More information about the Python-bugs-list mailing list