]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-117953: Track Extra Details in Global Extensions Cache (gh-118532)
authorEric Snow <ericsnowcurrently@gmail.com>
Sat, 4 May 2024 21:24:02 +0000 (15:24 -0600)
committerGitHub <noreply@github.com>
Sat, 4 May 2024 21:24:02 +0000 (21:24 +0000)
commit291cfa454b9c5b677c955aaf53fab91f0186b6fa
tree0a0976010c9f0bd5fb77f80e00f44fa726d7c665
parent978fba58aef347de4a1376e525df2dacc7b2fff3
gh-117953: Track Extra Details in Global Extensions Cache (gh-118532)

We have only been tracking each module's PyModuleDef.  However, there are some problems with that.  For example, in some cases we load single-phase init extension modules from def->m_base.m_init or def->m_base.m_copy, but if multiple modules share a def then we can end up with unexpected behavior.

With this change, we track the following:

* PyModuleDef (same as before)
* for some modules, its init function or a copy of its __dict__, but specific to that module
* whether it is a builtin/core module or a "dynamic" extension
* the interpreter (ID) that owns the cached __dict__ (only if cached)

This also makes it easier to remember the module's kind (e.g. single-phase init) and if loading it previously failed, which I'm doing separately.
Include/internal/pycore_importdl.h
Python/import.c
Python/importdl.c