From 4ccd418a024d15d986a01588f935f43248c2f05d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Wed, 18 Oct 2023 01:20:36 +0200 Subject: [3.11] gh-110756: Fix libregrtest clear_caches() for distutils (#111011) gh-110756: Fix libregrtest clear_caches() for distutils Restore code removed by recent sync with the main branch which no longer has distutils: commit 26748ed4f61520c59af15547792d1e73144a4314. --- Lib/test/libregrtest/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index b5bbe0e..f62184a 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -184,6 +184,15 @@ def clear_caches(): if stream is not None: stream.flush() + # Clear assorted module caches. + # Don't worry about resetting the cache if the module is not loaded + try: + distutils_dir_util = sys.modules['distutils.dir_util'] + except KeyError: + pass + else: + distutils_dir_util._path_created.clear() + try: re = sys.modules['re'] except KeyError: -- cgit v0.12