Issue2373

classification
Title: jython 2.7.0 Console.py Demo does not work
Type: Severity: normal
Components: Library Versions: Jython 2.7
Milestone: Jython 2.7.2
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: saltnlight5, zyasoft
Priority: normal Keywords:

Created on 2015-06-26.13:04:56 by saltnlight5, last changed 2016-03-10.18:26:17 by zyasoft.

Messages
msg10134 (view) Author: Zemian Deng (saltnlight5) Date: 2015-06-26.13:04:55
This failed to load:
  D:\apps\jython2.7.0\bin>jython ..\Demo\swing\JythonConsole\Console.py
I get a flash of window and then it disappeared and the program exited.

However this works fine:
  D:\apps\jython2.7.0\bin>jython ..\Demo\swing\TreeDemo.py

Here are some more my PC info:
D:\apps\jython2.7.0\bin>jython -V
Jython 2.7.0

D:\apps\jython2.7.0\bin>jython --print
D:\apps\jdk1.7.0_67\bin\java -Xmx512m -Xss1024k -classpath D:\apps\jython2.7.0\jython.jar;. -Dpython.home=D:\apps\jython2.7.0 -Dpython.executable=D:\apps\jython2.7.0\bin\jython.exe -Dpython.launcher.uname=windows -Dpython.launcher.tty=true org.python.util.jython

D:\apps\jython2.7.0\bin>jython -c "import platform; print platform.platform()"
Java-1.7.0_67-Java_HotSpot-TM-_64-Bit_Server_VM,_24.65-b04,_Oracle_Corporation-on-Windows_7-6.1-amd64
msg10542 (view) Author: Jim Baker (zyasoft) Date: 2015-12-17.04:03:56
This code is failing due to sys.ps1 not being defined, per https://docs.python.org/2/library/sys.html#sys.ps1

Related issue I found: https://github.com/don/jythonconsole/issues/33
msg10543 (view) Author: Jim Baker (zyasoft) Date: 2015-12-17.04:12:37
This demo is absolutely ancient code - JPython?!!! - and uses some arguable bad coding practices such as stopping threads and what appears to be an unnecessary late import of sys. The underlying problem is that it needs to now construct an interactive console much like org.python.util.jython. So something like this code snippet:

        // Now create an interpreter
        if (!opts.interactive) {
            // Not (really) interactive, so do not use console prompts
            systemState.ps1 = systemState.ps2 = Py.EmptyString;
        }
        InteractiveConsole interp = new InteractiveConsole();

At this point, sys.ps1 and sys.ps2 are defined.
msg10559 (view) Author: Jim Baker (zyasoft) Date: 2015-12-29.04:08:35
Should fix for 2.7.1, but could slip to 2.7.2. We definitely can push this out to late in the RC process for 2.7.1 given it's demo code.
msg10813 (view) Author: Jim Baker (zyasoft) Date: 2016-03-10.18:26:17
Slipping to 2.7.2, but remains an easy fix
History
Date User Action Args
2016-03-10 18:26:17zyasoftsetmessages: + msg10813
milestone: Jython 2.7.1 -> Jython 2.7.2
2015-12-30 00:01:55zyasoftsetpriority: normal
2015-12-29 04:08:36zyasoftsetmessages: + msg10559
milestone: Jython 2.7.1
2015-12-17 04:12:38zyasoftsetmessages: + msg10543
2015-12-17 04:05:17zyasoftsettitle: jython 2.7.0 Console.py Demo does not work on Windows 7 -> jython 2.7.0 Console.py Demo does not work
2015-12-17 04:03:56zyasoftsetnosy: + zyasoft
messages: + msg10542
2015-06-26 13:04:56saltnlight5create