Skip to content

New repl closes CLI session on SyntaxError inside of the match statement #119555

Closed
@skirpichev

Description

@skirpichev

Bug report

Bug description:

>>> match 1:
...     case {0: _, 0j: _}:
...         pass
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/sk/src/cpython/Lib/_pyrepl/__main__.py", line 47, in <module>
    interactive_console()
    ~~~~~~~~~~~~~~~~~~~^^
  File "/home/sk/src/cpython/Lib/_pyrepl/__main__.py", line 44, in interactive_console
    return run_interactive(mainmodule)
  File "/home/sk/src/cpython/Lib/_pyrepl/simple_interact.py", line 176, in run_multiline_interactive_console
    more = console.push(_strip_final_indent(statement), filename=input_name, _symbol="single")  # type: ignore[call-arg]
  File "/home/sk/src/cpython/Lib/code.py", line 303, in push
    more = self.runsource(source, filename, symbol=_symbol)
  File "/home/sk/src/cpython/Lib/_pyrepl/simple_interact.py", line 98, in runsource
    code = compile(item, filename, the_symbol)
  File "<python-input-0>", line 2
SyntaxError: mapping pattern checks duplicate key (0j)

At that point I'm in the system shell...

C.f.:

>>> def f():
...     raise ValueError("boo!")
...     
>>> f()
Traceback (most recent call last):
  File "<python-input-1>", line 1, in <module>
    f()
    ~^^
  File "<python-input-0>", line 2, in f
    raise ValueError("boo!")
ValueError: boo!
>>>  3.to_bytes()
  File "<unknown>", line 1
    3.to_bytes()
     ^
SyntaxError: invalid decimal literal

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13bugs and security fixes3.14bugs and security fixestopic-replRelated to the interactive shelltype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions