Skip to content

gh-136438: Make sure test_interpreters pass with all optimization levels #136499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

donBarbos
Copy link
Contributor

@donBarbos donBarbos commented Jul 10, 2025

Before:

Using random seed: 1235010185
0:00:00 load avg: 0.68 Run 1 test sequentially in a single process
0:00:00 load avg: 0.68 [1/1] test_interpreters
Failed to import test module: test.test_interpreters.test_api
Traceback (most recent call last):
  File ".../cpython/Lib/unittest/loader.py", line 426, in _find_test_path
    module = self._get_module_from_name(name)
  File ".../cpython/Lib/unittest/loader.py", line 367, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File ".../cpython/Lib/test/test_interpreters/test_api.py", line 16, in <module>
    from concurrent import interpreters
  File ".../cpython/Lib/concurrent/interpreters/__init__.py", line 12, in <module>
    from ._queues import (
    ...<2 lines>...
    )
  File ".../cpython/Lib/concurrent/interpreters/_queues.py", line 49, in <module>
    UNBOUND = _crossinterp.UnboundItem.singleton('queue', __name__)
  File ".../cpython/Lib/concurrent/interpreters/_crossinterp.py", line 43, in singleton
    doc = cls.__doc__.replace('cross-interpreter container', kind)
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

Failed to import test module: test.test_interpreters.test_channels
Traceback (most recent call last):
  File ".../cpython/Lib/unittest/loader.py", line 426, in _find_test_path
    module = self._get_module_from_name(name)
  File ".../Lib/unittest/loader.py", line 367, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File ".../cpython/Lib/test/test_interpreters/test_channels.py", line 11, in <module>
    from concurrent import interpreters
  File ".../cpython/Lib/concurrent/interpreters/__init__.py", line 12, in <module>
    from ._queues import (
    ...<2 lines>...
    )
  File ".../cpython/Lib/concurrent/interpreters/_queues.py", line 49, in <module>
    UNBOUND = _crossinterp.UnboundItem.singleton('queue', __name__)
  File ".../cpython/Lib/concurrent/interpreters/_crossinterp.py", line 43, in singleton
    doc = cls.__doc__.replace('cross-interpreter container', kind)
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

Failed to import test module: test.test_interpreters.test_lifecycle
Traceback (most recent call last):
  File ".../cpython/Lib/unittest/loader.py", line 426, in _find_test_path
    module = self._get_module_from_name(name)
  File ".../cpython/Lib/unittest/loader.py", line 367, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File ".../cpython/Lib/test/test_interpreters/test_lifecycle.py", line 14, in <module>
    from .utils import TestBase
  File ".../cpython/Lib/test/test_interpreters/utils.py", line 24, in <module>
    from concurrent import interpreters
  File ".../cpython/Lib/concurrent/interpreters/__init__.py", line 12, in <module>
    from ._queues import (
    ...<2 lines>...
    )
  File ".../cpython/Lib/concurrent/interpreters/_queues.py", line 49, in <module>
    UNBOUND = _crossinterp.UnboundItem.singleton('queue', __name__)
  File ".../cpython/Lib/concurrent/interpreters/_crossinterp.py", line 43, in singleton
    doc = cls.__doc__.replace('cross-interpreter container', kind)
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

Failed to import test module: test.test_interpreters.test_queues
Traceback (most recent call last):
  File ".../cpython/Lib/unittest/loader.py", line 426, in _find_test_path
    module = self._get_module_from_name(name)
  File ".../cpython/Lib/unittest/loader.py", line 367, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File ".../cpython/Lib/test/test_interpreters/test_queues.py", line 10, in <module>
    from concurrent import interpreters
  File ".../cpython/Lib/concurrent/interpreters/__init__.py", line 12, in <module>
    from ._queues import (
    ...<2 lines>...
    )
  File ".../cpython/Lib/concurrent/interpreters/_queues.py", line 49, in <module>
    UNBOUND = _crossinterp.UnboundItem.singleton('queue', __name__)
  File ".../cpython/Lib/concurrent/interpreters/_crossinterp.py", line 43, in singleton
    doc = cls.__doc__.replace('cross-interpreter container', kind)
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

Failed to import test module: test.test_interpreters.test_stress
Traceback (most recent call last):
  File ".../cpython/Lib/unittest/loader.py", line 426, in _find_test_path
    module = self._get_module_from_name(name)
  File ".../cpython/Lib/unittest/loader.py", line 367, in _get_module_from_name
    __import__(name)
    ~~~~~~~~~~^^^^^^
  File ".../cpython/Lib/test/test_interpreters/test_stress.py", line 9, in <module>
    from concurrent import interpreters
  File ".../cpython/Lib/concurrent/interpreters/__init__.py", line 12, in <module>
    from ._queues import (
    ...<2 lines>...
    )
  File ".../cpython/Lib/concurrent/interpreters/_queues.py", line 49, in <module>
    UNBOUND = _crossinterp.UnboundItem.singleton('queue', __name__)
  File ".../cpython/Lib/concurrent/interpreters/_crossinterp.py", line 43, in singleton
    doc = cls.__doc__.replace('cross-interpreter container', kind)
          ^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'replace'

test test_interpreters crashed -- Traceback (most recent call last):
  File ".../cpython/Lib/test/libregrtest/single.py", line 210, in _runtest_env_changed_exc
    _load_run_test(result, runtests)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File ".../cpython/Lib/test/libregrtest/single.py", line 165, in _load_run_test
    regrtest_runner(result, test_func, runtests)
    ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File ".../cpython/Lib/test/libregrtest/single.py", line 118, in regrtest_runner
    test_result = test_func()
  File ".../cpython/Lib/test/libregrtest/single.py", line 162, in test_func
    return run_unittest(test_mod, runtests)
  File ".../cpython/Lib/test/libregrtest/single.py", line 38, in run_unittest
    raise Exception("errors while loading tests")
Exception: errors while loading tests

0:00:00 load avg: 0.68 [1/1/1] test_interpreters failed (uncaught exception)

== Tests result: FAILURE ==

And after the singleton method is fixed but before the tests are fixed:

Using random seed: 1139154734
0:00:00 load avg: 1.36 Run 1 test sequentially in a single process
0:00:00 load avg: 1.36 [1/1] test_interpreters
test test_interpreters failed -- Traceback (most recent call last):
  File ".../cpython/Lib/test/test_interpreters/test_api.py", line 778, in test_created_with_capi
    with self.assertRaisesRegex(ExecutionFailed, 'NameError'):
         ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: ExecutionFailed not raised

0:00:14 load avg: 1.28 [1/1/1] test_interpreters failed (1 failure)

== Tests result: FAILURE ==

@@ -40,8 +40,10 @@ class UnboundItem:

@classonly
def singleton(cls, kind, module, name='UNBOUND'):
doc = cls.__doc__.replace('cross-interpreter container', kind)
doc = doc.replace('cross-interpreter', kind)
doc = cls.__doc__
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we pass doc as the value for __doc__ on line 53 so I think it's important to keep the possibility of None existing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy