Skip to content

Difference in Ctrl+D Behavior Between REPL and code.interact #139875

@adqm

Description

@adqm

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions