Skip to content

Commit 77fb293

Browse files
committed
Cover missing } at the end of f-strings
1 parent 45903ad commit 77fb293

File tree

2 files changed

+522
-259
lines changed

2 files changed

+522
-259
lines changed

Grammar/python.gram

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,9 @@ invalid_replacement_field:
13631363
| '{' a='!' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: expression required before '!'") }
13641364
| '{' a='}' { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: empty expression not allowed") }
13651365
| '{' (yield_expr | star_expressions) "="? invalid_conversion_character
1366+
| '{' (yield_expr | star_expressions) "="? [ "!" NAME ] [ ':' fstring_format_spec* ] !'}' {
1367+
RAISE_SYNTAX_ERROR("f-string: expecting '}'")
1368+
}
13661369
invalid_conversion_character:
13671370
| a="!" &(':'|'}') { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: missed conversion character") }
13681371
| a="!" !NAME { RAISE_SYNTAX_ERROR_KNOWN_LOCATION(a, "f-string: invalid conversion character") }

0 commit comments

Comments
 (0)