Skip to content

Commit a1b027a

Browse files
Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED.
1 parent 1c420e1 commit a1b027a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Include/moduleobject.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct PyModuleDef_Slot {
8787
/* for Py_mod_multiple_interpreters: */
8888
#define Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED ((void *)0)
8989
#define Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED ((void *)1)
90+
#define Py_MOD_PER_INTERPRETER_GIL_SUPPORTED ((void *)2)
9091

9192
#endif /* New in 3.5 */
9293

Objects/moduleobject.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio
250250
int has_execution_slots = 0;
251251
const char *name;
252252
int ret;
253+
PyInterpreterState *interp = _PyInterpreterState_GET();
253254

254255
PyModuleDef_Init(def);
255256

@@ -316,13 +317,13 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio
316317
multiple_interpreters = Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
317318
}
318319
if (multiple_interpreters == Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED) {
319-
PyInterpreterState *interp = _PyInterpreterState_GET();
320320
if (!_Py_IsMainInterpreter(interp)
321321
&& _PyImport_CheckSubinterpIncompatibleExtensionAllowed(name) < 0)
322322
{
323323
goto error;
324324
}
325325
}
326+
// XXX Do a similar check once we have PyInterpreterState.ceval.own_gil.
326327

327328
if (create) {
328329
m = create(spec, def);

0 commit comments

Comments
 (0)