]> granicus.if.org Git - python/commitdiff
Return results from Python callbacks to Tcl as Tcl objects.
authorMartin v. Löwis <martin@v.loewis.de>
Tue, 1 Jan 2008 21:05:17 +0000 (21:05 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Tue, 1 Jan 2008 21:05:17 +0000 (21:05 +0000)
Fixes Tk issue #1851526

Modules/_tkinter.c

index 8f5be851b17ec44d8a526d33e746a92e559f598a..3cef4e73a81b25f68c1f5bc5d3e48a654ea602ff 100644 (file)
@@ -1992,9 +1992,9 @@ static int
 PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
 {
        PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
-       PyObject *self, *func, *arg, *res, *tmp;
+       PyObject *self, *func, *arg, *res;
        int i, rv;
-       char *s;
+       Tcl_Obj *obj_res;
 
        ENTER_PYTHON
 
@@ -2021,24 +2021,17 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
        if (res == NULL)
                return PythonCmd_Error(interp);
 
-       if (!(tmp = PyList_New(0))) {
-               Py_DECREF(res);
-               return PythonCmd_Error(interp);
-       }
-
-       s = AsString(res, tmp);
-       if (s == NULL) {
+       obj_res = AsObj(res);
+       if (obj_res == NULL) {
                Py_DECREF(res);
-               Py_DECREF(tmp);
                return PythonCmd_Error(interp);
        }
        else {
-               Tcl_SetResult(Tkapp_Interp(self), s, TCL_VOLATILE);
+               Tcl_SetObjResult(Tkapp_Interp(self), obj_res);
                rv = TCL_OK;
        }
 
        Py_DECREF(res);
-       Py_DECREF(tmp);
 
        LEAVE_PYTHON