From 1c68a756390ef25629c2bc81927dd0e31ea5c4c2 Mon Sep 17 00:00:00 2001 From: Zachary Ware Date: Thu, 8 Sep 2022 12:37:28 -0500 Subject: [PATCH] gh-96465: Clear fractions hash lru_cache under refleak testing --- Lib/test/libregrtest/utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index 8578a028c78bc2..332dcc4c6db247 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -210,3 +210,10 @@ def clear_caches(): else: for f in typing._cleanups: f() + + try: + fractions = sys.modules['fractions'] + except KeyError: + pass + else: + fractions._hash_algorithm.cache_clear()