mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-40334: Fix shifting of nested f-strings in the new parser (GH-19771)
`JoinedStr`s and `FormattedValue also needs to be shifted, in order to correctly compute the location information of nested f-strings.
This commit is contained in:
parent
ae00a5a885
commit
37af21b667
2 changed files with 10 additions and 2 deletions
|
@ -449,6 +449,15 @@ static void fstring_shift_children_locations(expr_ty n, int lineno, int col_offs
|
|||
case Tuple_kind:
|
||||
fstring_shift_seq_locations(n, n->v.Tuple.elts, lineno, col_offset);
|
||||
break;
|
||||
case JoinedStr_kind:
|
||||
fstring_shift_seq_locations(n, n->v.JoinedStr.values, lineno, col_offset);
|
||||
break;
|
||||
case FormattedValue_kind:
|
||||
shift_expr(n, n->v.FormattedValue.value, lineno, col_offset);
|
||||
if (n->v.FormattedValue.format_spec) {
|
||||
shift_expr(n, n->v.FormattedValue.format_spec, lineno, col_offset);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue