@@ -1017,9 +1017,10 @@ struct extensions_cache_value {
10171017 _Py_ext_module_origin origin ;
10181018
10191019#ifdef Py_GIL_DISABLED
1020- /* The module's md_gil slot, for legacy modules that are reinitialized from
1021- m_dict rather than calling their initialization function again. */
1022- void * md_gil ;
1020+ /* The module's md_requires_gil member, for legacy modules that are
1021+ * reinitialized from m_dict rather than calling their initialization
1022+ * function again. */
1023+ bool md_requires_gil ;
10231024#endif
10241025};
10251026
@@ -1350,7 +1351,7 @@ static struct extensions_cache_value *
13501351_extensions_cache_set (PyObject * path , PyObject * name ,
13511352 PyModuleDef * def , PyModInitFunction m_init ,
13521353 Py_ssize_t m_index , PyObject * m_dict ,
1353- _Py_ext_module_origin origin , void * md_gil )
1354+ _Py_ext_module_origin origin , bool requires_gil )
13541355{
13551356 struct extensions_cache_value * value = NULL ;
13561357 void * key = NULL ;
@@ -1405,11 +1406,11 @@ _extensions_cache_set(PyObject *path, PyObject *name,
14051406 /* m_dict is set by set_cached_m_dict(). */
14061407 .origin = origin ,
14071408#ifdef Py_GIL_DISABLED
1408- .md_gil = md_gil ,
1409+ .md_requires_gil = requires_gil ,
14091410#endif
14101411 };
14111412#ifndef Py_GIL_DISABLED
1412- (void )md_gil ;
1413+ (void )requires_gil ;
14131414#endif
14141415 if (init_cached_m_dict (newvalue , m_dict ) < 0 ) {
14151416 goto finally ;
@@ -1547,7 +1548,8 @@ _PyImport_CheckGILForModule(PyObject* module, PyObject *module_name)
15471548 }
15481549
15491550 if (!PyModule_Check (module ) ||
1550- ((PyModuleObject * )module )-> md_gil == Py_MOD_GIL_USED ) {
1551+ ((PyModuleObject * )module )-> md_requires_gil )
1552+ {
15511553 if (_PyEval_EnableGILPermanent (tstate )) {
15521554 int warn_result = PyErr_WarnFormat (
15531555 PyExc_RuntimeWarning ,
@@ -1725,7 +1727,7 @@ struct singlephase_global_update {
17251727 Py_ssize_t m_index ;
17261728 PyObject * m_dict ;
17271729 _Py_ext_module_origin origin ;
1728- void * md_gil ;
1730+ bool md_requires_gil ;
17291731};
17301732
17311733static struct extensions_cache_value *
@@ -1784,7 +1786,7 @@ update_global_state_for_extension(PyThreadState *tstate,
17841786#endif
17851787 cached = _extensions_cache_set (
17861788 path , name , def , m_init , singlephase -> m_index , m_dict ,
1787- singlephase -> origin , singlephase -> md_gil );
1789+ singlephase -> origin , singlephase -> md_requires_gil );
17881790 if (cached == NULL ) {
17891791 // XXX Ignore this error? Doing so would effectively
17901792 // mark the module as not loadable.
@@ -1873,7 +1875,7 @@ reload_singlephase_extension(PyThreadState *tstate,
18731875 if (def -> m_base .m_copy != NULL ) {
18741876 // For non-core modules, fetch the GIL slot that was stored by
18751877 // import_run_extension().
1876- ((PyModuleObject * )mod )-> md_gil = cached -> md_gil ;
1878+ ((PyModuleObject * )mod )-> md_requires_gil = cached -> md_requires_gil ;
18771879 }
18781880#endif
18791881 /* We can't set mod->md_def if it's missing,
@@ -2128,7 +2130,7 @@ import_run_extension(PyThreadState *tstate, PyModInitFunction p0,
21282130 .m_index = def -> m_base .m_index ,
21292131 .origin = info -> origin ,
21302132#ifdef Py_GIL_DISABLED
2131- .md_gil = ((PyModuleObject * )mod )-> md_gil ,
2133+ .md_requires_gil = ((PyModuleObject * )mod )-> md_requires_gil ,
21322134#endif
21332135 };
21342136 // gh-88216: Extensions and def->m_base.m_copy can be updated
@@ -2323,7 +2325,7 @@ _PyImport_FixupBuiltin(PyThreadState *tstate, PyObject *mod, const char *name,
23232325 .origin = _Py_ext_module_origin_CORE ,
23242326#ifdef Py_GIL_DISABLED
23252327 /* Unused when m_dict == NULL. */
2326- .md_gil = NULL ,
2328+ .md_requires_gil = false ,
23272329#endif
23282330 };
23292331 cached = update_global_state_for_extension (
0 commit comments