changeset: 90726:6318d2191407 tag: tip user: Victor Stinner date: Fri May 16 14:49:53 2014 +0200 files: Lib/test/test_codecs.py Objects/unicodeobject.c Python/codecs.c description: Issue #13916: Fix name of the Python encoding in Unicode errors of the code page codec: use "cp65000" and "cp65001" instead of "CP_UTF7" and "CP_UTF8" which are not valid Python code names. diff -r 8ee2b73cda7a -r 6318d2191407 Lib/test/test_codecs.py --- a/Lib/test/test_codecs.py Fri May 16 14:46:20 2014 +0200 +++ b/Lib/test/test_codecs.py Fri May 16 14:49:53 2014 +0200 @@ -2759,7 +2759,7 @@ class CodePageTest(unittest.TestCase): codecs.code_page_encode, 932, '\xff') self.assertRaisesRegex(UnicodeDecodeError, 'cp932', codecs.code_page_decode, 932, b'\x81\x00', 'strict', True) - self.assertRaisesRegex(UnicodeDecodeError, 'CP_UTF8', + self.assertRaisesRegex(UnicodeDecodeError, 'cp65001', codecs.code_page_decode, self.CP_UTF8, b'\xff', 'strict', True) def check_decode(self, cp, tests): diff -r 8ee2b73cda7a -r 6318d2191407 Objects/unicodeobject.c --- a/Objects/unicodeobject.c Fri May 16 14:46:20 2014 +0200 +++ b/Objects/unicodeobject.c Fri May 16 14:49:53 2014 +0200 @@ -6806,10 +6806,6 @@ code_page_name(UINT code_page, PyObject *obj = NULL; if (code_page == CP_ACP) return "mbcs"; - if (code_page == CP_UTF7) - return "CP_UTF7"; - if (code_page == CP_UTF8) - return "CP_UTF8"; *obj = PyBytes_FromFormat("cp%u", code_page); if (*obj == NULL) diff -r 8ee2b73cda7a -r 6318d2191407 Python/codecs.c --- a/Python/codecs.c Fri May 16 14:46:20 2014 +0200 +++ b/Python/codecs.c Fri May 16 14:49:53 2014 +0200 @@ -960,7 +960,7 @@ get_standard_encoding(const char *encodi } } } - else if (strcmp(encoding, "CP_UTF8") == 0) { + else if (strcmp(encoding, "cp65001") == 0) { *bytelength = 3; return ENC_UTF8; }