From: Victor Stinner Date: Tue, 17 Oct 2023 23:20:36 +0000 (+0200) Subject: [3.11] gh-110756: Fix libregrtest clear_caches() for distutils (#111011) X-Git-Tag: v3.11.7~173 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4ccd418a024d15d986a01588f935f43248c2f05d;p=thirdparty%2FPython%2Fcpython.git [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. --- diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index b5bbe0ef6596..f62184ad4fec 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: