@@ -994,8 +994,10 @@ do_warn(PyObject *message, PyObject *category, Py_ssize_t stack_level,
994
994
& filename , & lineno , & module , & registry ))
995
995
return NULL ;
996
996
997
+ #ifdef Py_GIL_DISABLED
997
998
WarningsState * st = warnings_get_state (tstate -> interp );
998
999
assert (st != NULL );
1000
+ #endif
999
1001
1000
1002
Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
1001
1003
res = warn_explicit (tstate , category , message , filename , lineno , module , registry ,
@@ -1149,8 +1151,10 @@ warnings_warn_explicit_impl(PyObject *module, PyObject *message,
1149
1151
}
1150
1152
}
1151
1153
1154
+ #ifdef Py_GIL_DISABLED
1152
1155
WarningsState * st = warnings_get_state (tstate -> interp );
1153
1156
assert (st != NULL );
1157
+ #endif
1154
1158
1155
1159
Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
1156
1160
returned = warn_explicit (tstate , category , message , filename , lineno ,
@@ -1296,8 +1300,10 @@ PyErr_WarnExplicitObject(PyObject *category, PyObject *message,
1296
1300
return -1 ;
1297
1301
}
1298
1302
1303
+ #ifdef Py_GIL_DISABLED
1299
1304
WarningsState * st = warnings_get_state (tstate -> interp );
1300
1305
assert (st != NULL );
1306
+ #endif
1301
1307
1302
1308
Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
1303
1309
res = warn_explicit (tstate , category , message , filename , lineno ,
@@ -1367,8 +1373,10 @@ PyErr_WarnExplicitFormat(PyObject *category,
1367
1373
PyObject * res ;
1368
1374
PyThreadState * tstate = get_current_tstate ();
1369
1375
if (tstate != NULL ) {
1376
+ #ifdef Py_GIL_DISABLED
1370
1377
WarningsState * st = warnings_get_state (tstate -> interp );
1371
1378
assert (st != NULL );
1379
+ #endif
1372
1380
1373
1381
Py_BEGIN_CRITICAL_SECTION_MUT (& st -> mutex );
1374
1382
res = warn_explicit (tstate , category , message , filename , lineno ,
0 commit comments