]> granicus.if.org Git - python/commitdiff
Merged revisions 81685 via svnmerge from
authorR. David Murray <rdmurray@bitdance.com>
Fri, 4 Jun 2010 16:15:34 +0000 (16:15 +0000)
committerR. David Murray <rdmurray@bitdance.com>
Fri, 4 Jun 2010 16:15:34 +0000 (16:15 +0000)
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r81685 | r.david.murray | 2010-06-04 12:11:08 -0400 (Fri, 04 Jun 2010) | 4 lines

  #4768: store base64 encoded email body parts as text, not binary.

  Patch and tests by Forest Bond.
........

Lib/email/encoders.py
Lib/email/test/test_email.py
Misc/ACKS
Misc/NEWS

index 20feb026fdf02975bdee07ad879c101577cfbc8b..0ea441d963794d69bb29f433615199c47661406a 100644 (file)
@@ -29,7 +29,7 @@ def encode_base64(msg):
     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'
 
index 5508456389e59f66e277d010b7b37bd218e89a14..395e2003a78e0ace68b4d976d715bc675dfcd241 100644 (file)
@@ -966,7 +966,8 @@ class TestMIMEAudio(unittest.TestCase):
 
     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')
@@ -1006,7 +1007,8 @@ class TestMIMEImage(unittest.TestCase):
 
     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')
@@ -1046,7 +1048,7 @@ class TestMIMEApplication(unittest.TestCase):
         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)
 
 
index 459e21640dfa4d363e105b99ee429b24014dc1f1..51aeeec470f8e3eaddf71faf5e9a94c6246988d5 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -81,6 +81,7 @@ Finn Bock
 Paul Boddie
 Matthew Boedicker
 David Bolen
+Forest Bond
 Gregory Bond
 Jurjen Bos
 Peter Bosch
index 91d59b18280f1d0e36731b36b21774baffa97d8a..213cc03f762b0415040c743415eebfd3e3d74f27 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -54,6 +54,9 @@ C-API
 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.