Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3293,7 +3293,7 @@ def test_code_page_name(self):
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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
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. Patch by Victor Stinner.
4 changes: 0 additions & 4 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -7713,10 +7713,6 @@ code_page_name(UINT code_page, PyObject **obj)
*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)
Expand Down
2 changes: 1 addition & 1 deletion Python/codecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ get_standard_encoding_impl(const char *encoding, int *bytelength)
}
}
}
else if (strcmp(encoding, "CP_UTF8") == 0) {
else if (strcmp(encoding, "cp65001") == 0) {
*bytelength = 3;
return ENC_UTF8;
}
Expand Down
Loading