You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
mboxMessage.get_payload throws TypeError on malformed content type #80361
import mailbox
mbox = mailbox.mbox("broken.mbox")
for msg in mbox:
msg.get_payload()
Fails rather unexpectedly:
$ python3 broken.py
Traceback (most recent call last):
File "broken.py", line 5, in <module>
msg.get_payload()
File "/usr/lib/python3.7/email/message.py", line 267, in get_payload
payload = bpayload.decode(self.get_param('charset', 'ascii'), 'replace')
TypeError: decode() argument 1 must be str, not tuple
(I'm attaching a zip with code and mailbox)
I would have expected either that the part past text/plain is ignored if it doesn't make sense, or that content-type is completely ignored.
I have to process a large mailbox archive, and this is currently how I had to work around this issue, and it's causing me to have to skip email content which would otherwise be reasonably accessible:
Activity
enrico commentedon Mar 4, 2019
This simple code:
Fails rather unexpectedly:
(I'm attaching a zip with code and mailbox)
I would have expected either that the part past text/plain is ignored if it doesn't make sense, or that content-type is completely ignored.
I have to process a large mailbox archive, and this is currently how I had to work around this issue, and it's causing me to have to skip email content which would otherwise be reasonably accessible:
https://salsa.debian.org/nm-team/echelon/commit/617ce935a31f6256257ffb24e11a5666306406c3
tirkarthi commentedon Apr 14, 2019
A simplified reproducer as below. The tuple is returned from here
cpython/Lib/email/message.py
Line 93 in 830b43d
pythongh-80361: Fix TypeError in email.Message.get_payload()
gh-80361: Fix TypeError in email.Message.get_payload() (GH-117994)
pythongh-80361: Fix TypeError in email.Message.get_payload() (pythonG…
[3.12] gh-80361: Fix TypeError in email.Message.get_payload() (GH-117994