classification
Title: Windows launcher breaks history in Git Bash
Type: Stage:
Components: Windows Versions: Python 3.7, Python 3.6, Python 3.3, Python 3.4, Python 3.5
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: eryksun, evan_, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2016-12-28 12:48 by evan_, last changed 2016-12-31 21:20 by eryksun. This issue is now closed.

Messages (10)
msg284171 - (view) Author: Evan Andrews (evan_) * Date: 2016-12-28 12:48
When I launch *any* version of Python using py.exe from Git Bash, the up and down arrows clear the line buffer instead of navigating history.

The following things all work as intended:

* py.exe in cmd.exe
* py.exe in Git Bash using winpty
* Python 2.7, 3.5, 3.6 when run directly

The only thing that appears to trigger this bug is using the launcher in Git Bash without winpty.

Tested with the following versions of Git Bash:

* GNU bash, version 4.3.42(2)-release (x86_64-pc-msys)
* GNU bash, version 4.3.46(2)-release (x86_64-pc-msys)

Unfortunately I can't point to exactly which version of the launcher introduced this bug. Initially I was certain this only happened when I upgraded from 3.5.2 to 3.6.0, but now I've checked another machine with 3.5.2 and 3.4.4, and the bug appears there too.
msg284179 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2016-12-28 15:54
You mean the history within Python? That's extremely strange.

Have you reported this to the git bash folks? We'll probably need someone who understands what their shell is actually doing to make any progress here.
msg284184 - (view) Author: Evan Andrews (evan_) * Date: 2016-12-28 17:05
Yes, the history within the current Python session. It's worth noting that the history usually behaves like in cmd.exe, not bash. (I don't have a py.exe without the bug at the moment to confirm that is the same.)

Testing now, it seems all the history shortcuts (F1-F9) function correctly when running Python directly, but when run with the launcher all behave as though the history buffer were empty. Somehow the combination of the shell and the launcher are stopping it from keeping history.

I'll open an issue on their bug tracker and report back.
msg284195 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-12-28 20:20
Does the git bash shell leave a readline DLL on the user's PATH? If so, Python's readline support will kick in, and as a result Python will behave differently.
msg284219 - (view) Author: Evan Andrews (evan_) * Date: 2016-12-29 01:00
No, it doesn't provide a version of readline that works with Windows binaries. Trying to import readline fails no matter how I start Python.
msg284235 - (view) Author: Evan Andrews (evan_) * Date: 2016-12-29 07:43
I tried compiling the version of the launcher from https://github.com/python/cpython/tree/3.3, and the bug is still present there.

Previously when I was testing older versions with the launcher I had to uninstall pyreadline from several of them to confirm the bug was present. In retrospect it's obvious that this means the bug would have been hidden from me until now; I just happened to notice it after installing 3.6 because I hadn't installed pyreadline.

I now believe this affects *all* versions of the launcher, and that this has nothing to do with 3.6.0 in particular.

Associated issue: https://github.com/git-for-windows/git/issues/1013
msg284381 - (view) Author: Evan Andrews (evan_) * Date: 2016-12-31 11:06
This appears to be a bug with Git Bash, not Python or the launcher. Closing.
msg284387 - (view) Author: Paul Moore (paul.moore) * (Python committer) Date: 2016-12-31 12:02
Thanks for letting us know
msg284393 - (view) Author: Evan Andrews (evan_) * Date: 2016-12-31 14:43
No problem, thanks for your time.
msg284414 - (view) Author: Eryk Sun (eryksun) * (Python triager) Date: 2016-12-31 21:20
git-bash.exe runs bash.exe via cmd.exe, which means the console (conhost.exe) ends up with 5 attached processes:

    cmd.exe
        bash.exe
            bash.exe
                py.exe
                    python.exe

The default console configuration uses 4 history buffers, so by the time python.exe runs, they've all been used up. You can change this in the Alt+Space control menu's "Properties" dialog. This should modify the settings associated with cmd.exe, which are stored at "HKCU\Console\%SystemRoot%_system32_cmd.exe". In the upper right section increase the number of buffers to 32. You can also increase the size. I increase it to 500 commands. Start a new console via "Git Bash Here" to confirm that the new settings are remembered.  

Also modify the default configuration used for new programs, which is stored at "HKCU\Console". Back on the Alt+Space control menu, choose "Defaults" and similarly modify the size and number of buffers. 

Note that if you run a console program using a shortcut, such as the default "Command Prompt" shortcut, the console configuration is stored in the .LNK shortcut file instead of the registry.
History
Date User Action Args
2016-12-31 21:20:41eryksunsetnosy: + eryksun
messages: + msg284414
2016-12-31 14:43:26evan_setmessages: + msg284393
2016-12-31 12:02:49paul.mooresetmessages: + msg284387
2016-12-31 11:06:12evan_setstatus: open -> closed
resolution: third party
messages: + msg284381
2016-12-29 07:43:56evan_setmessages: + msg284235
versions: + Python 3.3
2016-12-29 01:00:48evan_setmessages: + msg284219
2016-12-28 20:20:46paul.mooresetmessages: + msg284195
2016-12-28 17:05:09evan_setmessages: + msg284184
2016-12-28 15:54:18steve.dowersetmessages: + msg284179
2016-12-28 12:48:17evan_create