diff --git a/Lib/email/Parser.py b/Lib/email/Parser.py index 5fea3c39863..6dfa4d38e6d 100644 --- a/Lib/email/Parser.py +++ b/Lib/email/Parser.py @@ -221,9 +221,13 @@ def _parsebody(self, container, fp): # msgobj in this case is the "message/rfc822" container msgobj = self.parsestr(parthdrs, headersonly=1) # while submsgobj is the message itself - submsgobj = self.parsestr(part) - msgobj.attach(submsgobj) msgobj.set_default_type('message/rfc822') + maintype = msgobj.get_content_maintype() + if maintype in ('message', 'multipart'): + submsgobj = self.parsestr(part) + msgobj.attach(submsgobj) + else: + msgobj.set_payload(part) else: msgobj = self.parsestr(part) container.preamble = preamble