diff options
| author | R David Murray <rdmurray@bitdance.com> | 2012-03-23 02:17:51 (GMT) |
|---|---|---|
| committer | R David Murray <rdmurray@bitdance.com> | 2012-03-23 02:17:51 (GMT) |
| commit | 8680bcc5db7c0edc09b09387c145932da34cd889 (patch) | |
| tree | 5901ccac2b8e03dd7904d2a65eec65570160599c /Lib/test/test_email/test_email.py | |
| parent | 192195a4fcf3aec27a43169df901667b21ea763a (diff) | |
| download | cpython-8680bcc5db7c0edc09b09387c145932da34cd889.zip cpython-8680bcc5db7c0edc09b09387c145932da34cd889.tar.gz cpython-8680bcc5db7c0edc09b09387c145932da34cd889.tar.bz2 | |
#14380: Have MIMEText defaults to utf-8 when passed non-ASCII unicode
Previously it would just accept the unicode, which would wind up as unicode in
the transfer-encoded message object, which is just wrong.
Patch by Jeff Knupp.
Diffstat (limited to 'Lib/test/test_email/test_email.py')
| -rw-r--r-- | Lib/test/test_email/test_email.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_email/test_email.py b/Lib/test/test_email/test_email.py index e771c20..86aa60c 100644 --- a/Lib/test/test_email/test_email.py +++ b/Lib/test/test_email/test_email.py @@ -617,6 +617,19 @@ class TestMessageAPI(TestEmailBase): abc """)) + def test_unicode_body_defaults_to_utf8_encoding(self): + # Issue 14291 + m = MIMEText('É testabc\n') + self.assertEqual(str(m),textwrap.dedent("""\ + MIME-Version: 1.0 + Content-Type: text/plain; charset="utf-8" + Content-Transfer-Encoding: base64 + + w4kgdGVzdGFiYwo= + """)) + + + # Test the email.encoders module class TestEncoders(unittest.TestCase): @@ -642,7 +655,7 @@ class TestEncoders(unittest.TestCase): eq(msg['content-transfer-encoding'], '7bit') # Similar, but with 8bit data msg = MIMEText('hello \xf8 world') - eq(msg['content-transfer-encoding'], '8bit') + eq(msg['content-transfer-encoding'], 'base64') # And now with a different charset msg = MIMEText('hello \xf8 world', _charset='iso-8859-1') eq(msg['content-transfer-encoding'], 'quoted-printable') |
