]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix issue #1822: MIMEMultipart.is_multipart() behaves correctly for a
authorFacundo Batista <facundobatista@gmail.com>
Sat, 19 Jan 2008 12:32:27 +0000 (12:32 +0000)
committerFacundo Batista <facundobatista@gmail.com>
Sat, 19 Jan 2008 12:32:27 +0000 (12:32 +0000)
just-created (and empty) instance.  Added tests for this. Thanks
Jonathan Share.

Lib/email/mime/multipart.py
Lib/email/test/test_email.py
Misc/NEWS

index 5c8c9dbc4d4a309776ba0d31ed1986af12d2d199..96618650c519c5cdf38cd2dbfe6ddba8d78ec63f 100644 (file)
@@ -34,6 +34,12 @@ class MIMEMultipart(MIMEBase):
         keyword arguments (or passed into the _params argument).
         """
         MIMEBase.__init__(self, 'multipart', _subtype, **_params)
+
+        # Initialise _payload to an empty list as the Message superclass's
+        # implementation of is_multipart assumes that _payload is a list for
+        # multipart messages.
+        self._payload = []
+
         if _subparts:
             for p in _subparts:
                 self.attach(p)
index 5a86da8a3c3790ec267106611e9032aea23c79af..3a68f02b4880bea1ee8ddd4b30d0a93957178e7a 100644 (file)
@@ -1861,6 +1861,9 @@ message 2
         eq(msg.get_payload(0), text1)
         eq(msg.get_payload(1), text2)
 
+    def test_default_multipart_constructor(self):
+        msg = MIMEMultipart()
+        self.assertTrue(msg.is_multipart())
 
 \f
 # A general test of parser->model->generator idempotency.  IOW, read a message
index cc74e16f471a622c835b118996d4e6e9814d9c70..35d96344be8d2d694040cddffd8aa0332cb017b7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -367,6 +367,9 @@ Core and builtins
 Library
 -------
 
+- #1822: MIMEMultipart.is_multipart() behaves correctly for a just-created
+  (and empty) instance. Thanks Jonathan Share.
+
 - #1861: Added an attribute to the sched module which returns an ordered
   list of upcoming events (displayed as named tuples).