8000 Fix test_compile with -O mode by serhiy-storchaka · Pull Request #115346 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

Fix test_compile with -O mode #115346

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

Merged
merged 1 commit into from
Feb 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions Lib/test/test_compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ def f():
return "unused"

self.assertEqual(f.__code__.co_consts,
("docstring", "used"))
(f.__doc__, "used"))

@support.cpython_only
def test_remove_unused_consts_no_docstring(self):
Expand Down Expand Up @@ -792, 9875 7 +792,7 @@ def test_strip_unused_None(self):
def f1():
"docstring"
return 42
self.assertEqual(f1.__code__.co_consts, ("docstring", 42))
self.assertEqual(f1.__code__.co_consts, (f1.__doc__, 42))

# This is a regression test for a CPython specific peephole optimizer
# implementation bug present in a few releases. It's assertion verifies
Expand Down Expand Up @@ -1021,6 +1021,8 @@ def no_code2():

for func in (no_code1, no_code2):
with self.subTest(func=func):
if func is no_code1 and no_code1.__doc__ is None:
continue
code = func.__code__
[(start, end, line)] = code.co_lines()
self.assertEqual(start, 0)
Expand Down Expand Up @@ -1498,6 +1500,7 @@ def test_multiline_boolean_expression(self):
self.assertOpcodeSourcePositionIs(compiled_code, 'POP_JUMP_IF_TRUE',
line=4, end_line=4, column=8, end_column=13, occurrence=2)

@unittest.skipIf(sys.flags.optimize, "Assertions are disabled in optimized mode")
def test_multiline_assert(self):
snippet = textwrap.dedent("""\
assert (a > 0 and
Expand Down
0