Merge: #14645: Generator now emits correct linesep for all parts.
authorR David Murray <rdmurray@bitdance.com>
Thu, 7 Mar 2013 21:43:58 +0000 (16:43 -0500)
committerR David Murray <rdmurray@bitdance.com>
Thu, 7 Mar 2013 21:43:58 +0000 (16:43 -0500)
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.

1  2 
Lib/email/generator.py
Lib/test/test_email/test_email.py
Misc/NEWS

index de9da391248caec99f7933f763f56afddce2b459,cba0382fedb38a9371bb92087a7f199ede71152b..27dd0db3c1ed4daec73bb7c4d236309e7af97185
@@@ -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)
  
Simple merge
diff --cc Misc/NEWS
Simple merge