Start PyPY 3.7 and 3.8 decompilation support

This commit is contained in:
rocky
2021-11-02 06:05:09 -04:00
parent 470d203b40
commit 7fd1cea877
3 changed files with 50 additions and 2 deletions

View File

@@ -1,10 +1,10 @@
import pytest
# uncompyle6
from uncompyle6 import PYTHON_VERSION
from xdis.version_info import PYTHON_VERSION_TRIPLE, IS_PYPY
from validate import validate_uncompyle
@pytest.mark.skipif(PYTHON_VERSION < 3.6, reason='need at least python 3.6')
@pytest.mark.skipif(PYTHON_VERSION_TRIPLE < (3, 6) or IS_PYPY, reason="need at least Python 3.6 and not PyPY")
@pytest.mark.parametrize('text', (
"{0.: 'a', -1: 'b'}", # BUILD_MAP
"{'a':'b'}", # BUILD_MAP

View File

@@ -0,0 +1,24 @@
# Copyright (c) 2021 by Rocky Bernstein
"""
Python PyPy 3.7 decompiler scanner.
Does some additional massaging of xdis-disassembled instructions to
make things easier for decompilation.
"""
import decompyle3.scanners.scanner3y as scan
# bytecode verification, verify(), uses JUMP_OPS from here
from xdis.opcodes import opcode_37pypy as opc # is this right?
JUMP_OPs = opc.JUMP_OPS
# We base this off of 3.7
class ScannerPyPy37(scan.Scanner37):
def __init__(self, show_asm):
# There are no differences in initialization between
# pypy 3.7 and 3.7
scan.Scanner37.__init__(self, show_asm, is_pypy=True)
self.version = (3, 7)
self.opc = opc
return

View File

@@ -0,0 +1,24 @@
# Copyright (c) 2021 by Rocky Bernstein
"""
Python PyPy 3.8 decompiler scanner.
Does some additional massaging of xdis-disassembled instructions to
make things easier for decompilation.
"""
import decompyle3.scanners.scanner38 as scan
# bytecode verification, verify(), uses JUMP_OPS from here
from xdis.opcodes import opcode_38pypy as opc
JUMP_OPs = opc.JUMP_OPS
# We base this off of 3.8
class ScannerPyPy38(scan.Scanner38):
def __init__(self, show_asm):
# There are no differences in initialization between
# pypy 3.8 and 3.8
scan.Scanner38.__init__(self, show_asm, is_pypy=True)
self.version = (3, 8)
self.opc = opc
return