Skip to content

Commit

Permalink
Slight changes to code in symtable
Browse files Browse the repository at this point in the history
  • Loading branch information
lysnikolaou committed Jul 15, 2024
1 parent 69fb43b commit 114411f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -5027,7 +5027,6 @@ compiler_interpolation(struct compiler *c, expr_ty e)
c->u->u_metadata.u_posonlyargcount = 0;
c->u->u_metadata.u_kwonlyargcount = 0;

int oparg = 2;
VISIT_IN_SCOPE(c, expr, e->v.Interpolation.body);
if (c->u->u_ste->ste_generator) {
co = optimize_and_assemble(c, 0);
Expand All @@ -5047,6 +5046,8 @@ compiler_interpolation(struct compiler *c, expr_ty e)
return ERROR;
}
Py_DECREF(co);

int oparg = 2;
VISIT(c, expr, e->v.Interpolation.str);
if (e->v.Interpolation.conversion) {
VISIT(c, expr, e->v.Interpolation.conversion);
Expand Down
14 changes: 9 additions & 5 deletions Python/symtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -2344,21 +2344,25 @@ symtable_visit_expr(struct symtable *st, expr_ty e)
break;
case Interpolation_kind: {
int is_in_class = st->st_cur->ste_type == ClassBlock;
st->st_cur->ste_needs_classdict = st->st_cur->ste_needs_classdict || is_in_class;
if (!symtable_enter_block(st, &_Py_ID(interpolation),
FunctionBlock, (void *)e,
e->lineno, e->col_offset,
e->end_lineno, e->end_col_offset))
if (!symtable_enter_block(st, &_Py_ID(interpolation), FunctionBlock, e, LOCATION(e))) {
VISIT_QUIT(st, 0);
}

st->st_cur->ste_can_see_class_scope = is_in_class;
if (is_in_class && !symtable_add_def(st, &_Py_ID(__classdict__), USE, LOCATION(e))) {
VISIT_QUIT(st, 0);
}

VISIT(st, expr, e->v.Interpolation.body);
VISIT(st, expr, e->v.Interpolation.str);
if (e->v.Interpolation.conversion)
VISIT(st, expr, e->v.Interpolation.conversion);
if (e->v.Interpolation.format_spec)
VISIT(st, expr, e->v.Interpolation.format_spec);

if (!symtable_exit_block(st))
VISIT_QUIT(st, 0);

break;
}
case Decoded_kind:
Expand Down

0 comments on commit 114411f

Please sign in to comment.