@@ -873,29 +873,14 @@ PyThreadState *
873873PyThreadState_New (PyInterpreterState * interp )
874874{
875875 PyThreadState * tstate = new_threadstate (interp );
876- if (tstate ) {
877- _PyThreadState_SetCurrent (tstate );
878- if (PySys_Audit ("cpython.PyThreadState_New" , "K" , tstate -> id ) < 0 ) {
879- PyThreadState_Clear (tstate );
880- _PyThreadState_DeleteCurrent (tstate );
881- return NULL ;
882- }
883- }
876+ _PyThreadState_SetCurrent (tstate );
884877 return tstate ;
885878}
886879
887880PyThreadState *
888881_PyThreadState_Prealloc (PyInterpreterState * interp )
889882{
890- PyThreadState * tstate = new_threadstate (interp );
891- if (tstate ) {
892- if (PySys_Audit ("cpython.PyThreadState_New" , "K" , tstate -> id ) < 0 ) {
893- PyThreadState_Clear (tstate );
894- _PyThreadState_Delete (tstate , 0 );
895- return NULL ;
896- }
897- }
898- return tstate ;
883+ return new_threadstate (interp );
899884}
900885
901886// We keep this around for (accidental) stable ABI compatibility.
@@ -1043,10 +1028,6 @@ _PyInterpreterState_ClearModules(PyInterpreterState *interp)
10431028void
10441029PyThreadState_Clear (PyThreadState * tstate )
10451030{
1046- if (PySys_Audit ("cpython.PyThreadState_Clear" , "K" , tstate -> id ) < 0 ) {
1047- PyErr_WriteUnraisable (NULL );
1048- }
1049-
10501031 int verbose = _PyInterpreterState_GetConfig (tstate -> interp )-> verbose ;
10511032
10521033 if (verbose && tstate -> cframe -> current_frame != NULL ) {
@@ -1564,16 +1545,16 @@ _PyGILState_Init(_PyRuntimeState *runtime)
15641545PyStatus
15651546_PyGILState_SetTstate (PyThreadState * tstate )
15661547{
1567- /* must init with valid states */
1568- assert (tstate != NULL );
1569- assert (tstate -> interp != NULL );
1570-
15711548 if (!_Py_IsMainInterpreter (tstate -> interp )) {
15721549 /* Currently, PyGILState is shared by all interpreters. The main
15731550 * interpreter is responsible to initialize it. */
15741551 return _PyStatus_OK ();
15751552 }
15761553
1554+ /* must init with valid states */
1555+ assert (tstate != NULL );
1556+ assert (tstate -> interp != NULL );
1557+
15771558 struct _gilstate_runtime_state * gilstate = & tstate -> interp -> runtime -> gilstate ;
15781559
15791560 gilstate -> autoInterpreterState = tstate -> interp ;
0 commit comments