aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorEric Snow <ericsnowcurrently@gmail.com>2022-11-11 17:06:05 -0700
committerGitHub <noreply@github.com>2022-11-11 17:06:05 -0700
commit7f3a4b967cfb1596a3fda6c34f900f8586b16700 (patch)
treec4381e2cdfce4f636d2eff0288bf5ec59c74c44d /Python/sysmodule.c
parent67807cfc87135fdce4992d38d2ffe3e44747e73b (diff)
downloadcpython-7f3a4b967cfb1596a3fda6c34f900f8586b16700.tar.gz
cpython-7f3a4b967cfb1596a3fda6c34f900f8586b16700.zip
gh-81057: Move PyImport_Inittab to _PyRuntimeState (gh-99402)
We actually don't move PyImport_Inittab. Instead, we make a copy that we keep on _PyRuntimeState and use only that after Py_Initialize(). We also prevent folks from modifying PyImport_Inittab (the best we can) after that point. https://github.com/python/cpython/issues/81057
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 5de684e7195..1090b124fea 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -2252,8 +2252,9 @@ list_builtin_module_names(void)
if (list == NULL) {
return NULL;
}
- for (Py_ssize_t i = 0; PyImport_Inittab[i].name != NULL; i++) {
- PyObject *name = PyUnicode_FromString(PyImport_Inittab[i].name);
+ struct _inittab *inittab = _PyRuntime.imports.inittab;
+ for (Py_ssize_t i = 0; inittab[i].name != NULL; i++) {
+ PyObject *name = PyUnicode_FromString(inittab[i].name);
if (name == NULL) {
goto error;
}