@@ -2481,19 +2481,21 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
2481
2481
// If we start with a bracket, we defer to the normal mode as there is nothing for us to tokenize
2482
2482
// before it.
2483
2483
int start_char = tok_nextc (tok );
2484
- int peek1 = tok_nextc (tok );
2485
- tok_backup (tok , peek1 );
2486
- tok_backup (tok , start_char );
2487
-
2488
- if ((start_char == '{' && peek1 != '{' ) || (start_char == '}' && peek1 != '}' )) {
2489
- if (start_char == '{' ) {
2484
+ if (start_char == '{' ) {
2485
+ int peek1 = tok_nextc (tok );
2486
+ tok_backup (tok , peek1 );
2487
+ tok_backup (tok , start_char );
2488
+ if (peek1 != '{' ) {
2490
2489
current_tok -> curly_bracket_expr_start_depth ++ ;
2491
2490
if (current_tok -> curly_bracket_expr_start_depth >= MAX_EXPR_NESTING ) {
2492
2491
return MAKE_TOKEN (syntaxerror (tok , "f-string: expressions nested too deeply" ));
2493
2492
}
2493
+ TOK_GET_MODE (tok )-> kind = TOK_REGULAR_MODE ;
2494
+ return tok_get_normal_mode (tok , current_tok , token );
2494
2495
}
2495
- TOK_GET_MODE (tok )-> kind = TOK_REGULAR_MODE ;
2496
- return tok_get_normal_mode (tok , current_tok , token );
2496
+ }
2497
+ else {
2498
+ tok_backup (tok , start_char );
2497
2499
}
2498
2500
2499
2501
// Check if we are at the end of the string
0 commit comments