Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dc35cda

Browse files
committed
Issue #27594: Prevent assertion error when running test_ast with coverage
enabled: ensure code object has a valid first line number. Patch suggested by Ivan Levkivskyi.
1 parent 8bcf312 commit dc35cda

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ Tests
167167
- Issue #27369: In test_pyexpat, avoid testing an error message detail that
168168
changed in Expat 2.2.0.
169169

170+
- Issue #27594: Prevent assertion error when running test_ast with coverage
171+
enabled: ensure code object has a valid first line number.
172+
Patch suggested by Ivan Levkivskyi.
173+
170174
Windows
171175
-------
172176

Python/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4963,7 +4963,7 @@ assemble(struct compiler *c, int addNone)
49634963

49644964
/* Set firstlineno if it wasn't explicitly set. */
49654965
if (!c->u->u_firstlineno) {
4966-
if (entryblock && entryblock->b_instr)
4966+
if (entryblock && entryblock->b_instr && entryblock->b_instr->i_lineno)
49674967
c->u->u_firstlineno = entryblock->b_instr->i_lineno;
49684968
else
49694969
c->u->u_firstlineno = 1;

0 commit comments

Comments
 (0)