You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Misc lint stuff from pycharm...
that has been applied to decompyle3 already
This commit is contained in:
@@ -2,3 +2,8 @@
|
|||||||
hypothesis==2.0.0
|
hypothesis==2.0.0
|
||||||
pytest
|
pytest
|
||||||
-e .
|
-e .
|
||||||
|
|
||||||
|
Click~=7.0
|
||||||
|
xdis>=6.0.4
|
||||||
|
configobj~=5.0.6
|
||||||
|
setuptools~=65.3.0
|
||||||
|
7
setup.py
7
setup.py
@@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
import setuptools
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
"""Setup script for the 'uncompyle6' distribution."""
|
"""Setup script for the 'uncompyle6' distribution."""
|
||||||
@@ -39,9 +40,7 @@ from __pkginfo__ import (
|
|||||||
zip_safe,
|
zip_safe,
|
||||||
)
|
)
|
||||||
|
|
||||||
from setuptools import setup, find_packages
|
setuptools.setup(
|
||||||
|
|
||||||
setup(
|
|
||||||
author=author,
|
author=author,
|
||||||
author_email=author_email,
|
author_email=author_email,
|
||||||
classifiers=classifiers,
|
classifiers=classifiers,
|
||||||
@@ -52,7 +51,7 @@ setup(
|
|||||||
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=setuptools.find_packages(),
|
||||||
py_modules=py_modules,
|
py_modules=py_modules,
|
||||||
test_suite="nose.collector",
|
test_suite="nose.collector",
|
||||||
url=web,
|
url=web,
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
import sys, os, getopt
|
import sys, os, getopt
|
||||||
|
|
||||||
from uncompyle6.disas import disassemble_file
|
from uncompyle6.code_fns import disassemble_file
|
||||||
from uncompyle6.version import __version__
|
from uncompyle6.version import __version__
|
||||||
|
|
||||||
program, ext = os.path.splitext(os.path.basename(__file__))
|
program, ext = os.path.splitext(os.path.basename(__file__))
|
||||||
|
@@ -18,7 +18,7 @@ import datetime, py_compile, os, sys
|
|||||||
|
|
||||||
from xdis import iscode
|
from xdis import iscode
|
||||||
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE, version_tuple_to_str
|
from xdis.version_info import IS_PYPY, PYTHON_VERSION_TRIPLE, version_tuple_to_str
|
||||||
from uncompyle6.disas import check_object_path
|
from uncompyle6.code_fns import check_object_path
|
||||||
from uncompyle6.semantics import pysource
|
from uncompyle6.semantics import pysource
|
||||||
from uncompyle6.semantics.pysource import PARSER_DEFAULT_DEBUG
|
from uncompyle6.semantics.pysource import PARSER_DEFAULT_DEBUG
|
||||||
from uncompyle6.parser import ParserError
|
from uncompyle6.parser import ParserError
|
||||||
|
@@ -133,9 +133,9 @@ class Scanner(object):
|
|||||||
assert count <= i
|
assert count <= i
|
||||||
|
|
||||||
if collection_type == "CONST_DICT":
|
if collection_type == "CONST_DICT":
|
||||||
# constant dictonaries work via BUILD_CONST_KEY_MAP and
|
# constant dictionaries work via BUILD_CONST_KEY_MAP and
|
||||||
# handle the values() like sets and lists.
|
# handle the values() like sets and lists.
|
||||||
# However the keys() are an LOAD_CONST of the keys.
|
# However, the keys() are an LOAD_CONST of the keys.
|
||||||
# adjust offset to account for this
|
# adjust offset to account for this
|
||||||
count += 1
|
count += 1
|
||||||
|
|
||||||
|
@@ -13,6 +13,7 @@ from xdis.opcodes import opcode_37pypy as opc # is this right?
|
|||||||
|
|
||||||
JUMP_OPs = opc.JUMP_OPS
|
JUMP_OPs = opc.JUMP_OPS
|
||||||
|
|
||||||
|
|
||||||
# We base this off of 3.7
|
# We base this off of 3.7
|
||||||
class ScannerPyPy37(scan.Scanner37):
|
class ScannerPyPy37(scan.Scanner37):
|
||||||
def __init__(self, show_asm):
|
def __init__(self, show_asm):
|
||||||
|
@@ -13,6 +13,7 @@ from xdis.opcodes import opcode_38pypy as opc
|
|||||||
|
|
||||||
JUMP_OPs = opc.JUMP_OPS
|
JUMP_OPs = opc.JUMP_OPS
|
||||||
|
|
||||||
|
|
||||||
# We base this off of 3.8
|
# We base this off of 3.8
|
||||||
class ScannerPyPy38(scan.Scanner38):
|
class ScannerPyPy38(scan.Scanner38):
|
||||||
def __init__(self, show_asm):
|
def __init__(self, show_asm):
|
||||||
|
@@ -120,7 +120,7 @@ class Scanner37(Scanner37Base):
|
|||||||
return new_tokens
|
return new_tokens
|
||||||
|
|
||||||
def ingest(
|
def ingest(
|
||||||
self, co, classname=None, code_objects={}, show_asm=None
|
self, bytecode, classname=None, code_objects={}, show_asm=None
|
||||||
) -> Tuple[list, dict]:
|
) -> Tuple[list, dict]:
|
||||||
"""
|
"""
|
||||||
Create "tokens" the bytecode of an Python code object. Largely these
|
Create "tokens" the bytecode of an Python code object. Largely these
|
||||||
@@ -141,7 +141,7 @@ class Scanner37(Scanner37Base):
|
|||||||
cause specific rules for the specific number of arguments they take.
|
cause specific rules for the specific number of arguments they take.
|
||||||
"""
|
"""
|
||||||
tokens, customize = Scanner37Base.ingest(
|
tokens, customize = Scanner37Base.ingest(
|
||||||
self, co, classname, code_objects, show_asm
|
self, bytecode, classname, code_objects, show_asm
|
||||||
)
|
)
|
||||||
new_tokens = []
|
new_tokens = []
|
||||||
for i, t in enumerate(tokens):
|
for i, t in enumerate(tokens):
|
||||||
|
@@ -47,14 +47,18 @@ import sys
|
|||||||
globals().update(op3.opmap)
|
globals().update(op3.opmap)
|
||||||
|
|
||||||
|
|
||||||
|
CONST_COLLECTIONS = ("CONST_LIST", "CONST_SET", "CONST_DICT")
|
||||||
|
|
||||||
|
|
||||||
class Scanner37Base(Scanner):
|
class Scanner37Base(Scanner):
|
||||||
def __init__(self, version: Tuple[int], show_asm=None, debug="", is_pypy=False):
|
def __init__(self, version: Tuple[int, int], show_asm=None, debug="", is_pypy=False):
|
||||||
super(Scanner37Base, self).__init__(version, show_asm, is_pypy)
|
super(Scanner37Base, self).__init__(version, show_asm, is_pypy)
|
||||||
|
self.offset2tok_index = None
|
||||||
self.debug = debug
|
self.debug = debug
|
||||||
self.is_pypy = is_pypy
|
self.is_pypy = is_pypy
|
||||||
|
|
||||||
# Create opcode classification sets
|
# Create opcode classification sets
|
||||||
# Note: super initilization above initializes self.opc
|
# Note: super initialization above initializes self.opc
|
||||||
|
|
||||||
# Ops that start SETUP_ ... We will COME_FROM with these names
|
# Ops that start SETUP_ ... We will COME_FROM with these names
|
||||||
# Some blocks and END_ statements. And they can start
|
# Some blocks and END_ statements. And they can start
|
||||||
@@ -139,7 +143,7 @@ class Scanner37Base(Scanner):
|
|||||||
self.opc.POP_JUMP_IF_FALSE,
|
self.opc.POP_JUMP_IF_FALSE,
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
# Not really a set, but still clasification-like
|
# Not really a set, but still classification-like
|
||||||
self.statement_opcode_sequences = [
|
self.statement_opcode_sequences = [
|
||||||
(self.opc.POP_JUMP_IF_FALSE, self.opc.JUMP_FORWARD),
|
(self.opc.POP_JUMP_IF_FALSE, self.opc.JUMP_FORWARD),
|
||||||
(self.opc.POP_JUMP_IF_FALSE, self.opc.JUMP_ABSOLUTE),
|
(self.opc.POP_JUMP_IF_FALSE, self.opc.JUMP_ABSOLUTE),
|
||||||
@@ -274,7 +278,7 @@ class Scanner37Base(Scanner):
|
|||||||
if inst.opname == "JUMP_FORWARD":
|
if inst.opname == "JUMP_FORWARD":
|
||||||
jump_inst = self.insts[self.offset2inst_index[inst.argval]]
|
jump_inst = self.insts[self.offset2inst_index[inst.argval]]
|
||||||
if jump_inst.has_extended_arg and jump_inst.opname.startswith("JUMP"):
|
if jump_inst.has_extended_arg and jump_inst.opname.startswith("JUMP"):
|
||||||
# Create comination of the jump-to instruction and
|
# Create a combination of the jump-to instruction and
|
||||||
# this one. Keep the position information of this instruction,
|
# this one. Keep the position information of this instruction,
|
||||||
# but the operator and operand properties come from the other
|
# but the operator and operand properties come from the other
|
||||||
# instruction
|
# instruction
|
||||||
@@ -442,9 +446,9 @@ class Scanner37Base(Scanner):
|
|||||||
elif op == self.opc.JUMP_ABSOLUTE:
|
elif op == self.opc.JUMP_ABSOLUTE:
|
||||||
# Refine JUMP_ABSOLUTE further in into:
|
# Refine JUMP_ABSOLUTE further in into:
|
||||||
#
|
#
|
||||||
# * "JUMP_LOOP" - which are are used in loops. This is sometimes
|
# * "JUMP_LOOP" - which are used in loops. This is sometimes
|
||||||
# found at the end of a looping construct
|
# found at the end of a looping construct
|
||||||
# * "BREAK_LOOP" - which are are used to break loops.
|
# * "BREAK_LOOP" - which are used to break loops.
|
||||||
# * "CONTINUE" - jumps which may appear in a "continue" statement.
|
# * "CONTINUE" - jumps which may appear in a "continue" statement.
|
||||||
# It is okay to confuse this with JUMP_LOOP. The
|
# It is okay to confuse this with JUMP_LOOP. The
|
||||||
# grammar should tolerate this.
|
# grammar should tolerate this.
|
||||||
|
@@ -44,7 +44,7 @@ class Scanner38(Scanner37):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def ingest(
|
def ingest(
|
||||||
self, co, classname=None, code_objects={}, show_asm=None
|
self, bytecode, classname=None, code_objects={}, show_asm=None
|
||||||
) -> Tuple[list, dict]:
|
) -> Tuple[list, dict]:
|
||||||
"""
|
"""
|
||||||
Create "tokens" the bytecode of an Python code object. Largely these
|
Create "tokens" the bytecode of an Python code object. Largely these
|
||||||
@@ -65,7 +65,7 @@ class Scanner38(Scanner37):
|
|||||||
cause specific rules for the specific number of arguments they take.
|
cause specific rules for the specific number of arguments they take.
|
||||||
"""
|
"""
|
||||||
tokens, customize = super(Scanner38, self).ingest(
|
tokens, customize = super(Scanner38, self).ingest(
|
||||||
co, classname, code_objects, show_asm
|
bytecode, classname, code_objects, show_asm
|
||||||
)
|
)
|
||||||
|
|
||||||
# Hacky way to detect loop ranges.
|
# Hacky way to detect loop ranges.
|
||||||
|
@@ -15,7 +15,8 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import re, sys
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
intern = sys.intern
|
intern = sys.intern
|
||||||
|
|
||||||
@@ -87,7 +88,7 @@ class Token:
|
|||||||
print(f"I don't know about Python version {e} yet.")
|
print(f"I don't know about Python version {e} yet.")
|
||||||
try:
|
try:
|
||||||
version_tuple = tuple(int(i) for i in str(e)[1:-1].split("."))
|
version_tuple = tuple(int(i) for i in str(e)[1:-1].split("."))
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
if version_tuple > (3, 9):
|
if version_tuple > (3, 9):
|
||||||
|
Reference in New Issue
Block a user