Skip to content

Commit

Permalink
Merge pull request python#64 from lysnikolaou/preserve-double-brance-…
Browse files Browse the repository at this point in the history
…formatspec
  • Loading branch information
pablogsal authored Apr 6, 2023
2 parents 77fb293 + 591d2bd commit aba4fc9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Parser/tokenizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2523,9 +2523,10 @@ tok_get_fstring_mode(struct tok_state *tok, tokenizer_mode* current_tok, struct
end_quote_size = 0;
}

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

0 comments on commit aba4fc9

Please sign in to comment.