Issue #13153: Tkinter functions now raise TclError instead of ValueError when
authorSerhiy Storchaka <storchaka@gmail.com>
Mon, 18 Feb 2013 11:00:08 +0000 (13:00 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 18 Feb 2013 11:00:08 +0000 (13:00 +0200)
a unicode argument contains non-BMP character.

Misc/NEWS
Modules/_tkinter.c

index 5924366d953a3e807da4f2a33e4b942cc6c003c9..ef3d053109cdcaacfa40505de6b6b486f9b42577 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -205,6 +205,9 @@ Core and Builtins
 Library
 -------
 
+- Issue #13153: Tkinter functions now raise TclError instead of ValueError when
+  a unicode argument contains non-BMP character.
+
 - Issue #9669: Protect re against infinite loops on zero-width matching in
   non-greedy repeat.  Patch by Matthew Barnett.
 
index 40c8be2ce7cba028c85c46b0c99bc2dd4be3e889..7872df3bf18e62c0e934c36ec99c51994e4b54e1 100644 (file)
@@ -987,8 +987,10 @@ AsObj(PyObject *value)
         for (i = 0; i < size; i++) {
             if (inbuf[i] >= 0x10000) {
                 /* Tcl doesn't do UTF-16, yet. */
-                PyErr_SetString(PyExc_ValueError,
-                                "unsupported character");
+                PyErr_Format(Tkinter_TclError,
+                             "character U+%x is above the range "
+                             "(U+0000-U+FFFF) allowed by Tcl",
+                             (int)inbuf[i]);
                 ckfree(FREECAST outbuf);
                 return NULL;
             }