R. David Murray <rdmur...@bitdance.com> added the comment:

Thanks for the report, but parseaddr and formataddr are defined *only* for 
ASCII.  In the port to python3, parseaddr sort-of-maybe-sometimes does the 
naively expected thing with non-ascii, but that's just an accident.  We could 
have added a check for non-ascii to parseaddr during the python3 port, but we 
didn't think of it, and it is too late now since adding it would break 
otherwise working code even though that code is technically broken.

So, for the defined API of parseaddr/formataddr, there is no bug here.

As for handling non-ascii in email per your link:

    >>> from email.message import EmailMessage
    >>> from email.policy import default
    >>> m = EmailMessage(policy=default.clone(utf8=True))
    >>> m['From'] = 'skreft+ñandú@sudoai.com
    >>> bytes(m)
    b'From: skreft+\xc3\xb1and\xc3\x...@sudoai.com\n\n'

(NB: in testing the above I discovered there is actually a recent bug in the 
serialization when utf8 is *False*: it does RFC2047 encoding of the username, 
which it should not do...instead it should raise an error.  Feel free to open a 
bug report for that...)

----------
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue35222>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to