diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-11-21 11:43:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-21 11:43:23 (GMT) |
commit | 9dda9020abcf0d51d59b283a89c58c8e1fb0f574 (patch) | |
tree | 7dbd62607a0231f091aaf86e05affe4b4c338d76 /Python | |
parent | bb4c09158324e0369e5cc1f6a021ebe144703202 (diff) | |
download | cpython-9dda9020abcf0d51d59b283a89c58c8e1fb0f574.zip cpython-9dda9020abcf0d51d59b283a89c58c8e1fb0f574.tar.gz cpython-9dda9020abcf0d51d59b283a89c58c8e1fb0f574.tar.bz2 |
gh-99578: Fix refleak in _imp.create_builtin() (GH-99642)
Fix a reference bug in _imp.create_builtin() after the creation of
the first sub-interpreter for modules "builtins" and "sys".
(cherry picked from commit cb2ef8b2acbb231c207207d3375b2f8b0077a6ee)
Co-authored-by: Victor Stinner <vstinner@python.org>
Diffstat (limited to 'Python')
-rw-r--r-- | Python/import.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Python/import.c b/Python/import.c index ca728c4..07a8b90 100644 --- a/Python/import.c +++ b/Python/import.c @@ -978,7 +978,8 @@ create_builtin(PyThreadState *tstate, PyObject *name, PyObject *spec) if (_PyUnicode_EqualToASCIIString(name, p->name)) { if (p->initfunc == NULL) { /* Cannot re-init internal module ("sys" or "builtins") */ - return PyImport_AddModuleObject(name); + mod = PyImport_AddModuleObject(name); + return Py_XNewRef(mod); } mod = _PyImport_InitFunc_TrampolineCall(*p->initfunc); if (mod == NULL) { |