Skip to content

Fix KeyboardInterrupt leaking from Abort echo in prompt - #3813

Open
cnbei wants to merge 1 commit into
pallets:mainfrom
cnbei:cursor/fix-prompt-keyboardinterrupt-race-a25d
Open

Fix KeyboardInterrupt leaking from Abort echo in prompt#3813
cnbei wants to merge 1 commit into
pallets:mainfrom
cnbei:cursor/fix-prompt-keyboardinterrupt-race-a25d

Conversation

@cnbei

@cnbei cnbei commented Aug 30, 2026

Copy link
Copy Markdown

Fixes #3802

Ctrl-C during click.prompt() becomes Abort, then Command.main echoes Aborted. A second SIGINT in isatty() leaks because KeyboardInterrupt is a BaseException. Catch KeyboardInterrupt around that abort echo and still sys.exit(1).

Adds test_prompt_abort_echo_survives_keyboard_interrupt. 1931 tests passed.

A second Ctrl-C while Command.main prints Aborted! after prompt()
is cancelled could escape as an unhandled KeyboardInterrupt.

Fixes pallets#3802.

Co-authored-by: cnbei <baymy@foxmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyboardInterrupt during click.prompt() can race

2 participants