Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when delegated through PathFinder. #116812

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -1470,6 +1470,9 @@ def invalidate_caches():
# https://bugs.python.org/issue45703
_NamespacePath._epoch += 1

from importlib.metadata import MetadataPathFinder
MetadataPathFinder.invalidate_caches()

@staticmethod
def _path_hooks(path):
"""Search sys.path_hooks for a finder for 'path'."""
Expand Down
1 change: 1 addition & 0 deletions Lib/importlib/metadata/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ def _search_paths(cls, name, paths):
path.search(prepared) for path in map(FastPath, paths)
)

@classmethod
def invalidate_caches(cls) -> None:
FastPath.__new__.cache_clear()

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
In ``PathFinder.invalidate_caches``, delegate to
``MetadataPathFinder.invalidate_caches``.
Loading