Index: Lib/email/test/test_email.py =================================================================== --- Lib/email/test/test_email.py (revision 81675) +++ Lib/email/test/test_email.py (working copy) @@ -2868,7 +2868,11 @@ self.assertEqual(str(charset), 'us-ascii') self.assertRaises(Errors.CharsetError, Charset, 'asc\xffii') + def test_codecs_aliases_accepted(self): + charset = Charset('utf8') + self.assertEqual(str(charset), 'utf-8') + # Test multilingual MIME headers. class TestHeader(TestEmailBase): Index: Lib/email/charset.py =================================================================== --- Lib/email/charset.py (revision 81673) +++ Lib/email/charset.py (working copy) @@ -9,6 +9,7 @@ 'add_codec', ] +import codecs import email.base64mime import email.quoprimime @@ -209,7 +210,12 @@ except UnicodeError: raise errors.CharsetError(input_charset) input_charset = input_charset.lower() - # Set the input charset after filtering through the aliases + # Set the input charset after filtering through the aliases and/or codecs + if not (input_charset in ALIASES or input_charset in CHARSETS): + try: + input_charset = codecs.lookup(input_charset).name + except LookupError: + pass self.input_charset = ALIASES.get(input_charset, input_charset) # We can try to guess which encoding and conversion to use by the # charset_map dictionary. Try that first, but let the user override