[issue24797] email.header.decode_header return type is not consistent
R. David Murray added the comment: Right, it's provisional in 3.4. I'm working on the doc rewrite now (although I suppose there's a chance it won't get accepted for 3.5, I expect it to). Take a look at https://docs.python.org/3/library/email.policy.html. Basically, if you use EmailMessage instead of Message (and therefore policy.default instead of policy.compat32) header parsing and decoding is handled for you. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24797 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24797] email.header.decode_header return type is not consistent
Sebastian Kreft added the comment: And what would the new API be? There is nothing pointing to it either in the documentation https://docs.python.org/3.4/library/email.header.html or source code. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24797 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24797] email.header.decode_header return type is not consistent
New submission from Sebastian Kreft: The return type of email.header.decode_header is not consistent. When there are encoded parts the return type is a list of (bytes, charset or None) (Note that the documentation says it is a list of (str, charset)). However, when there are no encoded parts the return type is [(str, None)]. Note that, at the end of the function, there is a routine that converts everything to bytes. Compare: In [01]: email.header.decode_header('=?UTF-8?Q?foo?=bar') Out[01]: [(b'foo', 'utf-8'), (b'bar', None)] In [02]: email.header.decode_header('foobar') Out[02]: [('foobar', None)] -- messages: 248047 nosy: Sebastian Kreft priority: normal severity: normal status: open title: email.header.decode_header return type is not consistent versions: Python 3.4, Python 3.5, Python 3.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24797 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24797] email.header.decode_header return type is not consistent
Changes by Serhiy Storchaka storch...@gmail.com: -- components: +email nosy: +barry, r.david.murray type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24797 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24797] email.header.decode_header return type is not consistent
R. David Murray added the comment: Yeah, don't use that, use the new APIs. -- resolution: - duplicate stage: - resolved status: open - closed superseder: - email.header.decode_header sometimes returns bytes, sometimes str ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue24797 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com