Skip to content

AI junk - #3806

Closed
arimu1 wants to merge 1 commit into
pallets:mainfrom
arimu1:fix-3802-prompt-keyboard-interrupt-race
Closed

AI junk#3806
arimu1 wants to merge 1 commit into
pallets:mainfrom
arimu1:fix-3802-prompt-keyboard-interrupt-race

Conversation

@arimu1

@arimu1 arimu1 commented Aug 29, 2026

Copy link
Copy Markdown

Summary

Fixes #3802.

When a user cancels click.prompt() with Ctrl-C, click converts the KeyboardInterrupt to Abort and main() prints "Aborted!" via echo(). That path calls should_strip_ansi()isatty(). A second KeyboardInterrupt arriving during the isatty() probe was not caught because isatty() only handled Exception, so the interrupt escaped main() and crashed the process instead of exiting cleanly.

  • Extend isatty() to treat KeyboardInterrupt like other probe failures and return False.
  • Add a regression test covering the prompt()Abortecho("Aborted!") path with a KeyboardInterrupt raised inside isatty().

Test plan

  • pytest tests/test_termui.py::test_prompt_abort_handles_keyboard_interrupt_during_abort_echo
  • pytest tests/test_termui.py (260 passed, 23 skipped)

When Ctrl-C cancels click.prompt(), main() prints "Aborted!" via echo(),
which probes isatty(). A second KeyboardInterrupt during that probe was
not caught because isatty() only handled Exception, letting the interrupt
escape and crash the process. Treat KeyboardInterrupt like other probe
failures and return False.

Fixes pallets#3802
@davidism

Copy link
Copy Markdown
Member

@davidism davidism closed this Aug 29, 2026
@davidism davidism changed the title fix: handle KeyboardInterrupt gracefully during prompt AI junk Aug 29, 2026
@davidism davidism added the rejected AI Contribution rejected because of its untrustworthy AI origin label Aug 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rejected AI Contribution rejected because of its untrustworthy AI origin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

KeyboardInterrupt during click.prompt() can race

2 participants