Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-99113: Add a check for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED #104206

Merged
Prev Previous commit
Add a test for when an extension has multiple Py_mod_multiple_interpr…
…eters slots.
  • Loading branch information
ericsnowcurrently committed May 6, 2023
commit 376217a8bfb08f49ac993cc4185f9fd92f3bb49e
1 change: 1 addition & 0 deletions Lib/test/test_importlib/extension/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ def test_bad_modules(self):
'exec_raise',
'exec_unreported_exception',
'multiple_create_slots',
'multiple_multiple_interpreters_slots',
]:
with self.subTest(name_base):
name = self.name + '_' + name_base
Expand Down
17 changes: 17 additions & 0 deletions Modules/_testmultiphase.c
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,23 @@ PyInit__test_module_state_shared(void)

/* multiple interpreters support */

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

static PyModuleDef def_multiple_multiple_interpreters_slots = TEST_MODULE_DEF(
"_testmultiphase_multiple_multiple_interpreters_slots",
slots_multiple_multiple_interpreters_slots,
NULL);

PyMODINIT_FUNC
PyInit__testmultiphase_multiple_multiple_interpreters_slots(void)
{
return PyModuleDef_Init(&def_multiple_multiple_interpreters_slots);
}

static PyModuleDef_Slot non_isolated_slots[] = {
{Py_mod_exec, execfunc},
{Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED},
Expand Down