Issue #15379: Fix passing of non-BMP characters as integers for the charmap decoder (already working as unicode strings).

Patch by Serhiy Storchaka.
This commit is contained in:
Antoine Pitrou 2012-09-23 20:00:04 +02:00
commit a1f7655fa7
3 changed files with 123 additions and 3 deletions

View file

@ -7525,9 +7525,10 @@ Error:
/* Apply mapping */
if (PyLong_Check(x)) {
long value = PyLong_AS_LONG(x);
if (value < 0 || value > 65535) {
PyErr_SetString(PyExc_TypeError,
"character mapping must be in range(65536)");
if (value < 0 || value > MAX_UNICODE) {
PyErr_Format(PyExc_TypeError,
"character mapping must be in range(0x%lx)",
(unsigned long)MAX_UNICODE + 1);
Py_DECREF(x);
goto onError;
}