bpo-12458: Fix line numbers for multiline expressions. (GH-8774)

This commit is contained in:
Serhiy Storchaka 2018-09-17 15:17:29 +03:00 committed by GitHub
parent 5e99b56d6b
commit da8d72c953
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 3741 additions and 3709 deletions

View file

@ -4089,10 +4089,6 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,
is_async_generator = c->u->u_ste->ste_coroutine;
if (is_async_generator && !is_async_function && type != COMP_GENEXP) {
if (e->lineno > c->u->u_lineno) {
c->u->u_lineno = e->lineno;
c->u->u_lineno_set = 0;
}
compiler_error(c, "asynchronous comprehension outside of "
"an asynchronous function");
goto error_in_scope;
@ -4430,17 +4426,8 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)
}
static int
compiler_visit_expr(struct compiler *c, expr_ty e)
compiler_visit_expr1(struct compiler *c, expr_ty e)
{
/* If expr e has a different line number than the last expr/stmt,
set a new line number for the next instruction.
*/
if (e->lineno > c->u->u_lineno) {
c->u->u_lineno = e->lineno;
c->u->u_lineno_set = 0;
}
/* Updating the column offset is always harmless. */
c->u->u_col_offset = e->col_offset;
switch (e->kind) {
case BoolOp_kind:
return compiler_boolop(c, e);
@ -4609,6 +4596,31 @@ compiler_visit_expr(struct compiler *c, expr_ty e)
return 1;
}
static int
compiler_visit_expr(struct compiler *c, expr_ty e)
{
/* If expr e has a different line number than the last expr/stmt,
set a new line number for the next instruction.
*/
int old_lineno = c->u->u_lineno;
int old_col_offset = c->u->u_col_offset;
if (e->lineno != c->u->u_lineno) {
c->u->u_lineno = e->lineno;
c->u->u_lineno_set = 0;
}
/* Updating the column offset is always harmless. */
c->u->u_col_offset = e->col_offset;
int res = compiler_visit_expr1(c, e);
if (old_lineno != c->u->u_lineno) {
c->u->u_lineno = old_lineno;
c->u->u_lineno_set = 0;
}
c->u->u_col_offset = old_col_offset;
return res;
}
static int
compiler_augassign(struct compiler *c, stmt_ty s)
{

2197
Python/importlib.h generated

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff