From: D-Man <ds...@ri...> - 2001-04-03 19:18:40
|
Through a small piece of stupid code, I found a bug in the Jython 2.0 compiler. In a function (in a class, in a module if it matters) I had the following code : del some_var Originally some_var existed (a temporary local), but though some modifications some_var no longer existed. Trying to run the app yielded the following (partial) result : ./run.bash Main.py Traceback (innermost last): File "Main.py", line 33, in ? File "SessionTests\__init__.py", line 25, in ? java.lang.NullPointerException at org.python.compiler.CodeCompiler.Name(Compiled Code) at org.python.parser.SimpleNode.visit(Compiled Code) at org.python.compiler.CodeCompiler.del_stmt(CodeCompiler.java:470) at org.python.parser.SimpleNode.visit(Compiled Code) at org.python.compiler.CodeCompiler.suite(Compiled Code) at org.python.parser.SimpleNode.visit(Compiled Code) at org.python.compiler.CodeCompiler.parse(Compiled Code) ... (very long stack trace) at org.python.core.PyTableCode.call(Compiled Code) at org.python.core.Py.runCode(Py.java:1055) at org.python.core.__builtin__.execfile(__builtin__.java:288) at org.python.core.__builtin__.execfile(__builtin__.java:292) at org.python.util.PythonInterpreter.execfile(PythonInterpreter.java:155) at org.python.util.jython.main(jython.java:159) java.lang.NullPointerException: java.lang.NullPointerException Obviously the error was on my part (can't del a var that DNE), but the compiler should give a more informative error message (;-)). Maybe it should wait and give a NameError during exection, since it is possible that I created the name through exec() or something. (I didn't use any fancy dynamism in this case) I just checked against CPython and found this: >>> def foo( ): ... del dne ... >>> foo() Traceback (most recent call last): File "<stdin>", line 1, in ? File "<stdin>", line 2, in foo UnboundLocalError: Local variable 'dne' referenced before assignment >>> All of this is on a Win2k box. Version 2.0 for both python interpreters, jdk1.1.8 for the jvm. If you want any more info just yell ;-). -D |