[issue1349106] email.Generator does not separate headers with "\r\n"
R. David Murray
report at bugs.python.org
Wed Oct 20 03:33:17 CEST 2010
R. David Murray <rdmurray at bitdance.com> added the comment:
Malcolm: a Content-Transfer-Encoding of 8bit may only contain \r and \n characters as part of the line ending sequence. 8bit is *not* binary; to use a CTE of binary the SMTP server must support BINARYMIME, which I don't think is all that common yet. At any rate, my up-to-date postfix server doesn't support it.
And in any case, the email package doesn't support the binary CTE, so it's kind of irrelevant anyway :)
All that said, however, it certainly seems useful to be able to generate crlf terminated messages as an option. And it turns out that that capability is needed in order to be able to generate binary messages in Python3 while still remaining backward compatible with the behavior of Python2 when parsing binary messages (see issue 10134). (Actually I think the scenario I'm finding problematic in Python3 is also problematic in Python2, it's just that there are tricks you can use to work around it in Python2 that aren't allowed in Python3 because of the byte/string separation.)
So, attached find a patch implementing a linesep option in Generator.flatten and Header.encode.
Note that this patch also fleshes out the currently abbreviated documentation for BytesGenerator.
stage: unit test needed -> patch review
title: email.Generators does not separates headers with "\r\n" -> email.Generator does not separate headers with "\r\n"
versions: -Python 2.7
Added file: http://bugs.python.org/file19291/email_linesep.patch
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list