Issue2276

classification
Title: Ctrl-Z doesn't exit Jython console on Windows
Type: Severity: normal
Components: Versions:
Milestone: Jython 2.7.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: eaaltonen, pekka.klarck, zyasoft
Priority: normal Keywords:

Created on 2015-02-25.13:00:24 by pekka.klarck, last changed 2016-01-19.18:36:19 by zyasoft.

Messages
msg9560 (view) Author: Pekka Klärck (pekka.klarck) Date: 2015-02-25.13:00:24
Using Ctrl-D works but Ctrl-Z is what CPython uses.
msg9561 (view) Author: Jim Baker (zyasoft) Date: 2015-02-25.14:02:23
I found a workaround with a little experimentation. Create a file %USERPROFILE%\.inputrc and put the desired key binding in:

"\C-z": "\C-d"

Presumably we can create this key binding programmatically in JLine2, using http://jline.github.io/jline2/apidocs/reference/jline/console/KeyMap.html, specifically http://jline.github.io/jline2/apidocs/reference/jline/console/KeyMap.html#bindIfNotBound(java.lang.CharSequence, java.lang.Object), so as to not override user intent.

With my workaround defined, I attempted to look up how JLine2 actually sets things up by examining the key map in use by starting with the ConsoleReader as set with sys._jy_console.reader (defined if using JLine2, otherwise an AttributeError). As usual for such experiments, I use the Jython console itself. However sys._jy_console.reader.keys.getBound("\z") returned jline.console.Operation.SELF_INSERT - no difference from not setting .inputrc - so looks there's some additional work to figure out what's going on here. As usual, this will require reading JLine2 source - that's really the only docs available.
msg9778 (view) Author: (eaaltonen) Date: 2015-04-08.13:22:26
Would an acceptable fix be to just change the instruction text to read
"Use exit() or Ctrl-D plus Return to exit" ?

Ctrl-D is so common in Linux environments, that many programmers are already familiar with it.
msg9779 (view) Author: Jim Baker (zyasoft) Date: 2015-04-08.17:47:06
eaaltonen - what instruction text should we modify? Not certain what we should modify to get to ""Use exit() or Ctrl-D plus Return to exit". However, I do expect this to be documented in the release notes.

I expect control-Z will be supported on Windows as of 2.7.1, but in addition to control-D. This also works well with the philosophy of JLine, which attempts to provide standard Unix-like console usage.
msg9947 (view) Author: (eaaltonen) Date: 2015-04-24.10:49:20
Looks like it's in Lib/site.py

elif os.sep == '\\':
        eof = 'Ctrl-Z plus Return'
msg9949 (view) Author: Jim Baker (zyasoft) Date: 2015-04-24.12:50:24
Ack. By the time we fix in 2.7.1, we probably will have control-Z support re-enabled, but it's good to know it's coming from the exit *string* set when running the console interactively.
msg10636 (view) Author: Jim Baker (zyasoft) Date: 2016-01-12.01:31:16
Fixed as of https://hg.python.org/jython/rev/e14b67be0bad, per eaaltonen's recommendation to stick to how we document on other underlying OS. It's cross platform! :)

C:\Users\Jim>c:\jython2.7.1-ctrld\bin\jython
Jython 2.7.1b2 (default:e5d62908c495+, Jan 11 2016, 18:21:27)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.7.0_55
Type "help", "copyright", "credits" or "license" for more information.
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>

At which point I used Ctrl-D to exit.

We can look at Ctrl-Z support at some point, but we use JLine 2 with the capabilities it provides, or not.
History
Date User Action Args
2016-01-19 18:36:19zyasoftsetstatus: pending -> closed
2016-01-12 01:31:18zyasoftsetstatus: open -> pending
assignee: zyasoft
resolution: remind -> fixed
messages: + msg10636
2015-12-30 00:01:48zyasoftsetpriority: high -> normal
2015-12-29 23:52:33zyasoftsetresolution: remind
2015-04-24 12:50:24zyasoftsetmessages: + msg9949
2015-04-24 10:49:21eaaltonensetmessages: + msg9947
2015-04-20 20:57:01zyasoftsetmilestone: Jython 2.7.1
2015-04-08 17:47:06zyasoftsetpriority: high
messages: + msg9779
2015-04-08 13:22:26eaaltonensetnosy: + eaaltonen
messages: + msg9778
2015-02-25 14:02:24zyasoftsetnosy: + zyasoft
messages: + msg9561
2015-02-25 13:00:24pekka.klarckcreate