From: Serhiy Storchaka Date: Mon, 18 Feb 2013 11:02:41 +0000 (+0200) Subject: Issue #13153: Tkinter functions now raise TclError instead of ValueError when X-Git-Tag: v3.3.1rc1~162 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=df4aa642a5d13ddd5646495fcefd2a92aaf07e74;p=thirdparty%2FPython%2Fcpython.git Issue #13153: Tkinter functions now raise TclError instead of ValueError when a string argument contains non-BMP character. --- df4aa642a5d13ddd5646495fcefd2a92aaf07e74 diff --cc Modules/_tkinter.c index 70f47036d068,c6a3e388ef3e..d18c7f06cb09 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@@ -984,16 -991,12 +984,16 @@@ 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_Format(PyExc_ValueError, + PyErr_Format(Tkinter_TclError, "character U+%x is above the range " "(U+0000-U+FFFF) allowed by Tcl", - inbuf[i]); + ch); ckfree(FREECAST outbuf); return NULL; }