Issue2296

classification
Title: Importation of modules with unicode names with non-ASCII characters should raise UnicodeEncodeError instead of java.lang.IllegalArgumentException
Type: Severity: normal
Components: Core Versions: Jython 2.7
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: zyasoft Nosy List: Arfrever, zyasoft
Priority: Keywords:

Created on 2015-03-19.12:52:50 by Arfrever, last changed 2015-03-27.23:38:57 by zyasoft.

Messages
msg9678 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2015-03-19.12:52:50
Importation of modules with unicode names with non-ASCII characters should raise UnicodeEncodeError instead of java.lang.IllegalArgumentException.

$ cat test.py
# coding: utf-8
import sys
sys.path.append("/tmp")
module = __import__(u"ćśź")
print(module)
$ python2.7 test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    module = __import__(u"ćśź")
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-2: ordinal not in range(128)
$ jython2.7 test.py
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    module = __import__(u"ćśź")
java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
        at org.python.core.PyString.<init>(PyString.java:64)
        at org.python.core.PyString.<init>(PyString.java:70)
        at org.python.core.imp.find_module(imp.java:533)
        at org.python.core.imp.import_next(imp.java:837)
        at org.python.core.imp.import_module_level(imp.java:956)
        at org.python.core.imp.importName(imp.java:1057)
        at org.python.core.ImportFunction.__call__(__builtin__.java:1280)
        at org.python.core.PyObject.__call__(PyObject.java:461)
        at org.python.core.PyObject.__call__(PyObject.java:465)
        at org.python.pycode._pyx1.f$0(test.py:5)
        at org.python.pycode._pyx1.call_function(test.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:167)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.Py.runCode(Py.java:1374)
        at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:299)
        at org.python.util.jython.run(jython.java:367)
        at org.python.util.jython.main(jython.java:142)

java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
msg9690 (view) Author: Jim Baker (zyasoft) Date: 2015-03-20.18:50:48
Fixed as of https://hg.python.org/jython/rev/b0d8aed3a8cd
History
Date User Action Args
2015-03-27 23:38:57zyasoftsetstatus: pending -> closed
2015-03-20 18:50:48zyasoftsetstatus: open -> pending
assignee: zyasoft
resolution: fixed
messages: + msg9690
2015-03-19 12:52:50Arfrevercreate