Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 934a4ce

Browse files
committed
Show names of locals in disco (Ka-Ping Yee)
1 parent dc082eb commit 934a4ce

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

Lib/dis.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ def disassemble(co, lasti):
4040
print '(' + co.co_names[oparg] + ')',
4141
elif op in hasjrel:
4242
print '(to ' + `i + oparg` + ')',
43+
elif op in haslocal:
44+
print '(' + co.co_varnames[oparg] + ')',
4345
print
4446

4547
def findlabels(code):
@@ -67,6 +69,7 @@ def findlabels(code):
6769
hasname = []
6870
hasjrel = []
6971
hasjabs = []
72+
haslocal = []
7073

7174
opname = [''] * 256
7275
for op in range(256): opname[op] = '<' + `op` + '>'
@@ -183,8 +186,11 @@ def jabs_op(name, op):
183186
def_op('RESERVE_FAST', 123) # Number of local variables
184187
hasconst.append(123)
185188
def_op('LOAD_FAST', 124) # Local variable number
189+
haslocal.append(124)
186190
def_op('STORE_FAST', 125) # Local variable number
191+
haslocal.append(125)
187192
def_op('DELETE_FAST', 126) # Local variable number
193+
haslocal.append(126)
188194

189195
def_op('SET_LINENO', 127) # Current line number
190196
SET_LINENO = 127

0 commit comments

Comments
 (0)