Title: dis.dis Fails with AttributeError: 'tablecode' object has no attribute 'co_lnotab'
Type: behaviour Severity: normal
Components: Library Versions: 2.5.1, 2.5.0
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: goon12, zyasoft
Priority: Keywords:

Created on 2009-09-04.13:44:28 by goon12, last changed 2009-09-04.15:44:32 by zyasoft.

msg5101 (view) Author: Joe Riopel (goon12) Date: 2009-09-04.13:44:28
I am unable to use the dis.dis function. The following behavior is 
consistent between classes, functions, and instance methods:
>>> import dis
>>> def addem(x,y):
...     return (x + y)
>>> dis.dis(addem)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\jython2.5.1rc1\Lib\", line 42, in dis
  File "C:\jython2.5.1rc1\Lib\", line 64, in disassemble
    linestarts = dict(findlinestarts(co))
  File "C:\jython2.5.1rc1\Lib\", line 183, in findlinestarts
    byte_increments = [ord(c) for c in code.co_lnotab[0::2]]
AttributeError: 'tablecode' object has no attribute 'co_lnotab'
msg5103 (view) Author: Jim Baker (zyasoft) Date: 2009-09-04.15:44:32
The standard Python module dis.dis only works on PyBytecode objects, not
PyTableCode ones (which are the default). At some point, there will be
more opportunities to use PyBytecode, for now it's purely experimental
(see Lib/test/ for how to use, or the source of
org.python.core.PyBytecode, which uses dis for debugging). Because
PyTablecode objects use Java bytecode, it doesn't makes sense to use dis
on them. Nor is the bytecode directly available - you would need
something like inspect to fetch that resource, then use a tool like asm
to disassemble or jad to decompile.
Date User Action Args
2009-09-04 15:44:32zyasoftsetstatus: open -> closed
resolution: wont fix
messages: + msg5103
nosy: + zyasoft
2009-09-04 13:44:28goon12create