[issue8054] "as_string" method in email's mime objects encode text segmentedly

Dongying Zhang report at bugs.python.org
Fri Mar 5 07:34:15 CET 2010


Dongying Zhang <zhangdongying1986 at gmail.com> added the comment:

Hello R. David Murray:

Thanks for your care.

The examples I given both in message and file is just the same. You got the 'UnicodeEncodeError' because your system default encoding is ascii. The declaration of encoding at the top didn't help with this situation.

To solve this, you can add following lines at the import part of the codes.
=====================================================================
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
=====================================================================
Then it should work by executing it directly or in a terminal (but not in IDLE).

You can try the new file I submit. Thanks!

----------
Added file: http://bugs.python.org/file16446/utf8_test.py

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


More information about the Python-bugs-list mailing list