[issue1368247] unicode in email.MIMEText and email/Charset.py

R. David Murray report at bugs.python.org
Tue May 5 23:54:34 CEST 2009


R. David Murray <rdmurray at bitdance.com> added the comment:

It looks to me like MIMEText doesn't actually support unicode input.  .

One way to get the example to work is to do this:

 MIMEText(u'\u043a\u0438\u0440\u0438\u043b\u0438\u0446\u0430'.encode('utf-8'), 'plain', 'utf-8')

The above call produces valid output from as_string:

'Content-Type: text/plain; charset="utf-8"\nMIME-Version:
1.0\nContent-Transfer-Encoding: base64\n\n0LrQuNGA0LjQu9C40YbQsA==\n'

How you'd get it to use 8bit, I have no idea.  Still, I'm inclined to
close this as invalid unless Barry tells me my analysis is wrong.

(CF: http://mg.pov.lt/blog/unicode-emails-in-python for a good example
of handling unicode using the email package, which I found after
figuring out the above.)

Clearly, the documentation of this could be better, but I suspect the
developers would rather spend their time fixing the email module in py3.
 A doc patch would certainly be accepted.  (Maybe someone could ask the
above blogger if we could borrow his example for the docs.)

----------
nosy: +r.david.murray
resolution:  -> invalid
stage:  -> committed/rejected
status: open -> pending
type:  -> behavior
versions: +Python 2.6, Python 2.7, Python 3.0, Python 3.1

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


More information about the Python-bugs-list mailing list