changeset 82251:bb5a8564e186 2.7

Issue #13153: Tkinter functions now raise TclError instead of ValueError when a unicode argument contains non-BMP character.
author Serhiy Storchaka <storchaka@gmail.com>
date Mon, 18 Feb 2013 13:00:08 +0200
parents 50ed06b3d419
children 3c5517c4fa5d
files Misc/NEWS Modules/_tkinter.c
diffstat 2 files changed, 7 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/Misc/NEWS	Mon Feb 18 12:20:44 2013 +0200
+++ b/Misc/NEWS	Mon Feb 18 13:00:08 2013 +0200
@@ -205,6 +205,9 @@
 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.
 
--- a/Modules/_tkinter.c	Mon Feb 18 12:20:44 2013 +0200
+++ b/Modules/_tkinter.c	Mon Feb 18 13:00:08 2013 +0200
@@ -987,8 +987,10 @@
         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;
             }