diff --git a/test/Makefile b/test/Makefile index d4db0489..4b6fbd48 100644 --- a/test/Makefile +++ b/test/Makefile @@ -58,7 +58,8 @@ check-bytecode-3: #: Check deparsing bytecode that works running Python 2 and Python 3 check-bytecode: check-bytecode-3 - $(PYTHON) test_pythonlib.py --bytecode-2.3 --bytecode-2.4 \ + $(PYTHON) test_pythonlib.py \ + --bytecode-2.2 --bytecode-2.3 --bytecode-2.4 \ --bytecode-2.5 --bytecode-2.6 --bytecode-2.7 --bytecode-pypy2.7 #: Check deparsing Python 2.3 diff --git a/test/bytecode_2.2/02_apply_equiv.pyc b/test/bytecode_2.2/02_apply_equiv.pyc new file mode 100644 index 00000000..b018753b Binary files /dev/null and b/test/bytecode_2.2/02_apply_equiv.pyc differ diff --git a/test/bytecode_2.2/03_if_elif.pyc b/test/bytecode_2.2/03_if_elif.pyc new file mode 100644 index 00000000..8e8858d5 Binary files /dev/null and b/test/bytecode_2.2/03_if_elif.pyc differ diff --git a/test/simple_source/bug22/02_apply_equiv.py b/test/simple_source/bug22/02_apply_equiv.py new file mode 100644 index 00000000..e8e3d944 --- /dev/null +++ b/test/simple_source/bug22/02_apply_equiv.py @@ -0,0 +1,27 @@ +# decompyle's test_appyEquiv.py + +def kwfunc(**kwargs): + print kwargs.items() + + +def argsfunc(*args): + print args + + +def no_apply(*args, **kwargs): + print args + print kwargs.items() + argsfunc(34) + foo = argsfunc(*args) + argsfunc(*args) + argsfunc(34, *args) + kwfunc(**None) + kwfunc(x = 11, **None) + no_apply(*args, **args) + no_apply(34, *args, **args) + no_apply(x = 11, *args, **args) + no_apply(34, x = 11, *args, **args) + no_apply(42, 34, x = 11, *args, **args) + return foo + +no_apply(1, 2, 4, 8, a = 2, b = 3, c = 5) diff --git a/test/test_pythonlib.py b/test/test_pythonlib.py index ea98f7e1..321cf2bf 100755 --- a/test/test_pythonlib.py +++ b/test/test_pythonlib.py @@ -78,7 +78,8 @@ for vers in (2.7, 3.4, 3.5, 3.6): test_options[key] = (os.path.join(src_dir, pythonlib), PYOC, key, vers) pass -for vers in (2.3, 2.4, 2.5, 2.6, 2.7, 3.2, 3.3, 3.4, 3.5, 3.6, 'pypy3.2', 'pypy2.7'): +for vers in (2.2, 2.3, 2.4, 2.5, 2.6, 2.7, + 3.2, 3.3, 3.4, 3.5, 3.6, 'pypy3.2', 'pypy2.7'): bytecode = "bytecode_%s" % vers key = "bytecode-%s" % vers test_options[key] = (bytecode, PYC, bytecode, vers) diff --git a/uncompyle6/parsers/parse22.py b/uncompyle6/parsers/parse22.py index 42f5f21d..ffa9e53f 100644 --- a/uncompyle6/parsers/parse22.py +++ b/uncompyle6/parsers/parse22.py @@ -13,7 +13,6 @@ class Python22Parser(Python23Parser): def p_misc22(self, args): ''' - stmt ::= SET_LINENO _for ::= LOAD_CONST FOR_LOOP ''' diff --git a/uncompyle6/scanners/scanner22.py b/uncompyle6/scanners/scanner22.py index 8c773036..0eaa52ac 100644 --- a/uncompyle6/scanners/scanner22.py +++ b/uncompyle6/scanners/scanner22.py @@ -8,6 +8,7 @@ information for later use in deparsing. """ import uncompyle6.scanners.scanner23 as scan +# from uncompyle6.scanners.scanner26 import disassemble as disassemble26 # bytecode verification, verify(), uses JUMP_OPs from here from xdis.opcodes import opcode_22 @@ -24,4 +25,11 @@ class Scanner22(scan.Scanner23): self.opname = opcode_22.opname self.version = 2.2 self.genexpr_name = ''; + self.parent_injest = self.disassemble + self.disassemble = self.disassemble22 return + + def disassemble22(self, co, classname=None, code_objects={}, show_asm=None): + tokens, customize = self.parent_injest(co, classname, code_objects, show_asm) + tokens = [t for t in tokens if t.type != 'SET_LINENO'] + return tokens, customize