summaryrefslogtreecommitdiffstats
path: root/Lib/importlib
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2024-03-15 13:59:28 (GMT)
committerGitHub <noreply@github.com>2024-03-15 13:59:28 (GMT)
commit8336cb2b6f428246803b02a4e97fce49d0bb1e09 (patch)
tree2c5ff62912a690bc1be9a54401cf15645878541a /Lib/importlib
parentabd079806d5f676410fbeaf1a7980f75f85833f7 (diff)
downloadcpython-8336cb2b6f428246803b02a4e97fce49d0bb1e09.zip
cpython-8336cb2b6f428246803b02a4e97fce49d0bb1e09.tar.gz
cpython-8336cb2b6f428246803b02a4e97fce49d0bb1e09.tar.bz2
[3.12] gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when delegated through PathFinder. (GH-116812) (#116864)
* Make MetadataPathFinder a proper classmethod. * In PathFinder.invalidate_caches, also invoke MetadataPathFinder.invalidate_caches. * Add blurb (cherry picked from commit 5f52d20a93908196f74271db8437cc1ba7e1e262)
Diffstat (limited to 'Lib/importlib')
-rw-r--r--Lib/importlib/_bootstrap_external.py3
-rw-r--r--Lib/importlib/metadata/__init__.py1
2 files changed, 4 insertions, 0 deletions
diff --git a/Lib/importlib/_bootstrap_external.py b/Lib/importlib/_bootstrap_external.py
index e6f75a9..61dafc0 100644
--- a/Lib/importlib/_bootstrap_external.py
+++ b/Lib/importlib/_bootstrap_external.py
@@ -1450,6 +1450,9 @@ class PathFinder:
# 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'."""
diff --git a/Lib/importlib/metadata/__init__.py b/Lib/importlib/metadata/__init__.py
index 82e0ce1..54156e9 100644
--- a/Lib/importlib/metadata/__init__.py
+++ b/Lib/importlib/metadata/__init__.py
@@ -795,6 +795,7 @@ class MetadataPathFinder(DistributionFinder):
path.search(prepared) for path in map(FastPath, paths)
)
+ @classmethod
def invalidate_caches(cls):
FastPath.__new__.cache_clear()