mirror of
https://github.com/python/cpython.git
synced 2026-05-04 01:20:58 +00:00
[3.12] Fix test_compile with -O mode (GH-115346) (GH-115668)
(cherry picked from commit 7b25a82e83)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
323f63574b
commit
3fd72d99ab
1 changed files with 5 additions and 2 deletions
|
|
@ -722,7 +722,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):
|
||||
|
|
@ -767,7 +767,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
|
||||
|
|
@ -996,6 +996,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)
|
||||
|
|
@ -1394,6 +1396,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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue