Use xdis 3.5.0's opcode sets

This commit is contained in:
rocky
2017-07-08 20:41:46 -04:00
parent 2e164763eb
commit 27ab6fe2f5
7 changed files with 26 additions and 26 deletions

View File

@@ -40,7 +40,7 @@ entry_points = {
]}
ftp_url = None
install_requires = ['spark-parser >= 1.6.1, < 1.7.0',
'xdis >= 3.4.0, < 3.5.0', 'six']
'xdis >= 3.5.0, < 3.6.0', 'six']
license = 'MIT'
mailing_list = 'python-debugger@googlegroups.com'
modname = 'uncompyle6'

View File

@@ -89,7 +89,7 @@ class Scanner(object):
if op is None:
op = self.code[pos]
target = self.get_argument(pos)
if op in self.opc.hasjrel:
if op in self.opc.JREL_OPS:
target += pos + 3
return target
@@ -100,7 +100,7 @@ class Scanner(object):
def print_bytecode(self):
for i in self.op_range(0, len(self.code)):
op = self.code[i]
if op in self.opc.hasjabs+self.opc.hasjrel:
if op in self.JUMP_OPs:
dest = self.get_target(i, op)
print('%i\t%s\t%i' % (i, self.opname[op], dest))
else:

View File

@@ -189,7 +189,7 @@ class Scanner2(Scanner):
if op == self.opc.EXTENDED_ARG:
extended_arg = oparg * L65536
continue
if op in self.opc.hasconst:
if op in self.opc.CONST_OPS:
const = co.co_consts[oparg]
if iscode(const):
oparg = const
@@ -210,23 +210,23 @@ class Scanner2(Scanner):
pattr = '<code_object ' + const.co_name + '>'
else:
pattr = const
elif op in self.opc.hasname:
elif op in self.opc.NAME_OPS:
pattr = names[oparg]
elif op in self.opc.hasjrel:
elif op in self.opc.JREL_OPS:
# use instead: hasattr(self, 'patch_continue'): ?
if self.version == 2.7:
self.patch_continue(tokens, offset, op)
pattr = repr(offset + 3 + oparg)
elif op in self.opc.hasjabs:
elif op in self.opc.JABS_OPS:
# use instead: hasattr(self, 'patch_continue'): ?
if self.version == 2.7:
self.patch_continue(tokens, offset, op)
pattr = repr(oparg)
elif op in self.opc.haslocal:
elif op in self.opc.LOCAL_OPS:
pattr = varnames[oparg]
elif op in self.opc.hascompare:
elif op in self.opc.COMPARE_OPS:
pattr = self.opc.cmp_op[oparg]
elif op in self.opc.hasfree:
elif op in self.opc.FREE_OPS:
pattr = free[oparg]
if op in self.varargs_ops:
@@ -603,7 +603,7 @@ class Scanner2(Scanner):
if test == offset:
loop_type = 'while 1'
elif self.code[test] in self.opc.hasjabs + self.opc.hasjrel:
elif self.code[test] in self.opc.JUMP_OPs:
self.ignore_if.add(test)
test_target = self.get_target(test)
if test_target > (jump_back+3):
@@ -994,11 +994,11 @@ class Scanner2(Scanner):
oparg = self.get_argument(offset)
if label is None:
if op in self.opc.hasjrel and self.op_name(op) != 'FOR_ITER':
# if (op in self.opc.hasjrel and
if op in self.opc.JREL_OPS and self.op_name(op) != 'FOR_ITER':
# if (op in self.opc.JREL_OPS and
# (self.version < 2.0 or op != self.opc.FOR_ITER)):
label = offset + 3 + oparg
elif self.version == 2.7 and op in self.opc.hasjabs:
elif self.version == 2.7 and op in self.opc.JABS_OPS:
if op in (self.opc.JUMP_IF_FALSE_OR_POP,
self.opc.JUMP_IF_TRUE_OR_POP):
if (oparg > offset):

View File

@@ -181,7 +181,7 @@ class Scanner26(scan.Scanner2):
if op == self.opc.EXTENDED_ARG:
extended_arg = oparg * L65536
continue
if op in self.opc.hasconst:
if op in self.opc.CONST_OPS:
const = co.co_consts[oparg]
# We can't use inspect.iscode() because we may be
# using a different version of Python than the
@@ -206,9 +206,9 @@ class Scanner26(scan.Scanner2):
pattr = '<code_object ' + const.co_name + '>'
else:
pattr = const
elif op in self.opc.hasname:
elif op in self.opc.NAME_OPS:
pattr = names[oparg]
elif op in self.opc.hasjrel:
elif op in self.opc.JREL_OPS:
pattr = repr(offset + 3 + oparg)
if op == self.opc.JUMP_FORWARD:
target = self.get_target(offset)
@@ -218,13 +218,13 @@ class Scanner26(scan.Scanner2):
if len(tokens) and tokens[-1].type == 'JUMP_BACK':
tokens[-1].type = intern('CONTINUE')
elif op in self.opc.hasjabs:
elif op in self.opc.JABS_OPS:
pattr = repr(oparg)
elif op in self.opc.haslocal:
elif op in self.opc.LOCAL_OPS:
pattr = varnames[oparg]
elif op in self.opc.hascompare:
elif op in self.opc.COMPARE_OPS:
pattr = self.opc.cmp_op[oparg]
elif op in self.opc.hasfree:
elif op in self.opc.FREE_OPS:
pattr = free[oparg]
if op in self.varargs_ops:
# CE - Hack for >= 2.5

View File

@@ -633,11 +633,11 @@ class Scanner3(Scanner):
rel_offset = 0
if self.version >= 3.6:
target = self.code[offset+1]
if op in self.opc.hasjrel:
if op in self.opc.JREL_OPS:
rel_offset = offset + 2
else:
target = self.code[offset+1] + self.code[offset+2] * 256
if op in self.opc.hasjrel:
if op in self.opc.JREL_OPS:
rel_offset = offset + 3
pass
pass

View File

@@ -120,7 +120,7 @@ class Scanner30(Scanner3):
if test == offset:
loop_type = 'while 1'
elif self.code[test] in opc.hasjabs+opc.hasjrel:
elif self.code[test] in opc.JUMP_OPs:
self.ignore_if.add(test)
test_target = self.get_target(test)
if test_target > (jump_back+3):

View File

@@ -65,10 +65,10 @@ class Token:
if self.pattr:
pattr = self.pattr
if self.opc:
if self.op in self.opc.hasjrel:
if self.op in self.opc.JREL_OPS:
if not self.pattr.startswith('to '):
pattr = "to " + self.pattr
elif self.op in self.opc.hasjabs:
elif self.op in self.opc.JABS_OPS:
self.pattr= str(self.pattr)
if not self.pattr.startswith('to '):
pattr = "to " + str(self.pattr)