calimeroteknik <calimerotek...@free.fr> added the comment: Eventually there is no bug, I was just confused at the output of print() on the EmailMessage.
I noticed that in email/_header_value_parser.py policy.utf8 was True. The reason is found in email/message.py line 970 (class MIMEPart): def __str__(self): return self.as_string(policy=self.policy.clone(utf8=True) print() will use __str__() and this is why it happens. I didn't dig out the exact reason since there are so many delegated calls. In any case, the flattened message in smtplib.SMTP does contain what as_string() returns, which means that the policy.utf8 is only forced when using print(). Sorry for the false alert. I can guess that the intention in forcing policy.utf8=True in __str__() was that SMTPUTF8 output is visually prettier than any ASCII-armored text. After additional fuzzing, checking the output with EmailMessage.as_string(), everything seems OK. That's a +1 for gh-3488, which fixes this bug. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31831> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com