-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed as not planned
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixestopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Description
Bug report
Bug description:
If you write a SyntaxError that gets caught by the parser, a nice error is shown and you go back to the main prompt.
But if you hit a SyntaxError thrown from the compiler, the REPL exits.
% ./python.exe
Python 3.14.0a0 (heads/pep649-compile-dirty:3b4a645ee8, May 28 2024, 18:48:32) [Clang 14.0.0 (clang-1400.0.29.202)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> def f():
... x++
File "<unknown>", line 2
x++
^
SyntaxError: invalid syntax
>>> def f():
... nonlocal y
Traceback (most recent call last):
File "/Users/jelle/py/cpython/Lib/runpy.py", line 198, in _run_module_as_main
return _run_code(code, main_globals, None,
"__main__", mod_spec)
File "/Users/jelle/py/cpython/Lib/runpy.py", line 88, in _run_code
exec(code, run_globals)
~~~~^^^^^^^^^^^^^^^^^^^
File "/Users/jelle/py/cpython/Lib/_pyrepl/__main__.py", line 47, in <module>
interactive_console()
~~~~~~~~~~~~~~~~~~~^^
File "/Users/jelle/py/cpython/Lib/_pyrepl/__main__.py", line 44, in interactive_console
return run_interactive(mainmodule)
File "/Users/jelle/py/cpython/Lib/_pyrepl/simple_interact.py", line 181, in run_multiline_interactive_console
more = console.push(_strip_final_indent(statement), filename=input_name, _symbol="single") # type: ignore[call-arg]
File "/Users/jelle/py/cpython/Lib/code.py", line 303, in push
more = self.runsource(source, filename, symbol=_symbol)
File "/Users/jelle/py/cpython/Lib/_pyrepl/simple_interact.py", line 103, in runsource
code = compile(item, filename, the_symbol, dont_inherit=True)
File "<python-input-1>", line 2
SyntaxError: no binding for nonlocal 'y' found
CPython versions tested on:
CPython main branch
Operating systems tested on:
macOS
Linked PRs
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixestopic-replRelated to the interactive shellRelated to the interactive shelltype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error