Skip to content

gh-136438: Make sure test_ast pass with all optimization levels #136596

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

efimov-mikhail
Copy link
Contributor

@efimov-mikhail efimov-mikhail commented Jul 12, 2025

Now tests pass with all combinations of -OO and --without-doc-strings.
It was long lists of errors before, but all proposed fixes are just to add some needed optimize=False options.

@bedevere-app bedevere-app bot mentioned this pull request Jul 12, 2025
8 tasks
@bedevere-app bedevere-app bot added the tests Tests in the Lib/test dir label Jul 12, 2025
@@ -131,7 +131,7 @@ def test_snippets(self):
(eval_tests, eval_results, "eval")):
for i, o in zip(input, output):
with self.subTest(action="parsing", input=i):
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST)
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST, optimize=0)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST, optimize=0)
ast_tree = compile(i, "?", kind, ast.PyCF_ONLY_AST, optimize=False)

Let's unify it, provided it doesn't break anything.

@Eclips4
Copy link
Member

Eclips4 commented Jul 17, 2025

I believe the explanation is as follows:
If the optimize parameter isn’t passed explicitly, the interpreter uses its internal setting (which can be modified using the -O or -OO flags).
Am I right, @efimov-mikhail?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants