I wanted to post this here because I would like to check if anyone else is having this same issue within the community.
A couple of days ago a user reported they were getting a “cryptic” error that read “Cannot create PyString with non-byte value”.
At first I could not replicate the error on my computer, so after doing some remote assistance I finally found the issue, and it relied on a harmless line of code; an import of the time module.
The only way I was able to replicate this behavior on my machine running Windows 10 I had to switch my system language to Čeština (a.k.a. Czech), run the Designer, and open the Script Console.
This is the code I executed on the Script Console:
import time
print time.__name__
And this is the console output:
Jython 2.7.1 (default:0df7adb1b397, Jun 30 2017, 19:02:43)
[OpenJDK 64-Bit Server VM (Azul Systems, Inc.)] on java11.0.5
>>>
Java Traceback:
Traceback (most recent call last):
File "<input>", line 1, 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.modules.time.Time.classDictInit(Time.java:124)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyJavaType.init(PyJavaType.java:571)
at org.python.core.PyType.createType(PyType.java:1573)
at org.python.core.PyType.addFromClass(PyType.java:1508)
at org.python.core.PyType.fromClass(PyType.java:1609)
at org.python.core.imp.createFromClass(imp.java:469)
at org.python.core.imp.loadBuiltin(imp.java:578)
at org.python.core.imp.find_module(imp.java:534)
at org.python.core.imp.import_next(imp.java:838)
at org.python.core.imp.import_module_level(imp.java:957)
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:450)
at org.python.core.__builtin__.__import__(__builtin__.java:1232)
at org.python.core.imp.importOne(imp.java:1076)
at org.python.pycode._pyx5.f$0(<input>:3)
at org.python.pycode._pyx5.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:131)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:605)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:593)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
at org.python.core.Py.JavaError(Py.java:552)
at org.python.core.Py.JavaError(Py.java:543)
at org.python.core.PyJavaType.init(PyJavaType.java:578)
at org.python.core.PyType.createType(PyType.java:1573)
at org.python.core.PyType.addFromClass(PyType.java:1508)
at org.python.core.PyType.fromClass(PyType.java:1609)
at org.python.core.imp.createFromClass(imp.java:469)
at org.python.core.imp.loadBuiltin(imp.java:578)
at org.python.core.imp.find_module(imp.java:534)
at org.python.core.imp.import_next(imp.java:838)
at org.python.core.imp.import_module_level(imp.java:957)
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:450)
at org.python.core.__builtin__.__import__(__builtin__.java:1232)
at org.python.core.imp.importOne(imp.java:1076)
at org.python.pycode._pyx5.f$0(<input>:3)
at org.python.pycode._pyx5.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:131)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:605)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:593)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
Caused by: 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.modules.time.Time.classDictInit(Time.java:124)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyJavaType.init(PyJavaType.java:571)
... 29 more
Traceback (most recent call last):
File "<input>", line 1, 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.modules.time.Time.classDictInit(Time.java:124)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.base/java.lang.reflect.Method.invoke(Unknown Source)
at org.python.core.PyJavaType.init(PyJavaType.java:571)
at org.python.core.PyType.createType(PyType.java:1573)
at org.python.core.PyType.addFromClass(PyType.java:1508)
at org.python.core.PyType.fromClass(PyType.java:1609)
at org.python.core.imp.createFromClass(imp.java:469)
at org.python.core.imp.loadBuiltin(imp.java:578)
at org.python.core.imp.find_module(imp.java:534)
at org.python.core.imp.import_next(imp.java:838)
at org.python.core.imp.import_module_level(imp.java:957)
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:450)
at org.python.core.__builtin__.__import__(__builtin__.java:1232)
at org.python.core.imp.importOne(imp.java:1076)
at org.python.pycode._pyx5.f$0(<input>:3)
at org.python.pycode._pyx5.call_function(<input>)
at org.python.core.PyTableCode.call(PyTableCode.java:171)
at org.python.core.PyCode.call(PyCode.java:18)
at org.python.core.Py.runCode(Py.java:1614)
at org.python.core.Py.exec(Py.java:1658)
at org.python.util.PythonInterpreter.exec(PythonInterpreter.java:276)
at org.python.util.InteractiveInterpreter.runcode(InteractiveInterpreter.java:131)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:605)
at com.inductiveautomation.ignition.designer.gui.tools.jythonconsole.JythonConsole$ConsoleWorker.doInBackground(JythonConsole.java:593)
at java.desktop/javax.swing.SwingWorker$1.call(Unknown Source)
at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
at java.desktop/javax.swing.SwingWorker.run(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: Cannot create PyString with non-byte value
This error was being thrown on a function I created where I Temporarily enable DB connection, and between retries I “sleep” the process for a second, and the only way I could squash this bug was to remove that sleep and replace it with a while loop.
I am aware this may sound a bit weird, but it is the behavior we are noticing.
Thanks!