Index: Modules/unicodedata.c =================================================================== --- Modules/unicodedata.c (revision 55927) +++ Modules/unicodedata.c (working copy) @@ -1077,7 +1077,6 @@ unicodedata_lookup(PyObject* self, PyObject* args) { Py_UCS4 code; - Py_UNICODE str[1]; char errbuf[256]; char* name; @@ -1102,8 +1101,20 @@ return NULL; } - str[0] = (Py_UNICODE) code; - return PyUnicode_FromUnicode(str, 1); +#ifndef Py_UNICODE_WIDE + if (code < 0x10000) { +#endif + Py_UNICODE str[1] = {(Py_UNICODE) code}; + return PyUnicode_FromUnicode(str, 1); +#ifndef Py_UNICODE_WIDE + } + else { + Py_UNICODE str[2]; + str[0] = 0xd800 + ((code - 0x10000) >> 10); + str[1] = 0xdc00 + ((code - 0x10000) & 0x3ff); + return PyUnicode_FromUnicode(str, 2); + } +#endif } /* XXX Add doc strings. */