[New-bugs-announce] [issue36180] mboxMessage.get_payload throws TypeError on malformed content type
Enrico Zini
report at bugs.python.org
Mon Mar 4 06:03:37 EST 2019
New submission from Enrico Zini <enrico at enricozini.org>:
This simple code:
```
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:
https://salsa.debian.org/nm-team/echelon/commit/617ce935a31f6256257ffb24e11a5666306406c3
----------
files: broken.zip
messages: 337091
nosy: enrico
priority: normal
severity: normal
status: open
title: mboxMessage.get_payload throws TypeError on malformed content type
Added file: https://bugs.python.org/file48184/broken.zip
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36180>
_______________________________________
More information about the New-bugs-announce
mailing list