]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-130094: Fix race conditions in `importlib` (gh-130101)
authorSam Gross <colesbury@gmail.com>
Tue, 18 Feb 2025 23:02:42 +0000 (18:02 -0500)
committerGitHub <noreply@github.com>
Tue, 18 Feb 2025 23:02:42 +0000 (18:02 -0500)
commit857bdba0ac66ed7963e9fca45ab1a5f7a32b4bfb
tree2afdcdf8b7928992c726b892a40f900f0a4a40f6
parent8207454bc00db8efa0e05c93381ecc8e3efc86a7
gh-130094: Fix race conditions in `importlib` (gh-130101)

Entries may be added or removed from `sys.meta_path` concurrently. For
example, setuptools temporarily adds and removes the `distutils` finder from
the beginning of the list. The local copy ensures that we don't skip over any
entries.

Some packages modify `sys.modules` during import. For example, `collections`
inserts the entry for `collections.abc`  into `sys.modules` during import. We
need to ensure that we re-check `sys.modules` *after* the parent module is
fully initialized.
Lib/importlib/_bootstrap.py
Misc/NEWS.d/next/Core_and_Builtins/2025-02-14-00-32-52.gh-issue-130094.m3EF9E.rst [new file with mode: 0644]