You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-04 01:09:52 +08:00
Merge branch 'python-3.3-to-3.5' into python-2.4
This commit is contained in:
2
.github/workflows/osx.yml
vendored
2
.github/workflows/osx.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
# Until the next xdis release
|
||||
pip install git+git://github.com/rocky/python-xdis.git@python-2.4-to-2.7#egg=xdis
|
||||
# pip install git+git://github.com/rocky/python-xdis.git@python-2.4-to-2.7#egg=xdis
|
||||
pip install -e .
|
||||
pip install -r requirements-dev.txt
|
||||
- name: Test uncompyle6
|
||||
|
2
.github/workflows/ubuntu.yml
vendored
2
.github/workflows/ubuntu.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
# Until the next xdis release
|
||||
pip install git+git://github.com/rocky/python-xdis.git@python-2.4-to-2.7#egg=xdis
|
||||
# pip install git+git://github.com/rocky/python-xdis.git@python-2.4-to-2.7#egg=xdis
|
||||
pip install -e .
|
||||
pip install -r requirements-dev.txt
|
||||
- name: Test uncompyle6
|
||||
|
2
.github/workflows/windows.yml
vendored
2
.github/workflows/windows.yml
vendored
@@ -22,7 +22,7 @@ jobs:
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
# Until the next xdis release
|
||||
pip install git+git://github.com/rocky/python-xdis.git@python-2.4-to-2.7#egg=xdis
|
||||
# pip install git+git://github.com/rocky/python-xdis.git@python-2.4-to-2.7#egg=xdis
|
||||
pip install -e .
|
||||
pip install -r requirements-dev.txt
|
||||
- name: Test uncompyle6
|
||||
|
@@ -76,6 +76,8 @@ check-3.7: check-bytecode
|
||||
# check-3.8: check-bytecode
|
||||
# $(PYTHON) test_pythonlib.py --bytecode-3.8-run --verify-run
|
||||
# $(PYTHON) test_pythonlib.py --bytecode-3.8 --syntax-verify $(COMPILE)
|
||||
check-pypy37: check-bytecode
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy37 --verify-run
|
||||
|
||||
check-3.9: check-bytecode
|
||||
@echo "Note that we do not support decompiling Python 3.9 bytecode - no 3.9 tests run"
|
||||
@@ -358,10 +360,14 @@ check-bytecode-pypy3.6: 7.1
|
||||
|
||||
#: PyPy 5.0.x with Python 3.6.9
|
||||
check-bytecode-pypy3.6: 7.2 7.3
|
||||
7.3 7.2:
|
||||
|
||||
7.2:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy3.6-run --verify-run
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy3.6 --verify
|
||||
|
||||
7.3:
|
||||
$(PYTHON) test_pythonlib.py --bytecode-pypy3.7 --verify-run
|
||||
|
||||
|
||||
|
||||
clean: clean-py-dis clean-dis clean-unverified
|
||||
|
BIN
test/bytecode_pypy3.7/01_callback.pyc
Normal file
BIN
test/bytecode_pypy3.7/01_callback.pyc
Normal file
Binary file not shown.
10
test/simple_source/bug_pypy37/01_callback.py
Normal file
10
test/simple_source/bug_pypy37/01_callback.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""This program is self-checking!"""
|
||||
|
||||
|
||||
def lcase(s):
|
||||
return s.lower()
|
||||
|
||||
|
||||
l = ["xyz", "ABC"]
|
||||
l.sort(key=lcase)
|
||||
assert l == ["ABC", "xyz"]
|
@@ -46,6 +46,7 @@ TEST_VERSIONS = (
|
||||
"pypy3.6-7.1.0",
|
||||
"pypy3.6-7.1.1",
|
||||
"pypy3.6-7.2.0",
|
||||
"pypy3.8-7.3.7",
|
||||
"native",
|
||||
) + tuple(python_versions)
|
||||
|
||||
|
@@ -114,6 +114,12 @@ for vers in (
|
||||
pythonlib = os.path.join(pythonlib, "__pycache__")
|
||||
test_options[key] = (os.path.join(lib_prefix, pythonlib), PYOC, pythonlib, vers)
|
||||
|
||||
vers = 3.7
|
||||
bytecode = "bytecode_pypy%s_run" % vers
|
||||
key = "bytecode-pypy37"
|
||||
test_options[key] = (bytecode, PYC, bytecode, vers)
|
||||
|
||||
|
||||
# -----
|
||||
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
Python 3.7 grammar for the spark Earley-algorithm parser.
|
||||
"""
|
||||
|
||||
from uncompyle6.scanners.tok import Token
|
||||
from uncompyle6.parser import PythonParserSingle, nop_func
|
||||
from spark_parser import DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||
from uncompyle6.parsers.parse37base import Python37BaseParser
|
||||
|
@@ -523,15 +523,30 @@ class Python37BaseParser(PythonParser):
|
||||
|
||||
args_pos, args_kw = self.get_pos_kw(token)
|
||||
|
||||
# number of apply equiv arguments:
|
||||
nak = (len(opname_base) - len("CALL_METHOD")) // 3
|
||||
rule = (
|
||||
"call ::= expr "
|
||||
+ ("pos_arg " * args_pos)
|
||||
+ ("kwarg " * args_kw)
|
||||
+ "expr " * nak
|
||||
+ opname
|
||||
)
|
||||
if opname == "CALL_METHOD_KW":
|
||||
args_kw = token.attr
|
||||
rules_str = """
|
||||
expr ::= call_kw_pypy37
|
||||
pypy_kw_keys ::= LOAD_CONST
|
||||
"""
|
||||
self.add_unique_doc_rules(rules_str, customize)
|
||||
rule = (
|
||||
"call_kw_pypy37 ::= expr "
|
||||
+ ("expr " * args_kw)
|
||||
+ " pypy_kw_keys "
|
||||
+ opname
|
||||
)
|
||||
else:
|
||||
args_pos, args_kw = self.get_pos_kw(token)
|
||||
# number of apply equiv arguments:
|
||||
nak = (len(opname_base) - len("CALL_METHOD")) // 3
|
||||
rule = (
|
||||
"call ::= expr "
|
||||
+ ("expr " * args_pos)
|
||||
+ ("kwarg " * args_kw)
|
||||
+ "expr " * nak
|
||||
+ opname
|
||||
)
|
||||
self.add_unique_rule(rule, opname, token.attr, customize)
|
||||
|
||||
elif opname == "CONTINUE":
|
||||
|
2
uncompyle6/scanner.py
Executable file → Normal file
2
uncompyle6/scanner.py
Executable file → Normal file
@@ -581,7 +581,7 @@ def get_scanner(version, is_pypy=False, show_asm=None):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import inspect, uncompyle6
|
||||
import inspect
|
||||
|
||||
co = inspect.currentframe().f_code
|
||||
# scanner = get_scanner('2.7.13', True)
|
||||
|
@@ -6,7 +6,7 @@ Does some additional massaging of xdis-disassembled instructions to
|
||||
make things easier for decompilation.
|
||||
"""
|
||||
|
||||
import decompyle3.scanners.scanner3y as scan
|
||||
import decompyle3.scanners.scanner37 as scan
|
||||
|
||||
# bytecode verification, verify(), uses JUMP_OPS from here
|
||||
from xdis.opcodes import opcode_37pypy as opc # is this right?
|
||||
@@ -21,4 +21,5 @@ class ScannerPyPy37(scan.Scanner37):
|
||||
scan.Scanner37.__init__(self, show_asm, is_pypy=True)
|
||||
self.version = (3, 7)
|
||||
self.opc = opc
|
||||
self.is_pypy = True
|
||||
return
|
||||
|
@@ -16,9 +16,9 @@
|
||||
"""Isolate Python version-specific semantic actions here.
|
||||
"""
|
||||
|
||||
from uncompyle6.semantics.consts import PRECEDENCE, TABLE_R, TABLE_DIRECT
|
||||
|
||||
from uncompyle6.parsers.treenode import SyntaxTree
|
||||
from uncompyle6.semantics.consts import INDENT_PER_LEVEL, PRECEDENCE, TABLE_R, TABLE_DIRECT
|
||||
from uncompyle6.semantics.helper import flatten_list
|
||||
from uncompyle6.scanners.tok import Token
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@ def customize_for_version(self, is_pypy, version):
|
||||
# PyPy changes
|
||||
#######################
|
||||
TABLE_DIRECT.update({
|
||||
'assert_pypy': ( '%|assert %c\n' , (1, 'assert_expr') ),
|
||||
# This is as a result of an if transoration
|
||||
'assert0_pypy': ( '%|assert %c\n' , (0, 'assert_expr') ),
|
||||
"assert": ("%|assert %c\n", 0),
|
||||
"assert_pypy": ( '%|assert %c\n' , (1, 'assert_expr') ),
|
||||
# This is as a result of an if transformation
|
||||
'assert0_pypy': ( '%|assert %c\n' , 0),
|
||||
|
||||
'assert_not_pypy': ( '%|assert not %c\n' , (1, 'assert_exp') ),
|
||||
'assert2_not_pypy': ( '%|assert not %c, %c\n' , (1, 'assert_exp'),
|
||||
@@ -42,6 +43,42 @@ def customize_for_version(self, is_pypy, version):
|
||||
'assign3_pypy': ( '%|%c, %c, %c = %c, %c, %c\n', 5, 4, 3, 0, 1, 2 ),
|
||||
'assign2_pypy': ( '%|%c, %c = %c, %c\n', 3, 2, 0, 1),
|
||||
})
|
||||
|
||||
if version[:2] == (3, 7):
|
||||
|
||||
def n_call_kw_pypy37(node):
|
||||
self.template_engine(("%p(", (0, 100)), node)
|
||||
assert node[-1] == "CALL_METHOD_KW"
|
||||
pypy_kw_keys = node[-2]
|
||||
assert pypy_kw_keys == "pypy_kw_keys"
|
||||
|
||||
flat_elems = flatten_list(node[1:-2])
|
||||
# FIXME zip pypy_kw_keys and elems
|
||||
|
||||
self.indent_more(INDENT_PER_LEVEL)
|
||||
sep = ""
|
||||
|
||||
n = len(flat_elems)
|
||||
kw_keys_tuple = pypy_kw_keys[0].attr
|
||||
assert n == len(kw_keys_tuple)
|
||||
for i in range(n):
|
||||
elem = flat_elems[i]
|
||||
assert elem == "expr"
|
||||
line_number = self.line_number
|
||||
value = self.traverse(elem)
|
||||
if line_number != self.line_number:
|
||||
sep += "\n" + self.indent + INDENT_PER_LEVEL[:-1]
|
||||
pass
|
||||
self.write(sep)
|
||||
self.write("%s=%s" % (kw_keys_tuple[i], value))
|
||||
sep = ", "
|
||||
pass
|
||||
|
||||
self.write(")")
|
||||
self.prune()
|
||||
|
||||
self.n_call_kw_pypy37 = n_call_kw_pypy37
|
||||
|
||||
else:
|
||||
########################
|
||||
# Without PyPy
|
||||
|
Reference in New Issue
Block a user