This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients barry, jaraco, r.david.murray
Date 2014-02-06.14:56:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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/", line 112, in flatten
  File "/usr/lib/python3.3/email/", line 177, in _write
  File "/usr/lib/python3.3/email/", line 203, in _dispatch
  File "/usr/lib/python3.3/email/", line 421, in _handle_text
  File "/usr/lib/python3.3/email/", line 233, in _handle_text
  File "/usr/lib/python3.3/email/", line 158, in _write_lines
  File "/usr/lib/python3.3/email/", 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.
Date User Action Args
2014-02-06 14:56:53r.david.murraysetrecipients: + r.david.murray, barry, jaraco
2014-02-06 14:56:53r.david.murraysetmessageid: <>
2014-02-06 14:56:53r.david.murraylinkissue20531 messages
2014-02-06 14:56:52r.david.murraycreate