This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Console: holding right arrow key reproduces entire previous input
Type: behavior Stage: resolved
Components: Windows Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Matthijs Blom, eryksun, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2019-08-14 11:05 by Matthijs Blom, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg349679 - (view) Author: Matthijs Blom (Matthijs Blom) Date: 2019-08-14 11:05
To reproduce (on Windows):
On the console, enter some input:

    >>> "Ozewiezewoze wiezewalla kristalla"
    "Ozewiezewoze wiezewalla kristalla"

Next, hold the right arrow key, obtaining:

    >>> "Ozewiezewoze wiezewalla kristalla"

One can subsequently delete sections of this line and again reproduce (last parts of) the previous input.

I have produced this result on 3.4, 3.8.0b3 and master (077af8c).
I did not observe this behaviour on WSL, which is why I think this is a bug.
msg349680 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2019-08-14 11:19
This is normal behaviour of the Windows console command line editing. Python simply inherits the standard console behaviour.
msg349706 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2019-08-14 14:34
> I did not observe this behaviour on WSL, which is why I think 
> this is a bug.

WSL uses a low-level console interface in virtual-terminal mode. Python's console REPL in Windows is using the standard high-level console editing that's provided by the console host, conhost.exe, when the input mode contains ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT. This includes input history, aliases, and command-line editing that are based on the classic doskey utility from MS-DOS. The UI is documented for NT's doskey.exe command [1], which wraps the console interfaces for command-line history and aliases.

Python's built-in REPL could use a low-level console interface like PowerShell does, and implement a readline UI that's consistent with Unix, again like PowerShell has the option to do. Depending on whether we can integrate an existing readline library, that could be a monumental undertaking. pyreadline is a high-level ctypes wrapper that implements this. Last I checked it had some issues with Unicode and wasn't being vigorously maintained, but maybe that's changed.

[1] https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/doskey
History
Date User Action Args
2022-04-11 14:59:19adminsetgithub: 82031
2019-08-14 14:34:01eryksunsetnosy: + eryksun
messages: + msg349706
2019-08-14 11:19:29paul.mooresetstatus: open -> closed
resolution: not a bug
messages: + msg349680

stage: resolved
2019-08-14 11:05:36Matthijs Blomcreate