Issue2293

classification
Title: "java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value" triggered after adding unicode element with non-ASCII character to sys.path
Type: Severity: normal
Components: Core Versions: Jython 2.7
Milestone: Jython 2.7.2
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: jeff.allen Nosy List: Arfrever, jar594, jeff.allen, zyasoft
Priority: Keywords:

Created on 2015-03-19.11:39:34 by Arfrever, last changed 2017-03-21.03:28:08 by zyasoft.

Messages
msg9675 (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) Date: 2015-03-19.11:39:33
$ cat test.py
# coding: utf-8
import sys
sys.path.append(u"/tmp/ćśź")
print("sys.path[-1]: %r" % sys.path[-1])
import urllib
print(urllib)
$ python2.7 test.py
sys.path[-1]: u'/tmp/\u0107\u015b\u017a'
<module 'urllib' from '/usr/lib64/python2.7/urllib.pyc'>
$ jython2.7 test.py
sys.path[-1]: u'/tmp/\u0107\u015b\u017a'
Traceback (most recent call last):
  File "test.py", line 5, in <module>
    import urllib
  File "/usr/share/jython-2.7/Lib/urllib.py", line 25, in <module>
    import string
  File "/usr/share/jython-2.7/Lib/string.py", line 528, in <module>
    from strop import maketrans, lowercase, uppercase, whitespace
  File "/usr/share/jython-2.7/Lib/string.py", line 528, in <module>
    from strop import maketrans, lowercase, uppercase, whitespace
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.PyException.<init>(PyException.java:61)
        at org.python.modules.zipimport.zipimport.ZipImportError(zipimport.java:36)
        at org.python.modules.zipimport.zipimporter.zipimporter___init__(zipimporter.java:122)
        at org.python.modules.zipimport.zipimporter.zipimporter___init__(zipimporter.java:84)
        at org.python.modules.zipimport.zipimporter$exposed___new__.createOfType(Unknown Source)
        at org.python.core.PyOverridableNew.new_impl(PyOverridableNew.java:12)
        at org.python.core.PyType.invokeNew(PyType.java:494)
        at org.python.core.PyType.type___call__(PyType.java:1690)
        at org.python.core.PyType.__call__(PyType.java:1680)
        at org.python.core.PyObject.__call__(PyObject.java:461)
        at org.python.core.imp.getPathImporter(imp.java:479)
        at org.python.core.imp.find_module(imp.java:529)
        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:431)
        at org.python.core.__builtin__.__import__(__builtin__.java:1232)
        at org.python.core.imp.importFromAs(imp.java:1151)
        at org.python.core.imp.importFrom(imp.java:1127)
        at string$py.f$0(/usr/share/jython-2.7/Lib/string.py:543)
        at string$py.call_function(/usr/share/jython-2.7/Lib/string.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:167)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.imp.createFromCode(imp.java:435)
        at org.python.core.imp.createFromPyClass(imp.java:236)
        at org.python.core.imp.createFromPyClass(imp.java:205)
        at org.python.core.imp.loadFromSource(imp.java:649)
        at org.python.core.imp.find_module(imp.java:542)
        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:431)
        at org.python.core.__builtin__.__import__(__builtin__.java:1232)
        at org.python.core.imp.importOne(imp.java:1076)
        at urllib$py.f$0(/usr/share/jython-2.7/Lib/urllib.py:1599)
        at urllib$py.call_function(/usr/share/jython-2.7/Lib/urllib.py)
        at org.python.core.PyTableCode.call(PyTableCode.java:167)
        at org.python.core.PyCode.call(PyCode.java:18)
        at org.python.core.imp.createFromCode(imp.java:435)
        at org.python.core.imp.createFromPyClass(imp.java:236)
        at org.python.core.imp.createFromPyClass(imp.java:205)
        at org.python.core.imp.loadFromSource(imp.java:649)
        at org.python.core.imp.find_module(imp.java:542)
        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:431)
        at org.python.core.__builtin__.__import__(__builtin__.java:1232)
        at org.python.core.imp.importOne(imp.java:1076)
        at org.python.pycode._pyx1.f$0(test.py:6)
        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


(It might be related to bug #2288.)
msg10259 (view) Author: Jeff Allen (jeff.allen) Date: 2015-09-13.16:42:43
Probably similar cause to test_os_jy failure in #2397.
msg11000 (view) Author: Jeff Allen (jeff.allen) Date: 2016-12-06.21:04:43
Ok, I know this is bit old ... I am unable to reproduce this in the tip. I can reproduce it (around the time of the report) at 2.7b4, but not at 2.7rc1 or 2.7.0, so I propose we consider it fixed by side-effect of some other change.

There may be other byte/unicode things lurking, but is exactly this still a problem to anyone?
msg11256 (view) Author: Jonathan A Rees (jar594) Date: 2017-03-21.00:43:51
I just encountered this bug in 2.7.0, but looking at the source code it appears it has probably been fixed since that release (the backtrace says it's failing in PyString and there is now no PyString call in zipimporter.readZipFile). Can you advise me on how to obtain a jython-standalone-....jar file where this is fixed? Not familiar with the site or with build procedure.
msg11257 (view) Author: Jim Baker (zyasoft) Date: 2017-03-21.03:28:07
You can readily build using Java 8 and latest Ant. Note that there's a problem with Java 8's support of the Antlr version we use, so you have to run the build twice. (Not a good answer. It does build fine on Java 7, which is still available/possibly even supported on OS X.) Build like so:

$ ant all-jars

Then from the dist directory:

$ ls dist/*.jar
dist/callbacker_test.jar	dist/jython-standalone.jar
dist/javadoc.jar		dist/jython.jar
dist/jython-dev.jar		dist/sources.jar
dist/jython-installer.jar
History
Date User Action Args
2017-03-21 03:28:08zyasoftsetmessages: + msg11257
2017-03-21 00:43:51jar594setnosy: + jar594
messages: + msg11256
2017-02-27 04:44:11zyasoftsetstatus: pending -> closed
2016-12-06 21:04:44jeff.allensetstatus: open -> pending
resolution: out of date
messages: + msg11000
2015-12-29 23:56:18zyasoftsetmilestone: Jython 2.7.1 -> Jython 2.7.2
2015-09-13 16:42:43jeff.allensetassignee: jeff.allen
messages: + msg10259
nosy: + jeff.allen
2015-04-20 21:10:11zyasoftsetmilestone: Jython 2.7.1
2015-03-19 11:39:35Arfrevercreate