From 2e164763eb5e163baeb23e1ddd4759b154098b3b Mon Sep 17 00:00:00 2001 From: rocky Date: Sat, 8 Jul 2017 17:47:32 -0400 Subject: [PATCH] Start supporting Pypy 3.5 (5.7.1-beta) --- test/test_pyenvlib.py | 2 +- uncompyle6/scanners/pypy32.py | 16 ++++++---------- uncompyle6/scanners/pypy35.py | 22 ++++++++++++++++++++++ uncompyle6/scanners/scanner15.py | 4 ++-- uncompyle6/scanners/scanner32.py | 7 +++++-- uncompyle6/scanners/scanner34.py | 7 +++++-- uncompyle6/scanners/scanner35.py | 11 +++++++---- uncompyle6/scanners/scanner36.py | 5 ++++- 8 files changed, 52 insertions(+), 22 deletions(-) create mode 100644 uncompyle6/scanners/pypy35.py diff --git a/test/test_pyenvlib.py b/test/test_pyenvlib.py index 2cacdd4c..6ace979a 100755 --- a/test/test_pyenvlib.py +++ b/test/test_pyenvlib.py @@ -29,7 +29,7 @@ from fnmatch import fnmatch TEST_VERSIONS=('2.3.7', '2.4.6', '2.5.6', '2.6.9', 'pypy-2.4.0', 'pypy-2.6.1', - 'pypy-5.0.1', 'pypy-5.3.1', + 'pypy-5.0.1', 'pypy-5.3.1', 'pypy3.5-5.7.1-beta', '2.7.10', '2.7.11', '2.7.12', '2.7.13', '3.0.1', '3.1.5', '3.2.6', '3.3.5', '3.3.6', diff --git a/uncompyle6/scanners/pypy32.py b/uncompyle6/scanners/pypy32.py index 264708ef..232c168b 100644 --- a/uncompyle6/scanners/pypy32.py +++ b/uncompyle6/scanners/pypy32.py @@ -1,22 +1,18 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2017 by Rocky Bernstein """ -Python PyPy 3.2 bytecode scanner/deparser +Python PyPy 3.2 decompiler scanner. -This overlaps Python's 3.2's dis module, but it can be run from -Python 3 and other versions of Python. Also, we save token -information for later use in deparsing. +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. """ import uncompyle6.scanners.scanner32 as scan # bytecode verification, verify(), uses JUMP_OPs from here -from xdis.opcodes import opcode_32 as opc # is this rgith? +from xdis.opcodes import opcode_32 as opc # is this right? JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) -# We base this off of 2.6 instead of the other way around -# because we cleaned things up this way. -# The history is that 2.7 support is the cleanest, -# then from that we got 2.6 and so on. +# We base this off of 3.2 class ScannerPyPy32(scan.Scanner32): def __init__(self, show_asm): # There are no differences in initialization between diff --git a/uncompyle6/scanners/pypy35.py b/uncompyle6/scanners/pypy35.py new file mode 100644 index 00000000..a2c660a9 --- /dev/null +++ b/uncompyle6/scanners/pypy35.py @@ -0,0 +1,22 @@ +# Copyright (c) 2017 by Rocky Bernstein +""" +Python PyPy 3.2 decompiler scanner. + +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. +""" + +import uncompyle6.scanners.scanner35 as scan + +# bytecode verification, verify(), uses JUMP_OPs from here +from xdis.opcodes import opcode_35 as opc # is this right? +JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) + +# We base this off of 3.5 +class ScannerPyPy35(scan.Scanner35): + def __init__(self, show_asm): + # There are no differences in initialization between + # pypy 3.5 and 3.5 + scan.Scanner35.__init__(self, show_asm, is_pypy=True) + self.version = 3.5 + return diff --git a/uncompyle6/scanners/scanner15.py b/uncompyle6/scanners/scanner15.py index 74844a79..9ad9465e 100644 --- a/uncompyle6/scanners/scanner15.py +++ b/uncompyle6/scanners/scanner15.py @@ -1,6 +1,6 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2016-2017 by Rocky Bernstein """ -Python 1.5 bytecode scanner/deparser +Python 1.5 bytecode decompiler scanner. This massages tokenized 1.5 bytecode to make it more amenable for grammar parsing. diff --git a/uncompyle6/scanners/scanner32.py b/uncompyle6/scanners/scanner32.py index 710a282a..7859da63 100644 --- a/uncompyle6/scanners/scanner32.py +++ b/uncompyle6/scanners/scanner32.py @@ -1,6 +1,9 @@ -# Copyright (c) 2015-2016 by Rocky Bernstein +# Copyright (c) 2015-2017 by Rocky Bernstein """ -Python 3.2 bytecode scanner/deparser +Python 3.2 bytecode decompiler scanner. + +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. This sets up opcodes Python's 3.2 and calls a generalized scanner routine for Python 3. diff --git a/uncompyle6/scanners/scanner34.py b/uncompyle6/scanners/scanner34.py index bb0f3f87..f062b100 100644 --- a/uncompyle6/scanners/scanner34.py +++ b/uncompyle6/scanners/scanner34.py @@ -1,6 +1,9 @@ -# Copyright (c) 2015-2016 by Rocky Bernstein +# Copyright (c) 2015-2017 by Rocky Bernstein """ -Python 3.4 bytecode scanner/deparser +Python 3.4 bytecode decompiler scanner + +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. This sets up opcodes Python's 3.4 and calls a generalized scanner routine for Python 3. diff --git a/uncompyle6/scanners/scanner35.py b/uncompyle6/scanners/scanner35.py index bbb3dfbb..0feb65d8 100644 --- a/uncompyle6/scanners/scanner35.py +++ b/uncompyle6/scanners/scanner35.py @@ -1,6 +1,9 @@ -# Copyright (c) 2016 by Rocky Bernstein +# Copyright (c) 2017 by Rocky Bernstein """ -Python 3.5 bytecode scanner/deparser +Python 3.5 bytecode decompiler scanner + +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. This sets up opcodes Python's 3.5 and calls a generalized scanner routine for Python 3. @@ -16,8 +19,8 @@ JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs) class Scanner35(Scanner3): - def __init__(self, show_asm=None): - Scanner3.__init__(self, 3.5, show_asm) + def __init__(self, show_asm=None, is_pypy=False): + Scanner3.__init__(self, 3.5, show_asm, is_pypy) return pass diff --git a/uncompyle6/scanners/scanner36.py b/uncompyle6/scanners/scanner36.py index 3c511937..bb279441 100644 --- a/uncompyle6/scanners/scanner36.py +++ b/uncompyle6/scanners/scanner36.py @@ -1,6 +1,9 @@ # Copyright (c) 2016-2017 by Rocky Bernstein """ -Python 3.6 bytecode scanner/deparser +Python 3.6 bytecode decompiler scanner + +Does some additional massaging of xdis-disassembled instructions to +make things easier for decompilation. This sets up opcodes Python's 3.6 and calls a generalized scanner routine for Python 3.