diff Objects/unicodeobject.c @ 79108:c64dec45d46f

Issue #15379: Fix passing of non-BMP characters as integers for the charmap decoder (already working as unicode strings). Patch by Serhiy Storchaka.
author Antoine Pitrou <solipsis@pitrou.net>
date Sun, 23 Sep 2012 20:00:04 +0200
parents 99112b851b25 620d23f7ad41
children 3d9c323711d0
line wrap: on
line diff
--- a/Objects/unicodeobject.c	Sun Sep 23 18:20:23 2012 +0200
+++ b/Objects/unicodeobject.c	Sun Sep 23 20:00:04 2012 +0200
@@ -7525,9 +7525,10 @@
             /* 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;
                 }