diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-10 00:04:44 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2006-07-10 00:04:44 (GMT) |
commit | ed657556086076576050c936947935be0900020d (patch) | |
tree | 0865eee9ee94883e2d5ffd5de7f545acdc216480 /Python | |
parent | 28746aba9bf636d03eb1c1c5f4550c6f2dbf5300 (diff) | |
download | cpython-ed657556086076576050c936947935be0900020d.zip cpython-ed657556086076576050c936947935be0900020d.tar.gz cpython-ed657556086076576050c936947935be0900020d.tar.bz2 |
Bug #1512814, Fix incorrect lineno's when code at module scope
started after line 256.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/compile.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index 3ddb067..a96a503 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -1776,7 +1776,8 @@ compiler_mod(struct compiler *c, mod_ty mod) 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 @@ assemble(struct compiler *c, int addNone) 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); |