if free is None:
free = co.co_cellvars + co.co_freevars
print('(' + free[oparg] + ')', end=' ')
+ elif op in hasnargs:
+ print('(%d positional, %d keyword pair)'
+ % (code[i-2], code[i-1]), end=' ')
print()
def _disassemble_bytes(code, lasti=-1, varnames=None, names=None,
print('(%d)' % oparg, end=' ')
elif op in hascompare:
print('(' + cmp_op[oparg] + ')', end=' ')
+ elif op in hasnargs:
+ print('(%d positional, %d keyword pair)'
+ % (code[i-2], code[i-1]), end=' ')
print()
def _disassemble_str(source):
__all__ = ["cmp_op", "hasconst", "hasname", "hasjrel", "hasjabs",
"haslocal", "hascompare", "hasfree", "opname", "opmap",
- "HAVE_ARGUMENT", "EXTENDED_ARG"]
+ "HAVE_ARGUMENT", "EXTENDED_ARG", "hasnargs"]
cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is',
'is not', 'exception match', 'BAD')
haslocal = []
hascompare = []
hasfree = []
+hasnargs = []
opmap = {}
opname = [''] * 256
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
def_op('CALL_FUNCTION', 131) # #args + (#kwargs << 8)
+hasnargs.append(131)
def_op('MAKE_FUNCTION', 132) # Number of args with default values
def_op('BUILD_SLICE', 133) # Number of items
def_op('MAKE_CLOSURE', 134)
hasfree.append(138)
def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8)
+hasnargs.append(140)
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
+hasnargs.append(141)
def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
+hasnargs.append(142)
jrel_op('SETUP_WITH', 143)
dis_f = """\
%-4d 0 LOAD_GLOBAL 0 (print)
3 LOAD_FAST 0 (a)
- 6 CALL_FUNCTION 1
+ 6 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
9 POP_TOP
%-4d 10 LOAD_CONST 1 (1)
dis_f_co_code = """\
0 LOAD_GLOBAL 0 (0)
3 LOAD_FAST 0 (0)
- 6 CALL_FUNCTION 1
+ 6 CALL_FUNCTION 1 (1 positional, 0 keyword pair)
9 POP_TOP
10 LOAD_CONST 1 (1)
13 RETURN_VALUE
6 LOAD_CONST 1 (1)
%-4d 9 LOAD_CONST 2 (10)
- 12 CALL_FUNCTION 2
+ 12 CALL_FUNCTION 2 (2 positional, 0 keyword pair)
15 GET_ITER
>> 16 FOR_ITER 6 (to 25)
19 STORE_FAST 0 (res)