Author jamesmudd
Recipients jamesmudd
Date 2017-07-26.20:54:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
If you run Jython in a directory containing a subdirectory called test containing a compiled class Test and try to import it you will receive a NPE. It is caused in org.python.core.PyString.encode_UnicodeEscape as null is passed in by the import logic. e.g.

james@james-desktop ~/Desktop/JyTest
 % tree
├── jython-standalone-2.7.1.jar
└── test
    ├── Test.class

1 directory, 3 files
james@james-desktop ~/Desktop/JyTest

 % java  -jar jython-standalone-2.7.1.jar
Jython 2.7.1 (default:0df7adb1b397, Jun 30 2017, 19:02:43) 
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_131
Type "help", "copyright", "credits" or "license" for more information.
>>> from test import Test
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
	at org.python.core.PyString.encode_UnicodeEscape(
	at org.python.core.imp.loadFromSource(
	at org.python.core.imp.find_module(
	at org.python.core.imp.import_next(
	at org.python.core.imp.import_module_level(
	at org.python.core.imp.importName(
	at org.python.core.ImportFunction.__call__(
	at org.python.core.PyObject.__call__(
	at org.python.core.__builtin__.__import__(
	at org.python.core.imp.importFromAs(
	at org.python.core.imp.importFrom(
	at org.python.pycode._pyx1.f$0(<stdin>:1)
	at org.python.pycode._pyx1.call_function(<stdin>)
	at org.python.core.Py.runCode(
	at org.python.core.Py.exec(
	at org.python.util.PythonInterpreter.exec(
	at org.python.util.InteractiveInterpreter.runcode(
	at org.python.util.InteractiveInterpreter.runsource(
	at org.python.util.InteractiveInterpreter.runsource(
	at org.python.util.InteractiveConsole.push(
	at org.python.util.InteractiveConsole._interact(
	at org.python.util.InteractiveConsole.interact(
	at org.python.util.jython.main(
java.lang.NullPointerException: java.lang.NullPointerException

The simple fix is to check for null at the start of encode_UnicodeEscape then return null and that make this work but i'm not sure if that's the best fix.
Date User Action Args
2017-07-26 20:54:59jamesmuddsetrecipients: + jamesmudd
2017-07-26 20:54:59jamesmuddsetmessageid: <>
2017-07-26 20:54:58jamesmuddlinkissue2612 messages
2017-07-26 20:54:57jamesmuddcreate