Skip to content

Commit 8acd6ca

Browse files
authored
[3.11] gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when delegated through PathFinder. (GH-116812) (#116865)
* Make MetadataPathFinder a proper classmethod. * In PathFinder.invalidate_caches, also invoke MetadataPathFinder.invalidate_caches. * Add blurb (cherry picked from commit 5f52d20)
1 parent eaefa0b commit 8acd6ca

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

Lib/importlib/_bootstrap_external.py

+3
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

+1
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

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)