Issue1669

classification
Title: Interactive interpreter broken on Cygwin xterm
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.5
Milestone:
process
Status: open Resolution: accepted
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: amak, donmez, fwierzbicki, jeff.allen, neuroaudio, zyasoft
Priority: normal Keywords: console

Created on 2010-10-25.22:30:05 by neuroaudio, last changed 2015-05-14.15:37:20 by zyasoft.

Messages
msg6207 (view) Author: Mark Fuhs (neuroaudio) Date: 2010-10-25.22:30:04
$ uname -a
CYGWIN_NT-5.1 Rex 1.5.25(0.156/4/2) 2008-06-12 19:34 i686 Cygwin

In a regular cygwin shell, everything works fine. However, if one starts X windows and runs an xterm (very popular for X-style cut/paste, etc.), it was possible with earlier 2.5 betas to trick jython into working by adding the option "-Djline.terminal=jline.UnixTerminal" and running "stty -icanon min 1 -echo" beforehand. A hack, but it got the job done. Now, even this hack does not work. Interactive sessions have no readline support and look like:

print "hi"
hi

instead of:

Jython 2.5.2rc2 (Release_2_5_2rc2:7167, Oct 24 2010, 22:48:30)
[Java HotSpot(TM) Client VM (Sun Microsystems Inc.)] on java1.6.0_20
Type "help", "copyright", "credits" or "license" for more information.
>>> print "hi"
hi
>>>

A few clues I noticed in the cygwin xterm:
1) sys._jy_interpreter is InteractiveConsole instead of JLineConsole
2) sys.stdin.isatty() is False. This should be true, and it seems to determine which console object is used.
msg6208 (view) Author: Jim Baker (zyasoft) Date: 2010-10-26.02:47:37
Try using the -i option to jython to force an interactive console.  (See jython --help) Apparently sys.stdin.isatty does not properly work on cygwin xterm.
msg6211 (view) Author: Mark Fuhs (neuroaudio) Date: 2010-10-26.14:56:51
I forgot to mention it, but I did try the "-i" option.

$ ./jython.bat -i
print "hi"
hi
msg6212 (view) Author: Jim Baker (zyasoft) Date: 2010-10-26.16:54:50
As I understand it, this issue is related to this same problem seen in JRuby of the same setup (cygwin + alt terminal):
http://jira.codehaus.org/browse/JRUBY-5068

The reason it worked in the past was that the logic was backwards - isatty should return False, given the workaround used by such terminals by using pipes. This meant that just for this setup, our previous buggy logic actually worked!

-i does seem to be the obvious thing to do, but looking at org.python.util.jython#run shows that opts.fixInteractive is treated differently than opts.interactive. Need to figure out why. But maybe we need a separate flag, or more likely property specific to Jython, that means "terminal interactive", preserving the other case where it's only has a part of the interactive quality.

This was also recommend in the JRuby case.
msg8909 (view) Author: Jeff Allen (jeff.allen) Date: 2014-08-08.20:41:42
This issue has been discussed again on jython-users. See:
http://python.6.x6.nabble.com/Jython-Hangs-with-Cygwin-tp1778354p5067209.html

In 2.7, I have changed code in the area Jim mentions, to solve various console issues, but I kept the logic the same for combining opts.interactive, opts.fixInteractive and isatty(). This was because I didn't understand why it was like this, not because I thought it was right!
msg9788 (view) Author: Jim Baker (zyasoft) Date: 2015-04-10.02:14:35
Fixed with the new jython.exe launcher in 2.7, which determines interactivity (with CPython's support) before starting the Jython runtime.
msg10061 (view) Author: Ismail Donmez (donmez) Date: 2015-05-14.09:53:27
Could you point out the exact change you did? Because CPython still does not work correctly with cygwin. Would be nice to see if we can forward the fix there.
msg10062 (view) Author: Jim Baker (zyasoft) Date: 2015-05-14.15:37:19
We need to re-open - I believe this got broken yet again with https://hg.python.org/jython/rev/cc3e787c0a7c during RC3

We really need pexpect tests - using CPython (!), given that we do not support pty - so we can automatically test the console.
History
Date User Action Args
2015-05-14 15:37:20zyasoftsetstatus: closed -> open
resolution: fixed -> accepted
messages: + msg10062
2015-05-14 09:53:28donmezsetnosy: + donmez
messages: + msg10061
2015-04-20 21:56:05zyasoftsetstatus: pending -> closed
assignee: zyasoft
2015-04-10 02:14:35zyasoftsetstatus: open -> pending
resolution: fixed
messages: + msg9788
2014-08-08 20:41:43jeff.allensetnosy: + jeff.allen
messages: + msg8909
versions: + Jython 2.7
2013-02-26 17:38:41fwierzbickisettitle: 2.5.2rc2: interactive interpreter broken on Cygwin xterm -> Interactive interpreter broken on Cygwin xterm
versions: + Jython 2.5
2013-02-26 17:38:20fwierzbickisetpriority: normal
2013-02-26 17:38:12fwierzbickisetnosy: + fwierzbicki
2013-02-25 21:58:49amaksetnosy: + amak
2013-02-25 21:58:37amaksetkeywords: + console
2010-10-26 16:54:51zyasoftsetmessages: + msg6212
2010-10-26 14:56:51neuroaudiosetmessages: + msg6211
2010-10-26 02:47:37zyasoftsetnosy: + zyasoft
messages: + msg6208
2010-10-25 22:30:05neuroaudiocreate