diff options
author | Guido van Rossum <guido@python.org> | 1997-10-10 17:39:19 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1997-10-10 17:39:19 (GMT) |
commit | a59406abdfd1393db708b379003fe3ab0dd0af2e (patch) | |
tree | 4d15e01e6ca96c7b9a27955b0a3e2384465007ce /Modules/_tkinter.c | |
parent | 04d5c5827af1819d0b114655a3c5359bdd42a4a7 (diff) | |
download | cpython-a59406abdfd1393db708b379003fe3ab0dd0af2e.zip cpython-a59406abdfd1393db708b379003fe3ab0dd0af2e.tar.gz cpython-a59406abdfd1393db708b379003fe3ab0dd0af2e.tar.bz2 |
Darn. When thread support is disabled, the BEGIN/END macros don't
save and restore the tstate, but explicitly calling
PyEval_SaveThread() does reset it! While I think about how to fix
this for real, here's a fix that avoids getting a fatal error.
Diffstat (limited to 'Modules/_tkinter.c')
-rw-r--r-- | Modules/_tkinter.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 593b057..5958716 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -1456,14 +1456,15 @@ static PyInterpreterState *event_interp = NULL; static int EventHook() { - PyThreadState *tstate; + PyThreadState *tstate, *save_tstate; if (Tk_GetNumMainWindows() == 0) return 0; if (event_interp == NULL) return 0; tstate = PyThreadState_New(event_interp); - PyEval_AcquireThread(tstate); + save_tstate = PyThreadState_Swap(NULL); + PyEval_RestoreThread(tstate); if (!errorInCmd) Tcl_DoOneEvent(TCL_DONT_WAIT); if (errorInCmd) { @@ -1473,7 +1474,8 @@ EventHook() PyErr_Print(); } PyThreadState_Clear(tstate); - PyEval_ReleaseThread(tstate); + PyEval_SaveThread(); + PyThreadState_Swap(save_tstate); PyThreadState_Delete(tstate); return 0; } @@ -1536,7 +1538,6 @@ init_tkinter() PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type); if (PyOS_InputHook == NULL) { - PyEval_InitThreads(); event_interp = PyThreadState_Get()->interp; PyOS_InputHook = EventHook; } |