gh-115490: Make the interpreter.channels and interpreter.queues Modules Handle Reloading Properly (gh-115493)

The problem manifested when the .py module got reloaded and the corresponding extension module didn't. The .py module registers types with the extension and the extension was not allowing that to happen more than once. The solution: let it happen more than once.
This commit is contained in:
Eric Snow 2024-03-04 13:59:30 -07:00 committed by GitHub
parent 207030f552
commit eb22e2b251
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 60 additions and 19 deletions

View file

@ -384,15 +384,10 @@ class Regrtest:
result = self.run_test(test_name, runtests, tracer)
# 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"
# Unload the newly imported test modules (best effort finalization)
new_modules = [module for module in sys.modules
if module not in save_modules and
module.startswith(("test.", "test_"))
and not module.startswith(keep)]
module.startswith(("test.", "test_"))]
for module in new_modules:
sys.modules.pop(module, None)
# Remove the attribute of the parent module.