summaryrefslogtreecommitdiff
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorMichael W. Hudson <mwh@python.net>2002-08-15 14:59:02 +0000
committerMichael W. Hudson <mwh@python.net>2002-08-15 14:59:02 +0000
commitdd32a91cc0c8ba178d7ee5e78c30b6920aff66f4 (patch)
tree1a2062b54d3445ca788fd63c2bc63984dd85f34a /Lib/dis.py
parentadd88060c1d1a98c7970e35b326e6a65a17ddf04 (diff)
downloadcpython-git-dd32a91cc0c8ba178d7ee5e78c30b6920aff66f4.tar.gz
This is my patch
[ 587993 ] SET_LINENO killer Remove SET_LINENO. Tracing is now supported by inspecting co_lnotab. Many sundry changes to document and adapt to this change.
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py36
1 files changed, 32 insertions, 4 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 2674094434..a1cc215f98 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -55,6 +55,20 @@ def distb(tb=None):
def disassemble(co, lasti=-1):
"""Disassemble a code object."""
code = co.co_code
+
+ byte_increments = [ord(c) for c in co.co_lnotab[0::2]]
+ line_increments = [ord(c) for c in co.co_lnotab[1::2]]
+ table_length = len(byte_increments) # == len(line_increments)
+
+ lineno = co.co_firstlineno
+ table_index = 0
+ while (table_index < table_length
+ and byte_increments[table_index] == 0):
+ lineno += line_increments[table_index]
+ table_index += 1
+ addr = 0
+ line_incr = 0
+
labels = findlabels(code)
n = len(code)
i = 0
@@ -63,7 +77,23 @@ def disassemble(co, lasti=-1):
while i < n:
c = code[i]
op = ord(c)
- if op == SET_LINENO and i > 0: print # Extra blank line
+
+ if i >= addr:
+ lineno += line_incr
+ while table_index < table_length:
+ addr += byte_increments[table_index]
+ line_incr = line_increments[table_index]
+ table_index += 1
+ if line_incr:
+ break
+ else:
+ addr = sys.maxint
+ if i > 0:
+ print
+ print "%3d"%lineno,
+ else:
+ print ' ',
+
if i == lasti: print '-->',
else: print ' ',
if i in labels: print '>>',
@@ -224,6 +254,7 @@ def_op('INPLACE_XOR', 78)
def_op('INPLACE_OR', 79)
def_op('BREAK_LOOP', 80)
+def_op('RETURN_NONE', 81)
def_op('LOAD_LOCALS', 82)
def_op('RETURN_VALUE', 83)
def_op('IMPORT_STAR', 84)
@@ -277,9 +308,6 @@ haslocal.append(125)
def_op('DELETE_FAST', 126) # Local variable number
haslocal.append(126)
-def_op('SET_LINENO', 127) # Current line number
-SET_LINENO = 127
-
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8)
def_op('MAKE_FUNCTION', 132) # Number of args with default values