You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 09:22:40 +08:00
Fix make_closure compilation from 2.x of 3.3 bytecode
This commit is contained in:
@@ -156,25 +156,20 @@ class Scanner3(scan.Scanner):
|
|||||||
elif op in op3.hasfree:
|
elif op in op3.hasfree:
|
||||||
pattr = free[oparg]
|
pattr = free[oparg]
|
||||||
|
|
||||||
if op in (BUILD_LIST, BUILD_TUPLE, BUILD_SET, BUILD_SLICE,
|
if op_name in ('BUILD_LIST', 'BUILD_TUPLE', 'BUILD_SET', 'BUILD_SLICE',
|
||||||
UNPACK_SEQUENCE,
|
'UNPACK_SEQUENCE',
|
||||||
MAKE_FUNCTION, CALL_FUNCTION, MAKE_CLOSURE,
|
'MAKE_FUNCTION', 'CALL_FUNCTION', 'MAKE_CLOSURE',
|
||||||
CALL_FUNCTION_VAR, CALL_FUNCTION_KW,
|
'CALL_FUNCTION_VAR', 'CALL_FUNCTION_KW',
|
||||||
CALL_FUNCTION_VAR_KW, RAISE_VARARGS
|
'CALL_FUNCTION_VAR_KW', 'RAISE_VARARGS'
|
||||||
):
|
):
|
||||||
# As of Python 2.5, values loaded via LOAD_CLOSURE are packed into
|
|
||||||
# a tuple before calling MAKE_CLOSURE.
|
|
||||||
if (op == BUILD_TUPLE and
|
|
||||||
self.code[self.prev_op[offset]] == LOAD_CLOSURE):
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
# CALL_FUNCTION OP renaming is done as a custom rule in parse3
|
# CALL_FUNCTION OP renaming is done as a custom rule in parse3
|
||||||
if op_name not in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR',
|
if op_name not in ('CALL_FUNCTION', 'CALL_FUNCTION_VAR',
|
||||||
'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW'):
|
'CALL_FUNCTION_VAR_KW', 'CALL_FUNCTION_KW',
|
||||||
|
):
|
||||||
op_name = '%s_%d' % (op_name, oparg)
|
op_name = '%s_%d' % (op_name, oparg)
|
||||||
if op != BUILD_SLICE:
|
if op_name != 'BUILD_SLICE':
|
||||||
customize[op_name] = oparg
|
customize[op_name] = oparg
|
||||||
elif op == JUMP_ABSOLUTE:
|
elif op_name == 'JUMP_ABSOLUTE':
|
||||||
target = self.get_target(offset)
|
target = self.get_target(offset)
|
||||||
if target < offset:
|
if target < offset:
|
||||||
if (offset in self.stmts
|
if (offset in self.stmts
|
||||||
@@ -184,10 +179,10 @@ class Scanner3(scan.Scanner):
|
|||||||
else:
|
else:
|
||||||
op_name = 'JUMP_BACK'
|
op_name = 'JUMP_BACK'
|
||||||
|
|
||||||
elif op == LOAD_GLOBAL:
|
elif op_name == 'LOAD_GLOBAL':
|
||||||
if offset in self.load_asserts:
|
if offset in self.load_asserts:
|
||||||
op_name = 'LOAD_ASSERT'
|
op_name = 'LOAD_ASSERT'
|
||||||
elif op == RETURN_VALUE:
|
elif op_name == 'RETURN_VALUE':
|
||||||
if offset in self.return_end_ifs:
|
if offset in self.return_end_ifs:
|
||||||
op_name = 'RETURN_END_IF'
|
op_name = 'RETURN_END_IF'
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user