Skip to content

pyrepl messed up terminal if a signal handler expects stdin #130168

@gaogaotiantian

Description

@gaogaotiantian

Bug report

Bug description:

This is related to #129614 but more straightforward and irrelevant to pdb. (pdb needs this to be fixed though)

Start REPL from a terminal and do

import signal
signal.signal(signal.SIGINT, lambda s, f: input("test"))
<Ctrl+C>

Your terminal is messed up and newline won't work anymore. (Not the Python repl which will exit due to some run time error, the terminal itself is messed up)

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytopic-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