6 changes: 6 additions & 0 deletions Modules/_testmultiphase.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ static int execfunc(PyObject *m)

static PyModuleDef_Slot main_slots[] = {
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down Expand Up @@ -745,6 +746,7 @@ PyInit__testmultiphase_create_unreported_exception(void)
static PyModuleDef_Slot slots_nonmodule_with_exec_slots[] = {
{Py_mod_create, createfunc_nonmodule},
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand All @@ -765,6 +767,7 @@ execfunc_err(PyObject *mod)

static PyModuleDef_Slot slots_exec_err[] = {
{Py_mod_exec, execfunc_err},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand All @@ -786,6 +789,7 @@ execfunc_raise(PyObject *spec)

static PyModuleDef_Slot slots_exec_raise[] = {
{Py_mod_exec, execfunc_raise},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand All @@ -807,6 +811,7 @@ execfunc_unreported_exception(PyObject *mod)

static PyModuleDef_Slot slots_exec_unreported_exception[] = {
{Py_mod_exec, execfunc_unreported_exception},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down Expand Up @@ -845,6 +850,7 @@ meth_state_access_exec(PyObject *m)

static PyModuleDef_Slot meth_state_access_slots[] = {
{Py_mod_exec, meth_state_access_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1710,6 +1710,7 @@ The 'threading' module provides a more convenient interface.");

static PyModuleDef_Slot thread_module_slots[] = {
{Py_mod_exec, thread_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_typingmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ PyDoc_STRVAR(typing_doc,
"Accelerators for the typing module.\n");

static struct PyModuleDef_Slot _typingmodule_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_uuidmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ static PyMethodDef uuid_methods[] = {

static PyModuleDef_Slot uuid_slots[] = {
{Py_mod_exec, uuid_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_weakref.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ weakref_exec(PyObject *module)

static struct PyModuleDef_Slot weakref_slots[] = {
{Py_mod_exec, weakref_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_winapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,7 @@ static int winapi_exec(PyObject *m)

static PyModuleDef_Slot winapi_slots[] = {
{Py_mod_exec, winapi_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_xxinterpchannelsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2418,6 +2418,7 @@ module_exec(PyObject *mod)

static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down
1 change: 1 addition & 0 deletions Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,6 +822,7 @@ module_exec(PyObject *mod)

static struct PyModuleDef_Slot module_slots[] = {
{Py_mod_exec, module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down
5 changes: 4 additions & 1 deletion Modules/_zoneinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -2822,7 +2822,10 @@ zoneinfomodule_exec(PyObject *m)
}

static PyModuleDef_Slot zoneinfomodule_slots[] = {
{Py_mod_exec, zoneinfomodule_exec}, {0, NULL}};
{Py_mod_exec, zoneinfomodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

static struct PyModuleDef zoneinfomodule = {
.m_base = PyModuleDef_HEAD_INIT,
Expand Down
1 change: 1 addition & 0 deletions Modules/arraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3111,6 +3111,7 @@ array_modexec(PyObject *m)

static PyModuleDef_Slot arrayslots[] = {
{Py_mod_exec, array_modexec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
6 changes: 6 additions & 0 deletions Modules/atexitmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -314,12 +314,18 @@ upon normal program termination.\n\
Two public functions, register and unregister, are defined.\n\
");

static PyModuleDef_Slot atexitmodule_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

static struct PyModuleDef atexitmodule = {
PyModuleDef_HEAD_INIT,
.m_name = "atexit",
.m_doc = atexit__doc__,
.m_size = 0,
.m_methods = atexit_methods,
.m_slots = atexitmodule_slots,
};

PyMODINIT_FUNC
Expand Down
1 change: 1 addition & 0 deletions Modules/audioop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,7 @@ audioop_exec(PyObject* module)

static PyModuleDef_Slot audioop_slots[] = {
{Py_mod_exec, audioop_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/binascii.c
Original file line number Diff line number Diff line change
Expand Up @@ -1291,6 +1291,7 @@ binascii_exec(PyObject *module) {

static PyModuleDef_Slot binascii_slots[] = {
{Py_mod_exec, binascii_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/cjkcodecs/cjkcodecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ static struct PyMethodDef _cjk_methods[] = {

static PyModuleDef_Slot _cjk_slots[] = {
{Py_mod_exec, _cjk_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/cjkcodecs/multibytecodec.c
Original file line number Diff line number Diff line change
Expand Up @@ -2062,6 +2062,7 @@ static struct PyMethodDef _multibytecodec_methods[] = {

static PyModuleDef_Slot _multibytecodec_slots[] = {
{Py_mod_exec, _multibytecodec_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/cmathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,7 @@ cmath_exec(PyObject *mod)

static PyModuleDef_Slot cmath_slots[] = {
{Py_mod_exec, cmath_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/errnomodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,7 @@ errno_exec(PyObject *module)

static PyModuleDef_Slot errno_slots[] = {
{Py_mod_exec, errno_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
2 changes: 2 additions & 0 deletions Modules/faulthandler.c
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,8 @@ PyExec_faulthandler(PyObject *module) {

static PyModuleDef_Slot faulthandler_slots[] = {
{Py_mod_exec, PyExec_faulthandler},
// XXX gh-103092: fix isolation.
//{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
erlend-aasland marked this conversation as resolved.
Show resolved Hide resolved
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/fcntlmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,7 @@ fcntl_exec(PyObject *module)

static PyModuleDef_Slot fcntl_slots[] = {
{Py_mod_exec, fcntl_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/gcmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,7 @@ gcmodule_exec(PyObject *module)

static PyModuleDef_Slot gcmodule_slots[] = {
{Py_mod_exec, gcmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/grpmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ grpmodule_exec(PyObject *module)

static PyModuleDef_Slot grpmodule_slots[] = {
{Py_mod_exec, grpmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/itertoolsmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4693,6 +4693,7 @@ itertoolsmodule_exec(PyObject *mod)

static struct PyModuleDef_Slot itertoolsmodule_slots[] = {
{Py_mod_exec, itertoolsmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/mathmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4064,6 +4064,7 @@ static PyMethodDef math_methods[] = {

static PyModuleDef_Slot math_slots[] = {
{Py_mod_exec, math_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/md5module.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ md5_exec(PyObject *m)

static PyModuleDef_Slot _md5_slots[] = {
{Py_mod_exec, md5_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/mmapmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,6 +1713,7 @@ mmap_exec(PyObject *module)

static PyModuleDef_Slot mmap_slots[] = {
{Py_mod_exec, mmap_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
3 changes: 3 additions & 0 deletions Modules/nismodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,9 @@ nis_exec(PyObject *module)

static PyModuleDef_Slot nis_slots[] = {
{Py_mod_exec, nis_exec},
// XXX gh-103092: fix isolation.
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
//{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/overlapped.c
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,7 @@ overlapped_exec(PyObject *module)

static PyModuleDef_Slot overlapped_slots[] = {
{Py_mod_exec, overlapped_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -16793,6 +16793,7 @@ posixmodule_exec(PyObject *m)

static PyModuleDef_Slot posixmodile_slots[] = {
{Py_mod_exec, posixmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/pwdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ pwdmodule_exec(PyObject *module)

static PyModuleDef_Slot pwdmodule_slots[] = {
{Py_mod_exec, pwdmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
3 changes: 3 additions & 0 deletions Modules/pyexpat.c
Original file line number Diff line number Diff line change
Expand Up @@ -2056,6 +2056,9 @@ pyexpat_free(void *module)

static PyModuleDef_Slot pyexpat_slots[] = {
{Py_mod_exec, pyexpat_exec},
// XXX gh-103092: fix isolation.
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
//{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ resource_exec(PyObject *module)

static struct PyModuleDef_Slot resource_slots[] = {
{Py_mod_exec, resource_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/selectmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,7 @@ _select_exec(PyObject *m)

static PyModuleDef_Slot _select_slots[] = {
{Py_mod_exec, _select_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/sha1module.c
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ _sha1_exec(PyObject *module)

static PyModuleDef_Slot _sha1_slots[] = {
{Py_mod_exec, _sha1_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/sha2module.c
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ static int sha2_exec(PyObject *module)

static PyModuleDef_Slot _sha2_slots[] = {
{Py_mod_exec, sha2_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/signalmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,6 +1695,7 @@ _signal_module_free(void *module)

static PyModuleDef_Slot signal_slots[] = {
{Py_mod_exec, signal_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -8870,6 +8870,7 @@ socket_exec(PyObject *m)

static struct PyModuleDef_Slot socket_slots[] = {
{Py_mod_exec, socket_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down
1 change: 1 addition & 0 deletions Modules/spwdmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ spwdmodule_exec(PyObject *module)

static PyModuleDef_Slot spwdmodule_slots[] = {
{Py_mod_exec, spwdmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/symtablemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ symtable_init_constants(PyObject *m)

static PyModuleDef_Slot symtable_slots[] = {
{Py_mod_exec, symtable_init_constants},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/syslogmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ syslog_exec(PyObject *module)

static PyModuleDef_Slot syslog_slots[] = {
{Py_mod_exec, syslog_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/termios.c
Original file line number Diff line number Diff line change
Expand Up @@ -1253,6 +1253,7 @@ termios_exec(PyObject *mod)

static PyModuleDef_Slot termios_slots[] = {
{Py_mod_exec, termios_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/timemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,7 @@ time_module_free(void *module)

static struct PyModuleDef_Slot time_slots[] = {
{Py_mod_exec, time_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/unicodedata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,7 @@ unicodedata_exec(PyObject *module)

static PyModuleDef_Slot unicodedata_slots[] = {
{Py_mod_exec, unicodedata_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/xxlimited.c
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ xx_modexec(PyObject *m)

static PyModuleDef_Slot xx_slots[] = {
{Py_mod_exec, xx_modexec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/xxlimited_35.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ xx_modexec(PyObject *m)

static PyModuleDef_Slot xx_slots[] = {
{Py_mod_exec, xx_modexec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Modules/xxmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ xx_exec(PyObject *m)

static struct PyModuleDef_Slot xx_slots[] = {
{Py_mod_exec, xx_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down
1 change: 1 addition & 0 deletions Modules/xxsubtype.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ xxsubtype_exec(PyObject* m)

static struct PyModuleDef_Slot xxsubtype_slots[] = {
{Py_mod_exec, xxsubtype_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down
1 change: 1 addition & 0 deletions Modules/zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2109,6 +2109,7 @@ zlib_exec(PyObject *mod)

static PyModuleDef_Slot zlib_slots[] = {
{Py_mod_exec, zlib_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

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
6 changes: 6 additions & 0 deletions Objects/unicodeobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -15192,12 +15192,18 @@ static PyMethodDef _string_methods[] = {
{NULL, NULL}
};

static PyModuleDef_Slot module_slots[] = {
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

static struct PyModuleDef _string_module = {
PyModuleDef_HEAD_INIT,
.m_name = "_string",
.m_doc = PyDoc_STR("string helper module"),
.m_size = 0,
.m_methods = _string_methods,
.m_slots = module_slots,
};

PyMODINIT_FUNC
Expand Down
1 change: 1 addition & 0 deletions PC/_testconsole.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ static int execfunc(PyObject *m)

PyModuleDef_Slot testconsole_slots[] = {
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL},
};

Expand Down
1 change: 1 addition & 0 deletions PC/msvcrtmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@ exec_module(PyObject* m)

static PyModuleDef_Slot msvcrt_slots[] = {
{Py_mod_exec, exec_module},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions PC/winreg.c
Original file line number Diff line number Diff line change
Expand Up @@ -2184,6 +2184,7 @@ exec_module(PyObject *m)

static PyModuleDef_Slot winreg_slots[] = {
{Py_mod_exec, exec_module},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions PC/winsound.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ exec_module(PyObject *module)

static PyModuleDef_Slot sound_slots[] = {
{Py_mod_exec, exec_module},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Parser/asdl_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ def visitModule(self, mod):
self.emit("""
static PyModuleDef_Slot astmodule_slots[] = {
{Py_mod_exec, astmodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Python/Python-ast.c

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Python/Python-tokenize.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ static PyMethodDef tokenize_methods[] = {

static PyModuleDef_Slot tokenizemodule_slots[] = {
{Py_mod_exec, tokenizemodule_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Python/_warnings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,6 +1449,7 @@ warnings_module_exec(PyObject *module)

static PyModuleDef_Slot warnings_slots[] = {
{Py_mod_exec, warnings_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -3840,6 +3840,7 @@ imp_module_exec(PyObject *module)

static PyModuleDef_Slot imp_slots[] = {
{Py_mod_exec, imp_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down
1 change: 1 addition & 0 deletions Python/marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1870,6 +1870,7 @@ marshal_module_exec(PyObject *mod)

static PyModuleDef_Slot marshalmodule_slots[] = {
{Py_mod_exec, marshal_module_exec},
{Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
{0, NULL}
};

Expand Down