Skip to content

Error exiting the new REPL with Ctrl+Z on Windows #119896

@eryksun

Description

@eryksun

Bug report

Bug description:

With the new REPL implementation on Windows, I'm getting an error from code that mistakenly tries to suspend the current process via os.kill(os.getpid(), signal.SIGSTOP) when exiting via Ctrl+Z, Enter. This raises the following AttributeError:

    os.kill(os.getpid(), signal.SIGSTOP)
                         ^^^^^^^^^^^^^^
AttributeError: module 'signal' has no attribute 'SIGSTOP'

This is due to Ctrl+Z getting mapped to the "suspend" command. This key sequence has always been supported for exiting the REPL on Windows. It's also supported when reading from io._WindowsConsoleIO console-input files. Anything after Ctrl+Z at the start of a line gets ignored, yielding an empty read.

Note that the kernel on Windows has no support for POSIX signals. There's just a basic emulation of a few signals in the C runtime library. There's no support for SIGSTOP. It could be emulated, but it's not, and the GUI task manager hasn't implemented support for suspending and resuming processes. Thus on Windows you could just map Ctrl+Z to the "delete" command, and update the delete class to also exit the REPL if the raw event character is "\x1a".

CPython versions tested on:

CPython main branch

Operating systems tested on:

Windows

Linked PRs

Metadata

Metadata

Assignees

Labels

3.13bugs and security fixes3.14bugs and security fixesOS-windowsstdlibPython modules in the Lib dirtopic-replRelated to the interactive shelltriagedThe issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions