gh-107901: duplicate blocks with no lineno that have an eval break and multiple predecessors (#113950)

This commit is contained in:
Irit Katriel 2024-01-12 15:38:09 +00:00 committed by GitHub
parent e02c15b3f1
commit 8aa0088ea2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 10 deletions

View file

@ -1098,6 +1098,21 @@ class TestSpecifics(unittest.TestCase):
code_lines = self.get_code_lines(test.__code__)
self.assertEqual(expected_lines, code_lines)
def test_line_number_synthetic_jump_multiple_predecessors(self):
def f():
for x in it:
try:
if C1:
yield 2
except OSError:
pass
# Ensure that all JUMP_BACKWARDs have line number
code = f.__code__
for inst in dis.Bytecode(code):
if inst.opname == 'JUMP_BACKWARD':
self.assertIsNotNone(inst.positions.lineno)
def test_lineno_of_backward_jump(self):
# Issue gh-107901
def f():