[New-bugs-announce] [issue20089] email.message_from_string no longer working in Python 3.4

Florian Apolloner report at bugs.python.org
Sat Dec 28 15:09:03 CET 2013


New submission from Florian Apolloner:

Given this email:
---
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: =?utf-8?q?Ch=C3=A8re_maman?=
From: from at example.com
To: to at example.com
Date: Sat, 28 Dec 2013 13:08:07 -0000
Message-ID: <20131228130807.3669.79195 at localhost>

Je t'aime très fort
---

I get this traceback:
---
  File "/home/florian/sources/cpython/Lib/email/__init__.py", line 40, in message_from_string
    return Parser(*args, **kws).parsestr(s)
  File "/home/florian/sources/cpython/Lib/email/parser.py", line 70, in parsestr
    return self.parse(StringIO(text), headersonly=headersonly)
  File "/home/florian/sources/cpython/Lib/email/parser.py", line 60, in parse
    return feedparser.close()
  File "/home/florian/sources/cpython/Lib/email/feedparser.py", line 170, in close
    self._call_parse()
  File "/home/florian/sources/cpython/Lib/email/feedparser.py", line 163, in _call_parse
    self._parse()
  File "/home/florian/sources/cpython/Lib/email/feedparser.py", line 449, in _parsegen
    self._cur.set_payload(EMPTYSTRING.join(lines))
  File "/home/florian/sources/cpython/Lib/email/message.py", line 311, in set_payload
    " payload") from None
TypeError: charset argument must be specified when non-ASCII characters are used in the payload
---

This is new in 3.4 since that's the first version which requires set_payload to provide a charset argument, imo message_from_string should figure that out from the message.

----------
messages: 207028
nosy: apollo13
priority: normal
severity: normal
status: open
title: email.message_from_string no longer working in Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20089>
_______________________________________


More information about the New-bugs-announce mailing list