]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-116811: Ensure MetadataPathFinder.invalidate_caches is reachable when deleg...
authorJason R. Coombs <jaraco@jaraco.com>
Fri, 15 Mar 2024 13:59:32 +0000 (09:59 -0400)
committerGitHub <noreply@github.com>
Fri, 15 Mar 2024 13:59:32 +0000 (09:59 -0400)
* Make MetadataPathFinder a proper classmethod.

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

* Add blurb
(cherry picked from commit 5f52d20a93908196f74271db8437cc1ba7e1e262)

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 f603a89f7f5a98c5081df371ee6f76aed4df7f79..e53f6acf38fc642f79a744f46d70b8b289ca7be0 100644 (file)
@@ -1405,6 +1405,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 bbdbceebe759d9ca3d0ae66b9c05f8474b2980c1..7b2858f8621d006b2a773251914189f76b0e41c8 100644 (file)
@@ -915,6 +915,7 @@ class MetadataPathFinder(DistributionFinder):
             path.search(prepared) for path in map(FastPath, paths)
         )
 
+    @classmethod
     def invalidate_caches(cls):
         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``.