Issue1874

classification
Title: Jython fails to import os module when using tr_TR locale
Type: behaviour Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: Arfrever, amak, fwierzbicki, jjaggars, kabir, miclark, zyasoft
Priority: urgent Keywords: patch

Created on 2012-04-11.17:18:03 by jjaggars, last changed 2015-02-02.16:32:32 by zyasoft.

Files
File name Uploaded Description Edit Remove
1874.patch kabir, 2012-04-18.14:25:29 Patch to get our tests working in Turkish
Messages
msg7045 (view) Author: Jesse Jaggars (jjaggars) Date: 2012-04-11.17:18:02
[jhjaggars ~]$ cd jython2.5.3b1/
[jhjaggars jython2.5.3b1]$ cat ~/bin/turkish.sh 
if [ "$LANG" == "tr_TR.UTF-8" ]; then
    echo "switching to english"
    export LC_ALL=en_US.UTF-8
    export LANG=en_US.UTF-8
else
    echo "switching to turkish"
    export LC_ALL=tr_TR.UTF-8
    export LANG=tr_TR.UTF-8
fi
[jhjaggars jython2.5.3b1]$ source ~/bin/turkish.sh 
switching to turkish
[jhjaggars jython2.5.3b1]$ java -jar jython.jar 
Jython 2.5.3b1 (2.5:5fa0a5810b25, Feb 22 2012, 12:39:02) 
[Java HotSpot(TM) 64-Bit Server VM (Apple Inc.)] on java1.6.0_31
>>> import os
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/jhjaggars/jython2.5.3b1/jython.jar/Lib/os.py", line 118, in <module>
ImportError: no os specific module found
>>> 

Changing os.py to print out sys.builtin_module_names yields the following tuple:

('sys', 'imp', 'gc', 'jffi', '_sre', '_threading', '_csv', 'exceptions', 'time', '_py_compile', 'struct', 'zipimport', '_functools', 'thread', 'ucnhash', 'synchronize', 'binascii', '_codecs', '_random', '_systemrestart', 'cmath', '_marshal', 'cStringIO', 'pos\u0131x', '_ast', 'operator', 'jarray', 'math', '_collections', 'errno', '_hashlib', '__builtin__', '_weakref', 'itertools', 'cPickle', 'array')

Note that 'posix' is actually 'pos\u0131x'.
msg7066 (view) Author: Kabir Khan (kabir) Date: 2012-04-18.14:25:29
The attached patch fixes the issues we were seeing in JBoss AS.

This fixes the issues we were seeing for:
https://issues.jboss.org/browse/AS7-4449
https://issues.jboss.org/browse/AS7-4301

However, I am not familiar with Python so there may well be issues unknown to me with the fixes made to PyString
msg7448 (view) Author: Alan Kennedy (amak) Date: 2012-08-28.21:55:22
Kabir: The patch looks good in relation to the changes to OS.py, which correctly lowercases the OS name.

But the changes to PyString should not be necessary, because they would affect lower-casing of all strings, which would be wrong for non-English locales.

http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#toLowerCase%28%29

Do you find in your testing that the bug is not fixed, in relation to JBoss AS, when you only patch OS.java? Must you apply the PyString.java changes also to fix the issue? I expect not.
msg9443 (view) Author: Jim Baker (zyasoft) Date: 2015-01-22.20:40:42
Blocker for beta 4.

This came up again in #2260 - the recent change in #2037 made this fail earlier (which is generally a good thing!).

Per Jesse's original bug post, this behaves by changing "posix" to "pos\u0131x", which prints identical to "posix", because of the computed module name in Setup.java.

As Alan pointed out, the fix for this is to just change org.python.modules.posix.OS; it can be readily tested in our regrtest if the OS has Turkish locale support installed (easy on Ubuntu), otherwise skipped.
msg9444 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2015-01-22.20:50:45
In CPython, locale does not affect str.upper(), str.lower(), unicode.upper(), unicode.lower(), so maybe proposed changes PyString.java would be correct.

$ LC_ALL="tr_TR.UTF-8" python2.7 -c 'print(("I".lower(), u"I".lower(), "i".upper(), u"i".upper()))'
('i', u'i', 'I', u'I')
msg9451 (view) Author: Jim Baker (zyasoft) Date: 2015-01-23.23:35:24
Fixed as of https://hg.python.org/jython/rev/5c60689c2819
History
Date User Action Args
2015-02-02 16:32:32zyasoftsetstatus: pending -> closed
2015-01-23 23:35:24zyasoftsetstatus: open -> pending
resolution: accepted -> fixed
messages: + msg9451
2015-01-22 20:50:46Arfreversetmessages: + msg9444
2015-01-22 20:40:48zyasoftsetversions: + Jython 2.7, - Jython 2.5
2015-01-22 20:40:43zyasoftsetpriority: normal -> urgent
assignee: fwierzbicki -> zyasoft
resolution: accepted
messages: + msg9443
nosy: + zyasoft, Arfrever
2013-02-19 21:43:57fwierzbickisetversions: + Jython 2.5, - 2.5.3b1
2012-08-28 21:55:22amaksetmessages: + msg7448
2012-08-10 21:21:35fwierzbickisetpriority: normal
assignee: fwierzbicki
nosy: + fwierzbicki
2012-06-05 20:11:30amaksetnosy: + amak
2012-04-18 14:25:30kabirsetfiles: + 1874.patch
keywords: + patch
messages: + msg7066
nosy: + kabir
2012-04-11 18:51:15miclarksetnosy: + miclark
2012-04-11 17:18:03jjaggarscreate