New submission from Tim Rawlinson:

In Python 3.3 decoding of headers to unicode is supposed to be automatic but 
fails in several cases, including one shown as successful in the documentation:

   >>> msg = message_from_string('Subject: =?utf-8?q?=C3=89ric?=\n\n', 
policy=default)
   >>> msg['Subject']
   '=?utf-8?q?=C3=89ric?='

   >>> msg = message_from_string('To: =?utf-8?q?=C3=89ric 
<f...@example.com>\n\n', policy=default)
   >>> msg['To']
   '=?utf-8?q?=C3=89ric?= <f...@example.com>'

Although the following works:

   >>> msg = message_from_string('Subject: =?utf-8?q?Eric?=\n\n', 
policy=default)
   >>> msg['Subject']
   'Eric'

Though this does not:

   >>> msg = message_from_string('To: =?utf-8?q?Eric?= <f...@example.com>\n\n', 
policy=default)
   >>> msg['To']
   '=?utf-8?q?Eric?= <f...@example.com>'

And just to prove some things are working as they should:

    >>> msg = message_from_string("Subject: 
=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=\n\n", policy=default)
    >>> msg['Subject']
    '这是中文测试!'

----------
assignee: docs@python
components: Documentation, email
messages: 189862
nosy: Tim.Rawlinson, barry, docs@python, r.david.murray
priority: normal
severity: normal
status: open
title: Email headers do not properly decode to unicode.
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18044>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to