summaryrefslogtreecommitdiff
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index a0cffde5bf..6f2a75cdad 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -2511,6 +2511,10 @@ run_in_subinterp(PyObject *self, PyObject *args)
r = PyRun_SimpleString(code);
Py_EndInterpreter(substate);
+ /* restore previous thread safe. It was replaced by Py_NewInterpreter()
+ which creates a new thread state. */
+ _PyThreadState_Init(mainstate);
+
PyThreadState_Swap(mainstate);
return PyLong_FromLong(r);