Hi, https://docs.python.org/3.7/library/email.header.html states:
| This module is part of the legacy (Compat32) email API. In the current
| API encoding and decoding of headers is handled transparently by the
| dictionary-like API of the EmailMessage class.
I understood this to mean that an EmailMessage does decode RFC 2047
encoded header fields automatically.
However this does not seem to be the case:
portia:~/tmp 13:06 :-) 16% python3
Python 3.7.2+ (default, Feb 27 2019, 15:41:59)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import email.parser
>>> import email.message
>>> p = email.parser.Parser(email.message.EmailMessage)
>>> f = open("test.msg", "r")
>>> m = p.parse(f)
>>> m
<email.message.EmailMessage object at 0x7f3b5cac4278>
>>> m["Subject"]
'[luga]
=?utf-8?Q?=C3=84ndern_des_Passwortes_mittels_We?=\n\t=?utf-8?Q?bformular?='
>>> m["From"]
'Martin =?iso-8859-15?Q?W=FCrtele?= <[email protected]>'
>>>
Am I using it wrong or did I misunderstand what is meant by "handled
transparently by the dictionary-like API of the EmailMessage class"? If
the latter, what does it mean?
hp
--
_ | Peter J. Holzer | we build much bigger, better disasters now
|_|_) | | because we have much more sophisticated
| | | [email protected] | management tools.
__/ | http://www.hjp.at/ | -- Ross Anderson <https://www.edge.org/>
signature.asc
Description: PGP signature
-- https://mail.python.org/mailman/listinfo/python-list
