[Python-checkins] r81685 - in python/branches/py3k: Lib/email/encoders.py Lib/email/test/test_email.py Misc/ACKS Misc/NEWS
r.david.murray
python-checkins at python.org
Fri Jun 4 18:11:08 CEST 2010
Author: r.david.murray
Date: Fri Jun 4 18:11:08 2010
New Revision: 81685
Log:
#4768: store base64 encoded email body parts as text, not binary.
Patch and tests by Forest Bond.
Modified:
python/branches/py3k/Lib/email/encoders.py
python/branches/py3k/Lib/email/test/test_email.py
python/branches/py3k/Misc/ACKS
python/branches/py3k/Misc/NEWS
Modified: python/branches/py3k/Lib/email/encoders.py
==============================================================================
--- python/branches/py3k/Lib/email/encoders.py (original)
+++ python/branches/py3k/Lib/email/encoders.py Fri Jun 4 18:11:08 2010
@@ -29,7 +29,7 @@
Also, add an appropriate Content-Transfer-Encoding header.
"""
orig = msg.get_payload()
- encdata = _bencode(orig)
+ encdata = str(_bencode(orig), 'ascii')
msg.set_payload(encdata)
msg['Content-Transfer-Encoding'] = 'base64'
Modified: python/branches/py3k/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k/Lib/email/test/test_email.py (original)
+++ python/branches/py3k/Lib/email/test/test_email.py Fri Jun 4 18:11:08 2010
@@ -970,7 +970,8 @@
def test_encoding(self):
payload = self._au.get_payload()
- self.assertEqual(base64.decodebytes(payload), self._audiodata)
+ self.assertEqual(base64.decodebytes(bytes(payload, 'ascii')),
+ self._audiodata)
def test_checkSetMinor(self):
au = MIMEAudio(self._audiodata, 'fish')
@@ -1010,7 +1011,8 @@
def test_encoding(self):
payload = self._im.get_payload()
- self.assertEqual(base64.decodebytes(payload), self._imgdata)
+ self.assertEqual(base64.decodebytes(bytes(payload, 'ascii')),
+ self._imgdata)
def test_checkSetMinor(self):
im = MIMEImage(self._imgdata, 'fish')
@@ -1050,7 +1052,7 @@
eq = self.assertEqual
bytes = b'\xfa\xfb\xfc\xfd\xfe\xff'
msg = MIMEApplication(bytes)
- eq(msg.get_payload(), b'+vv8/f7/')
+ eq(msg.get_payload(), '+vv8/f7/')
eq(msg.get_payload(decode=True), bytes)
Modified: python/branches/py3k/Misc/ACKS
==============================================================================
--- python/branches/py3k/Misc/ACKS (original)
+++ python/branches/py3k/Misc/ACKS Fri Jun 4 18:11:08 2010
@@ -83,6 +83,7 @@
Paul Boddie
Matthew Boedicker
David Bolen
+Forest Bond
Gawain Bolton
Gregory Bond
Jurjen Bos
Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Fri Jun 4 18:11:08 2010
@@ -398,6 +398,9 @@
Library
-------
+- Issue #4768: base64 encoded email body parts were incorrectly stored as
+ binary strings. They are now correctly converted to strings.
+
- Issue #8833: tarfile created hard link entries with a size field != 0 by
mistake.
More information about the Python-checkins
mailing list