]> granicus.if.org Git - python/commitdiff
Fix BytesGenerator._handle_text() if the message has no payload (None)
authorVictor Stinner <victor.stinner@haypocalc.com>
Wed, 26 Jan 2011 00:39:19 +0000 (00:39 +0000)
committerVictor Stinner <victor.stinner@haypocalc.com>
Wed, 26 Jan 2011 00:39:19 +0000 (00:39 +0000)
Lib/email/generator.py

index 9d33f1cb870a97b584b60b3ae77b9dd453f40caf..e382b8522bb945939f53d1302febec6dbe8e8c60 100644 (file)
@@ -377,8 +377,11 @@ class BytesGenerator(Generator):
     def _handle_text(self, msg):
         # If the string has surrogates the original source was bytes, so
         # just write it back out.
-        if _has_surrogates(msg._payload):
-            self.write(msg._payload)
+        payload = msg.get_payload()
+        if payload is None:
+            return
+        if _has_surrogates(payload):
+            self.write(payload)
         else:
             super(BytesGenerator,self)._handle_text(msg)