Skip to content

Commit 591d2bd

Browse files
committed
Preserve double open-braces in format specs
1 parent 77fb293 commit 591d2bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Parser/tokenizer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2523,9 +2523,10 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
25232523
end_quote_size = 0;
25242524
}
25252525

2526+
int in_format_spec = current_tok->last_expr_end != -1 && current_tok->bracket_mark_index >= 0;
25262527
if (c == '{') {
25272528
char peek = tok_nextc(tok);
2528-
if (peek != '{') {
2529+
if (peek != '{' || in_format_spec) {
25292530
tok_backup(tok, peek);
25302531
tok_backup(tok, c);
25312532
current_tok->bracket_mark[++current_tok->bracket_mark_index] = current_tok->bracket_stack;
@@ -2549,7 +2550,6 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
25492550
// scanning (indicated by the end of the expression being set) and we are not at the top level
25502551
// of the bracket stack (-1 is the top level). Since format specifiers can't legally use double
25512552
// brackets, we can bypass it here.
2552-
int in_format_spec = current_tok->last_expr_end != -1 && current_tok->bracket_mark_index >= 0;
25532553
if (peek == '}' && !in_format_spec) {
25542554
p_start = tok->start;
25552555
p_end = tok->cur - 1;

0 commit comments

Comments
 (0)