Issue 33568: Inconsistent behavior of non-ascii handling in EmailPolicy.fold (original) (raw)

policy.utf8 is False, but non-ascii are not well-handled. Repro. code.

Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from email.message import EmailMessage
>>> from email.policy import default
>>> 
>>> policy = default.clone()
>>> policy.utf8
False
>>> msg = EmailMessage()
>>> msg["Subject"] = "á"
>>> policy.fold("Subject", msg["Subject"])
'Subject: =?utf-8?q?=C3=A1?=\n'
>>> policy.fold("Subject", 'á')
'Subject: á\n'