Skip to content

Commit 23877ec

Browse files
committed
Set line number for RETURN_GENERATOR instruction.
1 parent bf0394d commit 23877ec

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Lib/test/test_compile.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ def return_genexp():
954954
x
955955
in
956956
y)
957-
genexp_lines = [None, 1, 3, 1]
957+
genexp_lines = [1, 3, 1]
958958

959959
genexp_code = return_genexp.__code__.co_consts[1]
960960
code_lines = [ None if line is None else line-return_genexp.__code__.co_firstlineno
@@ -967,7 +967,7 @@ async def test(aseq):
967967
async for i in aseq:
968968
body
969969

970-
expected_lines = [None, 0, 1, 2, 1]
970+
expected_lines = [0, 1, 2, 1]
971971
code_lines = [ None if line is None else line-test.__code__.co_firstlineno
972972
for (_, _, line) in test.__code__.co_lines() ]
973973
self.assertEqual(expected_lines, code_lines)

Python/compile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8002,9 +8002,9 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock,
80028002
struct instr make_gen = {
80038003
.i_opcode = RETURN_GENERATOR,
80048004
.i_oparg = 0,
8005-
.i_lineno = -1,
8005+
.i_lineno = c->u->u_firstlineno,
80068006
.i_col_offset = -1,
8007-
.i_end_lineno = -1,
8007+
.i_end_lineno = c->u->u_firstlineno,
80088008
.i_end_col_offset = -1,
80098009
.i_target = NULL,
80108010
};

0 commit comments

Comments
 (0)