@@ -994,8 +994,10 @@ do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level,
994994 & filename , & lineno , & module , & registry ))
995995 return NULL ;
996996
997+ #ifdef Py_GIL_DISABLED
997998 WarningsState * st = warnings_get_state (tstate -> interp );
998999 assert (st != NULL );
1000+ #endif
9991001
10001002 Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
10011003 res = warn_explicit (tstate , category , message , filename , lineno , module , registry ,
@@ -1149,8 +1151,10 @@ warnings_warn_explicit_impl(PyObject *module, PyObject *message,
11491151 }
11501152 }
11511153
1154+ #ifdef Py_GIL_DISABLED
11521155 WarningsState * st = warnings_get_state (tstate -> interp );
11531156 assert (st != NULL );
1157+ #endif
11541158
11551159 Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
11561160 returned = warn_explicit (tstate , category , message , filename , lineno ,
@@ -1296,8 +1300,10 @@ PyErr_WarnExplicitObject(PyObject *category, PyObject *message,
12961300 return -1 ;
12971301 }
12981302
1303+ #ifdef Py_GIL_DISABLED
12991304 WarningsState * st = warnings_get_state (tstate -> interp );
13001305 assert (st != NULL );
1306+ #endif
13011307
13021308 Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
13031309 res = warn_explicit (tstate , category , message , filename , lineno ,
@@ -1367,8 +1373,10 @@ PyErr_WarnExplicitFormat(PyObject *category,
13671373 PyObject * res ;
13681374 PyThreadState * tstate = get_current_tstate ();
13691375 if (tstate != NULL ) {
1376+ #ifdef Py_GIL_DISABLED
13701377 WarningsState * st = warnings_get_state (tstate -> interp );
13711378 assert (st != NULL );
1379+ #endif
13721380
13731381 Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
13741382 res = warn_explicit (tstate , category , message , filename , lineno ,
0 commit comments