Skip to content
Prev Previous commit
Next Next commit
Fix "Py_NOGIL" sysconfig variable.
It should be zero or one and always defined.
  • Loading branch information
colesbury committed Oct 4, 2023
commit 34fe412468a1b5be2adbf14f78856c117880a46b
10 changes: 8 additions & 2 deletions Modules/_sysconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Python.h"

#include "pycore_importdl.h" // _PyImport_DynLoadFiletab
#include "pycore_long.h" // _PyLong_GetZero, _PyLong_GetOne


/*[clinic input]
Expand Down Expand Up @@ -54,12 +55,17 @@ _sysconfig_config_vars_impl(PyObject *module)
return NULL;
}
#endif

#ifdef Py_NOGIL
if (PyDict_SetItem(config, "Py_NOGIL", _PyLong_GetOne()) < 0) {
PyObject *py_nogil = _PyLong_GetOne();
#else
PyObject *py_nogil = _PyLong_GetZero();
#endif
if (PyDict_SetItemString(config, "Py_NOGIL", py_nogil) < 0) {
Py_DECREF(config);
return NULL;
}
#endif

return config;
}

Expand Down