# 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

<!-- gh-linked-prs -->
### Linked PRs
* gh-119703
<!-- /gh-linked-prs -->

SyntaxError thrown from the compiler exits the REPL
This is a GitHub Issue
repo:cpython
owner:python
Title : SyntaxError thrown from the compiler exits the REPL
Issue date:

--- start body ---
# 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

<!-- gh-linked-prs -->
### Linked PRs
* gh-119703
<!-- /gh-linked-prs -->

--- end body ---
