Index: Modules/_tkinter.c =================================================================== --- Modules/_tkinter.c (revision 68102) +++ Modules/_tkinter.c (working copy) @@ -2171,20 +2171,8 @@ &file, &mask, &func)) return NULL; -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.createfilehandler not supported " - "for threaded Tcl"); - return NULL; - } -#endif + CHECK_TCL_APPARTMENT; - if (self) { - CHECK_TCL_APPARTMENT; - } - tfile = PyObject_AsFileDescriptor(file); if (tfile < 0) return NULL; @@ -2214,20 +2202,8 @@ if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file)) return NULL; -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.deletefilehandler not supported " - "for threaded Tcl"); - return NULL; - } -#endif + CHECK_TCL_APPARTMENT; - if (self) { - CHECK_TCL_APPARTMENT; - } - tfile = PyObject_AsFileDescriptor(file); if (tfile < 0) return NULL; @@ -2400,20 +2376,8 @@ return NULL; } -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.createtimerhandler not supported " - "for threaded Tcl"); - return NULL; - } -#endif + CHECK_TCL_APPARTMENT; - if (self) { - CHECK_TCL_APPARTMENT; - } - v = Tktt_New(func); if (v) { v->token = Tcl_CreateTimerHandler(milliseconds, TimerHandler, @@ -2427,10 +2391,9 @@ /** Event Loop **/ static PyObject * -Tkapp_MainLoop(PyObject *selfptr, PyObject *args) +Tkapp_MainLoop(TkappObject *self, PyObject *args) { int threshold = 0; - TkappObject *self = (TkappObject*)selfptr; #ifdef WITH_THREAD PyThreadState *tstate = PyThreadState_Get(); #endif @@ -2438,21 +2401,9 @@ if (!PyArg_ParseTuple(args, "|i:mainloop", &threshold)) return NULL; -#ifdef WITH_THREAD - if (!self && !tcl_lock) { - /* We don't have the Tcl lock since Tcl is threaded. */ - PyErr_SetString(PyExc_RuntimeError, - "_tkinter.mainloop not supported " - "for threaded Tcl"); - return NULL; - } -#endif + CHECK_TCL_APPARTMENT; + self->dispatching = 1; - if (self) { - CHECK_TCL_APPARTMENT; - self->dispatching = 1; - } - quitMainLoop = 0; while (Tk_GetNumMainWindows() > threshold && !quitMainLoop && @@ -2461,7 +2412,7 @@ int result; #ifdef WITH_THREAD - if (self && self->threaded) { + if (self->threaded) { /* Allow other Python threads to run. */ ENTER_TCL result = Tcl_DoOneEvent(0); @@ -2483,15 +2434,13 @@ #endif if (PyErr_CheckSignals() != 0) { - if (self) - self->dispatching = 0; + self->dispatching = 0; return NULL; } if (result < 0) break; } - if (self) - self->dispatching = 0; + self->dispatching = 0; quitMainLoop = 0; if (errorInCmd) { @@ -2650,7 +2599,7 @@ {"deletefilehandler", Tkapp_DeleteFileHandler, METH_VARARGS}, #endif {"createtimerhandler", Tkapp_CreateTimerHandler, METH_VARARGS}, - {"mainloop", Tkapp_MainLoop, METH_VARARGS}, + {"mainloop", (PyCFunction)Tkapp_MainLoop, METH_VARARGS}, {"dooneevent", Tkapp_DoOneEvent, METH_VARARGS}, {"quit", Tkapp_Quit, METH_VARARGS}, {"interpaddr", Tkapp_InterpAddr, METH_VARARGS}, @@ -2884,12 +2833,6 @@ { {"_flatten", Tkinter_Flatten, METH_VARARGS}, {"create", Tkinter_Create, METH_VARARGS}, -#ifdef HAVE_CREATEFILEHANDLER - {"createfilehandler", Tkapp_CreateFileHandler, METH_VARARGS}, - {"deletefilehandler", Tkapp_DeleteFileHandler, METH_VARARGS}, -#endif - {"createtimerhandler", Tkapp_CreateTimerHandler, METH_VARARGS}, - {"mainloop", Tkapp_MainLoop, METH_VARARGS}, {"dooneevent", Tkapp_DoOneEvent, METH_VARARGS}, {"quit", Tkapp_Quit, METH_VARARGS}, {"setbusywaitinterval",Tkinter_setbusywaitinterval, METH_VARARGS,