Fix SF #692416, don't crash interpreter for _tkinter.deletefilehandler
in addition to createfilehandler and creaetetimerhandler.
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c
index 813d27c..100e06f 100644
--- a/Modules/_tkinter.c
+++ b/Modules/_tkinter.c
@@ -2243,7 +2243,19 @@
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;