Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-133400: Fixed Ctrl+D (^D) behavior in :mod:_pyrepl module #133883

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
Loading
from

Conversation

deepwzh
Copy link

@deepwzh deepwzh commented May 11, 2025

Fixed Ctrl+D (^D) behavior in :mod:_pyrepl module:

  • Now properly exits multiline mode when pressed in multiline section
  • Added test cases to verify the behavior in both multiline and single line modes

@deepwzh deepwzh force-pushed the fix-issue-133400 branch from 16848f9 to b0c288a Compare May 11, 2025 09:47
@StanFromIreland
Copy link
Contributor

StanFromIreland commented May 11, 2025

This is not ideal:

>>> if True:
...     
  File "<python-input-2>", line 1
    if True:
            ^
IndentationError: expected an indented block after 'if' statement on line 1
>>>

@deepwzh
Copy link
Author

deepwzh commented May 11, 2025

This is not ideal:

>>> if True:
...     
  File "<python-input-2>", line 1
    if True:
            ^
IndentationError: expected an indented block after 'if' statement on line 1
>>>

This fix is ​​to correctly handle the issue of Ctrl+D to exit multi-line mode. What do you think the expected behavior should be?
@StanFromIreland

@ZeroIntensity ZeroIntensity added topic-repl Related to the interactive shell needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes labels May 11, 2025
@feoh
Copy link
Contributor

feoh commented May 19, 2025

@ambv FWIW I tested this PR on my Mac (main branch, latest, MacOS latest) and it works great. I tried throwing a bunch of other unclosed constructs (e.g. {, [, etc.) and none exhibited this error either.

@feoh
Copy link
Contributor

feoh commented May 19, 2025

@StanFromIreland Are you suggesting that the error message in the if True: case could be more clear?

The fact that the user isn't supplying a valid indented block after the if True: is indeed a problem the language needs to flag, so I'm curious what specific wording you think might be more clear. Also it seems to me like this could be a separate Github issue. Do you agree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review needs backport to 3.13 bugs and security fixes needs backport to 3.14 bugs and security fixes topic-repl Related to the interactive shell
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.