diff options
author | Barry Warsaw <barry@python.org> | 2002-07-23 04:29:54 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2002-07-23 04:29:54 (GMT) |
commit | 15d3739446661b11e4caeb960a1903af5ba7e7dc (patch) | |
tree | f5d18001605f1c3f54ff3154182d6a1eb2fd0f59 /Lib/email/Header.py | |
parent | 2d5389c08f4e9b4f325fba6dc88be1db9d0ba3e0 (diff) | |
download | cpython-15d3739446661b11e4caeb960a1903af5ba7e7dc.zip cpython-15d3739446661b11e4caeb960a1903af5ba7e7dc.tar.gz cpython-15d3739446661b11e4caeb960a1903af5ba7e7dc.tar.bz2 |
make_header(): Watch out for charset is None, which decode_header()
will return as the charset if implicit us-ascii is used.
Diffstat (limited to 'Lib/email/Header.py')
-rw-r--r-- | Lib/email/Header.py | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/Lib/email/Header.py b/Lib/email/Header.py index 5ad2968..e691c3c 100644 --- a/Lib/email/Header.py +++ b/Lib/email/Header.py @@ -55,7 +55,6 @@ def decode_header(header): header = str(header) if not ecre.search(header): return [(header, None)] - decoded = [] dec = '' for line in header.splitlines(): @@ -63,7 +62,6 @@ def decode_header(header): if not ecre.search(line): decoded.append((line, None)) continue - parts = ecre.split(line) while parts: unenc = parts.pop(0).strip() @@ -108,7 +106,8 @@ def make_header(decoded_seq, maxlinelen=None, header_name=None, h = Header(maxlinelen=maxlinelen, header_name=header_name, continuation_ws=continuation_ws) for s, charset in decoded_seq: - if not isinstance(charset, Charset): + # None means us-ascii but we can simply pass it on to h.append() + if charset is not None and not isinstance(charset, Charset): charset = Charset(charset) h.append(s, charset) return h |