-
-
Notifications
You must be signed in to change notification settings - Fork 32.7k
Closed
Labels
topic-subinterpreterstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
test_interpreters fails when running tests sequentially (which we do as part of the release process). The easiest reproducer seems to be python -m test test_interpreters test_interpreters.test_channels
:
% bin/python -m test test_interpreters test_interpreters.test_channels
0:00:00 load avg: 0.86 [1/2] test_interpreters
0:00:02 load avg: 0.87 [2/2] test_interpreters.test_channels
test test_interpreters.test_channels crashed -- Traceback (most recent call last):
File "/tmp/testinstall/lib/python3.13/test/libregrtest/single.py", line 178, in _runtest_env_changed_exc
_load_run_test(result, runtests)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
File "/tmp/testinstall/lib/python3.13/test/libregrtest/single.py", line 125, in _load_run_test
test_mod = importlib.import_module(module_name)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^
File "/tmp/testinstall/lib/python3.13/importlib/__init__.py", line 88, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 1014, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/tmp/testinstall/lib/python3.13/test/test_interpreters/test_channels.py", line 10, in <module>
from test.support.interpreters import channels
File "/tmp/testinstall/lib/python3.13/test/support/interpreters/channels.py", line 171, in <module>
_channels._register_end_types(SendChannel, RecvChannel)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: already registered
The cause is libregrtest's behaviour of unloading newly imported modules from sys.modules
after each test run. Either test.support.interpreters.channels should support being imported multiple times (perhaps by not doing any setup at import time, but via deliberate calls?), or libregrtest should be taught to skip unloading test.support.interpreters modules.
@ericsnowcurrently, since this seems to be your area, any opinion making test.support.interpreters do the right thing here?
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
Metadata
Metadata
Assignees
Labels
topic-subinterpreterstype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Projects
Status
Done
Status
Done