python / cpython

The Python programming language
https://www.python.org
Other
62.15k stars 29.86k forks source link

F1/F2/F3 behavior in the new repl #121584

Open saucoide opened 1 month ago

saucoide commented 1 month ago

Bug report

Bug description:

Not sure if to split this into different issues may be better but anyhow

Trying out the new repl in 3.13.0b3, some of these maybe are not bugs but the behavior feels weird:

When using the F1/F2/F3 keys there are these different behaviors:

F3 - pressing it twice toggles between paste/prompt F2 - Pressing it twice does nothing, q exits, but ignores whatever was already in the prompt, and adds a new one without a newline, shifting the prompt rightwards:

F2 + q multipe times:

➜ python
Python 3.13.0b3 (main, Jun 27 2024, 13:06:51) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> >>> >>> >>> >>> >>> >>> >>> 

F2 + q after having something there already

Python 3.13.0b3 (main, Jun 27 2024, 13:06:51) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def foo():
...     i = 0
...     for n in range(10):>>> 

F1 - pressing it twice opens a nested help menu, if you do it a few times because you think it didnt work, you have to q-q-q-quit

Trying on pypy's repl it doesnt seem possible to trigger help() from within help but in the 3.13's repl its bound to F1 and keeps working :)

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

Octopus136 commented 1 month ago

I've noticed this as well at 3.14.0a0.

Also, when typing the help command directly and then q, >>> appears twice.

help> q

You are now leaving help and returning to the Python interpreter.
If you want to ask for help on a particular object directly from the
interpreter, you can type "help(object)".  Executing "help('string')"
has the same effect as typing a particular string at the help> prompt.
>>> >>>
saucoide commented 1 month ago

i think something like this works for the help / F1 at least, and would toggle it on/off instead, not sure if the signal way of stopping the help is the best way but seems to work

https://github.com/saucoide/cpython/commit/3ede94127dc6161ea13e854efa645849372e15b2