1
0
Fork 1
mirror of https://github.com/coddingtonbear/django-mailbox.git synced 2026-07-09 22:38:19 +02:00

Improve the workaround of https://bugs.python.org/issue27321 in coddingtonbear#136.

Attempt to use patch from https://bugs.python.org/msg308362.
This commit is contained in:
Scott Stafford 2019-02-25 22:02:14 -05:00
parent 26786a0b32
commit cdda047f9f

View file

@ -372,8 +372,13 @@ class Mailbox(models.Model):
except KeyError as exc:
# email.message.replace_header may raise 'KeyError' if the header
# 'content-transfer-encoding' is missing
logger.warning("Failed to parse message: %s", exc,)
return None
try:
# Before we give up, let's try mailman's approach:
# https://bugs.python.org/msg308362
body = message.as_bytes(self).decode('ascii', 'replace')
except KeyError as exc:
logger.warning("Failed to parse message: %s", exc,)
return None
msg.set_body(body)
if message['in-reply-to']:
try: