You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Start PyPY 3.7 and 3.8 decompilation support
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
import pytest
|
import pytest
|
||||||
# uncompyle6
|
# uncompyle6
|
||||||
from uncompyle6 import PYTHON_VERSION
|
from xdis.version_info import PYTHON_VERSION_TRIPLE, IS_PYPY
|
||||||
from validate import validate_uncompyle
|
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', (
|
@pytest.mark.parametrize('text', (
|
||||||
"{0.: 'a', -1: 'b'}", # BUILD_MAP
|
"{0.: 'a', -1: 'b'}", # BUILD_MAP
|
||||||
"{'a':'b'}", # BUILD_MAP
|
"{'a':'b'}", # BUILD_MAP
|
||||||
|
24
uncompyle6/scanners/pypy37.py
Normal file
24
uncompyle6/scanners/pypy37.py
Normal 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
|
24
uncompyle6/scanners/pypy38.py
Normal file
24
uncompyle6/scanners/pypy38.py
Normal 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
|
Reference in New Issue
Block a user