summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Modules/_tkinter.c9
-rw-r--r--Modules/readline.c3
2 files changed, 8 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;
}
diff --git a/Modules/readline.c b/Modules/readline.c
index 1231e03..e12ae1d 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -168,8 +168,10 @@ on_completion(text, state)
char *result = NULL;
if (completer != NULL) {
PyObject *r;
+ PyThreadState *save_tstate;
/* Note that readline is called with the interpreter
lock released! */
+ save_tstate = PyThreadState_Swap(NULL);
PyEval_RestoreThread(tstate);
r = PyObject_CallFunction(completer, "si", text, state);
if (r == NULL)
@@ -190,6 +192,7 @@ on_completion(text, state)
Py_XDECREF(r);
done:
PyEval_SaveThread();
+ PyThreadState_Swap(save_tstate);
}
return result;
}