From: Victor Stinner Date: Thu, 3 Nov 2011 23:43:35 +0000 (+0100) Subject: (Merge 3.2) Issue #12342: Improve _tkinter error message on unencodable character X-Git-Tag: v3.3.0a1~957 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6777e6f9b1d2756aa59c57b554395e5fc0a9f540;p=thirdparty%2FPython%2Fcpython.git (Merge 3.2) Issue #12342: Improve _tkinter error message on unencodable character --- 6777e6f9b1d2756aa59c57b554395e5fc0a9f540 diff --cc Modules/_tkinter.c index ffb8ab08c95a,3608e2d993a2..f42f068bb389 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@@ -984,19 -991,16 +984,21 @@@ AsObj(PyObject *value return NULL; } for (i = 0; i < size; i++) { - if (inbuf[i] >= 0x10000) { + Py_UCS4 ch = PyUnicode_READ(kind, inbuf, i); + /* We cannot test for sizeof(Tcl_UniChar) directly, + so we test for UTF-8 size instead. */ +#if TCL_UTF_MAX == 3 + if (ch >= 0x10000) { /* Tcl doesn't do UTF-16, yet. */ - PyErr_SetString(PyExc_ValueError, - "unsupported character"); + PyErr_Format(PyExc_ValueError, + "character U+%x is above the range " + "(U+0000-U+FFFF) allowed by Tcl", + inbuf[i]); ckfree(FREECAST outbuf); return NULL; +#endif } - outbuf[i] = inbuf[i]; + outbuf[i] = ch; } result = Tcl_NewUnicodeObj(outbuf, size); ckfree(FREECAST outbuf);