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 <>
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/", line 1025, in iter_attachments
parts = self.get_payload().copy()
AttributeError: 'str' object has no attribute 'copy'

/usr/lib/python3.5/email/ 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?

Date User Action Args
2018-06-26 14:43:31skrohlassetrecipients: + skrohlas, barry, r.david.murray
2018-06-26 14:43:31skrohlassetmessageid: <>
2018-06-26 14:43:31skrohlaslinkissue33972 messages
2018-06-26 14:43:31skrohlascreate