Title: sys.stdin.readline() hangs when used interactively (JLine, Windows)
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7, Jython 2.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jeff.allen Nosy List: amak, emcdowell, jeff.allen
Priority: Keywords: console

Created on 2013-05-11.14:10:40 by jeff.allen, last changed 2013-10-30.20:45:31 by jeff.allen.

msg8009 (view) Author: Jeff Allen (jeff.allen) Date: 2013-05-11.14:10:39
This behaviour was identified by Edward McDowell during discussion of Issue #1972, which it resembles, but differs from. Quoting from there ...

...(emcdowell) sys.stdin.readline() hangs on Windows as well.  This problem persists in both jython 254RC1 and 27b1.  raw_input must be used to successfully read from the keyboard.  I have encountered this problem using the standalone jar distributions on both Windows 7 and Windows XP. To reproduce the problem:

Start the jython shell: java -jar jython.jar
>>> import sys
>>> sys.stdin.readline()
Type a line of input.  Will hang.

A work-around is to use the alternative console org.python.util.InteractiveConsole although one loses the interactive line recall, of course.

dev>jython -Dpython.console=org.python.util.InteractiveConsole
Jython 2.7b1+ (default:1af38173c96d, Feb 12 2013, 15:40:07)
[Java HotSpot(TM) 64-Bit Server VM (Sun Microsystems Inc.)] on java1.6.0_35
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdin.readline()

The root cause of this behaviour is known to be that the JLine console reprogrammes the Windows console to deliver single keystrokes exactly as types. In particular, \r is no longer translated to the system end of line (\r\n for Windows), which is what TextIOWrapper is looking for during readline. It also no longer traps the keyboard interrupt ctrl-C (see Issue #1313).
msg8133 (view) Author: Jeff Allen (jeff.allen) Date: 2013-09-27.21:50:09
Fixed in 2.7 at changeset

It's quite a big change to the way the console integrates. Does anyone think a backport to 2.5 desirable?
msg8169 (view) Author: Jeff Allen (jeff.allen) Date: 2013-10-30.20:45:30
Ok, time's up. :)
Date User Action Args
2013-10-30 20:45:31jeff.allensetstatus: open -> closed
resolution: fixed
messages: + msg8169
2013-09-27 21:50:09jeff.allensetmessages: + msg8133
2013-05-11 14:10:41jeff.allencreate