]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #1028: Tk returns invalid Unicode null in %A: UnicodeDecodeError.
authorKurt B. Kaiser <kbk@shore.net>
Wed, 11 May 2011 16:24:17 +0000 (12:24 -0400)
committerKurt B. Kaiser <kbk@shore.net>
Wed, 11 May 2011 16:24:17 +0000 (12:24 -0400)
With Tk < 8.5 _tkinter.c:PythonCmd() raised UnicodeDecodeError, caused IDLE to
exit.  Converted to valid Unicode null in PythonCmd().

Lib/idlelib/NEWS.txt
Misc/NEWS
Modules/_tkinter.c

index 6a031e1496f051f92180b01e75b71561e721ced0..d45941a28b104ac46d93393a98939da1aa15b7da 100644 (file)
@@ -1,18 +1,21 @@
 What's New in IDLE 3.1.4?
 =========================
 
-*Release date: XX-XXX-XX*
+*Release date: 15-May-11*
+
+- Issue #1028: Ctrl-space binding to show completions was causing IDLE to exit.
+  Tk < 8.5 was sending invalid Unicode null; replaced with valid null.
 
 - <Home> toggle failing on Tk 8.5, causing IDLE exits and strange selection
   behavior. Issue 4676.  Improve selection extension behaviour.
-- <Home> toggle non-functional when NumLock set on Windows.  Issue 3851.
 
+- <Home> toggle non-functional when NumLock set on Windows.  Issue 3851.
 
 
 What's New in IDLE 3.1b1?
 =========================
 
-*Release date: XX-XXX-09*
+*Release date: 06-May-09*
 
 - Use of 'filter' in keybindingDialog.py was causing custom key assignment to
   fail.  Patch 5707 amaury.forgeotdarc.
index b77a9a6130cebd52bef0f8414066ab72a184d583..f065b5a99b0d680d8717e7ab79e6592cc96cd5a4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -69,6 +69,10 @@ Core and Builtins
 Library
 -------
 
+- Issue #1028: Tk returns invalid Unicode null in %A: UnicodeDecodeError.
+  With Tk < 8.5 _tkinter.c:PythonCmd() raised UnicodeDecodeError, caused
+  IDLE to exit.  Converted to valid Unicode null in PythonCmd().
+
 - Issue #10419: Fix build_scripts command of distutils to handle correctly
   non-ASCII scripts. Open and write the script in binary mode, but ensure that
   the shebang is decodable from UTF-8 and from the encoding of the script.
index 8552575f408c5ce50e7e85cf513d1ab9d19628cb..438955ed4645ea95c3dd1c477b2fbf73dbadc260 100644 (file)
@@ -2023,7 +2023,19 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
 
     for (i = 0; i < (argc - 1); i++) {
         PyObject *s = PyUnicode_FromString(argv[i + 1]);
-        if (!s || PyTuple_SetItem(arg, i, s)) {
+        if (!s) {
+            /* Is Tk leaking 0xC080 in %A - a "modified" utf-8 null? */
+            if (PyErr_ExceptionMatches(PyExc_UnicodeDecodeError) &&
+                !strcmp(argv[i + 1], "\xC0\x80")) {
+                PyErr_Clear();
+                /* Convert to "strict" utf-8 null */
+                s = PyUnicode_FromString("\0");
+            } else {
+                Py_DECREF(arg);
+                return PythonCmd_Error(interp);
+            }
+        }
+        if (PyTuple_SetItem(arg, i, s)) {
             Py_DECREF(arg);
             return PythonCmd_Error(interp);
         }