Kaydet (Commit) 76875223 authored tarafından Guido van Rossum's avatar Guido van Rossum

* tkintermodule.c (Tkapp_New): Remove #ifdef WITH_APPINIT.

	* tkintermodule.c (FileHandler): Make arg a tuple; bug found
	by <tnb2d@cs.virginia.edu>.  Call the Python file handler
	function with (file, mask) argument.  Fix a few of my refcnt bugs.
üst 535cf0cb
...@@ -254,13 +254,11 @@ Tkapp_New (screenName, baseName, className, interactive) ...@@ -254,13 +254,11 @@ Tkapp_New (screenName, baseName, className, interactive)
else else
Tcl_SetVar (v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY); Tcl_SetVar (v->interp, "tcl_interactive", "0", TCL_GLOBAL_ONLY);
#ifndef WITH_APPINIT
if (Tcl_AppInit (v->interp) != TCL_OK) if (Tcl_AppInit (v->interp) != TCL_OK)
{ {
PyErr_SetString (Tkinter_TclError, "Tcl_AppInit failed"); /* XXX */ PyErr_SetString (Tkinter_TclError, "Tcl_AppInit failed"); /* XXX */
return NULL; return NULL;
} }
#endif /* !WITH_APPINIT */
return v; return v;
} }
...@@ -768,15 +766,15 @@ Tkapp_DeleteCommand (self, args) ...@@ -768,15 +766,15 @@ Tkapp_DeleteCommand (self, args)
void void
FileHandler (clientData, mask) FileHandler (clientData, mask)
ClientData clientData; /* Is: func */ ClientData clientData; /* Is: (func, file) */
int mask; int mask;
{ {
PyObject *func; PyObject *func, *file, *arg, *res;
PyObject *arg, *res;
func = (PyObject *) clientData; func = PyTuple_GetItem ((PyObject *) clientData, 0);
file = PyTuple_GetItem ((PyObject *) clientData, 1);
arg = PyInt_FromLong ((long) mask); arg = Py_BuildValue ("(Oi)", file, (long) mask);
res = PyEval_CallObject (func, arg); res = PyEval_CallObject (func, arg);
Py_DECREF (arg); Py_DECREF (arg);
if (res == NULL) if (res == NULL)
...@@ -784,6 +782,7 @@ FileHandler (clientData, mask) ...@@ -784,6 +782,7 @@ FileHandler (clientData, mask)
errorInCmd = 1; errorInCmd = 1;
PyErr_GetAndClear (&excInCmd, &valInCmd); PyErr_GetAndClear (&excInCmd, &valInCmd);
} }
Py_DECREF (res);
} }
static PyObject * static PyObject *
...@@ -791,10 +790,8 @@ Tkapp_CreateFileHandler (self, args) ...@@ -791,10 +790,8 @@ Tkapp_CreateFileHandler (self, args)
PyObject *self; PyObject *self;
PyObject *args; /* Is (file, mask, func) */ PyObject *args; /* Is (file, mask, func) */
{ {
PyObject *file; PyObject *file, *func, *data;
int mask; int mask, id;
PyObject *func;
int id;
if (!PyArg_Parse (args, "(OiO)", &file, &mask, &func)) if (!PyArg_Parse (args, "(OiO)", &file, &mask, &func))
return NULL; return NULL;
...@@ -805,10 +802,13 @@ Tkapp_CreateFileHandler (self, args) ...@@ -805,10 +802,13 @@ Tkapp_CreateFileHandler (self, args)
return NULL; return NULL;
} }
/* ClientData is: (func, file) */
data = Py_BuildValue ("(OO)", func, file);
id = fileno (PyFile_AsFile (file)); id = fileno (PyFile_AsFile (file));
Py_DECREF (file); Tk_CreateFileHandler (id, mask, FileHandler, (ClientData) data);
Tk_CreateFileHandler (id, mask, FileHandler, (ClientData) func);
/* XXX fileHandlerDict */ /* XXX fileHandlerDict */
Py_INCREF (Py_None); Py_INCREF (Py_None);
return Py_None; return Py_None;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment