You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Correct SET_LINENO handling in Python 2.2
Add more 2.2 tests
This commit is contained in:
@@ -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
|
||||
|
BIN
test/bytecode_2.2/02_apply_equiv.pyc
Normal file
BIN
test/bytecode_2.2/02_apply_equiv.pyc
Normal file
Binary file not shown.
BIN
test/bytecode_2.2/03_if_elif.pyc
Normal file
BIN
test/bytecode_2.2/03_if_elif.pyc
Normal file
Binary file not shown.
27
test/simple_source/bug22/02_apply_equiv.py
Normal file
27
test/simple_source/bug22/02_apply_equiv.py
Normal 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)
|
@@ -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)
|
||||
|
@@ -13,7 +13,6 @@ class Python22Parser(Python23Parser):
|
||||
|
||||
def p_misc22(self, args):
|
||||
'''
|
||||
stmt ::= SET_LINENO
|
||||
_for ::= LOAD_CONST FOR_LOOP
|
||||
'''
|
||||
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user