Misc lint stuff from pycharm...

that has been applied to decompyle3 already
This commit is contained in:
rocky 2022-09-16 15:38:13 -04:00
parent 4260deea11
commit 4b2a2e218a
12 changed files with 31 additions and 20 deletions

View File

@ -2,3 +2,8 @@
hypothesis==2.0.0
pytest
-e .
Click~=7.0
xdis>=6.0.4
configobj~=5.0.6
setuptools~=65.3.0

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python
import setuptools
import sys
"""Setup script for the 'uncompyle6' distribution."""
@ -39,9 +40,7 @@ from __pkginfo__ import (
zip_safe,
)
from setuptools import setup, find_packages
setup(
setuptools.setup(
author=author,
author_email=author_email,
classifiers=classifiers,
@ -52,7 +51,7 @@ setup(
long_description=long_description,
long_description_content_type="text/x-rst",
name=modname,
packages=find_packages(),
packages=setuptools.find_packages(),
py_modules=py_modules,
test_suite="nose.collector",
url=web,

View File

@ -6,7 +6,7 @@
from __future__ import print_function
import sys, os, getopt
from uncompyle6.disas import disassemble_file
from uncompyle6.code_fns import disassemble_file
from uncompyle6.version import __version__
program, ext = os.path.splitext(os.path.basename(__file__))

View File

@ -18,7 +18,7 @@ import datetime, py_compile, os, sys
from xdis import iscode
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.pysource import PARSER_DEFAULT_DEBUG
from uncompyle6.parser import ParserError

View File

@ -133,9 +133,9 @@ class Scanner(object):
assert count <= i
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.
# 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
count += 1

View File

@ -13,6 +13,7 @@ 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):

View File

@ -13,6 +13,7 @@ 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):

View File

@ -120,7 +120,7 @@ class Scanner37(Scanner37Base):
return new_tokens
def ingest(
self, co, classname=None, code_objects={}, show_asm=None
self, bytecode, classname=None, code_objects={}, show_asm=None
) -> Tuple[list, dict]:
"""
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.
"""
tokens, customize = Scanner37Base.ingest(
self, co, classname, code_objects, show_asm
self, bytecode, classname, code_objects, show_asm
)
new_tokens = []
for i, t in enumerate(tokens):

View File

@ -47,14 +47,18 @@ import sys
globals().update(op3.opmap)
CONST_COLLECTIONS = ("CONST_LIST", "CONST_SET", "CONST_DICT")
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)
self.offset2tok_index = None
self.debug = debug
self.is_pypy = is_pypy
# 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
# Some blocks and END_ statements. And they can start
@ -139,7 +143,7 @@ class Scanner37Base(Scanner):
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.opc.POP_JUMP_IF_FALSE, self.opc.JUMP_FORWARD),
(self.opc.POP_JUMP_IF_FALSE, self.opc.JUMP_ABSOLUTE),
@ -274,7 +278,7 @@ class Scanner37Base(Scanner):
if inst.opname == "JUMP_FORWARD":
jump_inst = self.insts[self.offset2inst_index[inst.argval]]
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,
# but the operator and operand properties come from the other
# instruction
@ -442,9 +446,9 @@ class Scanner37Base(Scanner):
elif op == self.opc.JUMP_ABSOLUTE:
# 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
# * "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.
# It is okay to confuse this with JUMP_LOOP. The
# grammar should tolerate this.

View File

@ -44,7 +44,7 @@ class Scanner38(Scanner37):
pass
def ingest(
self, co, classname=None, code_objects={}, show_asm=None
self, bytecode, classname=None, code_objects={}, show_asm=None
) -> Tuple[list, dict]:
"""
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.
"""
tokens, customize = super(Scanner38, self).ingest(
co, classname, code_objects, show_asm
bytecode, classname, code_objects, show_asm
)
# Hacky way to detect loop ranges.

View File

@ -15,7 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re, sys
import re
import sys
intern = sys.intern
@ -87,7 +88,7 @@ class Token:
print(f"I don't know about Python version {e} yet.")
try:
version_tuple = tuple(int(i) for i in str(e)[1:-1].split("."))
except:
except Exception:
pass
else:
if version_tuple > (3, 9):