[docs] [issue17505] email.header.Header.__unicode__ does not decode header

R. David Murray report at bugs.python.org
Thu Mar 21 19:41:46 CET 2013


R. David Murray added the comment:

I agree that this is not the worlds best API.  However, it is the API that we have in 2.7/3.2, and we can't change how Header.__unicode__ behaves without breaking backward compatibility.  

What we could do is add an example of how to use this API to get unicode strings to the top of the docs:

   >>>  unicode(make_header(decode_header('=?gb2312?b?1eLKx9bQzsSy4srUo6E=?=')))
   u'\u8fd9\u662f\u4e2d\u6587\u6d4b\u8bd5\uff01'

But you already know about that.

In Python 3.3 you get this:

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

So, I'll make this a doc bug.

----------
assignee:  -> docs at python
components: +Documentation
nosy: +docs at python
versions: +Python 3.2, Python 3.3, Python 3.4

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


More information about the docs mailing list