[issue22833] The decode_header() function decodes raw part to bytes or str, depending on encoded part

py.user report at bugs.python.org
Mon Nov 10 03:42:40 CET 2014


New submission from py.user:

It depends on encoded part in the header, what email.header.decode_header() returns.
If the header has both raw part and encoded part, the function returns (bytes, None) for the raw part. But if the header has only raw part, the function returns (str, None) for it.

>>> import email.header
>>> 
>>> s = 'abc=?koi8-r?q?\xc1\xc2\xd7?='
>>> email.header.decode_header(s)
[(b'abc', None), (b'\xc1\xc2\xd7', 'koi8-r')]
>>> 
>>> s = 'abc'
>>> email.header.decode_header(s)
[('abc', None)]
>>>

There should be (bytes, None) for both cases.

----------
components: Library (Lib), email
messages: 230932
nosy: barry, py.user, r.david.murray
priority: normal
severity: normal
status: open
title: The decode_header() function decodes raw part to bytes or str, depending on encoded part
versions: Python 3.3, Python 3.4, Python 3.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22833>
_______________________________________


More information about the Python-bugs-list mailing list