diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 9bba1b39cf7..236442f05bc 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -79,6 +79,23 @@ str2uni(const char* s) return res2; } +#ifdef Py_DEBUG +void +dump_str(const char *name, const char *value) +{ + size_t i, len = strlen(value); + printf("Decode localeconv() %s: {", name); + for (i=0; is); \ + x = str2uni(l->s); \ + if (!x) goto failed;\ + PyDict_SetItemString(result, #s, x);\ + Py_XDECREF(x) +#else #define RESULT_STRING(s)\ x = str2uni(l->s); \ if (!x) goto failed;\ PyDict_SetItemString(result, #s, x);\ Py_XDECREF(x) +#endif #define RESULT_INT(i)\ x = PyLong_FromLong(l->i);\ diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6798ef81452..6307a983e51 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -391,6 +391,19 @@ _PyUnicode_CheckConsistency(PyObject *op, int check_content) if (ch > maxchar) maxchar = ch; } + if (maxchar > 0x10FFFF) { + printf("Invalid Unicode string! {"); + for (i=0; i < ascii->length; i++) + { + Py_UCS4 ch = PyUnicode_READ(kind, data, i); + if (i) + printf(", U+%04x", ch); + else + printf("U+%04x", ch); + } + printf("} (len=%u)\n", ascii->length); + abort(); + } if (kind == PyUnicode_1BYTE_KIND) { if (ascii->state.ascii == 0) { assert(maxchar >= 128);