Mercurial > cpython-lru_cache-weakref
diff Python/compile.c @ 39040:ca3d9a67126b legacy-trunk
Bug #1512814, Fix incorrect lineno's when code at module scope
started after line 256.
| author | Neal Norwitz <nnorwitz@gmail.com> |
|---|---|
| date | Mon, 10 Jul 2006 00:04:44 +0000 |
| parents | 9f70f6ba7b69 |
| children | 756d57acda85 |
line wrap: on
line diff
--- a/Python/compile.c Sun Jul 09 22:14:42 2006 +0000 +++ b/Python/compile.c Mon Jul 10 00:04:44 2006 +0000 @@ -1776,7 +1776,8 @@ if (!module) return NULL; } - if (!compiler_enter_scope(c, module, mod, 1)) + /* Use 0 for firstlineno initially, will fixup in assemble(). */ + if (!compiler_enter_scope(c, module, mod, 0)) return NULL; switch (mod->kind) { case Module_kind: @@ -4446,6 +4447,13 @@ entryblock = b; } + /* Set firstlineno if it wasn't explicitly set. */ + if (!c->u->u_firstlineno) { + if (entryblock && entryblock->b_instr) + c->u->u_firstlineno = entryblock->b_instr->i_lineno; + else + c->u->u_firstlineno = 1; + } if (!assemble_init(&a, nblocks, c->u->u_firstlineno)) goto error; dfs(c, entryblock, &a);
