summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorT. Wouters <thomas@python.org>2024-02-15 13:24:13 (GMT)
committerGitHub <noreply@github.com>2024-02-15 13:24:13 (GMT)
commitb0e5c35ded6d4a16d7a021c10c99bac94250edd0 (patch)
tree8b7a3a2d8652ee2dcb3b3ae1203117feb4decbc2
parenta0149fa6cf5792728bb18ee8e63f6f43b1c96934 (diff)
downloadcpython-b0e5c35ded6d4a16d7a021c10c99bac94250edd0.zip
cpython-b0e5c35ded6d4a16d7a021c10c99bac94250edd0.tar.gz
cpython-b0e5c35ded6d4a16d7a021c10c99bac94250edd0.tar.bz2
gh-115490: Work around test.support.interpreters.channels not handling unloading (#115515)
Work around test.support.interpreters.channels not handling unloading, which regrtest does when running tests sequentially, by explicitly skipping the unloading of test.support.interpreters and its submodules. This can be rolled back once test.support.interpreters.channels supports unloading, if we are keeping sequential runs in the same process around.
-rw-r--r--Lib/test/libregrtest/main.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 7ca1b1c..b24c1b9 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -335,10 +335,15 @@ class Regrtest:
result = self.run_test(test_name, runtests, tracer)
- # Unload the newly imported test modules (best effort finalization)
+ # Unload the newly imported test modules (best effort
+ # finalization). To work around gh-115490, don't unload
+ # test.support.interpreters and its submodules even if they
+ # weren't loaded before.
+ keep = "test.support.interpreters"
new_modules = [module for module in sys.modules
if module not in save_modules and
- module.startswith(("test.", "test_"))]
+ module.startswith(("test.", "test_"))
+ and not module.startswith(keep)]
for module in new_modules:
sys.modules.pop(module, None)
# Remove the attribute of the parent module.