8000 gh-104108: Add the Py_mod_multiple_interpreters Module Def Slot by ericsnowcurrently · Pull Request #104148 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-104108: Add the Py_mod_multiple_interpreters Module Def Slot #104148

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

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix the flags.
  • Loading branch information
ericsnowcurrently committed May 4, 2023
commit 6e875bcaba0521353b2e8cf20bc8ccd43aaf51fc
14 changes: 8 additions & 6 deletions Objects/moduleobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio
PyObject *(*create)(PyObject *, PyModuleDef*) = NULL;
PyObject *nameobj;
PyObject *m = NULL;
Py_ssize_t multiple_interpreters = -1;
int has_multiple_interpreters_slot = 0;
void *multiple_interpreters;
int has_execution_slots = 0;
const char *name;
int ret;
Expand Down Expand Up @@ -289,14 +290,15 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio
has_execution_slots = 1;
break;
case Py_mod_multiple_interpreters:
if (multiple_interpreters >= 0) {
if (has_multiple_interpreters_slot) {
PyErr_Format(
PyExc_SystemError,
"module %s has more than one 'multiple interpreters' slots",
name);
goto error;
}
multiple_interpreters = (Py_ssize_t)cur_slot->value;
multiple_interpreters = cur_slot->value;
has_multiple_interpreters_slot = 1;
break;
default:
assert(cur_slot->slot < 0 || cur_slot->slot > _Py_mod_LAST_SLOT);
Expand All @@ -310,10 +312,10 @@ PyModule_FromDefAndSpec2(PyModuleDef* def, PyObject *spec, int module_api_versio

/* By default, multi-phase init modules are expected
to work under multiple interpreters. */
if (multiple_interpreters < 0) {
multiple_interpreters = (Py_ssize_t)Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
if (!has_multiple_interpreters_slot) {
multiple_interpreters = Py_MOD_MULTIPLE_INTERPRETERS_SUPPORTED;
}
if (!multiple_interpreters) {
if (multiple_interpreters == Py_MOD_MULTIPLE_INTERPRETERS_NOT_SUPPORTED) {
PyInterpreterState *interp = _PyInterpreterState_GET();
if (!_Py_IsMainInterpreter(interp)
&& _PyImport_CheckSubinterpIncompatibleExtensionAllowed(name) < 0)
Expand Down
0