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/test | |
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/test')
-rw-r--r-- | Lib/email/test/test_email.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 250a644..245f659 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -3918,6 +3918,20 @@ A very long line that must get split to something other than at the h.append(x, errors='replace') eq(str(h), e) + def test_escaped_8bit_header(self): + x = b'Ynwp4dUEbay Auction Semiar- No Charge \x96 Earn Big' + x = x.decode('ascii', 'surrogateescape') + h = Header(x, charset=email.charset.UNKNOWN8BIT) + self.assertEqual(str(h), + 'Ynwp4dUEbay Auction Semiar- No Charge \uFFFD Earn Big') + self.assertEqual(email.header.decode_header(h), [(x, 'unknown-8bit')]) + + def test_modify_returned_list_does_not_change_header(self): + h = Header('test') + chunks = email.header.decode_header(h) + chunks.append(('ascii', 'test2')) + self.assertEqual(str(h), 'test') + def test_encoded_adjacent_nonencoded(self): eq = self.assertEqual h = Header() |