diff options
author | Kurt B. Kaiser <kbk@shore.net> | 2011-05-11 16:24:17 (GMT) |
---|---|---|
committer | Kurt B. Kaiser <kbk@shore.net> | 2011-05-11 16:24:17 (GMT) |
commit | e147806da9b138e53d86f0a2569a107f6a975834 (patch) | |
tree | c69f482841231160bf4b4af337b3f3dd76e5b8e8 /Modules/_tkinter.c | |
parent | ba9c6645f795c7bf82ee097a240cbd060605afe7 (diff) | |
download | cpython-e147806da9b138e53d86f0a2569a107f6a975834.zip cpython-e147806da9b138e53d86f0a2569a107f6a975834.tar.gz cpython-e147806da9b138e53d86f0a2569a107f6a975834.tar.bz2 |
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().
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r-- | Modules/_tkinter.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 8552575..438955e 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -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); } |