Hi, Jeff,

Thanks a lot for the detailed explanation. That's really help.

As to the issue of "aa='aa'", you are right about the assumption for the multi-byte characters. The machine I am using is:

Microsoft Windows 8 Enterprise Chinese (Simplified) (Intel 64-bit, Bare OS)


>java -jar jython-standalone-2.7-b1.jar
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.7.0_51
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdin.encoding
'ms936'
>>> aa="aa"
...                    <-- Hangs

If changing the code page to 1252: "chcp 1252" before running Jython, the aa="aa" works fine without hanging, but it will miss the multi-byte characters support.

>java -jar jython-standalone-2.7-b1.jar
Jython 2.7b1 (default:ac42d59644e9, Feb 9 2013, 15:24:52)
[Java HotSpot(TM) Client VM (Oracle Corporation)] on java1.7.0_51
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.stdin.encoding
'cp1252'
>>> aa="??"        <-- Multi-byte characters are not display correctly
>>> print aa
??
>>>

In jython 2.2.1, aa="aa" works fine with the code page ms936.

c:\jython2.2.1>chcp
活动代码页: 936

c:\jython2.2.1>jython.bat
Jython 2.2.1 on java1.7.0_51
Type "copyright", "credits" or "license" for more information.
>>> aa="aa"
>>>                 <-- No hang
>>> aa="操作"  <-- Multi-byte characters are displayed correctly
>>> print aa
操作
>>>

So it looks like a regression on Jython 2.7-b1. If beta 2 could cover this issue, that would be very helpful on running Jython on multi-bytes character machine (while other issues mentioned previously can be workarounded by -Dpython.console= property).

Thanks a lot,
Rose



On Fri, Mar 21, 2014 at 5:04 PM, Jeff Allen <ja.py@farowl.co.uk> wrote:
Rose, Alan:

There are several different issues here. As Alan says I've done some work on the console since 2.7b1 that may help.

1. aa = "aa" ... I've no idea why that wouldn't work, unless it is a side effect of other problems. I've never had any problem entering even quite complicated lines interactively. The fact that ctrl-D breaks you out of the hang suggests Jython is stuck in a read, as if maybe it missed the closing quote or end of line.

2. Problems with sys.stdin.readline() were discussed in Issue #1972. Although we got two issues mixed up in the discussion there, I worked on the never-ending readline() as part of the console and believe it is fixed. (The console ended lines with \r and readline() was looking for \n.)

3. I agree ctrl-C doesn't work: it irritates me too. This is logged as issue #1957. Enabling it would be easy (I think), but comments hint it was disabled because handling it is difficult. This may be a misunderstanding.

ms936 looks like the sort of name Java uses, meaning page 936. Jython uses a number of sources to guess the correct encoding, including asking Java. (I tweaked this when I added support for PYTHONIOENCODING.) Our support for multi-byte characters is weak: the codecs are missing and it isn't as simple as using the Java ones. The JLineConsole doesn't seem to do multi-byte at all. It supports UTF-8 (on Linux) but on Windows cp65001 there just seemed to be no input.

Some of these console problems would be alleviated by using a newer version. I think a beta 2 is not far away. Although we've heard that before, Jim Baker is writing optimistically about this over on jython-dev. When that becomes available (or if you build Jython yourself) it would be worth looking at https://wiki.python.org/jython/ConsoleChoices .

Jeff
Jeff Allen
On 21/03/2014 22:06, Qianhong Pan wrote:
Hi, Alan,

Thanks a lot for the quick reply and the links. So glad the Windows issues are being addressed.

The workaround works for most of the issues except the "aa='aa'" command on Windows which is a very basic command. So we can't really rely on this workaround.

Is there a Jython issue logged for this?

Having another beta would help to verify and test issues on Windows.

BTW, the jdk version is 1.7.0_51 if it matters.

>java -version
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode, sharing)

Thanks again,
Rose


On Fri, Mar 21, 2014 at 1:55 PM, Alan Kennedy <jython-dev@xhaus.com> wrote:
Jython beta 1 is over a year old now, and had significant problems with terminal IO on Windows.

