Issue1563

classification
Title: unicode() for Java objects working differently in 2.2 and 2.5
Type: Severity: normal
Components: Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: pekka.klarck, pjenvey, yanne
Priority: Keywords:

Created on 2010-02-23.09:38:59 by yanne, last changed 2010-04-02.09:33:02 by pekka.klarck.

Messages
msg5550 (view) Author: Janne Härkönen (yanne) Date: 2010-02-23.09:38:58
jth@l228:~$ cat TestObj.java 
public class TestObj {
    public String toString() {
        return "Circle is 360\u00B0";
    }
}
jth@l228:~$ javac TestObj.java

jth@l228:~$ jython22 -c "import TestObj as T; print unicode(T())"
Circle is 360°
jth@l228:~$ jython25 -c "import TestObj as T; print unicode(T())"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 13: ordinal not in range(128)

I can get unicode working by first calling toString() of the object:

jth@l228:~$ jython25 -c "import TestObj as T; print unicode(T().toString())"
Circle is 360°

Should unicode() call toString() automatically also with 2.5?
msg5614 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-01.20:03:09
This should be a simple fix (as long as it doesn't break anything). PyJavaType just needs to override __unicode__ to do the right thing
msg5615 (view) Author: Philip Jenvey (pjenvey) Date: 2010-04-02.01:42:25
fixed in r6996, thanks
msg5618 (view) Author: Pekka Klärck (pekka.klarck) Date: 2010-04-02.09:33:02
Thanks for the fix Philip.
History
Date User Action Args
2010-04-02 09:33:02pekka.klarcksetmessages: + msg5618
2010-04-02 01:42:26pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg5615
2010-04-01 20:03:10pjenveysetassignee: pjenvey
messages: + msg5614
nosy: + pjenvey
2010-04-01 19:30:02pekka.klarcksetnosy: + pekka.klarck
2010-02-23 09:38:59yannecreate