yihong0618 · GitHub

Bug report

Bug description:

The resumed REPL can't be exited on Unix-like platforms other than through kill:

./python.exe -m asyncio
ctrl + z
fg
# then the terminal boom
>>>
Traceback (most recent call last):
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/readline.py", line 395, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 752, in readline
    self.restore()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 608, in restore
    self.console.restore()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/unix_console.py", line 377, in restore
    signal.signal(signal.SIGWINCH, self.old_sigwinch)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/signal.py", line 58, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter
>>>
Traceback (most recent call last):
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/readline.py", line 395, in multiline_input
    return reader.readline()
           ~~~~~~~~~~~~~~~^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 752, in readline
    self.restore()
    ~~~~~~~~~~~~^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/reader.py", line 608, in restore
    self.console.restore()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/_pyrepl/unix_console.py", line 377, in restore
    signal.signal(signal.SIGWINCH, self.old_sigwinch)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/hyi/.local/share/uv/python/cpython-3.14.0rc2-macos-aarch64-none/lib/python3.14/signal.py", line 58, in signal
    handler = _signal.signal(_enum_to_int(signalnum), _enum_to_int(handler))
ValueError: signal only works in main thread of the main interpreter
>>>

Image

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

Linked PRs

Read the original on github.com ↗