rprichard / winpty

A Windows software package providing an interface similar to a Unix pty-master for communicating with Windows console programs.
MIT License
1.29k stars 167 forks source link

iPython3 broken with winpty running under ConEmu Cygwin connector #102

Open CMCDragonkai opened 7 years ago

CMCDragonkai commented 7 years ago

Running iPython3 with winpty gives something like this:

%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

?[?25l?[?7l?[0m?[0m?[J?[0;38;5;28mIn [?[0;38;5;10;1m1?[0;38;5;28m]: ?[0m

?[21A?[8C?[0m?[?12l?[?25h?[?25l?[0me?[0m?[?12l?[?25h?[?25l?[0mx?[0m?[?12l?[?25h?[?25l?[0mi?[0m?[?12l?[?25h?[?25l?[0mt?[0m?[?12l?[?25h?[?25l?[12D?[0m?[J?
[0;38;5;28mIn [?[0;38;5;10;1m1?[0;38;5;28m]: ?[0mexit?[12D?[0m
?[J?[?7h?[0m?[?12l?[?25h%   
rprichard commented 7 years ago

I tested this just now, and the issue didn't reproduce for me.

capture

rprichard commented 7 years ago

@CMCDragonkai Are you using ConEmu? I am able to reproduce the issue with ConEmu and the Cygwin connector. The ConEmuANSI variable ends up set to ON in the hidden winpty console even though the ConEmu hook is not present (and therefore doesn't provide support for ANSI escape sequences).

rprichard commented 7 years ago

I'm guessing ipython uses prompt_toolkit, which decides its output is ConEmu by looking for ConEmuANSI=ON here: https://github.com/jonathanslenders/python-prompt-toolkit/blob/021e6cc963570e1bc645defcdeb2da10d0c83a9e/prompt_toolkit/utils.py#L190

CMCDragonkai commented 7 years ago

Yep using CONEMU and Cygwin

rprichard commented 7 years ago

I considered having winpty clear ConEmu environment variables only when it detected the presence of the ConEmu hook DLL, but that's too conservative a fix -- it's possible for (a) ConEmu to set those variables, then (b) ConEmu starts some other process unhooked, then (c) some descendant eventually starts winpty.exe.

rprichard commented 7 years ago

See https://github.com/rprichard/winpty/issues/106