[Python-checkins] r42280 - in python/branches/release24-maint/Lib/email: Message.py test/test_email.py

barry.warsaw python-checkins at python.org
Thu Feb 9 05:10:06 CET 2006


Author: barry.warsaw
Date: Thu Feb  9 05:10:03 2006
New Revision: 42280

Modified:
   python/branches/release24-maint/Lib/email/Message.py
   python/branches/release24-maint/Lib/email/test/test_email.py
Log:
Port of r42279 to email 3.0, but without the Python 2.1 backward compatible
nonsense.

Resolve SF bug 1409403: email.Message should supress warning from uu.decode.


Modified: python/branches/release24-maint/Lib/email/Message.py
==============================================================================
--- python/branches/release24-maint/Lib/email/Message.py	(original)
+++ python/branches/release24-maint/Lib/email/Message.py	Thu Feb  9 05:10:03 2006
@@ -198,7 +198,7 @@
             elif cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
                 sfp = StringIO()
                 try:
-                    uu.decode(StringIO(payload+'\n'), sfp)
+                    uu.decode(StringIO(payload+'\n'), sfp, quiet=True)
                     payload = sfp.getvalue()
                 except uu.Error:
                     # Some decoding problem

Modified: python/branches/release24-maint/Lib/email/test/test_email.py
==============================================================================
--- python/branches/release24-maint/Lib/email/test/test_email.py	(original)
+++ python/branches/release24-maint/Lib/email/test/test_email.py	Thu Feb  9 05:10:03 2006
@@ -211,6 +211,19 @@
         msg.set_payload('foo')
         eq(msg.get_payload(decode=True), 'foo')
 
+    def test_decode_bogus_uu_payload_quietly(self):
+        msg = Message()
+        msg.set_payload('begin 664 foo.txt\n%<W1F=0000H \n \nend\n')
+        msg['Content-Transfer-Encoding'] = 'x-uuencode'
+        old_stderr = sys.stderr
+        try:
+            sys.stderr = sfp = StringIO()
+            # We don't care about the payload
+            msg.get_payload(decode=True)
+        finally:
+            sys.stderr = old_stderr
+        self.assertEqual(sfp.getvalue(), '')
+
     def test_decoded_generator(self):
         eq = self.assertEqual
         msg = self._msgobj('msg_07.txt')


More information about the Python-checkins mailing list