]> granicus.if.org Git - python/commitdiff
Fix SF #692416, don't crash interpreter for _tkinter.deletefilehandler
authorNeal Norwitz <nnorwitz@gmail.com>
Mon, 3 Mar 2003 21:16:39 +0000 (21:16 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Mon, 3 Mar 2003 21:16:39 +0000 (21:16 +0000)
in addition to createfilehandler and creaetetimerhandler.

Misc/NEWS
Modules/_tkinter.c

index 5bf335a5a9fb87fb71d7cfad25718df8bc2e4a88..fa1b8f9fc3c495350b11c2127e9593be85b38f2c 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -24,6 +24,10 @@ Core and builtins
 Extension modules
 -----------------
 
+- Using createfilehandler, deletefilehandler, createtimerhandler functions
+  on Tkinter.tkinter (_tkinter module) no longer crashes the interpreter.
+  See SF bug #692416.
+
 - Modified the fcntl.ioctl() function to allow modification of a passed
   mutable buffer (for details see the reference documentation).
 
index 813d27c793e6b9501821552692774275f0b93033..100e06f227ff2f0055e3c4852ef9559f4307211a 100644 (file)
@@ -2243,7 +2243,19 @@ Tkapp_DeleteFileHandler(PyObject *self, PyObject *args)
 
        if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
                return NULL;
-       CHECK_TCL_APPARTMENT;
+
+       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;
+       }
+
+       if (self) {
+               CHECK_TCL_APPARTMENT;
+       }
+
        tfile = PyObject_AsFileDescriptor(file);
        if (tfile < 0)
                return NULL;