diff options
author | Barry Warsaw <barry@python.org> | 2009-03-30 23:12:30 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 2009-03-30 23:12:30 (GMT) |
commit | 70d61cedf7b2efe358d11a6a14fe654f21f2598c (patch) | |
tree | c85e376ced8722559702621905cfdf2fd6f4f5e1 /Lib/email | |
parent | 35d1f00902d6665f7f833bda5fad2fb6c0efce95 (diff) | |
download | cpython-70d61cedf7b2efe358d11a6a14fe654f21f2598c.zip cpython-70d61cedf7b2efe358d11a6a14fe654f21f2598c.tar.gz cpython-70d61cedf7b2efe358d11a6a14fe654f21f2598c.tar.bz2 |
"Port" the fix for issue 1974 from the trunk (2.7). Because Python 3.x does things much better, less changes are necessary.
This also shoves test_email_codecs_rename.py onto test_email_codecs.py even though the test needs to be ported to Python 3.
Diffstat (limited to 'Lib/email')
-rw-r--r-- | Lib/email/generator.py | 2 | ||||
-rw-r--r-- | Lib/email/test/test_email.py | 4 | ||||
-rw-r--r-- | Lib/email/test/test_email_codecs.py | 6 | ||||
-rw-r--r-- | Lib/email/test/test_email_codecs_renamed.py | 77 |
4 files changed, 6 insertions, 83 deletions
diff --git a/Lib/email/generator.py b/Lib/email/generator.py index ada14df..2b4d182 100644 --- a/Lib/email/generator.py +++ b/Lib/email/generator.py @@ -138,7 +138,7 @@ class Generator: else: # Header's got lots of smarts, so use it. header = Header(v, maxlinelen=self._maxheaderlen, - header_name=h, continuation_ws='\t') + header_name=h) print(header.encode(), file=self._fp) # A blank line always separates headers from body print(file=self._fp) diff --git a/Lib/email/test/test_email.py b/Lib/email/test/test_email.py index 8857e42..4b5065f 100644 --- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -769,7 +769,7 @@ Reply-To: =?utf-8?q?Britische_Regierung_gibt_gr=C3=BCnes_Licht_f=C3=BCr_Offs?= msg['To'] = to eq(msg.as_string(maxheaderlen=78), '''\ To: "Someone Test #A" <someone@eecs.umich.edu>,<someone@eecs.umich.edu>, -\t"Someone Test #B" <someone@umich.edu>, + "Someone Test #B" <someone@umich.edu>, "Someone Test #C" <someone@eecs.umich.edu>, "Someone Test #D" <someone@eecs.umich.edu> @@ -852,7 +852,7 @@ iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 # snug against the field name. eq(msg.as_string(maxheaderlen=78), """\ Face-1:\x20 -\tiVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 + iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 locQDQ4zJykFBAXJfWDjAAACYUlEQVR4nF2TQY/jIAyFc6lydlG5x8Nyp1Y69wj1PN2I5gzp Face-2:\x20 iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEUAAAAkHiJeRUIcGBi9 diff --git a/Lib/email/test/test_email_codecs.py b/Lib/email/test/test_email_codecs.py index 8accabe..acc19c3 100644 --- a/Lib/email/test/test_email_codecs.py +++ b/Lib/email/test/test_email_codecs.py @@ -6,9 +6,9 @@ import unittest from test.support import run_unittest from email.test.test_email import TestEmailBase -from email.Charset import Charset -from email.Header import Header, decode_header -from email.Message import Message +from email.charset import Charset +from email.header import Header, decode_header +from email.message import Message # We're compatible with Python 2.3, but it doesn't have the built-in Asian # codecs, so we have to skip all these tests. diff --git a/Lib/email/test/test_email_codecs_renamed.py b/Lib/email/test/test_email_codecs_renamed.py deleted file mode 100644 index acc19c3..0000000 --- a/Lib/email/test/test_email_codecs_renamed.py +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2002-2006 Python Software Foundation -# Contact: email-sig@python.org -# email package unit tests for (optional) Asian codecs - -import unittest -from test.support import run_unittest - -from email.test.test_email import TestEmailBase -from email.charset import Charset -from email.header import Header, decode_header -from email.message import Message - -# We're compatible with Python 2.3, but it doesn't have the built-in Asian -# codecs, so we have to skip all these tests. -try: - str('foo', 'euc-jp') -except LookupError: - raise unittest.SkipTest - - - -class TestEmailAsianCodecs(TestEmailBase): - def test_japanese_codecs(self): - eq = self.ndiffAssertEqual - j = Charset("euc-jp") - g = Charset("iso-8859-1") - h = Header("Hello World!") - jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa' - ghello = 'Gr\xfc\xdf Gott!' - h.append(jhello, j) - h.append(ghello, g) - # BAW: This used to -- and maybe should -- fold the two iso-8859-1 - # chunks into a single encoded word. However it doesn't violate the - # standard to have them as two encoded chunks and maybe it's - # reasonable <wink> for each .append() call to result in a separate - # encoded word. - eq(h.encode(), """\ -Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?= - =?iso-8859-1?q?Gr=FC=DF?= =?iso-8859-1?q?_Gott!?=""") - eq(decode_header(h.encode()), - [('Hello World!', None), - ('\x1b$B%O%m!<%o!<%k%I!*\x1b(B', 'iso-2022-jp'), - ('Gr\xfc\xdf Gott!', 'iso-8859-1')]) - int = 'test-ja \xa4\xd8\xc5\xea\xb9\xc6\xa4\xb5\xa4\xec\xa4\xbf\xa5\xe1\xa1\xbc\xa5\xeb\xa4\xcf\xbb\xca\xb2\xf1\xbc\xd4\xa4\xce\xbe\xb5\xc7\xa7\xa4\xf2\xc2\xd4\xa4\xc3\xa4\xc6\xa4\xa4\xa4\xde\xa4\xb9' - h = Header(int, j, header_name="Subject") - # test a very long header - enc = h.encode() - # TK: splitting point may differ by codec design and/or Header encoding - eq(enc , """\ -=?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?= - =?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""") - # TK: full decode comparison - eq(h.__unicode__().encode('euc-jp'), int) - - def test_payload_encoding(self): - jhello = '\xa5\xcf\xa5\xed\xa1\xbc\xa5\xef\xa1\xbc\xa5\xeb\xa5\xc9\xa1\xaa' - jcode = 'euc-jp' - msg = Message() - msg.set_payload(jhello, jcode) - ustr = str(msg.get_payload(), msg.get_content_charset()) - self.assertEqual(jhello, ustr.encode(jcode)) - - - -def suite(): - suite = unittest.TestSuite() - suite.addTest(unittest.makeSuite(TestEmailAsianCodecs)) - return suite - - -def test_main(): - run_unittest(TestEmailAsianCodecs) - - - -if __name__ == '__main__': - unittest.main(defaultTest='suite') |