diff options
author | R David Murray <rdmurray@bitdance.com> | 2011-03-25 19:10:55 (GMT) |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2011-03-25 19:10:55 (GMT) |
commit | 041015cc70465c8a008d4ef45ffe3fe05041fad2 (patch) | |
tree | d87526fb02459f89ec4681c274a2ba903a8cbb76 /Lib/email/header.py | |
parent | 213eb96902387dd1f5af0f5f1b80f3d227fd0186 (diff) | |
download | cpython-041015cc70465c8a008d4ef45ffe3fe05041fad2.zip cpython-041015cc70465c8a008d4ef45ffe3fe05041fad2.tar.gz cpython-041015cc70465c8a008d4ef45ffe3fe05041fad2.tar.bz2 |
#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.
Diffstat (limited to 'Lib/email/header.py')
-rw-r--r-- | Lib/email/header.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Lib/email/header.py b/Lib/email/header.py index 8c32514..2562b30 100644 --- a/Lib/email/header.py +++ b/Lib/email/header.py @@ -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)] |