python / python/cpython

CTRL+C/KeyboardInterrupt in editline not working properly on macOS REPL

Open
#100,610 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

OS-mac topic-repl type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

Bug report

With the following in ~/.editrc:

bind "^R" em-inc-search-prev

Pressing CTRL+R inside the macOS-bundled python (/usr/bin/python3, which is compiled against editline) to enter editline history, and then pressing CTRL+C does not properly remove "bck" and does not write KeyboardInterrupt until CTRL+C is pressed two more times for a total of three times.

In other words, inside an editline history search, CTRL+C needs to be sent three times to get back to the normal REPL state.

This video may help with understanding the issue: https://github.com/Homebrew/homebrew-core/issues/118869#issuecomment-1365364374

Your environment

  • CPython versions tested on: 3.9.6
  • Operating system and architecture: macOS Monterey 12.6.1 / M1 / arm64

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in the macOS-bundled /usr/bin/python3 REPL with the stated ~/.editrc binding, then trace the editline history-search and CTRL+C handling entry points. Done means one CTRL+C exits the history search cleanly and writes KeyboardInterrupt instead of requiring three presses.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, operating-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.