[issue6302] email.header.decode_header data types are inconsistent and incorrectly documented

R. David Murray report at bugs.python.org
Thu Jun 18 03:36:16 CEST 2009


New submission from R. David Murray <rdmurray at bitdance.com>:

decode_header only accepts str as input.  If the input contains no
encoded words, the output is str (ie: the input string) and None.  If it
does contain encoded words, the output is pairs of bytes plus str
charset identifiers (or None).  This makes it difficult to use this
function to decode headers, since one has to test for the special case
of str output when there are no encoded words.

I think decode_header should take bytes as input, and output (bytes.
str) pairs consistently.

In any case, the documentation is wrong since it says it returns
strings.  The example is also wrong, since the actual output is:

[(b'p\xf6stal', 'iso-8859-1')]

----------
components: Library (Lib)
messages: 89488
nosy: r.david.murray
priority: normal
severity: normal
stage: test needed
status: open
title: email.header.decode_header data types are inconsistent and incorrectly documented
type: behavior
versions: Python 3.1, Python 3.2

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


More information about the Python-bugs-list mailing list