-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
AssertionError
occurs using 3.130b1 interactive mode when pressed tab and up arrow
#118877
Comments
I was able to repro this on Fedora 39. The fastest repro is if you press TAB twice to show the completion options, and then you press up arrow, followed by down arrow. I think the up arrow should not "enter" the menu in the first place, since the menu is not currently interactive anyway right? (e.g. one cannot press Enter to select a suggested completion, left/right arrows don't do anything etc) . CC @pablogsal |
CC: @lysnikolaou @ambv |
I'm taking this one. |
I tested that the issue is not present in pypy, where pressing an up arrow goes back to in command history (instead of entering the completions menu). |
I found the issue I think. :-) @ambv I can open a PR over the weekend if you'd be okay with that, it's quite fun to hack on the new REPL. :-) |
The following patch seems to fix the issue diff --git a/Lib/_pyrepl/commands.py b/Lib/_pyrepl/commands.py
index 456cba0769..aa3edce09f 100644
--- a/Lib/_pyrepl/commands.py
+++ b/Lib/_pyrepl/commands.py
@@ -245,7 +245,8 @@ def do(self) -> None:
x, y = r.pos2xy()
new_y = y - 1
- if new_y < 0:
+ if r.bol() == 0:
if r.historyi > 0:
r.select_item(r.historyi - 1)
return I took the code from the original pypy implementation. I don't yet understand why the new code doesn't work, and don't know if this fix doesn't break something else. @BreezeWhite can you try it out? |
Looks like this was introduced in commit " Fix vertical navigation with wide characters " @lysnikolaou could you maybe try the suggested patch above to see if your commit still does what it aimed to do? (sorry for the noise if this is not helpful) |
I think the tests cover it but you can try to use a bunch of Chinese characters, press enter, and a bunch or regular characters and then move the cursor form one line to another and check that the cursor moves vertically and not jumping forwards in the previous line |
The patch above indeed fixes this issue, but the problem is bigger than that. For example, pressing the Left arrow after the completions are shown moves the cursor three positions to the left. It turns out |
A crash of the new pyrepl was triggered by pressing up arrow when tab completion menu was displayed.
A crash of the new pyrepl was triggered by pressing up arrow when tab completion menu was displayed.
Leave this open for the bug I described in #118877 (comment) above or open a new issue for that? |
(cherry picked from commit c0d81b2) Co-authored-by: Daniel Hollas <daniel.hollas@bristol.ac.uk>
Bug report
Bug description:
Hi dear core developers,
I was playing with the newest REPL v3.130b1 on my M2 MacBook Pro with macOS 14.3. I built the python binary from the source at commit
b62cb5234b
. It's really impressive and exciting to see how much the standard REPL has evolved in this version.However the bug occurred while I was playing with the auto-completion on the command. Says I want to see what operations are there under
datetime
module, typedatetime.
and pressTab
twice, the suggestions show up correctly. But when I try to surf the suggestions with arrow keys pressed several times, I got theAssertionError
:Not sure if this is the intended behavior of using the new REPL, but I still hope this could be solved as this can largely improve the user experience of using the new auto-completion feature.
Thanks for all your hard works, the new python features are really awesome. Can't wait to see the final release ^^ It's my first issue sending to cpython, and sorry if there is any missing information I did not provide.
CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: