Title: System.console().readLine only reads a single character
Type: Severity: normal
Components: Core Versions: Jython 2.5
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: JoshDavisNC, amak, fwierzbicki
Priority: Keywords: console

Created on 2012-11-14.23:44:17 by JoshDavisNC, last changed 2013-03-01.21:37:32 by amak.

msg7521 (view) Author: Josh Davis (JoshDavisNC) Date: 2012-11-14.23:50:37
I have a Jython script that calls into some Java classes.  One of these classes asks the user for a username and password using the java.lang.System.console().readLine() and .readPassword() API's.  When this class is used in a Java environment without Jython, those API's work correctly.  In my Jython environment, these API's only read a single character.  I can duplicate this behavior in the interactive console like this:

>>> from java.lang import System
>>> username = System.console().readLine("Username: ")
Username: >>>
>>> username
>>> password = System.console().readPassword("Password: ")
Password: >>>
>>> password
array('c', 'p')
msg7522 (view) Author: Josh Davis (JoshDavisNC) Date: 2012-11-14.23:53:26
I have duplicated this with Jython 2.5.2 / JRocket 1.6.0_29 in a Linux environment, and with Jython 2.5.3 / Java 1.7.0_07 in a Windows environment.
msg7705 (view) Author: Frank Wierzbicki (fwierzbicki) Date: 2013-02-19.23:06:42
Hi Josh, we have reason to believe this may be due to making JLine the default. A workaround is to use the InteractiveConsole (we are considering putting this back to the default) See here for the syntax:
msg7893 (view) Author: Alan Kennedy (amak) Date: 2013-03-01.21:37:32
Here's a bug report from scala, which appears to exhibit the same behaviour (they compare the behaviour to jython).

They also assert that it happens with jruby as well.
Date User Action Args
2013-03-01 21:37:32amaksetmessages: + msg7893
2013-02-25 21:59:06amaksetnosy: + amak
2013-02-25 21:58:03amaksetkeywords: + console
2013-02-19 23:06:42fwierzbickisetnosy: + fwierzbicki
messages: + msg7705
versions: + Jython 2.5, - 2.5.3b2
2012-11-14 23:53:27JoshDavisNCsetmessages: + msg7522
2012-11-14 23:50:37JoshDavisNCsetmessages: + msg7521
2012-11-14 23:44:17JoshDavisNCcreate