]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches...
authorPetr Viktorin <encukou@gmail.com>
Thu, 14 Mar 2024 15:47:12 +0000 (16:47 +0100)
committerGitHub <noreply@github.com>
Thu, 14 Mar 2024 15:47:12 +0000 (16:47 +0100)
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Lib/test/libregrtest/utils.py

index 7765ae8a933be44df3c8e64a3f5784ee4fdf9fc2..837f73b28b40184c42c9fde62beb6d0ba9c14749 100644 (file)
@@ -276,6 +276,15 @@ def clear_caches():
         pass
     else:
         inspect._shadowed_dict_from_mro_tuple.cache_clear()
+        inspect._filesbymodname.clear()
+        inspect.modulesbyfile.clear()
+
+    try:
+        importlib_metadata = sys.modules['importlib.metadata']
+    except KeyError:
+        pass
+    else:
+        importlib_metadata.FastPath.__new__.cache_clear()
 
 
 def get_build_info():