summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2011-03-16 20:14:43 (GMT)
committerR David Murray <rdmurray@bitdance.com>2011-03-16 20:14:43 (GMT)
commitbb35299fcd62d22a513dd33b8f9656de101575a6 (patch)
treea56d773dfccb55ce0259bc35807af3aca59fd218
parent3271daa00d3fdf2a450726078ab4d27884bf1299 (diff)
parent78099bb153c2b8399f80cb32798dda7215945157 (diff)
downloadcpython-bb35299fcd62d22a513dd33b8f9656de101575a6.zip
cpython-bb35299fcd62d22a513dd33b8f9656de101575a6.tar.gz
cpython-bb35299fcd62d22a513dd33b8f9656de101575a6.tar.bz2
Merge #9298 fix.
-rw-r--r--Lib/email/encoders.py2
-rw-r--r--Lib/email/test/test_email.py20
-rw-r--r--Misc/ACKS1
-rw-r--r--Misc/NEWS4
4 files changed, 21 insertions, 6 deletions
diff --git a/Lib/email/encoders.py b/Lib/email/encoders.py
index c66f4cc..e5c099f 100644
--- a/Lib/email/encoders.py
+++ b/Lib/email/encoders.py
@@ -12,7 +12,7 @@ __all__ = [
]
-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
index 3fa8f93..5adecae 100644
--- a/Lib/email/test/test_email.py
+++ b/Lib/email/test/test_email.py
@@ -573,9 +573,18 @@ class TestMessageAPI(TestEmailBase):
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 @@ class TestMIMEApplication(unittest.TestCase):
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
index c998250..997dd8c 100644
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -227,6 +227,7 @@ Jaromir Dolecek
Ismail Donmez
Marcos Donolo
Dima Dorfman
+Yves Dorfsman
Cesar Douady
Dean Draayer
Fred L. Drake, Jr.
diff --git a/Misc/NEWS b/Misc/NEWS
index 1de6111..90dd1d2 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -72,6 +72,10 @@ Core and Builtins
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.