Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e147806

Browse files
committed
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().
1 parent ba9c664 commit e147806

3 files changed

Lines changed: 23 additions & 4 deletions

File tree

Lib/idlelib/NEWS.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
What's New in IDLE 3.1.4?
22
=========================
33

4-
*Release date: XX-XXX-XX*
4+
*Release date: 15-May-11*
5+
6+
- Issue #1028: Ctrl-space binding to show completions was causing IDLE to exit.
7+
Tk < 8.5 was sending invalid Unicode null; replaced with valid null.
58

69
- <Home> toggle failing on Tk 8.5, causing IDLE exits and strange selection
710
behavior. Issue 4676. Improve selection extension behaviour.
8-
- <Home> toggle non-functional when NumLock set on Windows. Issue 3851.
911

12+
- <Home> toggle non-functional when NumLock set on Windows. Issue 3851.
1013

1114

1215
What's New in IDLE 3.1b1?
1316
=========================
1417

15-
*Release date: XX-XXX-09*
18+
*Release date: 06-May-09*
1619

1720
- Use of 'filter' in keybindingDialog.py was causing custom key assignment to
1821
fail. Patch 5707 amaury.forgeotdarc.

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,10 @@ Core and Builtins
6969
Library
7070
-------
7171

72+
- Issue #1028: Tk returns invalid Unicode null in %A: UnicodeDecodeError.
73+
With Tk < 8.5 _tkinter.c:PythonCmd() raised UnicodeDecodeError, caused
74+
IDLE to exit. Converted to valid Unicode null in PythonCmd().
75+
7276
- Issue #10419: Fix build_scripts command of distutils to handle correctly
7377
non-ASCII scripts. Open and write the script in binary mode, but ensure that
7478
the shebang is decodable from UTF-8 and from the encoding of the script.

Modules/_tkinter.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,19 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
20232023

20242024
for (i = 0; i < (argc - 1); i++) {
20252025
PyObject *s = PyUnicode_FromString(argv[i + 1]);
2026-
if (!s || PyTuple_SetItem(arg, i, s)) {
2026+
if (!s) {
2027+
/* Is Tk leaking 0xC080 in %A - a "modified" utf-8 null? */
2028+
if (PyErr_ExceptionMatches(PyExc_UnicodeDecodeError) &&
2029+
!strcmp(argv[i + 1], "\xC0\x80")) {
2030+
PyErr_Clear();
2031+
/* Convert to "strict" utf-8 null */
2032+
s = PyUnicode_FromString("\0");
2033+
} else {
2034+
Py_DECREF(arg);
2035+
return PythonCmd_Error(interp);
2036+
}
2037+
}
2038+
if (PyTuple_SetItem(arg, i, s)) {
20272039
Py_DECREF(arg);
20282040
return PythonCmd_Error(interp);
20292041
}

0 commit comments

Comments
 (0)