mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2024-11-23 05:00:07 +00:00
More 3.0 bug fixing and tollerance and...
add some 1.4 bytecode tests
This commit is contained in:
parent
78b8d1cd06
commit
d32e67891b
BIN
test/bytecode_1.4/addpack.pyc
Normal file
BIN
test/bytecode_1.4/addpack.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_1.4/anydbm.pyc
Normal file
BIN
test/bytecode_1.4/anydbm.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_3.0/02_ifelse_lambda.pyc
Normal file
BIN
test/bytecode_3.0/02_ifelse_lambda.pyc
Normal file
Binary file not shown.
@ -12,6 +12,12 @@ class Python30Parser(Python31Parser):
|
||||
def p_30(self, args):
|
||||
"""
|
||||
|
||||
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1 POP_TOP
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA POP_TOP
|
||||
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP
|
||||
JUMP_IF_FALSE POP_TOP compare_chained2
|
||||
compare_chained2 ::= expr COMPARE_OP RETURN_END_IF_LAMBDA
|
||||
|
||||
# FIXME: combine with parse3.2
|
||||
whileTruestmt ::= SETUP_LOOP l_stmts_opt JUMP_BACK
|
||||
COME_FROM_LOOP
|
||||
@ -85,6 +91,9 @@ class Python30Parser(Python31Parser):
|
||||
jump_absolute_else ::= JUMP_ABSOLUTE ELSE
|
||||
whilestmt ::= SETUP_LOOP testexpr l_stmts_opt COME_FROM JUMP_BACK POP_BLOCK
|
||||
COME_FROM_LOOP
|
||||
assert ::= assert_expr jmp_true LOAD_ASSERT RAISE_VARARGS_1
|
||||
return_if_lambda ::= RETURN_END_IF_LAMBDA
|
||||
compare_chained1 ::= expr DUP_TOP ROT_THREE COMPARE_OP JUMP_IF_FALSE_OR_POP compare_chained2 COME_FROM
|
||||
""")
|
||||
|
||||
return
|
||||
|
@ -503,25 +503,24 @@ def get_scanner(version, is_pypy=False, show_asm=None):
|
||||
# Pick up appropriate scanner
|
||||
if version in PYTHON_VERSIONS:
|
||||
v_str = "%s" % (int(version * 10))
|
||||
if PYTHON3:
|
||||
if version == 3.0:
|
||||
import uncompyle6.scanners.scanner30 as scan
|
||||
else:
|
||||
import importlib
|
||||
if is_pypy:
|
||||
scan = importlib.import_module("uncompyle6.scanners.pypy%s" % v_str)
|
||||
else:
|
||||
scan = importlib.import_module("uncompyle6.scanners.scanner%s" % v_str)
|
||||
if False: print(scan) # Avoid unused scan
|
||||
else:
|
||||
try:
|
||||
import importlib
|
||||
if is_pypy:
|
||||
exec("import uncompyle6.scanners.pypy%s as scan" % v_str)
|
||||
scan = importlib.import_module("uncompyle6.scanners.pypy%s" % v_str)
|
||||
else:
|
||||
exec("import uncompyle6.scanners.scanner%s as scan" % v_str)
|
||||
if is_pypy:
|
||||
scanner = eval("scan.ScannerPyPy%s(show_asm=show_asm)" % v_str)
|
||||
else:
|
||||
scanner = eval("scan.Scanner%s(show_asm=show_asm)" % v_str)
|
||||
scan = importlib.import_module("uncompyle6.scanners.scanner%s" % v_str)
|
||||
if False: print(scan) # Avoid unused scan
|
||||
except ImportError:
|
||||
if is_pypy:
|
||||
exec("import uncompyle6.scanners.pypy%s as scan" % v_str,
|
||||
locals(), globals())
|
||||
scanner = eval("scan.ScannerPyPy%s(show_asm=show_asm)" % v_str,
|
||||
locals(), globals())
|
||||
else:
|
||||
exec("import uncompyle6.scanners.scanner%s as scan" % v_str,
|
||||
locals(), globals())
|
||||
scanner = eval("scan.Scanner%s(show_asm=show_asm)" % v_str,
|
||||
locals(), globals())
|
||||
else:
|
||||
raise RuntimeError("Unsupported Python version %s" % version)
|
||||
return scanner
|
||||
|
@ -211,7 +211,12 @@ class Scanner3(Scanner):
|
||||
# If we have a JUMP_FORWARD after the
|
||||
# RAISE_VARARGS then we have a "raise" statement
|
||||
# else we have an "assert" statement.
|
||||
if inst.opname == 'POP_JUMP_IF_TRUE' and i+1 < n:
|
||||
if self.version == 3.0:
|
||||
# There is a an implied JUMP_IF_TRUE that we are not testing for (yet?) here
|
||||
assert_can_follow = inst.opname == 'POP_TOP' and i+1 < n
|
||||
else:
|
||||
assert_can_follow = inst.opname == 'POP_JUMP_IF_TRUE' and i+1 < n
|
||||
if assert_can_follow:
|
||||
next_inst = self.insts[i+1]
|
||||
if (next_inst.opname == 'LOAD_GLOBAL' and
|
||||
next_inst.argval == 'AssertionError'):
|
||||
|
Loading…
Reference in New Issue
Block a user