You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Empty unclosed f-string does not directly raise a SyntaxError in the REPL #103727
This is another bug introduced in 1ef61cf. When typing an empty single-quoted unclosed f-string in the REPL, another line is added and input is expected, before a SyntaxError is raised.
In IDLE, which uses code.interactive_interpreter, which ultimately uses codeop._maybe_compile, I get 'SyntaxError: incomplete input' in installed 3.12.0a7 and the new message at line 1 in fresh repository 3.12.0a7+.
codeop._maybe_compile uses compile, which doesn't encounter the problem mentioned here.
It's got to do with the interactive mode, where we advance the tokenizer far enough (to backup again afterwards) that a newline character alone is not enough for the syntax error to be emitted directly.
Activity
terryjreedy commentedon Apr 23, 2023
In IDLE, which uses code.interactive_interpreter, which ultimately uses codeop._maybe_compile, I get 'SyntaxError: incomplete input' in installed 3.12.0a7 and the new message at line 1 in fresh repository 3.12.0a7+.
lysnikolaou commentedon Apr 23, 2023
codeop._maybe_compileusescompile, which doesn't encounter the problem mentioned here.It's got to do with the interactive mode, where we advance the tokenizer far enough (to backup again afterwards) that a newline character alone is not enough for the syntax error to be emitted directly.
pythonGH-103727: Avoid advancing tokenizer too far in f-string mode
GH-103727: Avoid advancing tokenizer too far in f-string mode (GH-103775
Merge branch 'main' into superopt
Merge branch 'superopt' into superopt_spec
lysnikolaou commentedon Apr 26, 2023
Resolved in #103775.