diff options
author | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-03-22 03:57:58 (GMT) |
---|---|---|
committer | Jeremy Hylton <jeremy@alum.mit.edu> | 2001-03-22 03:57:58 (GMT) |
commit | 2e2cded1b56cc5488f49d395b46131fd995b02bc (patch) | |
tree | 657d06d83a966b54cb0000aadd684d3fbaa3f7ee /Python/compile.c | |
parent | 280e6bd742a50cf7f00739c7904f1b5aa66bdad9 (diff) | |
download | cpython-2e2cded1b56cc5488f49d395b46131fd995b02bc.zip cpython-2e2cded1b56cc5488f49d395b46131fd995b02bc.tar.gz cpython-2e2cded1b56cc5488f49d395b46131fd995b02bc.tar.bz2 |
Set the line number correctly for a nested function with an exec or
import *. Mark the offending stmt rather than the function def line.
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/Python/compile.c b/Python/compile.c index fe84921..3e638ca 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -4241,7 +4241,7 @@ symtable_check_unoptimized(struct compiling *c, if (c->c_symtable->st_nested_scopes) { PyErr_SetString(PyExc_SyntaxError, buf); PyErr_SyntaxLocation(c->c_symtable->st_filename, - ste->ste_lineno); + ste->ste_opt_lineno); return -1; } else { @@ -4820,8 +4820,10 @@ symtable_node(struct symtable *st, node *n) symtable_node(st, CHILD(n, 1)); if (NCH(n) > 2) symtable_node(st, CHILD(n, 3)); - else + else { st->st_cur->ste_optimized |= OPT_BARE_EXEC; + st->st_cur->ste_opt_lineno = n->n_lineno; + } if (NCH(n) > 4) symtable_node(st, CHILD(n, 5)); break; @@ -5106,6 +5108,7 @@ symtable_import(struct symtable *st, node *n) } if (TYPE(CHILD(n, 3)) == STAR) { st->st_cur->ste_optimized |= OPT_IMPORT_STAR; + st->st_cur->ste_opt_lineno = n->n_lineno; } else { for (i = 3; i < NCH(n); i += 2) { node *c = CHILD(n, i); |