]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-102660: Fix is_core_module() (gh-103257)
authorEric Snow <ericsnowcurrently@gmail.com>
Tue, 4 Apr 2023 23:03:40 +0000 (17:03 -0600)
committerGitHub <noreply@github.com>
Tue, 4 Apr 2023 23:03:40 +0000 (17:03 -0600)
commitf513d5c80672c76acbdaf7d5b601f4bbe9fae56a
tree2e62703bea7ceb964c1de11eaa14a1383b23aed8
parentbceb9e00ad2998e5193ad5b477e92a114dd31024
gh-102660: Fix is_core_module() (gh-103257)

In gh-102744 we added is_core_module() (in Python/import.c), which relies on get_core_module_dict() (also added in that PR).  The problem is that_PyImport_FixupBuiltin(), which ultimately calls is_core_module(), is called on the builtins module before interp->builtins_copyis set.  Consequently, the builtins module isn't considered a "core" module while it is getting "fixed up" and its module def m_copy erroneously gets set.  Under isolated interpreters this causes problems since sys and builtins are allowed even though they are still single-phase init modules.  (This was discovered while working on gh-101660.)

The solution is to stop relying on get_core_module_dict() in is_core_module().
Python/import.c