summaryrefslogtreecommitdiff
path: root/Objects
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2023-05-05 15:11:27 -0600
committerGitHub <noreply@github.com>2023-05-05 21:11:27 +0000
commita9c6e0618f26270e2591b3d99ffeef55eea02a33 (patch)
tree81bdd175c8c3b61aa3aab02cac66a122f1372871 /Objects
parent1c420e138fd828895b6bd3c44ef99156e8796095 (diff)
downloadcpython-git-a9c6e0618f26270e2591b3d99ffeef55eea02a33.tar.gz
gh-99113: Add Py_MOD_PER_INTERPRETER_GIL_SUPPORTED (gh-104205)
Here we are doing no more than adding the value for Py_mod_multiple_interpreters and using it for stdlib modules. We will start checking for it in gh-104206 (once PyInterpreterState.ceval.own_gil is added in gh-104204).
Diffstat (limited to 'Objects')
-rw-r--r--Objects/moduleobject.c3
-rw-r--r--Objects/unicodeobject.c6
2 files changed, 8 insertions, 1 deletions
diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c
index 63f4226dd9..c100d018d3 100644
--- a/Objects/moduleobject.c
+++ b/Objects/moduleobject.c
@@ -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);
@@ -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);
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 6ae68cc20f..1585a582f0 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -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