[Python-checkins] cpython (merge default -> default): Merged with hg.python.org.

reid.kleckner python-checkins at python.org
Wed Mar 16 22:10:11 CET 2011


http://hg.python.org/cpython/rev/84b7a68445aa
changeset:   68620:84b7a68445aa
parent:      68619:2e4879d44604
parent:      68617:de2cd04e5101
user:        Reid Kleckner <reid at kleckner.net>
date:        Wed Mar 16 17:09:41 2011 -0400
summary:
  Merged with hg.python.org.

files:
  

diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py
--- a/Lib/email/encoders.py
+++ b/Lib/email/encoders.py
@@ -12,7 +12,7 @@
     ]
 
 
-from base64 import b64encode as _bencode
+from base64 import encodebytes as _bencode
 from quopri import encodestring as _encodestring
 
 
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -573,9 +573,18 @@
         msg['Dummy'] = 'dummy\nX-Injected-Header: test'
         self.assertRaises(errors.HeaderParseError, msg.as_string)
 
-
 # Test the email.encoders module
 class TestEncoders(unittest.TestCase):
+
+    def test_EncodersEncode_base64(self):
+        with openfile('PyBanner048.gif', 'rb') as fp:
+            bindata = fp.read()
+        mimed = email.mime.image.MIMEImage(bindata)
+        base64ed = mimed.get_payload()
+        # the transfer-encoded body lines should all be <=76 characters
+        lines = base64ed.split('\n')
+        self.assertLessEqual(max([ len(x) for x in lines ]), 76)
+
     def test_encode_empty_payload(self):
         eq = self.assertEqual
         msg = Message()
@@ -1141,10 +1150,11 @@
 
     def test_body(self):
         eq = self.assertEqual
-        bytes = b'\xfa\xfb\xfc\xfd\xfe\xff'
-        msg = MIMEApplication(bytes)
-        eq(msg.get_payload(), '+vv8/f7/')
-        eq(msg.get_payload(decode=True), bytes)
+        bytesdata = b'\xfa\xfb\xfc\xfd\xfe\xff'
+        msg = MIMEApplication(bytesdata)
+        # whitespace in the cte encoded block is RFC-irrelevant.
+        eq(msg.get_payload().strip(), '+vv8/f7/')
+        eq(msg.get_payload(decode=True), bytesdata)
 
 
 
diff --git a/Misc/ACKS b/Misc/ACKS
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -227,6 +227,7 @@
 Ismail Donmez
 Marcos Donolo
 Dima Dorfman
+Yves Dorfsman
 Cesar Douady
 Dean Draayer
 Fred L. Drake, Jr.
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -72,6 +72,10 @@
 Library
 -------
 
+- Issue #9298: base64 bodies weren't being folded to line lengths less than 78,
+  which was a regression relative to Python2.  Unlike Python2, the last line
+  of the folded body now ends with a carriage return.
+
 - Issue #11560: shutil.unpack_archive now correctly handles the format
   parameter. Patch by Evan Dandrea.
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list