[3.14] gh-136438: Make sure test_builtins pass with all optimization levels (GH-136474) (#136496)

gh-136438: Make sure `test_builtins` pass with all optimization levels (GH-136474)
(cherry picked from commit c176543349)

Co-authored-by: sobolevn <mail@sobolevn.me>
This commit is contained in:
Miss Islington (bot) 2025-07-10 11:30:07 +02:00 committed by GitHub
parent 7880421983
commit 2de82bcc62
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -436,7 +436,7 @@ def f(): """doc"""
# test both direct compilation and compilation via AST
codeobjs = []
codeobjs.append(compile(codestr, "<test>", "exec", optimize=optval))
tree = ast.parse(codestr)
tree = ast.parse(codestr, optimize=optval)
codeobjs.append(compile(tree, "<test>", "exec", optimize=optval))
for code in codeobjs:
ns = {}
@ -624,7 +624,7 @@ def test_compile_ast(self):
for opt in [opt1, opt2]:
opt_right = opt.value.right
self.assertIsInstance(opt_right, ast.Constant)
self.assertEqual(opt_right.value, True)
self.assertEqual(opt_right.value, __debug__)
def test_delattr(self):
sys.spam = 1