Issue2151

classification
Title: Multiline REPL commands broken on Windows
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
process
Status: closed Resolution: invalid
Dependencies: Superseder:
Assigned To: Nosy List: emcdowell, zyasoft
Priority: Keywords:

Created on 2014-05-20.18:16:41 by emcdowell, last changed 2014-05-21.20:28:11 by zyasoft.

Messages
msg8448 (view) Author: Edward McDowell (emcdowell) Date: 2014-05-20.18:16:40
Jython 2.7b2 running on java1.8.0_05 on Windows 7 and 8 does not
handle multiline input in the REPL correctly.  In situations where
a command must span lines, Jython 2.7b2 aborts with a LookupError
on the encoding. This occurs for the legacy but default MS-DOS
codepage 437, for the Windows codepage 1252, and for the UTF-8
codepage 65001 (which Jython thinks is us-ascii).
 
Examples follow:

C:\Users\emcdowell\progs\jython>java -jar jython.jar
Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_05
>>> 2 + 3
5
>>> 2 +
LookupError: no codec search functions registered: can't find encoding 'ibm437'

C:\Users\emcdowell\progs\jython>chcp 65001
Active code page: 65001

C:\Users\emcdowell\progs\jython>java -jar jython.jar
console: Failed to install 'org.python.util.JLineConsole': java.nio.charset.UnsupportedCharsetException: cp65001.
console: Failed to install 'org.python.util.JLineConsole': java.nio.charset.UnsupportedCharsetException: cp65001.
Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_05
>>> 2 + 3
5
>>> 2 +
LookupError: no codec search functions registered: can't find encoding 'us-ascii'

C:\Users\emcdowell\progs\jython>
msg8451 (view) Author: Edward McDowell (emcdowell) Date: 2014-05-20.19:36:36
Even single-line function definitions suffer this problem:

H:\user\python\jytest>java -jar jython.jar
Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_05
>>> def foo(n): return n + 1
LookupError: no codec search functions registered: can't find encoding 'ibm437'

H:\user\python\jytest>
msg8453 (view) Author: Edward McDowell (emcdowell) Date: 2014-05-20.19:54:35
This problem is resolved using the full standalone jar: jython-standalone-2.7-b2.jar.  The required codecs are apparently among the files omitted from the smaller archive.

Examples: jython27b2.jar is the complete standalone jar mentioned above.

H:\user\down>java -jar jython27b2.jar
Jython 2.7b2 (default:a5bc0032cf79+, Apr 22 2014, 21:20:17)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.8.0_05
Type "help", "copyright", "credits" or "license" for more information.
>>> 2 +
  File "<stdin>", line 1
    2 +
      ^
SyntaxError: no viable alternative at input '\n'
>>> 2 + 5
7
>>> def foo(n): return n + 1
...
>>> foo(4)
5
>>> line = raw_input('? ')
? 67
>>> line
'67'
>>> exit
Use exit() or Ctrl-Z plus Return to exit
>>> →


H:\user\down>
msg8457 (view) Author: Jim Baker (zyasoft) Date: 2014-05-21.20:28:10
You cannot run jython unless it's standalone without the required dependencies. You can find out what these are on Windows via

jython.bat --print

Also I should mention running java -jar is problematic for other reasons, for any reasonably complex Java code. Usually you mean --classpath instead. Again, take a look at what jython.bat --print produces.
History
Date User Action Args
2014-05-21 20:28:11zyasoftsetstatus: open -> closed
resolution: invalid
messages: + msg8457
nosy: + zyasoft
2014-05-20 19:54:36emcdowellsetmessages: + msg8453
2014-05-20 19:36:37emcdowellsetmessages: + msg8451
2014-05-20 18:16:41emcdowellcreate