[Python-3000-checkins] r58855 - in python/branches/py3k-pep3137/Lib/email: base64mime.py test/test_email.py

christian.heimes python-3000-checkins at python.org
Mon Nov 5 14:55:19 CET 2007


Author: christian.heimes
Date: Mon Nov  5 14:55:19 2007
New Revision: 58855

Modified:
   python/branches/py3k-pep3137/Lib/email/base64mime.py
   python/branches/py3k-pep3137/Lib/email/test/test_email.py
Log:
Fixed test_email
And yet another bug caused by repr(bytes()) == str(bytes()).

Modified: python/branches/py3k-pep3137/Lib/email/base64mime.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/email/base64mime.py	(original)
+++ python/branches/py3k-pep3137/Lib/email/base64mime.py	Mon Nov  5 14:55:19 2007
@@ -70,7 +70,7 @@
     # Return empty headers unchanged
     if not header_bytes:
         return str(header_bytes)
-    encoded = b64encode(header_bytes)
+    encoded = b64encode(header_bytes).decode(charset)
     return '=?%s?b?%s?=' % (charset, encoded)
 
 
@@ -93,7 +93,7 @@
     for i in range(0, len(s), max_unencoded):
         # BAW: should encode() inherit b2a_base64()'s dubious behavior in
         # adding a newline to the encoded string?
-        enc = str(b2a_base64(s[i:i + max_unencoded]))
+        enc = b2a_base64(s[i:i + max_unencoded]).decode()
         if enc.endswith(NL) and eol != NL:
             enc = enc[:-1] + eol
         encvec.append(enc)

Modified: python/branches/py3k-pep3137/Lib/email/test/test_email.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/email/test/test_email.py	(original)
+++ python/branches/py3k-pep3137/Lib/email/test/test_email.py	Mon Nov  5 14:55:19 2007
@@ -2448,9 +2448,7 @@
 
     def test_crlf_separation(self):
         eq = self.assertEqual
-        # XXX When Guido fixes TextIOWrapper.read() to act just like
-        # .readlines(), open this in 'rb' mode with newlines='\n'.
-        with openfile('msg_26.txt', mode='rb') as fp:
+        with openfile('msg_26.txt', newline='\n') as fp:
             msg = Parser().parse(fp)
         eq(len(msg.get_payload()), 2)
         part1 = msg.get_payload(0)


More information about the Python-3000-checkins mailing list