Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Lib/test/test_fstring.py
Original file line number Diff line number Diff line change
Expand Up @@ -1532,5 +1532,18 @@ def test_syntax_error_for_starred_expressions(self):
"f-string: expecting a valid expression after '{'"):
compile("f'{**a}'", "?", "exec")

def test_semicolon(self):
self.assertAllRaise(SyntaxError,
"f-string: expecting a valid expression after '{'",
["f'{_=}{;",
"f'{1=}{+;'",
"f'{1=}{2}{;'",
])
self.assertAllRaise(SyntaxError,
"f-string: expecting '=', or '!', or ':', or '}'",
["f'{1=}{1;'",
"f'{1=}{1;}'",
])

if __name__ == '__main__':
unittest.main()
2 changes: 1 addition & 1 deletion Parser/action_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,7 @@ expr_ty _PyPegen_formatted_value(Parser *p, expr_ty expression, Token *debug, ex
end_col_offset, arena
);

if (debug) {
if (debug && !p->call_invalid_rules) {
/* Find the non whitespace token after the "=" */
int debug_end_line, debug_end_offset;

Expand Down