This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrohlas
Recipients barry, r.david.murray, skrohlas
Date 2018-06-26.14:43:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1530024211.47.0.56676864532.issue33972@psf.upfronthosting.co.za>
In-reply-to
Content
Hello everyone,

Today I stumbled over unexpected behaviour when parsing emails with Python 3.5.

mail is of type: <class 'email.message.EmailMessage'>


Traceback (most recent call last):
File "XXX", line YYY, in ZZZ
for attachment in mail.iter_attachments():
File "/usr/lib/python3.5/email/message.py", line 1025, in iter_attachments
parts = self.get_payload().copy()
AttributeError: 'str' object has no attribute 'copy'


/usr/lib/python3.5/email/message.py calls self.get_payload().copy() without distinguishing between different possible return types of get_payload().

get_payload() belongs to class MIMEPart(Message)

From the (base) class Message:


"def get_payload(self, i=None, decode=False):
"""Return a reference to the payload.

The payload will either be a list object or a string."

So, it might return a string, which seems to be the case I'm hitting here.

The code in cpython trunk still looks identical apart from a few line offsets, so newer versions might be affected, too.

Am I doing something wrong or do we have a bug to squash here?

Thanks,
Sven
History
Date User Action Args
2018-06-26 14:43:31skrohlassetrecipients: + skrohlas, barry, r.david.murray
2018-06-26 14:43:31skrohlassetmessageid: <1530024211.47.0.56676864532.issue33972@psf.upfronthosting.co.za>
2018-06-26 14:43:31skrohlaslinkissue33972 messages
2018-06-26 14:43:31skrohlascreate