GeezerVison is showing github.com — Multiple tests fail with `-OO` · Issue #136438 · python/cpython
Multiple tests fail with -OO #136438DescriptionWhen you run ./python.exe -OO -m test MODULE_NAME at least these ones fail:
8 tests failed:
test.test_pydoc.test_pydoc test_ast test_builtin test_compile
test_dis test_generated_cases test_interpreters test_remote_pdb
In my opinion it would be easier to contribute one test fix at a time. Rebases and reviews will be simplier. So, contributions are welcome!
I will create a single PR just to show how this can be solved for new contributors.
-
test.test_pydoc.test_pydoc
-
test_ast
-
test_builtin, @sobolevn
-
test_compile
-
test_dis
-
test_generated_cases
-
test_interpreters
-
test_remote_pdb
Linked PRs
Activitygvanrossum commented on Jul 8, 2025 Does anybody actually care about running the tests with -OO? Reacted by Shantanu Reacted by Rakesh Asapanna and Prakash Sellathurai sobolevn commented on Jul 8, 2025 @gvanrossum we have a lot of special-casing around this feature in tests. I guess it is used by someone, otherwise, it would not be here at all.
My usecase was to check that subinterpreters don't have any magic assert statements that are required as the part of the main logic. -OO allows me to disable them and run tests again to be sure that everything still works.
I am not sure that this is a common use-case, though. Reacted by Rakesh Asapanna kodsurfer commented on Jul 8, 2025 @sobolevn should we wait your example PR or find another way? sobolevn commented on Jul 8, 2025 @kodsurfer there's no rush :)
Let's first discuss whether this is worth doing, because clearly Guido has more context than me. If this is a waste of time, I will just close the issue. Reacted by kodsurfer, Ilya Solin and Kirill Podoprigora picnixz commented on Jul 8, 2025 FTR, I use -OO to remove expensive assertions when doing numerical optimizations so I would be interested in features working even in -OO.
Now, I don't think it's useful to run tests in -OO but it is useful to know that what we test works in -OO as well. gvanrossum commented on Jul 8, 2025 I don't actually have more context except that given what -OO does I would expect failures and think nothing of it (I have no desire to fix any of these).
Moreover, I presume we're not going to make CI even slower or more expensive by running all tests with all three "optimization" levels, so even if you fix the failures above, there won't be any guarantee that in the future other tests won't break with -O or -OO.
You could think of -OO as an unsupported platform.
Then again, if a particular test failure with -OO bothers you and is easy to fix I won't stop you. It just doesn't feel like an important thing to care about. Reacted by sobolevn and Kirill Podoprigora added 2 commits that reference this issue on Jul 9, 2025gh-136438: Make sure `test_builtins` pass with all optimization levels ( added a commit that references this issue on Aug 28, 2025gh-136438: Make sure `test_compile` pass with all optimization levels (… added a commit that references this issue on Oct 12, 2025gh-136438: Make sure test.test_pydoc.test_pydoc pass with all optimiz… donbarbos commented on Dec 25, 2025 It has been almost six months since this issue was opened, and during that time most of the test failures were fixed. However, new problematic spots in the test suite have appeared since then.
I have identified issues at least in the following tests:
test_inspect.test_inspect test_inspecttest_dataclasses test_idletest_importlib
test_interpreters test_pyrepl test_sys_settrace test_unparse
This seems to suggest that keeping this issue open may not be very effective unless there is an intention to actively monitor and enforce it in CI, as such cases tend to reappear and proliferate over time. added a commit that references this issue on Jan 9, 2026gh-136438: Make sure `test_interpreters` pass with all optimization l… StanFromIreland commented on Jan 9, 2026 I'm afraid I agree with Dan, we are fighting a loosing battle, currently on Linux I see:
This feels like a futile effort if the tests we fix are failing the following month. StanFromIreland commented on May 30, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|