mirror of
https://github.com/micropython/micropython.git
synced 2026-03-10 10:50:17 +01:00
py/lexer: Fix parsing of f'{{'.
Prior to this fix, f'{{' would raise a SyntaxError.
Signed-off-by: Damien George <damien@micropython.org>
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user