]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when delegated...
authorJason R. Coombs <jaraco@jaraco.com>
Thu, 14 Mar 2024 21:59:00 +0000 (17:59 -0400)
committerGitHub <noreply@github.com>
Thu, 14 Mar 2024 21:59:00 +0000 (17:59 -0400)
* Make MetadataPathFinder a proper classmethod.

* In PathFinder.invalidate_caches, also invoke MetadataPathFinder.invalidate_caches.

* Add blurb

Lib/importlib/_bootstrap_external.py
Lib/importlib/metadata/__init__.py
Misc/NEWS.d/next/Library/2024-03-14-10-01-23.gh-issue-116811._h5iKP.rst [new file with mode: 0644]

index 46ddceed07b0d4b43c6495445cff09ca974d371e..b26be8583d0f81bfaffb67f986ccd7eb8c691ada 100644 (file)
@@ -1470,6 +1470,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'."""
index c612fbefee2e8028297018122d080c2094009502..41c2a4a6088b5d7588ba1b95cd53a29dd75742bf 100644 (file)
@@ -797,6 +797,7 @@ class MetadataPathFinder(DistributionFinder):
             path.search(prepared) for path in map(FastPath, paths)
         )
 
+    @classmethod
     def invalidate_caches(cls) -> None:
         FastPath.__new__.cache_clear()
 
diff --git a/Misc/NEWS.d/next/Library/2024-03-14-10-01-23.gh-issue-116811._h5iKP.rst b/Misc/NEWS.d/next/Library/2024-03-14-10-01-23.gh-issue-116811._h5iKP.rst
new file mode 100644 (file)
index 0000000..0016863
--- /dev/null
@@ -0,0 +1,2 @@
+In ``PathFinder.invalidate_caches``, delegate to
+``MetadataPathFinder.invalidate_caches``.