]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Port of r42279 to email 3.0, but without the Python 2.1 backward compatible
authorBarry Warsaw <barry@python.org>
Thu, 9 Feb 2006 04:10:03 +0000 (04:10 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 9 Feb 2006 04:10:03 +0000 (04:10 +0000)
nonsense.

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

Lib/email/Message.py
Lib/email/test/test_email.py

index bc764163412586761b14560c29b8907acdff9f23..a5a8ff2856db916564c673f41f5d44db0fdd28d8 100644 (file)
@@ -198,7 +198,7 @@ class Message:
             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
index 5a42c2272d05a224f70451bf9d40c02d97a39e34..1360bbe309ba07cb0043054c807cec291531532a 100644 (file)
@@ -211,6 +211,19 @@ class TestMessageAPI(TestEmailBase):
         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')