diff Modules/_tkinter.c @ 44415:a1ff2faedc6b legacy-trunk

Return results from Python callbacks to Tcl as Tcl objects. Fixes Tk issue #1851526
author Martin v. Löwis <martin@v.loewis.de>
date Tue, 01 Jan 2008 21:05:17 +0000
parents 26384b8180c7
children 53ac3fc69b78
line wrap: on
line diff
--- a/Modules/_tkinter.c	Tue Jan 01 14:37:32 2008 +0000
+++ b/Modules/_tkinter.c	Tue Jan 01 21:05:17 2008 +0000
@@ -1992,9 +1992,9 @@
 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 @@
 	if (res == NULL)
 		return PythonCmd_Error(interp);
 
-	if (!(tmp = PyList_New(0))) {
+	obj_res = AsObj(res);
+	if (obj_res == NULL) {
 		Py_DECREF(res);
 		return PythonCmd_Error(interp);
 	}
-
-	s = AsString(res, tmp);
-	if (s == 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