You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
PyString with non-byte value while installing pip #20
C:\Users\Memory>jython --version
Jython 2.7.1
C:\Users\Memory>java -version
java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.171-b11, mixed mode)
C:\Users\Memory>jython -m ensurepip
�[31mException:
Traceback (most recent call last):
File "C:\Users\Memory\AppData\Local\Temp\tmplfy1lv\pip-9.0.1-py2.py3-none-any.whl\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\Memory\AppData\Local\Temp\tmplfy1lv\pip-9.0.1-py2.py3-none-any.whl\pip\commands\install.py", line 270, in run
global_options = options.global_options or []
File "C:\Users\Memory\AppData\Local\Temp\tmplfy1lv\pip-9.0.1-py2.py3-none-any.whl\pip\basecommand.py", line 71, in _build_session
retries=retries if retries is not None else options.retries,
File "C:\Users\Memory\AppData\Local\Temp\tmplfy1lv\pip-9.0.1-py2.py3-none-any.whl\pip\download.py", line 329, in __init__
self.headers["User-Agent"] = user_agent()
File "C:\Users\Memory\AppData\Local\Temp\tmplfy1lv\pip-9.0.1-py2.py3-none-any.whl\pip\download.py", line 110, in user_agent
if platform.system():
File "C:\opt\jython2.7.1\Lib\platform.py", line 1396, in system
return uname()[0]
File "C:\opt\jython2.7.1\Lib\platform.py", line 1213, in uname
machine = os.uname()[4]
IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value�[0m
Does your host name contain non-ascii characters? I'm afraid that's a known problem in 2.7.1. You might like to try 2.7.2b2.
Actually no. And I tried the 2.7.2b2 on Windows, it prompt, "Can't execute the specifed file". I don't know what is wrong. But the pip.exe which exist in the same directory works when pip --help
This same error happens when using print with a Java HashMap that contains Unicode characters. It can also occur with these HashMaps when using:
“%s” %(theHashMap) Or print “something”, theHashMap
Since the problem crops up during formatting of a java.lang.String, I think this problem (but not necessarily the OP's) is the one investigated in #190.
@yogi1967 : In fact, with HashMap and String keys or values, I only get this particular "non-byte value" error on v2.7.1, and v2.7.2 behaves sensibly, at least up to the point it tries to put the results on my console.
Jython 2.7.2 (v2.7.2:925a3cc3b49d, Mar 21 2020, 10:03:58)
[Java HotSpot(TM) 64-Bit Server VM (Oracle Corporation)] on java1.8.0_321
Type "help", "copyright", "credits" or "license" for more information.
>>> from java.lang import String
>>> from java.util import HashMap
>>> h = HashMap()
>>> h.put(String('\xce\xbb', 'utf-8'), 3)
>>> h.put('g', String('\xce\xb3', 'utf-8'))
>>> h
{u'g': u'\u03b3', u'\u03bb': 3}
>>> h.keySet()
[g, λ]
>>> print "%s" % h
{u'g': u'\u03b3', u'\u03bb': 3}
import jarray
from java.lang import String
from javax.swing import JOptionPane, JTextField, JPanel, JLabel
from java.awt import GridLayout
from java.nio.charset import StandardCharsets
print "\n"*10
print "-----"
def myPopupInformationBox(_txtArray):
pnl = JPanel(GridLayout(0, 1))
for txt in _txtArray: pnl.add(JLabel(txt))
JOptionPane.showMessageDialog(None, pnl, "DEMO ERROR", JOptionPane.INFORMATION_MESSAGE, None)
txtArray = []
txtArray.append("Normal text")
myBytes = jarray.array([-25, -72, -67, -26, -108, -81, -27, -121, -70], 'b')
newName2 = String(myBytes,StandardCharsets.UTF_8)
txtArray.append(newName2)
txtArray.append("More Normal text")
# This works
myPopupInformationBox(txtArray)
print "---"
# This works
for txt in txtArray: print txt
print "---"
# This fails with: java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
print txtArray
it spits out:
Traceback (most recent call last):
File "<string>", line 36, in <module>
java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
at org.python.core.PyString.<init>(PyString.java:57)
at org.python.core.PyString.<init>(PyString.java:70)
at org.python.core.PyString.<init>(PyString.java:74)
at org.python.core.PyObject.__repr__(PyObject.java:231)
at org.python.core.PyObject.__str__(PyObject.java:266)
at org.python.core.StdoutWrapper.printToFileWriter(StdoutWrapper.java:128)
at org.python.core.StdoutWrapper.print(StdoutWrapper.java:210)
at org.python.core.StdoutWrapper.println(StdoutWrapper.java:272)
at org.python.core.Py.println(Py.java:1905)
at org.python.pycode._pyx49.f$0(<string>:36)
at org.python.pycode._pyx49.call_function(<string>)
at org.python.core.PyTableCode.call(PyTableCode.java:173)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1687)
at org.python.core.Py.exec(Py.java:1731)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:268)
at com.moneydance.apps.md.view.gui.python.PythonRunner$2.run(PythonRunner.java:352)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
changed the title [-]java.lang.IllegalArgumentException: Cannot create PyString with non-byte value[/-][+]PyString with non-byte value while installing pip[/+]on Jun 26, 2022
The same "non-byte string" error turns up in multiple contexts, quite a few of which we've fixed. The cause of the OP's remains obscure, but I don't think we learn anything by keeping this open.
Activity
jeff5 commentedon Nov 2, 2019
Does your host name contain non-ascii characters? I'm afraid that's a known problem in 2.7.1. You might like to try 2.7.2b2.
ZhuBicen commentedon Nov 6, 2019
Actually no. And I tried the 2.7.2b2 on Windows, it prompt, "Can't execute the specifed file". I don't know what is wrong. But the pip.exe which exist in the same directory works when
pip --helpleurnkim commentedon Mar 10, 2020
I have the same issue when script processing file names with non-english characters.
java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
org.python.core.PyString.(PyString.java:57)
org.python.core.PyString.(PyString.java:70)
org.python.core.PyString.(PyString.java:74)
org.python.core.Py.newString(Py.java:647)
jeff5 commentedon Mar 12, 2020
We have tracked down most of the places this can happen, but there could be some left.
One would need more detail to be of any help: the version of Jython and a fragment of Python that produces the effect is a minimum.
jeff5 commentedon Jun 4, 2020
Originally raised as https://github.com/jythontools/jython issue 153
yogi1967 commentedon Jun 19, 2022
This same error happens when using print with a Java HashMap that contains Unicode characters. It can also occur with these HashMaps when using:
“%s” %(theHashMap)
Or
print “something”, theHashMap
jeff5 commentedon Jun 25, 2022
Since the problem crops up during formatting of a
java.lang.String, I think this problem (but not necessarily the OP's) is the one investigated in #190.jeff5 commentedon Jun 25, 2022
@yogi1967 : In fact, with
HashMapandStringkeys or values, I only get this particular "non-byte value" error on v2.7.1, and v2.7.2 behaves sensibly, at least up to the point it tries to put the results on my console.yogi1967 commentedon Jun 26, 2022
This code reproduces the problem...
it spits out:
jeff5 commentedon Jun 26, 2022
Sufficient to reproduce:
I opened a new issue #192 for this. The circumstances are quite different from of this one. (Maybe need a better title.)
[-]java.lang.IllegalArgumentException: Cannot create PyString with non-byte value[/-][+]PyString with non-byte value while installing pip[/+]jeff5 commentedon Jan 20, 2024
The same "non-byte string" error turns up in multiple contexts, quite a few of which we've fixed. The cause of the OP's remains obscure, but I don't think we learn anything by keeping this open.