mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
#11584: Since __getitem__ returns headers, make decode_header handle them.
Why I consider this a bug rather than an API change: the API change was to Message, which didn't used to return Headers unless you added them yourself. Now it does (for 8bit binary header input), so decode_header needs to be able to handle them.
This commit is contained in:
parent
213eb96902
commit
041015cc70
2 changed files with 20 additions and 0 deletions
|
@ -66,9 +66,15 @@ def decode_header(header):
|
|||
otherwise a lower-case string containing the name of the character set
|
||||
specified in the encoded string.
|
||||
|
||||
header may be a string that may or may not contain RFC2047 encoded words,
|
||||
or it may be a Header object.
|
||||
|
||||
An email.errors.HeaderParseError may be raised when certain decoding error
|
||||
occurs (e.g. a base64 decoding exception).
|
||||
"""
|
||||
# If it is a Header object, we can just return the chunks.
|
||||
if hasattr(header, '_chunks'):
|
||||
return list(header._chunks)
|
||||
# If no encoding, just return the header with no charset.
|
||||
if not ecre.search(header):
|
||||
return [(header, None)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue