Skip to content

Commit

Permalink
Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.
Browse files Browse the repository at this point in the history
  • Loading branch information
ericsnowcurrently committed May 5, 2023
1 parent 1c420e1 commit a1b027a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions Include/moduleobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct PyModuleDef_Slot {
/* for Py_mod_multiple_interpreters: */
#define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
#define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
#define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)

#endif /* New in 3.5 */

Expand Down
3 changes: 2 additions & 1 deletion Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio
int has_execution_slots = 0;
const char *name;
int ret;
PyInterpreterState *interp = _PyInterpreterState_GET();

PyModuleDef_Init(def);

Expand Down Expand Up @@ -316,13 +317,13 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio
multiple_interpreters = Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
}
if (multiple_interpreters == Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED) {
PyInterpreterState *interp = _PyInterpreterState_GET();
if (!_Py_IsMainInterpreter(interp)
&& _PyImport_CheckSubinterpIncompatibleExtensionAllowed(name) < 0)
{
goto error;
}
}
// XXX Do a similar check once we have PyInterpreterState.ceval.own_gil.

if (create) {
m = create(spec, def);
Expand Down

0 comments on commit a1b027a

Please sign in to comment.