]> granicus.if.org Git - python/commitdiff
Issue #27594: Prevent assertion error when running test_ast with coverage
authorNed Deily <nad@python.org>
Wed, 17 Aug 2016 21:18:33 +0000 (17:18 -0400)
committerNed Deily <nad@python.org>
Wed, 17 Aug 2016 21:18:33 +0000 (17:18 -0400)
enabled: ensure code object has a valid first line number.
Patch suggested by Ivan Levkivskyi.

Misc/NEWS
Python/compile.c

index c06539bdfdc89e46168a29215db5b7415621d54c..efa0f76229b47153131027c4f411d0c41995b34e 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -167,6 +167,10 @@ Tests
 - Issue #27369: In test_pyexpat, avoid testing an error message detail that
   changed in Expat 2.2.0.
 
+- 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.
+
 Windows
 -------
 
index e46676c0b03cc829b5fe10431c15c68cd7b76153..fb80f51fc00743d81be70803709692f94ce45356 100644 (file)
@@ -4963,7 +4963,7 @@ assemble(struct compiler *c, int addNone)
 
     /* Set firstlineno if it wasn't explicitly set. */
     if (!c->u->u_firstlineno) {
-        if (entryblock && entryblock->b_instr)
+        if (entryblock && entryblock->b_instr && entryblock->b_instr->i_lineno)
             c->u->u_firstlineno = entryblock->b_instr->i_lineno;
         else
             c->u->u_firstlineno = 1;