summaryrefslogtreecommitdiffstats
path: root/Lib/email
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-01-28 15:27:20 (GMT)
committerMichael W. Hudson <mwh@python.net>2002-01-28 15:27:20 (GMT)
commit7017724abfc58b994e5299cb1093d84dc9827022 (patch)
tree78a9646780d98eea4f34c2710c55a3dec7808e59 /Lib/email
parentfbfb20efaed0455da5b2db3aeb31e255233844e3 (diff)
downloadcpython-7017724abfc58b994e5299cb1093d84dc9827022.zip
cpython-7017724abfc58b994e5299cb1093d84dc9827022.tar.gz
cpython-7017724abfc58b994e5299cb1093d84dc9827022.tar.bz2
It's merge time!
Backport bwarsaw's checkin of revision 1.6: _parsebody(): When adding subparts to a multipart container, make sure that the first subpart added makes the payload a list object. Otherwise, a multipart/* with only one subpart will not have the proper structure.
Diffstat (limited to 'Lib/email')
-rw-r--r--Lib/email/Parser.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/email/Parser.py b/Lib/email/Parser.py
index 44a0ca2..2f131d6 100644
--- a/Lib/email/Parser.py
+++ b/Lib/email/Parser.py
@@ -1,10 +1,11 @@
-# Copyright (C) 2001 Python Software Foundation
+# Copyright (C) 2001,2002 Python Software Foundation
# Author: barry@zope.com (Barry Warsaw)
"""A parser of RFC 2822 and MIME email messages.
"""
from cStringIO import StringIO
+from types import ListType
# Intrapackage imports
import Errors
@@ -133,7 +134,11 @@ class Parser:
msgobj = self.parsestr(part)
container.preamble = preamble
container.epilogue = epilogue
- container.add_payload(msgobj)
+ # Ensure that the container's payload is a list
+ if not isinstance(container.get_payload(), ListType):
+ container.set_payload([msgobj])
+ else:
+ container.add_payload(msgobj)
elif container.get_type() == 'message/delivery-status':
# This special kind of type contains blocks of headers separated
# by a blank line. We'll represent each header block as a