@@ -1073,7 +1073,6 @@ _PyInterpreterState_SetNotRunningMain(PyInterpreterState *interp)
10731073 // thread, so it was set as threading._main_thread. (See gh-75698.)
10741074 // The thread has finished running the Python program so we mark
10751075 // the thread object as finished.
1076- assert (tstate -> _whence != _PyThreadState_WHENCE_THREADING );
10771076 tstate -> on_delete (tstate -> on_delete_data );
10781077 tstate -> on_delete = NULL ;
10791078 tstate -> on_delete_data = NULL ;
@@ -1159,8 +1158,7 @@ _PyInterpreterState_IDDecref(PyInterpreterState *interp)
11591158 PyThread_release_lock (interp -> id_mutex );
11601159
11611160 if (refcount == 0 && interp -> requires_idref ) {
1162- PyThreadState * tstate = _PyThreadState_New (interp ,
1163- _PyThreadState_WHENCE_INTERP );
1161+ PyThreadState * tstate = _PyThreadState_New (interp );
11641162 _PyThreadState_Bind (tstate );
11651163
11661164 // XXX Possible GILState issues?
@@ -1338,7 +1336,7 @@ free_threadstate(PyThreadState *tstate)
13381336
13391337static void
13401338init_threadstate (PyThreadState * tstate ,
1341- PyInterpreterState * interp , uint64_t id , int whence )
1339+ PyInterpreterState * interp , uint64_t id )
13421340{
13431341 if (tstate -> _status .initialized ) {
13441342 Py_FatalError ("thread state already initialized" );
@@ -1351,10 +1349,6 @@ init_threadstate(PyThreadState *tstate,
13511349 assert (tstate -> next == NULL );
13521350 assert (tstate -> prev == NULL );
13531351
1354- assert (tstate -> _whence == _PyThreadState_WHENCE_NOTSET );
1355- assert (whence >= 0 && whence <= _PyThreadState_WHENCE_EXEC );
1356- tstate -> _whence = whence ;
1357-
13581352 assert (id > 0 );
13591353 tstate -> id = id ;
13601354
@@ -1394,7 +1388,7 @@ add_threadstate(PyInterpreterState *interp, PyThreadState *tstate,
13941388}
13951389
13961390static PyThreadState *
1397- new_threadstate (PyInterpreterState * interp , int whence )
1391+ new_threadstate (PyInterpreterState * interp )
13981392{
13991393 PyThreadState * tstate ;
14001394 _PyRuntimeState * runtime = interp -> runtime ;
@@ -1433,7 +1427,7 @@ new_threadstate(PyInterpreterState *interp, int whence)
14331427 sizeof (* tstate ));
14341428 }
14351429
1436- init_threadstate (tstate , interp , id , whence );
1430+ init_threadstate (tstate , interp , id );
14371431 add_threadstate (interp , tstate , old_head );
14381432
14391433 HEAD_UNLOCK (runtime );
@@ -1447,8 +1441,7 @@ new_threadstate(PyInterpreterState *interp, int whence)
14471441PyThreadState *
14481442PyThreadState_New (PyInterpreterState * interp )
14491443{
1450- PyThreadState * tstate = new_threadstate (interp ,
1451- _PyThreadState_WHENCE_UNKNOWN );
1444+ PyThreadState * tstate = new_threadstate (interp );
14521445 if (tstate ) {
14531446 bind_tstate (tstate );
14541447 // This makes sure there's a gilstate tstate bound
@@ -1462,16 +1455,16 @@ PyThreadState_New(PyInterpreterState *interp)
14621455
14631456// This must be followed by a call to _PyThreadState_Bind();
14641457PyThreadState *
1465- _PyThreadState_New (PyInterpreterState * interp , int whence )
1458+ _PyThreadState_New (PyInterpreterState * interp )
14661459{
1467- return new_threadstate (interp , whence );
1460+ return new_threadstate (interp );
14681461}
14691462
14701463// We keep this for stable ABI compabibility.
14711464PyThreadState *
14721465_PyThreadState_Prealloc (PyInterpreterState * interp )
14731466{
1474- return _PyThreadState_New (interp , _PyThreadState_WHENCE_UNKNOWN );
1467+ return _PyThreadState_New (interp );
14751468}
14761469
14771470// We keep this around for (accidental) stable ABI compatibility.
@@ -2235,8 +2228,7 @@ PyGILState_Ensure(void)
22352228 if (tcur == NULL ) {
22362229 /* Create a new Python thread state for this thread */
22372230 // XXX Use PyInterpreterState_EnsureThreadState()?
2238- tcur = new_threadstate (runtime -> gilstate .autoInterpreterState ,
2239- _PyThreadState_WHENCE_GILSTATE );
2231+ tcur = new_threadstate (runtime -> gilstate .autoInterpreterState );
22402232 if (tcur == NULL ) {
22412233 Py_FatalError ("Couldn't create thread-state for new thread" );
22422234 }
0 commit comments