cpython: 013a1cd673fc (original) (raw)

Mercurial > cpython

changeset 68499:013a1cd673fc 3.2

#11554: reactivate test_email_codecs, and make it pass. The fix is to charset.py, which was not doing the encoding to the correct output character set when doing a body_encode for either the shift-jis or euc-jp charsets. There's also a fix for handling a bytes input in encoders.py. Patch by Michael Henry, comment changes by me. [#11554]

R David Murray rdmurray@bitdance.com
date Tue, 15 Mar 2011 12:20:02 -0400
parents 1579808ef25b
children a6390ebff835 983ed0ba44d0 f3ae657067ef
files Lib/email/charset.py Lib/email/encoders.py Lib/email/test/test_email.py Lib/email/test/test_email_codecs.py Lib/test/test_email.py Misc/ACKS Misc/NEWS
diffstat 7 files changed, 54 insertions(+), 22 deletions(-)[+] [-] Lib/email/charset.py 9 Lib/email/encoders.py 9 Lib/email/test/test_email.py 4 Lib/email/test/test_email_codecs.py 46 Lib/test/test_email.py 2 Misc/ACKS 1 Misc/NEWS 5

line wrap: on

line diff

--- a/Lib/email/charset.py +++ b/Lib/email/charset.py @@ -263,7 +263,7 @@ class Charset: Returns "quoted-printable" if self.body_encoding is QP. Returns "base64" if self.body_encoding is BASE64.

@@ -381,7 +381,10 @@ class Charset: """Body-encode a string by converting it first to bytes. The type of encoding (base64 or quoted-printable) will be based on

@@ -391,4 +394,6 @@ class Charset: elif self.body_encoding is QP: return email.quoprimime.body_encode(string) else:

--- a/Lib/email/encoders.py +++ b/Lib/email/encoders.py @@ -54,10 +54,13 @@ def encode_7or8bit(msg): # There's no payload. For backwards compatibility we use 7bit msg['Content-Transfer-Encoding'] = '7bit' return

--- a/Lib/email/test/test_email.py +++ b/Lib/email/test/test_email.py @@ -3365,9 +3365,9 @@ class TestCharset(unittest.TestCase): # built-in encodings where the header encoding is QP but the body # encoding is not. from email import charset as CharsetModule

def test_unicode_charset_name(self): charset = Charset('us-ascii')

--- a/Lib/email/test/test_email_codecs.py +++ b/Lib/email/test/test_email_codecs.py @@ -13,7 +13,7 @@ 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:

except LookupError: raise unittest.SkipTest @@ -22,11 +22,14 @@ except LookupError: class TestEmailAsianCodecs(TestEmailBase): def test_japanese_codecs(self): eq = self.ndiffAssertEqual

@@ -36,13 +39,17 @@ class TestEmailAsianCodecs(TestEmailBase # encoded word. eq(h.encode(), """[](#l4.33) Hello World! =?iso-2022-jp?b?GyRCJU8lbSE8JW8hPCVrJUkhKhsoQg==?=

@@ -50,15 +57,24 @@ Hello World! =?iso-2022-jp?b?GyRCJU8lbSE =?iso-2022-jp?b?dGVzdC1qYSAbJEIkWEVqOUYkNSRsJD8lYSE8JWskTztKGyhC?= =?iso-2022-jp?b?GyRCMnE8VCROPjVHJyRyQlQkQyRGJCQkXiQ5GyhC?=""") # TK: full decode comparison

+

def test_payload_encoding(self):

--- a/Lib/test/test_email.py +++ b/Lib/test/test_email.py @@ -3,10 +3,12 @@

The specific tests now live in Lib/email/test

from email.test.test_email import suite +from email.test.test_email_codecs import suite as codecs_suite from test import support def test_main(): support.run_unittest(suite())

if name == 'main': test_main()

--- a/Misc/ACKS +++ b/Misc/ACKS @@ -371,6 +371,7 @@ Kevan Heydon Jason Hildebrand Richie Hindle Konrad Hinsen +Michael Henry David Hobley Tim Hochberg Joerg-Cyril Hoehle

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -34,6 +34,9 @@ Core and Builtins Library ------- +- Issue #11554: Fixed support for Japanese codecs; previously the body output