You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Revise for xdis 3.6.0 ...
Simplify xdis imports where we can. Blacken (most) of those buffers too
This commit is contained in:
@@ -21,6 +21,17 @@
|
|||||||
# less elegant than having it here with reduced code, albeit there
|
# less elegant than having it here with reduced code, albeit there
|
||||||
# still is some room for improvement.
|
# still is some room for improvement.
|
||||||
|
|
||||||
|
# Python-version | package | last-version |
|
||||||
|
# -----------------------------------------
|
||||||
|
# 2.5 | pip | 1.1 |
|
||||||
|
# 2.6 | pip | 1.5.6 |
|
||||||
|
# 2.7 | pip | 19.2.3 |
|
||||||
|
# 2.7 | pip | 1.2.1 |
|
||||||
|
# 3.1 | pip | 1.5.6 |
|
||||||
|
# 3.2 | pip | 7.1.2 |
|
||||||
|
# 3.3 | pip | 10.0.1 |
|
||||||
|
# 3.4 | pip | 19.1.1 |
|
||||||
|
|
||||||
# Things that change more often go here.
|
# Things that change more often go here.
|
||||||
copyright = """
|
copyright = """
|
||||||
Copyright (C) 2015-2020 Rocky Bernstein <rb@dustyfeet.com>.
|
Copyright (C) 2015-2020 Rocky Bernstein <rb@dustyfeet.com>.
|
||||||
@@ -58,7 +69,7 @@ entry_points = {
|
|||||||
]}
|
]}
|
||||||
ftp_url = None
|
ftp_url = None
|
||||||
install_requires = ["spark-parser >= 1.8.9, < 1.9.0",
|
install_requires = ["spark-parser >= 1.8.9, < 1.9.0",
|
||||||
"xdis >= 4.5.1, < 4.6.0"]
|
"xdis >= 4.6.0, < 4.7.0"]
|
||||||
|
|
||||||
license = "GPL3"
|
license = "GPL3"
|
||||||
mailing_list = "python-debugger@googlegroups.com"
|
mailing_list = "python-debugger@googlegroups.com"
|
||||||
|
@@ -5,4 +5,4 @@ if [[ $0 == ${BASH_SOURCE[0]} ]] ; then
|
|||||||
echo "This script should be *sourced* rather than run directly through bash"
|
echo "This script should be *sourced* rather than run directly through bash"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
export PYVERSIONS='3.5.9 3.6.10 2.6.9 3.3.7 2.7.18 3.2.6 3.1.5 3.4.10 3.7.7 3.8.2'
|
export PYVERSIONS='3.5.9 3.6.10 2.6.9 3.3.7 2.7.18 3.2.6 3.1.5 3.4.10 3.7.7 3.8.3'
|
||||||
|
@@ -12,8 +12,7 @@ import functools
|
|||||||
from uncompyle6 import PYTHON_VERSION, PYTHON3, IS_PYPY, code_deparse
|
from uncompyle6 import PYTHON_VERSION, PYTHON3, IS_PYPY, code_deparse
|
||||||
|
|
||||||
# TODO : I think we can get xdis to support the dis api (python 3 version) by doing something like this there
|
# TODO : I think we can get xdis to support the dis api (python 3 version) by doing something like this there
|
||||||
from xdis.bytecode import Bytecode
|
from xdis import Bytecode, get_opcode
|
||||||
from xdis.main import get_opcode
|
|
||||||
|
|
||||||
opc = get_opcode(PYTHON_VERSION, IS_PYPY)
|
opc = get_opcode(PYTHON_VERSION, IS_PYPY)
|
||||||
Bytecode = functools.partial(Bytecode, opc=opc)
|
Bytecode = functools.partial(Bytecode, opc=opc)
|
||||||
|
72
setup.py
72
setup.py
@@ -4,40 +4,54 @@ import sys
|
|||||||
"""Setup script for the 'uncompyle6' distribution."""
|
"""Setup script for the 'uncompyle6' distribution."""
|
||||||
|
|
||||||
SYS_VERSION = sys.version_info[0:2]
|
SYS_VERSION = sys.version_info[0:2]
|
||||||
if not ((2, 6) <= SYS_VERSION <= (3, 9)):
|
if not ((2, 6) <= SYS_VERSION <= (3, 9)):
|
||||||
mess = "Python Release 2.6 .. 3.9 are supported in this code branch."
|
mess = "Python Release 2.6 .. 3.9 are supported in this code branch."
|
||||||
if ((2, 4) <= SYS_VERSION <= (2, 7)):
|
if (2, 4) <= SYS_VERSION <= (2, 7):
|
||||||
mess += ("\nFor your Python, version %s, use the python-2.4 code/branch." %
|
mess += (
|
||||||
sys.version[0:3])
|
"\nFor your Python, version %s, use the python-2.4 code/branch."
|
||||||
|
% sys.version[0:3]
|
||||||
|
)
|
||||||
elif SYS_VERSION < (2, 4):
|
elif SYS_VERSION < (2, 4):
|
||||||
mess += ("\nThis package is not supported for Python version %s."
|
mess += (
|
||||||
% sys.version[0:3])
|
"\nThis package is not supported for Python version %s." % sys.version[0:3]
|
||||||
|
)
|
||||||
print(mess)
|
print(mess)
|
||||||
raise Exception(mess)
|
raise Exception(mess)
|
||||||
|
|
||||||
from __pkginfo__ import \
|
from __pkginfo__ import (
|
||||||
author, author_email, install_requires, \
|
author,
|
||||||
license, long_description, classifiers, \
|
author_email,
|
||||||
entry_points, modname, py_modules, \
|
install_requires,
|
||||||
short_desc, VERSION, web, \
|
license,
|
||||||
zip_safe
|
long_description,
|
||||||
|
classifiers,
|
||||||
|
entry_points,
|
||||||
|
modname,
|
||||||
|
py_modules,
|
||||||
|
short_desc,
|
||||||
|
VERSION,
|
||||||
|
web,
|
||||||
|
zip_safe,
|
||||||
|
)
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
author = author,
|
author=author,
|
||||||
author_email = author_email,
|
author_email=author_email,
|
||||||
classifiers = classifiers,
|
classifiers=classifiers,
|
||||||
description = short_desc,
|
description=short_desc,
|
||||||
entry_points = entry_points,
|
entry_points=entry_points,
|
||||||
install_requires = install_requires,
|
install_requires=install_requires,
|
||||||
license = license,
|
license=license,
|
||||||
long_description = long_description,
|
long_description=long_description,
|
||||||
long_description_content_type = "text/x-rst",
|
long_description_content_type="text/x-rst",
|
||||||
name = modname,
|
name=modname,
|
||||||
packages = find_packages(),
|
packages=find_packages(),
|
||||||
py_modules = py_modules,
|
py_modules=py_modules,
|
||||||
test_suite = 'nose.collector',
|
test_suite="nose.collector",
|
||||||
url = web,
|
url=web,
|
||||||
tests_require = ['nose>=1.0'],
|
tests_require=["nose>=1.0"],
|
||||||
version = VERSION,
|
version=VERSION,
|
||||||
zip_safe = zip_safe)
|
zip_safe=zip_safe,
|
||||||
|
)
|
||||||
|
@@ -34,8 +34,8 @@ from __future__ import print_function
|
|||||||
import sys
|
import sys
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from xdis import iscode
|
from xdis import iscode, load_module
|
||||||
from xdis.load import check_object_path, load_module
|
from xdis.load import check_object_path
|
||||||
from uncompyle6.scanner import get_scanner
|
from uncompyle6.scanner import get_scanner
|
||||||
|
|
||||||
|
|
||||||
|
@@ -15,9 +15,15 @@
|
|||||||
|
|
||||||
from collections import deque
|
from collections import deque
|
||||||
|
|
||||||
from xdis import Bytecode, iscode, findlinestarts, load_file, load_module
|
from xdis import (
|
||||||
from xdis.main import get_opcode
|
Bytecode,
|
||||||
from xdis.bytecode import offset2line
|
iscode,
|
||||||
|
findlinestarts,
|
||||||
|
get_opcode,
|
||||||
|
offset2line,
|
||||||
|
load_file,
|
||||||
|
load_module,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def line_number_mapping(pyc_filename, src_filename):
|
def line_number_mapping(pyc_filename, src_filename):
|
||||||
|
@@ -23,8 +23,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from xdis import iscode
|
from xdis import iscode, py_str2float
|
||||||
from xdis.magics import py_str2float
|
|
||||||
from spark_parser import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
from spark_parser import GenericASTBuilder, DEFAULT_DEBUG as PARSER_DEFAULT_DEBUG
|
||||||
from uncompyle6.show import maybe_show_asm
|
from uncompyle6.show import maybe_show_asm
|
||||||
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
# Copyright (c) 2019 by Rocky Bernstein
|
# Copyright (c) 2019-2020 by Rocky Bernstein
|
||||||
"""
|
"""
|
||||||
Python PyPy 3.3 decompiler scanner.
|
Python PyPy 3.3 decompiler scanner.
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ import uncompyle6.scanners.scanner33 as scan
|
|||||||
|
|
||||||
# bytecode verification, verify(), uses JUMP_OPs from here
|
# bytecode verification, verify(), uses JUMP_OPs from here
|
||||||
from xdis.opcodes import opcode_33pypy as opc
|
from xdis.opcodes import opcode_33pypy as opc
|
||||||
|
|
||||||
JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs)
|
JUMP_OPs = map(lambda op: opc.opname[op], opc.hasjrel + opc.hasjabs)
|
||||||
|
|
||||||
# We base this off of 3.3
|
# We base this off of 3.3
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -67,8 +67,7 @@ from __future__ import print_function
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from xdis import iscode
|
from xdis import iscode, sysinfo2float
|
||||||
from xdis.magics import sysinfo2float
|
|
||||||
from uncompyle6.semantics import pysource
|
from uncompyle6.semantics import pysource
|
||||||
from uncompyle6 import parser
|
from uncompyle6 import parser
|
||||||
from uncompyle6.scanner import Token, Code, get_scanner
|
from uncompyle6.scanner import Token, Code, get_scanner
|
||||||
|
@@ -16,8 +16,7 @@
|
|||||||
All the crazy things we have to do to handle Python functions in 3.0-3.5 or so.
|
All the crazy things we have to do to handle Python functions in 3.0-3.5 or so.
|
||||||
The saga of changes before and after is in other files.
|
The saga of changes before and after is in other files.
|
||||||
"""
|
"""
|
||||||
from xdis import iscode, code_has_star_arg, code_has_star_star_arg
|
from xdis import iscode, code_has_star_arg, code_has_star_star_arg, CO_GENERATOR
|
||||||
from xdis.util import CO_GENERATOR
|
|
||||||
from uncompyle6.scanner import Code
|
from uncompyle6.scanner import Code
|
||||||
from uncompyle6.parsers.treenode import SyntaxTree
|
from uncompyle6.parsers.treenode import SyntaxTree
|
||||||
from uncompyle6 import PYTHON3
|
from uncompyle6 import PYTHON3
|
||||||
@@ -39,6 +38,7 @@ from uncompyle6.show import maybe_show_tree_param_default
|
|||||||
|
|
||||||
# FIXME: DRY the below code...
|
# FIXME: DRY the below code...
|
||||||
|
|
||||||
|
|
||||||
def make_function3_annotate(
|
def make_function3_annotate(
|
||||||
self, node, is_lambda, nested=1, code_node=None, annotate_last=-1
|
self, node, is_lambda, nested=1, code_node=None, annotate_last=-1
|
||||||
):
|
):
|
||||||
@@ -269,8 +269,8 @@ def make_function3_annotate(
|
|||||||
self.write("\n" + indent)
|
self.write("\n" + indent)
|
||||||
line_number = self.line_number
|
line_number = self.line_number
|
||||||
self.write(" -> ")
|
self.write(" -> ")
|
||||||
if 'return' in annotate_dict:
|
if "return" in annotate_dict:
|
||||||
self.write(annotate_dict['return'])
|
self.write(annotate_dict["return"])
|
||||||
else:
|
else:
|
||||||
# value, string = annotate_args['return']
|
# value, string = annotate_args['return']
|
||||||
# if string:
|
# if string:
|
||||||
@@ -427,9 +427,7 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
lc_index = -3
|
lc_index = -3
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if (len(node) > 2
|
if len(node) > 2 and (have_kwargs or node[lc_index].kind != "load_closure"):
|
||||||
and (have_kwargs or node[lc_index].kind != "load_closure")
|
|
||||||
):
|
|
||||||
|
|
||||||
# Find the index in "node" where the first default
|
# Find the index in "node" where the first default
|
||||||
# parameter value is located. Note this is in contrast to
|
# parameter value is located. Note this is in contrast to
|
||||||
@@ -480,7 +478,7 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
if is_lambda:
|
if is_lambda:
|
||||||
kwargs = []
|
kwargs = []
|
||||||
for i in range(kwonlyargcount):
|
for i in range(kwonlyargcount):
|
||||||
paramnames.append(scanner_code.co_varnames[argc+i])
|
paramnames.append(scanner_code.co_varnames[argc + i])
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
kwargs = list(scanner_code.co_varnames[argc : argc + kwonlyargcount])
|
kwargs = list(scanner_code.co_varnames[argc : argc + kwonlyargcount])
|
||||||
@@ -687,5 +685,5 @@ def make_function3(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
if need_bogus_yield:
|
if need_bogus_yield:
|
||||||
self.template_engine(("%|if False:\n%+%|yield None%-",), node)
|
self.template_engine(("%|if False:\n%+%|yield None%-",), node)
|
||||||
|
|
||||||
scanner_code._tokens = None # save memory
|
scanner_code._tokens = None # save memory
|
||||||
scanner_code._customize = None # save memory
|
scanner_code._customize = None # save memory
|
||||||
|
@@ -16,8 +16,13 @@
|
|||||||
All the crazy things we have to do to handle Python functions in 3.6 and above.
|
All the crazy things we have to do to handle Python functions in 3.6 and above.
|
||||||
The saga of changes before 3.6 is in other files.
|
The saga of changes before 3.6 is in other files.
|
||||||
"""
|
"""
|
||||||
from xdis import iscode, code_has_star_arg, code_has_star_star_arg
|
from xdis import (
|
||||||
from xdis.util import CO_GENERATOR, CO_ASYNC_GENERATOR
|
iscode,
|
||||||
|
code_has_star_arg,
|
||||||
|
code_has_star_star_arg,
|
||||||
|
CO_GENERATOR,
|
||||||
|
CO_ASYNC_GENERATOR,
|
||||||
|
)
|
||||||
from uncompyle6.scanner import Code
|
from uncompyle6.scanner import Code
|
||||||
from uncompyle6.parsers.treenode import SyntaxTree
|
from uncompyle6.parsers.treenode import SyntaxTree
|
||||||
from uncompyle6.semantics.parser_error import ParserError
|
from uncompyle6.semantics.parser_error import ParserError
|
||||||
@@ -107,9 +112,7 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
if annotate_node == "dict" and annotate_name_node.kind.startswith(
|
if annotate_node == "dict" and annotate_name_node.kind.startswith(
|
||||||
"BUILD_CONST_KEY_MAP"
|
"BUILD_CONST_KEY_MAP"
|
||||||
):
|
):
|
||||||
types = [
|
types = [self.traverse(n, indent="") for n in annotate_node[:-2]]
|
||||||
self.traverse(n, indent="") for n in annotate_node[:-2]
|
|
||||||
]
|
|
||||||
names = annotate_node[-2].attr
|
names = annotate_node[-2].attr
|
||||||
l = len(types)
|
l = len(types)
|
||||||
assert l == len(names)
|
assert l == len(names)
|
||||||
@@ -329,9 +332,7 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
self.write(" -> %s" % annotate_dict["return"])
|
self.write(" -> %s" % annotate_dict["return"])
|
||||||
self.println(":")
|
self.println(":")
|
||||||
|
|
||||||
if (
|
if node[-2] == "docstring" and not is_lambda:
|
||||||
node[-2] == "docstring" and not is_lambda
|
|
||||||
):
|
|
||||||
# docstring exists, dump it
|
# docstring exists, dump it
|
||||||
self.println(self.traverse(node[-2]))
|
self.println(self.traverse(node[-2]))
|
||||||
|
|
||||||
@@ -370,5 +371,5 @@ def make_function36(self, node, is_lambda, nested=1, code_node=None):
|
|||||||
if need_bogus_yield:
|
if need_bogus_yield:
|
||||||
self.template_engine(("%|if False:\n%+%|yield None%-",), node)
|
self.template_engine(("%|if False:\n%+%|yield None%-",), node)
|
||||||
|
|
||||||
scanner_code._tokens = None # save memory
|
scanner_code._tokens = None # save memory
|
||||||
scanner_code._customize = None # save memory
|
scanner_code._customize = None # save memory
|
||||||
|
Reference in New Issue
Block a user