summaryrefslogtreecommitdiff
path: root/Modules/unicodedata.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/unicodedata.c')
-rw-r--r--Modules/unicodedata.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/Modules/unicodedata.c b/Modules/unicodedata.c
index a30d30c8eb..1a32b64474 100644
--- a/Modules/unicodedata.c
+++ b/Modules/unicodedata.c
@@ -1102,8 +1102,18 @@ unicodedata_lookup(PyObject* self, PyObject* args)
return NULL;
}
+#ifndef Py_UNICODE_WIDE
+ if (code >= 0x10000) {
+ /* Raise KeyError for compatibility; the possibly more
+ correct ValueError was not documented as a possible
+ exception for 2.5.x and earlier. */
+ PyErr_Format(PyExc_KeyError, "result %d larger than sys.maxunicode",
+ code);
+ return NULL;
+ }
+#endif
str[0] = (Py_UNICODE) code;
- return PyUnicode_FromUnicode(str, 1);
+ return PyUnicode_FromUnicode(str, 1);
}
/* XXX Add doc strings. */