3.6 decompilation problems

This commit is contained in:
rocky
2018-03-29 17:21:22 -04:00
parent dc3e6b31ca
commit 7d110f17bc
6 changed files with 11 additions and 3 deletions

View File

@@ -47,3 +47,7 @@ def __init__(self, cnf={}):
def Value(self, fn, typecode_or_type, *args, lock=True):
return fn(typecode_or_type, *args, lock=lock,
ctx=self.get_context())
# From 3.6.4 heapq.py
def merge(*iterables, key=None, reverse=False):
return

View File

@@ -33,7 +33,7 @@ class Python35Parser(Python34Parser):
# ...
# the end of the if will jump back to the loop and there will be a COME_FROM
# after the jump
l_stmts ::= lastl_stmt COME_FROM l_stmts
l_stmts ::= lastl_stmt come_froms l_stmts
# Python 3.5+ Await statement
expr ::= await_expr

View File

@@ -49,8 +49,9 @@ class Python36Parser(Python35Parser):
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt
JUMP_BACK come_froms POP_BLOCK COME_FROM_LOOP
# This might be valid in < 3.6
# A COME_FROM is dropped off because of JUMP-to-JUMP optimization
and ::= expr jmp_false expr
and ::= expr jmp_false expr jmp_false
jf_cf ::= JUMP_FORWARD COME_FROM
conditional ::= expr jmp_false expr jf_cf expr COME_FROM

View File

@@ -592,7 +592,10 @@ def make_function3(self, node, is_lambda, nested=1, codeNode=None):
params.reverse() # back to correct order
if code_has_star_arg(code):
if self.version > 3.0:
if self.version >= 3.6:
j = -2 if code_has_star_star_arg(code) else -1
params.append('*%s' % code.co_varnames[j])
elif self.version > 3.0:
params.append('*%s' % code.co_varnames[argc + kw_pairs])
else:
params.append('*%s' % code.co_varnames[argc])