http://sourceforge.net/p/jython/mailman/message/30530772/

Jeff Allen has done a very significant amount of work to deal with these windows terminal issues (see recent checkin history for more information).

http://hg.python.org/jython/

> Is there any workaround?

I think you've already identified the simple workaround of using "-Dpython.concole=org.python.util.InteractiveConsole".


> or is there a plan to fix it soon?

Given Jeff's work, it's probably time for another beta, to get those fixes into the version that people are downloading and trying.

Jeff, thoughts?

Alan.



On Fri, Mar 21, 2014 at 6:03 PM, Qianhong Pan <rose.qpan@gmail.com> wrote:
Hi, Jython-users,

I am trying the Jython 2.7 beta 1 standalone downloaded from:

http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7-b1/jython-standalone-2.7-b1.jar

but found some issues running it on Windows 8 platform. The same commands works fine on Linux. Not sure if it's an known issue or not.

Below are the test results on Linux and Windows w/o the workaround of adding "-Dpython.concole=org.python.util.InteractiveConsole".

The stack trace is also attached.

The non working basic command like aa="aa" makes Jython 2.7 beta 1 not usable on Windows.

Is there any workaround or is there a plan to fix it soon?

Thanks a lot for your help.

Rose

===================

jython 2.7 beta 1 standalone:

Linux:

1. aa="aa" works.
2. sys.stdin.readline() works.
3. CTRL +C works.

Windows:

1. aa="aa" hangs. CTRL + D  + enter to exit
2. sys.stdin.readline() hangs. CTRL + D or CTRL + C not working. need to kill the java process
3. CTRL + C shows a heart. Hit "enter" to exit with this message:
LookupError: unknown encoding 'ms936'


jython 2.7 beta 1 standalone + -Dpython.console=org.python.util.InteractiveConsole:


Linux:

1. aa="aa" works
2. sys.stdin.readline() works.
3. CTRL + C works.

Windows:

1. aa="aa" hangs. CTRL + D  + enter to exit
2. sys.stdin.readline() works.
3. CTRL + C works.

=============================

The stack trace when aa="aa" hangs looks like this:

"main" prio=6 tid=0x011ab800 nid=0x4d8 runnable [0x011ff000]
   java.lang.Thread.State: RUNNABLE
        at java.io.FileInputStream.readBytes(Native Method)
        at java.io.FileInputStream.read(FileInputStream.java:272)
        at java.io.BufferedInputStream.read1(BufferedInputStream.java:273)
        at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
        - locked <0x2a3f0d00> (a java.io.BufferedInputStream)
        at java.nio.channels.Channels$ReadableByteChannelImpl.read(Channels.java:385)
        - locked <0x2a550550> (a java.lang.Object)
        at org.python.core.io.StreamIO.readinto(StreamIO.java:123)
        at org.python.core.io.BufferedReader.peek(BufferedReader.java:86)
        at org.python.core.io.BufferedReader.read1(BufferedReader.java:100)
        at org.python.core.io.TextIOBase.readChunk(TextIOBase.java:263)
        at org.python.core.io.TextIOWrapper.readline(TextIOWrapper.java:243)
        at org.python.core.PyFile.file_readline(PyFile.java:266)
        - locked <0x2a524558> (a org.python.core.PyFile)
        at org.python.core.PyFile.readline(PyFile.java:274)
        at org.python.core.__builtin__.readline(__builtin__.java:1003)
        at org.python.core.__builtin__.raw_input(__builtin__.java:1019)
        at org.python.core.__builtin__.raw_input(__builtin__.java:1035)
        at org.python.util.InteractiveConsole.raw_input(InteractiveConsole.java:126)
        at org.python.util.InteractiveConsole.interact(InteractiveConsole.java:81)
        at org.python.util.jython.run(jython.java:378)
        at org.python.util.jython.main(jython.java:137)

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users





------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech


_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Jython-users mailing list
Jython-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jython-users