diff Modules/_tkinter.c @ 84551:f53cdd4e2689 2.7

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().
author Serhiy Storchaka <storchaka@gmail.com>
date Thu, 11 Jul 2013 20:32:48 +0300
parents bb5a8564e186
children ee0bb673536c
line wrap: on
line diff
--- a/Modules/_tkinter.c	Thu Jul 11 19:14:07 2013 +0300
+++ b/Modules/_tkinter.c	Thu Jul 11 20:32:48 2013 +0300
@@ -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;
 }