Difference in Ctrl+D Behavior Between REPL and `code.interact`
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 77.2k
- Forks
- 35.9k
- PR merge metrics
- PR metrics pending
Description
Bug report
Bug description:
With #133883 merged, hitting ctrl+d at the start of a blank line in a multi-line entry causes the existing code to be evaluated in both the new REPL and the basic REPL:
>>> def foo(x):
...
File "<python-input-0>", line 1
def foo(x):
^
IndentationError: expected an indented block after function definition on line 1
But code.interact() exits immediately without executing the existing code:
>>> def foo(x):
...
now exiting InteractiveConsole...
I doubt this is terribly impactful, but I think it would still be nice to have these behave the same way.
I have a patch ready that I think will resolve this, so I'll open a PR shortly.
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Linked PRs
- gh-139876
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by comparing Ctrl+D handling in the new and basic REPL with code.interact(), using the blank-line multi-line function definition reproduction in the issue. Done means code.interact() evaluates the existing code consistently with the other REPLs; linked PR gh-139876 indicates work is already underway.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 20/100