|
From: <bc...@wo...> - 2001-11-01 20:13:02
|
[Ype Kingma]
>My class file parser does not find a linenumber table in java $py.class
>(21a3) files. It finds is an UTF8 'LineNumberTable' in the constant pool,
>but no attribute seems to be using that name.
The LineNumberTable is an attribute on each Code attribute.
>(Is this a bug?).
>In fact the only attributes it finds are an 'UTF8' 'SourceFile'
>attribute with the file name in the constant pool and
>an 'UTF8' 'org.python.APIVersion' with a 4byte of value 9.
That is the class file attributes.
>This coincides with Module.java in the compiler package.
>Method write() (line 550) does the attributes above,
>but no LineNumberTable. Adding it to a $py.class file
>would take 4 bytes per 'executable' line.
>
>The line number table is completely
>redundant given the setline() calls in the code.
Correct. It is completely and utterly redundant. It is *only* used when
the JVM prints a java stacktrace. With the LineNumberTable in place, the
java stacktrace will include nice and correct line numbers for the the
python sources:
...
at org.python.core.PyObject.invoke(PyObject.java:2028)
at org.python.pycode._pyx0.f$0(x.py:4)
at org.python.pycode._pyx0.call_function(x.py)
...
Notice the "(x.py:4)" part.
>The same parser for $py.class files can also fish for all
>the setline() arguments.
Correct, it is the same information.
>This works fine when called interactively.
>However when I use it via execfile() i get a:
>NameError: tracer
>on the "return tracer" statement.
Can you an example. Again, it works for me:
Jython 2.1a3 on java1.3.0 (JIT: null)
Type "copyright", "credits" or "license" for more information.
>>> execfile("tracer.py")
call 0 None
line 6 None
line 7 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 8 None
line 7 None
line 9 None
return 9 None
>>>
regards,
finn
|