Issue #18101: Tcl.split() now process Unicode strings nested in a tuple as it
do with byte strings.
Added tests for Tcl.split() and tcl.splitline().
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 7872df3..aed42ac 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -547,6 +547,33 @@
return Split(PyString_AsString(arg));
/* Fall through, returning arg. */
}
+ else if (PyUnicode_Check(arg)) {
+ int argc;
+ char **argv;
+ char *list;
+ PyObject *s = PyUnicode_AsUTF8String(arg);
+
+ if (s == NULL) {
+ Py_INCREF(arg);
+ return arg;
+ }
+ list = PyString_AsString(s);
+
+ if (list == NULL ||
+ Tcl_SplitList((Tcl_Interp *)NULL, list, &argc, &argv) != TCL_OK) {
+ Py_DECREF(s);
+ Py_INCREF(arg);
+ return arg;
+ }
+ Tcl_Free(FREECAST argv);
+ if (argc > 1) {
+ PyObject *v = Split(list);
+ Py_DECREF(s);
+ return v;
+ }
+ Py_DECREF(s);
+ /* Fall through, returning arg. */
+ }
Py_INCREF(arg);
return arg;
}