]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-110756: Fix libregrtest clear_caches() for distutils (#111011)
authorVictor Stinner <vstinner@python.org>
Tue, 17 Oct 2023 23:20:36 +0000 (01:20 +0200)
committerGitHub <noreply@github.com>
Tue, 17 Oct 2023 23:20:36 +0000 (23:20 +0000)
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

index b5bbe0ef6596a74a48790116b289b804ce2c7b99..f62184ad4fec6c931f21527abcdca62c82b12014 100644 (file)
@@ -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: