diff --git a/py/lexer.c b/py/lexer.c index 1b2e2f2cb9..8ddbe42339 100644 --- a/py/lexer.c +++ b/py/lexer.c @@ -408,6 +408,7 @@ static void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) vstr_add_byte(&lex->fstring_args, ','); } vstr_add_byte(&lex->vstr, '{'); + goto continue_outer; } #endif @@ -518,6 +519,9 @@ static void parse_string_literal(mp_lexer_t *lex, bool is_raw, bool is_fstring) } continue_parsing_string_literal: next_char(lex); + #if MICROPY_PY_FSTRINGS + continue_outer:; + #endif } // check we got the required end quotes diff --git a/tests/basics/string_fstring.py b/tests/basics/string_fstring.py index 200065e9d9..daa687dbdd 100644 --- a/tests/basics/string_fstring.py +++ b/tests/basics/string_fstring.py @@ -31,6 +31,8 @@ print(f"a{ {0,1,2}}") # PEP-0498 specifies that handling of double braces '{{' or '}}' should # behave like str.format. +print(f'{{') +print(f'}}') print(f'{{}}') print(f'{{{4*10}}}', '{40}')