classification
Title: REPL does not work in msys2, ConEmu terminals on windows
Type: behavior Stage:
Components: Windows Versions: Python 3.8, Python 3.7, Python 3.6, Python 3.5, Python 3.4, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Segev Finer, eric.smith, martin.panter, maxnoe, paul.moore, steve.dower, tim.golden, zach.ware
Priority: normal Keywords:

Created on 2018-07-11 09:02 by maxnoe, last changed 2018-07-13 09:22 by Segev Finer.

Messages (4)
msg321417 - (view) Author: Maximilian Nöthe (maxnoe) Date: 2018-07-11 09:02
The REPL won't start in interactive mode, it only starts when explicitly given the `-i` option. 

The problems IPython is having, e.g. missing syntax highlighting and no tab completion should have the same root.

See this issue for mingw:
https://github.com/Alexpux/MINGW-packages/issues/730

They fixed it by patching python using this patch:
https://github.com/Alexpux/MINGW-packages/blob/master/mingw-w64-python3/1700-cygpty-isatty.patch

And this issue at msys2:
https://sourceforge.net/p/msys2/tickets/32/
msg321422 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2018-07-11 09:45
The problem as I understand it is that Msys uses a pipe, but Python by default limits interactive REPL mode to terminals only. The same thing happens if you start Python on a pipe some other way, for instance “cat | python” vs “cat | python -i”.

I would prefer if Python decided to use interactive mode when no file name is given, rather than by checking if the file is a terminal. But that would break compatibility.

Another tip with Msys: enable unbuffered output with “python -u”. Otherwise output gets buffered, won’t be seen immediately, and may be lost if there is an unclean exit.
msg321437 - (view) Author: Maximilian Nöthe (maxnoe) Date: 2018-07-11 10:48
Tab completion does not work in the REPL even when started with `-i -u`, so there might be a deeper problem than just the PIPE that's preventing python from starting in interactive mode.
msg321585 - (view) Author: Segev Finer (Segev Finer) * Date: 2018-07-13 09:22
I'd assume this is using ConEmu's ChildGui which means it hacks up a MinTTY window to appear inside ConEmu's GUI. MinTTY doesn't use a real terminal but rather pipes as the processes stdio. Any native (non-MSYS2) Windows program would have a problem with this.

The known workaround is to launch such programs using WinPTY (Available in the MSYS2 pacman), which creates a real console for the program in the background and communicates it's input/output so that it appear in the original console.

Sadly that is a limitation of Windows, as Windows does not supply a proper PTY interface and MSYS2/MinTTY choose not to use something like WinPTY by default.
History
Date User Action Args
2018-07-13 09:22:15Segev Finersetnosy: + Segev Finer
messages: + msg321585
2018-07-11 10:48:06maxnoesetmessages: + msg321437
2018-07-11 10:36:59eric.smithsetnosy: + eric.smith
2018-07-11 09:45:20martin.pantersetnosy: + paul.moore, tim.golden, martin.panter, zach.ware, steve.dower
messages: + msg321422
components: + Windows
2018-07-11 09:02:12maxnoecreate