@@ -993,18 +993,21 @@ struct bootstate {
993993 PyObject * args ;
994994 PyObject * keyw ;
995995 PyThreadState * tstate ;
996+ _PyRuntimeState * runtime ;
996997};
997998
998999static void
9991000t_bootstrap (void * boot_raw )
10001001{
10011002 struct bootstate * boot = (struct bootstate * ) boot_raw ;
10021003 PyThreadState * tstate ;
1004+ _PyRuntimeState * runtime ;
10031005 PyObject * res ;
10041006
1007+ runtime = boot -> runtime ;
10051008 tstate = boot -> tstate ;
10061009 tstate -> thread_id = PyThread_get_thread_ident ();
1007- _PyThreadState_Init (& _PyRuntime , tstate );
1010+ _PyThreadState_Init (runtime , tstate );
10081011 PyEval_AcquireThread (tstate );
10091012 tstate -> interp -> num_threads ++ ;
10101013 res = PyObject_Call (boot -> func , boot -> args , boot -> keyw );
@@ -1025,13 +1028,14 @@ t_bootstrap(void *boot_raw)
10251028 PyMem_DEL (boot_raw );
10261029 tstate -> interp -> num_threads -- ;
10271030 PyThreadState_Clear (tstate );
1028- PyThreadState_DeleteCurrent ( );
1031+ _PyThreadState_DeleteCurrent ( runtime );
10291032 PyThread_exit_thread ();
10301033}
10311034
10321035static PyObject *
10331036thread_PyThread_start_new_thread (PyObject * self , PyObject * fargs )
10341037{
1038+ _PyRuntimeState * runtime = & _PyRuntime ;
10351039 PyObject * func , * args , * keyw = NULL ;
10361040 struct bootstate * boot ;
10371041 unsigned long ident ;
@@ -1062,6 +1066,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
10621066 boot -> args = args ;
10631067 boot -> keyw = keyw ;
10641068 boot -> tstate = _PyThreadState_Prealloc (boot -> interp );
1069+ boot -> runtime = runtime ;
10651070 if (boot -> tstate == NULL ) {
10661071 PyMem_DEL (boot );
10671072 return PyErr_NoMemory ();
0 commit comments