Correct SET_LINENO handling in Python 2.2

Add more  2.2 tests
This commit is contained in:
rocky
2016-08-13 20:25:19 -04:00
parent d8598f61e4
commit 7ccbd419c6
7 changed files with 39 additions and 3 deletions

View File

@@ -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

Binary file not shown.

Binary file not shown.

View File

@@ -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)

View File

@@ -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)

View File

@@ -13,7 +13,6 @@ class Python22Parser(Python23Parser):
def p_misc22(self, args):
'''
stmt ::= SET_LINENO
_for ::= LOAD_CONST FOR_LOOP
'''

View File

@@ -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 = '<generator expression>';
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