Index: Lib/email/test/test_email.py =================================================================== --- Lib/email/test/test_email.py (revision 84311) +++ Lib/email/test/test_email.py (working copy) @@ -3089,7 +3089,14 @@ s = 'Subject: =?EUC-KR?B?CSixpLDtKSC/7Liuvsax4iC6uLmwMcijIKHaILzSwd/H0SC8+LCjwLsgv7W/+Mj3I ?=' raises(Errors.HeaderParseError, decode_header, s) + def test_encode_unaliased_charset(self): + # Issue 1379416: when the charset was unknown, the output + # was accidentally getting coerced to unicode. + res = Header('abc','iso-8859-2').encode() + self.assertEqual(res, '=?iso-8859-2?q?abc?=') + self.assertIsInstance(res, str) + # Test RFC 2231 header parameters (en/de)coding class TestRFC2231(TestEmailBase):