diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2023-05-06 21:57:35 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-06 21:57:35 (GMT) |
commit | fff193bbfebe7b00229856b1e8105ab3de36437f (patch) | |
tree | 1deea51990bee00db4ddc40b868cbd7bcf098c64 /Modules | |
parent | 3b14b51d11ae23a915299a8f9bf650ca2ae90566 (diff) | |
download | cpython-fff193bbfebe7b00229856b1e8105ab3de36437f.zip cpython-fff193bbfebe7b00229856b1e8105ab3de36437f.tar.gz cpython-fff193bbfebe7b00229856b1e8105ab3de36437f.tar.bz2 |
gh-99113: Add a check for Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104206)
Py_MOD_PER_INTERPRETER_GIL_SUPPORTED is a new supported value for Py_mod_multiple_interpreters, added in gh-104205.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testmultiphase.c | 60 |
1 files changed, 59 insertions, 1 deletions
diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index 58b064b..ca71b61 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -682,6 +682,27 @@ PyInit__testmultiphase_export_unreported_exception(void) } static PyObject* +createfunc_noop(PyObject *spec, PyModuleDef *def) +{ + return PyModule_New("spam"); +} + +static PyModuleDef_Slot slots_multiple_create_slots[] = { + {Py_mod_create, createfunc_noop}, + {Py_mod_create, createfunc_noop}, + {0, NULL}, +}; + +static PyModuleDef def_multiple_create_slots = TEST_MODULE_DEF( + "_testmultiphase_multiple_create_slots", slots_multiple_create_slots, NULL); + +PyMODINIT_FUNC +PyInit__testmultiphase_multiple_create_slots(void) +{ + return PyModuleDef_Init(&def_multiple_create_slots); +} + +static PyObject* createfunc_null(PyObject *spec, PyModuleDef *def) { return NULL; @@ -892,7 +913,24 @@ PyInit__test_module_state_shared(void) } -/* multiple interpreters supports */ +/* 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}, @@ -909,3 +947,23 @@ PyInit__test_non_isolated(void) { return PyModuleDef_Init(&non_isolated_def); } + + +static PyModuleDef_Slot shared_gil_only_slots[] = { + {Py_mod_exec, execfunc}, + /* Note that Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED is the default. + We put it here explicitly to draw attention to the contrast + with Py_MOD_PER_INTERPRETER_GIL_SUPPORTED. */ + {Py_mod_multiple_interpreters, Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED}, + {0, NULL}, +}; + +static PyModuleDef shared_gil_only_def = TEST_MODULE_DEF("_test_shared_gil_only", + shared_gil_only_slots, + testexport_methods); + +PyMODINIT_FUNC +PyInit__test_shared_gil_only(void) +{ + return PyModuleDef_Init(&shared_gil_only_def); +} |