bpo-12458: Fix line numbers for multiline expressions. (GH-8774) · python/cpython@da8d72c (original) (raw)

`@@ -4089,10 +4089,6 @@ compiler_comprehension(struct compiler *c, expr_ty e, int type,

`

4089

4089

`is_async_generator = c->u->u_ste->ste_coroutine;

`

4090

4090

``

4091

4091

`if (is_async_generator && !is_async_function && type != COMP_GENEXP) {

`

4092

``

`-

if (e->lineno > c->u->u_lineno) {

`

4093

``

`-

c->u->u_lineno = e->lineno;

`

4094

``

`-

c->u->u_lineno_set = 0;

`

4095

``

`-

}

`

4096

4092

`compiler_error(c, "asynchronous comprehension outside of "

`

4097

4093

`"an asynchronous function");

`

4098

4094

` goto error_in_scope;

`

`@@ -4430,17 +4426,8 @@ compiler_with(struct compiler *c, stmt_ty s, int pos)

`

4430

4426

`}

`

4431

4427

``

4432

4428

`static int

`

4433

``

`-

compiler_visit_expr(struct compiler *c, expr_ty e)

`

``

4429

`+

compiler_visit_expr1(struct compiler *c, expr_ty e)

`

4434

4430

`{

`

4435

``

`-

/* If expr e has a different line number than the last expr/stmt,

`

4436

``

`-

set a new line number for the next instruction.

`

4437

``

`-

*/

`

4438

``

`-

if (e->lineno > c->u->u_lineno) {

`

4439

``

`-

c->u->u_lineno = e->lineno;

`

4440

``

`-

c->u->u_lineno_set = 0;

`

4441

``

`-

}

`

4442

``

`-

/* Updating the column offset is always harmless. */

`

4443

``

`-

c->u->u_col_offset = e->col_offset;

`

4444

4431

`switch (e->kind) {

`

4445

4432

`case BoolOp_kind:

`

4446

4433

`return compiler_boolop(c, e);

`

`@@ -4609,6 +4596,31 @@ compiler_visit_expr(struct compiler *c, expr_ty e)

`

4609

4596

`return 1;

`

4610

4597

`}

`

4611

4598

``

``

4599

`+

static int

`

``

4600

`+

compiler_visit_expr(struct compiler *c, expr_ty e)

`

``

4601

`+

{

`

``

4602

`+

/* If expr e has a different line number than the last expr/stmt,

`

``

4603

`+

set a new line number for the next instruction.

`

``

4604

`+

*/

`

``

4605

`+

int old_lineno = c->u->u_lineno;

`

``

4606

`+

int old_col_offset = c->u->u_col_offset;

`

``

4607

`+

if (e->lineno != c->u->u_lineno) {

`

``

4608

`+

c->u->u_lineno = e->lineno;

`

``

4609

`+

c->u->u_lineno_set = 0;

`

``

4610

`+

}

`

``

4611

`+

/* Updating the column offset is always harmless. */

`

``

4612

`+

c->u->u_col_offset = e->col_offset;

`

``

4613

+

``

4614

`+

int res = compiler_visit_expr1(c, e);

`

``

4615

+

``

4616

`+

if (old_lineno != c->u->u_lineno) {

`

``

4617

`+

c->u->u_lineno = old_lineno;

`

``

4618

`+

c->u->u_lineno_set = 0;

`

``

4619

`+

}

`

``

4620

`+

c->u->u_col_offset = old_col_offset;

`

``

4621

`+

return res;

`

``

4622

`+

}

`

``

4623

+

4612

4624

`static int

`

4613

4625

`compiler_augassign(struct compiler *c, stmt_ty s)

`

4614

4626

`{

`