diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2020-04-29 00:43:50 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-29 00:43:50 (GMT) |
commit | 37af21b667a9f41437b5b8e451497d7725016df5 (patch) | |
tree | 14dd65c5ff5287fda0e0b83d234734ed511469d6 /Parser | |
parent | ae00a5a88534fd45939f86c12e038da9fa6f9ed6 (diff) | |
download | cpython-37af21b667a9f41437b5b8e451497d7725016df5.zip cpython-37af21b667a9f41437b5b8e451497d7725016df5.tar.gz cpython-37af21b667a9f41437b5b8e451497d7725016df5.tar.bz2 |
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.
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/pegen/parse_string.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Parser/pegen/parse_string.c b/Parser/pegen/parse_string.c index 9a78a28..834239e 100644 --- a/Parser/pegen/parse_string.c +++ b/Parser/pegen/parse_string.c @@ -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; } |