gh-94485: Set line number of module's RESUME instruction to 0, as specified by PEP 626 (GH-94552)

Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
Irit Katriel 2022-07-05 13:38:44 +01:00 committed by GitHub
parent a2a3f2c541
commit 324d01944d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 26 deletions

View file

@ -161,7 +161,7 @@ if 1:
co = compile(s256, 'fn', 'exec')
self.assertEqual(co.co_firstlineno, 1)
lines = list(co.co_lines())
self.assertEqual(lines[0][2], None)
self.assertEqual(lines[0][2], 0)
self.assertEqual(lines[1][2], 257)
def test_literals_with_leading_zeroes(self):
@ -1032,8 +1032,8 @@ if 1:
def check_op_count(func, op, expected):
actual = 0
for instr in dis.Bytecode(func):
if instr.opname == op:
actual += 1
if instr.opname == op:
actual += 1
self.assertEqual(actual, expected)
def load():
@ -1090,6 +1090,8 @@ class TestSourcePositions(unittest.TestCase):
# Check against the positions in the code object.
for (line, end_line, col, end_col) in code.co_positions():
if line == 0:
continue # This is an artificial module-start line
# If the offset is not None (indicating missing data), ensure that
# it was part of one of the AST nodes.
if line is not None: