[3.12] gh-122026: Fix identification of mismatched parentheses inside f-strings (GH-122028) (#122062)

(cherry picked from commit 2009e25e26)

Signed-off-by: Pablo Galindo <pablogsal@gmail.com>
This commit is contained in:
Pablo Galindo Salgado 2024-07-21 01:03:10 +02:00 committed by GitHub
parent 0298da432d
commit 966eff9ce4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 0 deletions

View file

@ -2607,6 +2607,9 @@ letter_quote:
if (INSIDE_FSTRING(tok)) {
current_tok->curly_bracket_depth--;
if (current_tok->curly_bracket_depth < 0) {
return MAKE_TOKEN(syntaxerror(tok, "f-string: unmatched '%c'", c));
}
if (c == '}' && current_tok->curly_bracket_depth ==
current_tok->curly_bracket_expr_start_depth) {
current_tok->curly_bracket_expr_start_depth--;