New GitHub issue #119700 from JelleZijlstra:<br>

<hr>

<pre>
# 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.

```pycon
% ./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
</pre>

<hr>

<a href="https://github.com/python/cpython/issues/119700">View on GitHub</a>
<p>Labels: type-bug, 3.13, 3.14, topic-repl</p>
<p>Assignee: </p>