Skip to content
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

Python 3.13: gnureadline appears to no longer be used #125924

Closed
milosivanovic opened this issue Oct 24, 2024 · 5 comments
Closed

Python 3.13: gnureadline appears to no longer be used #125924

milosivanovic opened this issue Oct 24, 2024 · 5 comments
Labels
3.13 bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error

Comments

@milosivanovic
Copy link

milosivanovic commented Oct 24, 2024

Bug report

Bug description:

Tested in 3.12:
In the <=3.12 Python REPL on Linux, pressing CTRL+R invokes gnureadline and shows:

(reverse-i-search)`':

Tested in 3.13:
In the 3.13 Python REPL on Linux, pressing CTRL+R does not appear to invoke gnureadline and shows:

(r-search `')

Additionally, with nothing in the command history, typing a few characters in the 3.13 REPL (without pressing enter) and then using the up/down arrow keys moves the cursor to the start and end of the line. In 3.12 (any in any other software that uses gnureadline), pressing up/down in this scenario did nothing and is the expected behaviour.

Was gnureadline removed in 3.13 in favour of an in-house implementation that doesn't mirror the featureset? If so, is it possible to restore the previous behaviour from <=3.12? This used to be able to be done with ludwigschwardt/python-gnureadline#62 but this no longer appears to work in 3.13.

CPython versions tested on:

3.12, 3.13

Operating systems tested on:

Linux, macOS

@milosivanovic milosivanovic added the type-bug An unexpected behavior, bug, or error label Oct 24, 2024
@tomasr8 tomasr8 added 3.13 bugs and security fixes topic-repl Related to the interactive shell labels Oct 24, 2024
@nineteendo
Copy link
Contributor

The old REPL can still be activated: https://docs.python.org/3/using/cmdline.html#envvar-PYTHON_BASIC_REPL

@ludwigschwardt
Copy link

Out of interest, how much does the new REPL still depend on readline?

It is explicitly mentioned as a dependency in the docs linked above, and I see that the code in Lib/_pyrepl still imports rlcompleter but I can't tell at a glance how much functionality has been reimplemented in Python. Is there a summary somewhere?

@brettcannon brettcannon changed the title Python 3.13: gnureadline appears to longer be used Python 3.13: gnureadline appears to no longer be used Oct 24, 2024
@Architector4
Copy link

Not sure if I make this a separate issue or as a comment here, but another behavioral difference with CTRL+R search in the new REPL is that after looking up a line, pressing ENTER only closes the search and returns back to the normal mode, and then you need to press ENTER again to actually input the command.

That has been messing with my muscle memory as now I have to double-tap the key each time lol

@milosivanovic
Copy link
Author

@Architector4 I agree, and I don't like it either.

I think there are and will be lots of people in the same boat who will question this change. Many linux tools use GNU readline, so having to continuously switch between how Python's arbitrary readline implementation treats ENTER vs the standard GNU implementation which is present in so many tools makes for an incredibly frustrating command-line experience.

I personally stopped using the new REPL by setting PYTHON_BASIC_REPL=1. I hope that the Python team can achieve reasonable feature parity with GNU readline in 3.13+ or at the very least let us have PYTHON_BASIC_REPL=1 indefinitely. As mentioned, I think having to continuously learn/unlearn how to use CTRL+R depending on what tool I am using is quite inconvenient.

@ambv
Copy link
Contributor

ambv commented Mar 20, 2025

PYTHON_BASIC_REPL is indeed planned to be around forever. The CTRL+R difference is deliberate, to let you edit a search result before executing the command.

@ambv ambv closed this as completed Mar 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes topic-repl Related to the interactive shell type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

7 participants
@ambv @ludwigschwardt @milosivanovic @tomasr8 @Architector4 @nineteendo and others