Author Tim.Rawlinson
Recipients Tim.Rawlinson, barry, docs@python, r.david.murray
Date 2013-05-23.11:57:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1369310256.22.0.862828757307.issue18044@psf.upfronthosting.co.za>
In-reply-to
Content
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 <foo@example.com>\n\n', policy=default)
   >>> msg['To']
   '=?utf-8?q?=C3=89ric?= <foo@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?= <foo@example.com>\n\n', policy=default)
   >>> msg['To']
   '=?utf-8?q?Eric?= <foo@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']
    '这是中文测试!'
History
Date User Action Args
2013-05-23 11:57:36Tim.Rawlinsonsetrecipients: + Tim.Rawlinson, barry, r.david.murray, docs@python
2013-05-23 11:57:36Tim.Rawlinsonsetmessageid: <1369310256.22.0.862828757307.issue18044@psf.upfronthosting.co.za>
2013-05-23 11:57:36Tim.Rawlinsonlinkissue18044 messages
2013-05-23 11:57:35Tim.Rawlinsoncreate