Skip to content

gh-102660: Fix is_core_module() - #103257

Merged
ericsnowcurrently merged 1 commit into
python:mainfrom
ericsnowcurrently:fix-builtins-mcopy
Apr 4, 2023
Merged

ericsnowcurrently merged 1 commit into
python:mainfrom
ericsnowcurrently:fix-builtins-mcopy

Conversation

@ericsnowcurrently

@ericsnowcurrently ericsnowcurrently commented Apr 4, 2023 •

Copy link
Copy Markdown
Member

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 defm_copy` get 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().

@ericsnowcurrently
ericsnowcurrently merged commit f513d5c into python:main Apr 4, 2023
@ericsnowcurrently
ericsnowcurrently deleted the fix-builtins-mcopy branch April 4, 2023 23:03
gaogaotiantian pushed a commit to gaogaotiantian/cpython that referenced this pull request Apr 8, 2023
In pythongh-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 pythongh-101660.)

The solution is to stop relying on get_core_module_dict() in is_core_module().
warsaw pushed a commit to warsaw/cpython that referenced this pull request Apr 11, 2023
In pythongh-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 pythongh-101660.)

The solution is to stop relying on get_core_module_dict() in is_core_module().
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants