-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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.0b1 REPL changes behavior wrt PgUp, inserts first line of ~/.python_history #119034
Comments
Was talking to @ambv about this and decided to do some research on Ubuntu and Fedora's settings. I did some research on the default Digging into the details of those, here's what's missing... ConsistenciesHere are some seemingly missing key bindings that seem to be consistently mapped between Ubuntu and Fedora's default
Both Ubuntu and Fedora map those arrow shortcuts. Only Fedora maps these ones:
Since Ubuntu doesn't map these at all, it seems safe to enable these. InconsistentUbuntu has:
That maps Fedora has:
That maps SummaryThe missing keybindings that should probably be added are:
|
I wonder if the REPL could somehow inherit/use the inputrc settings. That way, the experience will be the same with other REPLs on the same system. (I am not saying that is a requirement. I would gladly accept a fix that makes my environment consistent.) |
Thanks Trey for the research, we will be implementing that. Miro, we won't be parsing inputrc, it is too advanced of a configuration format to accommodate. And it entails out-of-scope things like an vi edit mode that I already rejected. And on macOS we would have to also take editrc into account, which is yet another format, and also overly complex. We will implement the safe defaults and keep it at that. People very invested in their inputrc can keep using |
For the record, I found Fedora's inputr source at https://pagure.io/setup/blob/master/f/inputrc -- in case somebody wants to take a look without spinning up a container/VM. |
The quoted-insert vs overwrite-mode inconsistency is explained in the commit message of https://pagure.io/setup/c/b8ba4814b55da50c0946dbb5b1f72e8ba452c49e |
I think If I type Here's an example (I pressed >>> numbers = [2, 1, 3, 4, 7, 11]
>>> for n in numbers:
... print(n)
File "<unknown>", line 2
print(n)
^
SyntaxError: invalid non-printable character U+0016 I also managed to insert a null byte while teaching in the new Python REPL today. >>> names = ['Nellie', 'Ronald', 'Judith', 'Lavonda']
>>> for i in range(len(name)):
SyntaxError: source code string cannot contain null bytes I'll comment here or open a separate issue if I manage to reproduce the null byte I inserted. |
This comment was marked as off-topic.
This comment was marked as off-topic.
@ambv Is this something I should explore to implement myself if I want this fixed? |
There's an open PR about this in the duplicate issue gh-120767. |
We haven't gotten to that for RC1 but should be there in RC2. |
Workaround for that: use CTRL+R. Consider:
I'm using a different shortcut for that which works on bash and all Python versions:
There is also CTRL+S to search forward in the history. |
Thanks, I am aware of Ctrl+r. The PageUp thing is better when I already strated to type the command. It's really convenient and not having it makes my REPL experience in 3.13 seriously degraded. Omce again, should I submit a PR? I don't want to step on other people toes, but it's been a while and the window to get this into 3.13 is closing. |
Change <page up> and <page down> keys of the Python REPL to history search forward/backward.
I just wrote PR gh-123607 to implement these commands (history search backward/forward). Can you please test it and tell me if it behaves as expected? |
Change <page up> and <page down> keys of the Python REPL to history search forward/backward. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
…ythonGH-123607) Change <page up> and <page down> keys of the Python REPL to history search forward/backward. (cherry picked from commit 8311b11) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
…GH-123607) (GH-123773) Change <page up> and <page down> keys of the Python REPL to history search forward/backward. (cherry picked from commit 8311b11) Co-authored-by: Victor Stinner <vstinner@python.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
Bug report
Bug description:
When I use the Python REPL, I am used to PgUp browsing my prompt history based on the partial command I already typed.
Consider:
Python 3.12 REPL inserts
import os
with my cursor betweenm
andp
. I can keep pressing PgUp to getimport sys
and older commands from my history. I don't know if this is Fedora's configuration of readline, or the default. However, Bash and older Python REPLs behave that way, as well as IPython/Jupyter console.Python 3.130b1 REPL changes my prompt to
print("a")
when I press PgUp. The particular command is my first line of~/.python_history
. Pressing PgUp again changes nothing.CPython versions tested on:
3.13
Operating systems tested on:
Linux
Linked PRs
The text was updated successfully, but these errors were encountered: