comparison Python/compile.c @ 17132:55218e0495bc legacy-trunk

Set the line number correctly for a nested function with an exec or import *. Mark the offending stmt rather than the function def line.
author Jeremy Hylton <jeremy@alum.mit.edu>
date Thu, 22 Mar 2001 03:57:58 +0000
parents 1c90a1cf795c
children f9a30015e8b0
comparison
equal deleted inserted replaced
17131:1c90a1cf795c 17132:55218e0495bc
4239 } 4239 }
4240 4240
4241 if (c->c_symtable->st_nested_scopes) { 4241 if (c->c_symtable->st_nested_scopes) {
4242 PyErr_SetString(PyExc_SyntaxError, buf); 4242 PyErr_SetString(PyExc_SyntaxError, buf);
4243 PyErr_SyntaxLocation(c->c_symtable->st_filename, 4243 PyErr_SyntaxLocation(c->c_symtable->st_filename,
4244 ste->ste_lineno); 4244 ste->ste_opt_lineno);
4245 return -1; 4245 return -1;
4246 } 4246 }
4247 else { 4247 else {
4248 return issue_warning(buf, c->c_filename, ste->ste_lineno); 4248 return issue_warning(buf, c->c_filename, ste->ste_lineno);
4249 } 4249 }
4818 case exec_stmt: { 4818 case exec_stmt: {
4819 st->st_cur->ste_optimized |= OPT_EXEC; 4819 st->st_cur->ste_optimized |= OPT_EXEC;
4820 symtable_node(st, CHILD(n, 1)); 4820 symtable_node(st, CHILD(n, 1));
4821 if (NCH(n) > 2) 4821 if (NCH(n) > 2)
4822 symtable_node(st, CHILD(n, 3)); 4822 symtable_node(st, CHILD(n, 3));
4823 else 4823 else {
4824 st->st_cur->ste_optimized |= OPT_BARE_EXEC; 4824 st->st_cur->ste_optimized |= OPT_BARE_EXEC;
4825 st->st_cur->ste_opt_lineno = n->n_lineno;
4826 }
4825 if (NCH(n) > 4) 4827 if (NCH(n) > 4)
4826 symtable_node(st, CHILD(n, 5)); 4828 symtable_node(st, CHILD(n, 5));
4827 break; 4829 break;
4828 4830
4829 } 4831 }
5104 return; 5106 return;
5105 } 5107 }
5106 } 5108 }
5107 if (TYPE(CHILD(n, 3)) == STAR) { 5109 if (TYPE(CHILD(n, 3)) == STAR) {
5108 st->st_cur->ste_optimized |= OPT_IMPORT_STAR; 5110 st->st_cur->ste_optimized |= OPT_IMPORT_STAR;
5111 st->st_cur->ste_opt_lineno = n->n_lineno;
5109 } else { 5112 } else {
5110 for (i = 3; i < NCH(n); i += 2) { 5113 for (i = 3; i < NCH(n); i += 2) {
5111 node *c = CHILD(n, i); 5114 node *c = CHILD(n, i);
5112 if (NCH(c) > 1) /* import as */ 5115 if (NCH(c) > 1) /* import as */
5113 symtable_assign(st, CHILD(c, 2), 5116 symtable_assign(st, CHILD(c, 2),