diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2024-07-19 17:08:08 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-19 17:08:08 (GMT) |
commit | 2009e25e26040dca32696e70f91f13665350e7fd (patch) | |
tree | fd8886785c6a8645c0f49b23963b77ad3118c565 /Parser | |
parent | 186b4d8ea2fdc91bf18e8be695244ead1722af18 (diff) | |
download | cpython-2009e25e26040dca32696e70f91f13665350e7fd.zip cpython-2009e25e26040dca32696e70f91f13665350e7fd.tar.gz cpython-2009e25e26040dca32696e70f91f13665350e7fd.tar.bz2 |
gh-122026: Fix identification of mismatched parentheses inside f-strings (#122028)
Diffstat (limited to 'Parser')
-rw-r--r-- | Parser/lexer/lexer.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/Parser/lexer/lexer.c b/Parser/lexer/lexer.c index 9ca3bd6..8c86859 100644 --- a/Parser/lexer/lexer.c +++ b/Parser/lexer/lexer.c @@ -1238,6 +1238,9 @@ tok_get_normal_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct t if (INSIDE_FSTRING(tok)) { current_tok->curly_bracket_depth--; + if (current_tok->curly_bracket_depth < 0) { + return MAKE_TOKEN(_PyTokenizer_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--; current_tok->kind = TOK_FSTRING_MODE; |