]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_cac...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 14 Mar 2024 16:39:38 +0000 (17:39 +0100)
committerGitHub <noreply@github.com>
Thu, 14 Mar 2024 16:39:38 +0000 (16:39 +0000)
gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches (GH-116805)
(cherry picked from commit bae6579b46df50dee4dbb77ea242270d27cd0c9d)

Co-authored-by: Petr Viktorin <encukou@gmail.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Lib/test/libregrtest/utils.py

index c77e36cd88e5218f7ec20fce9b4a1440b9527ef3..1be5abd8828be844fb4ba95bd9c5b2306260ccd3 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():