Skip to content

Commit cc31cbd

Browse files
committed
[3.11] pythongh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when delegated through PathFinder. (pythonGH-116812)
* Make MetadataPathFinder a proper classmethod. * In PathFinder.invalidate_caches, also invoke MetadataPathFinder.invalidate_caches. * Add blurb (cherry picked from commit 5f52d20) Co-authored-by: Jason R. Coombs <[email protected]>
1 parent eaefa0b commit cc31cbd

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Lib/importlib/_bootstrap_external.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,9 @@ def invalidate_caches():
14051405
# https://bugs.python.org/issue45703
14061406
_NamespacePath._epoch += 1
14071407

1408+
from importlib.metadata import MetadataPathFinder
1409+
MetadataPathFinder.invalidate_caches()
1410+
14081411
@staticmethod
14091412
def _path_hooks(path):
14101413
"""Search sys.path_hooks for a finder for 'path'."""

Lib/importlib/metadata/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ def _search_paths(cls, name, paths):
915915
path.search(prepared) for path in map(FastPath, paths)
916916
)
917917

918+
@classmethod
918919
def invalidate_caches(cls):
919920
FastPath.__new__.cache_clear()
920921

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
In ``PathFinder.invalidate_caches``, delegate to
2+
``MetadataPathFinder.invalidate_caches``.

0 commit comments

Comments
 (0)