R. David Murray added the comment: This was an intentional change, but I'm having second thoughts about it. I think I need to make it a deprecation warning in 3.4.
Note that it doesn't actually do anything useful in 3.3: Python 3.3.2 (default, Dec 9 2013, 11:44:21) [GCC 4.7.2] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import email.parser >>> meta = """ ... Header: ☃ ... """ >>> m = email.parser.Parser().parsestr(meta) >>> str(m) '\nHeader: ☃\n' >>> import email.generator >>> import io >>> s = io.BytesIO() >>> g = email.generator.BytesGenerator(s) >>> g.flatten(m) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.3/email/generator.py", line 112, in flatten self._write(msg) File "/usr/lib/python3.3/email/generator.py", line 177, in _write self._dispatch(msg) File "/usr/lib/python3.3/email/generator.py", line 203, in _dispatch meth(msg) File "/usr/lib/python3.3/email/generator.py", line 421, in _handle_text super(BytesGenerator,self)._handle_text(msg) File "/usr/lib/python3.3/email/generator.py", line 233, in _handle_text self._write_lines(payload) File "/usr/lib/python3.3/email/generator.py", line 158, in _write_lines self.write(laststripped) File "/usr/lib/python3.3/email/generator.py", line 395, in write self._fp.write(s.encode('ascii', 'surrogateescape')) UnicodeEncodeError: 'ascii' codec can't encode character '\u2603' in position 8: ordinal not in range(128) That is, if you pretend the message is a string, it will happily output it as a string, including perhaps your writing the output to a file as utf-8...but it will *NOT* be a valid email message, since it will have non-ascii data in it with no specified CTE. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue20531> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com