summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2024-03-14 16:39:38 (GMT)
committerGitHub <noreply@github.com>2024-03-14 16:39:38 (GMT)
commit9d08e14a0038a03f042f2540d3680530059aa1fd (patch)
treebd397d79722843b9259aa7dc9a91504f1a2fe367 /Lib
parent56a3c5f7674d65023bf84759b797e603f09a93e3 (diff)
downloadcpython-9d08e14a0038a03f042f2540d3680530059aa1fd.zip
cpython-9d08e14a0038a03f042f2540d3680530059aa1fd.tar.gz
cpython-9d08e14a0038a03f042f2540d3680530059aa1fd.tar.bz2
[3.12] gh-116731: libregrtest: Clear inspect & importlib.metadata caches in clear_caches (GH-116805) (GH-116820)
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>
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/libregrtest/utils.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py
index c77e36c..1be5abd 100644
--- a/Lib/test/libregrtest/utils.py
+++ b/Lib/test/libregrtest/utils.py
@@ -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():