Issue1032

classification
Title: 2.2.1: "%s" % u"\xA7" -> UnicodeError
Type: behaviour Severity: normal
Components: Core Versions: 2.2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: fwierzbicki, leosoto, pekka.klarck, pjenvey
Priority: low Keywords:

Created on 2008-05-02.20:00:12 by pekka.klarck, last changed 2009-06-21.21:50:25 by pjenvey.

Messages
msg3175 (view) Author: Pekka Klärck (pekka.klarck) Date: 2008-05-02.20:00:12
Jython 2.2.1 on java1.6.0_03
Type "copyright", "credits" or "license" for more information.
>>> x = "%s" % u"\u00E4"
Traceback (innermost last):
 File "<console>", line 1, in ?
UnicodeError: ascii encoding error: ordinal not in range(128)

'\u00E4' is latin-1 character 'ä'. I can workaround this problem like below:

>>> from org.python.core import codecs
>>> codecs.setDefaultEncoding('iso-8859-1')
>>> x = "%s" % u"\u00E4"
>>> assert x == u"\u00E4"

But if I now try to use e.g. Cyrillic characters I got an UnicodeError
again:

>>> x = "%s" % u"\u0420"
Traceback (innermost last):
 File "<console>", line 1, in ?
UnicodeError: latin-1 encoding error: ordinal not in range(256)

Note that using syntax u'%s' doesn't help:

Jython 2.2.1 on java1.6.0
Type "copyright", "credits" or "license" for more information.
>>> u'%s' % u'\u00E4'        
Traceback (innermost last):
  File "<console>", line 1, in ?
UnicodeError: ascii decoding error: ordinal not in range(128)


All this works both on CPython (I've tested only with 2.5) and Jython
2.2 (tested both on Linux and Windows). With Jython 2.2 there's no
need to setDefaultEncoding.
msg3177 (view) Author: Pekka Klärck (pekka.klarck) Date: 2008-05-02.20:07:59
This issue might be related to http://bugs.jython.org/issue1032
msg3179 (view) Author: Leonardo Soto (leosoto) Date: 2008-05-02.21:29:09
I think you mean #1802339
msg3180 (view) Author: Pekka Klärck (pekka.klarck) Date: 2008-05-02.22:31:30
Yeah, I did mean #1802339. Copy'n'paste error. Thanks!
msg3604 (view) Author: Leonardo Soto (leosoto) Date: 2008-09-16.17:20:09
Changing the version to 2.2 because the example works on 2.5 (trunk).
msg4833 (view) Author: Philip Jenvey (pjenvey) Date: 2009-06-21.21:50:25
fixed in 2.5
History
Date User Action Args
2009-06-21 21:50:25pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg4833
nosy: + pjenvey
2009-03-14 02:18:32fwierzbickisetpriority: low
2008-11-01 13:51:22fwierzbickisetnosy: + fwierzbicki
components: + Core
2008-09-16 17:20:10leosotosetmessages: + msg3604
versions: + 2.2.2
2008-05-02 22:31:30pekka.klarcksetmessages: + msg3180
2008-05-02 21:29:09leosotosetnosy: + leosoto
messages: + msg3179
2008-05-02 20:07:59pekka.klarcksetmessages: + msg3177
2008-05-02 20:00:12pekka.klarckcreate