From: R David Murray Date: Thu, 7 Mar 2013 21:43:58 +0000 (-0500) Subject: Merge: #14645: Generator now emits correct linesep for all parts. X-Git-Tag: v3.3.1rc1~80 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=addb0be63e82fd99d931c227b07a8f515ad3d181;p=thirdparty%2FPython%2Fcpython.git Merge: #14645: Generator now emits correct linesep for all parts. Previously the parts of the message retained whatever linesep they had on read, which means if the messages weren't read in univeral newline mode, the line endings could well be inconsistent. In general sending it via smtplib would result in them getting fixed, but it is better to generate them correctly to begin with. Also, the new send_message method of smtplib does not do the fixup, so that method is producing rfc-invalid output without this fix. --- addb0be63e82fd99d931c227b07a8f515ad3d181 diff --cc Lib/email/generator.py index de9da391248c,cba0382fedb3..27dd0db3c1ed --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@@ -399,10 -404,10 +413,10 @@@ class BytesGenerator(Generator) # just write it back out. if msg._payload is None: return - if _has_surrogates(msg._payload): + if _has_surrogates(msg._payload) and not self.policy.cte_type=='7bit': if self._mangle_from_: msg._payload = fcre.sub(">From ", msg._payload) - self.write(msg._payload) + self._write_lines(msg._payload) else: super(BytesGenerator,self)._handle_text(msg)