You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-03 00:45:53 +08:00
Merge hell
This commit is contained in:
@@ -5,12 +5,10 @@
|
||||
# by Rocky Bernstein
|
||||
# Copyright (c) 2000-2002 by hartmut Goebel <h.goebel@crazy-compilers.com>
|
||||
#
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import sys
|
||||
import time
|
||||
from typing import List
|
||||
|
||||
import click
|
||||
from xdis.version_info import version_tuple_to_str
|
||||
@@ -31,7 +29,6 @@ def usage():
|
||||
# Usage:
|
||||
# %s [OPTIONS]... [ FILE | DIR]...
|
||||
# %s [--help | -h | --V | --version]
|
||||
>>>>>>> master
|
||||
|
||||
# Examples:
|
||||
# %s foo.pyc bar.pyc # decompile foo.pyc, bar.pyc to stdout
|
||||
@@ -160,11 +157,11 @@ def main_bin(
|
||||
"""
|
||||
|
||||
version_tuple = sys.version_info[0:2]
|
||||
if version_tuple < (3, 7):
|
||||
if not ((3, 3) <= version_tuple < (3, 6)):
|
||||
print(
|
||||
f"Error: This version of the {program} runs from Python 3.7 or greater."
|
||||
f"You need another branch of this code for Python before 3.7."
|
||||
f""" \n\tYou have version: {version_tuple_to_str()}."""
|
||||
"Error: This version of the {program} runs from Python 3.3 to 3.6."
|
||||
"You need another branch of this code for other Python versions."
|
||||
" \n\tYou have version: %s." % version_tuple_to_str()
|
||||
)
|
||||
sys.exit(-1)
|
||||
|
||||
@@ -172,7 +169,7 @@ def main_bin(
|
||||
out_base = None
|
||||
|
||||
out_base = None
|
||||
source_paths: List[str] = []
|
||||
source_paths = []
|
||||
timestamp = False
|
||||
timestampfmt = "# %Y.%m.%d %H:%M:%S %Z"
|
||||
pyc_paths = files
|
||||
|
@@ -258,7 +258,7 @@ def main(
|
||||
outfile=None,
|
||||
showasm=None,
|
||||
showast={},
|
||||
do_verify = None,
|
||||
do_verify=None,
|
||||
showgrammar: bool = False,
|
||||
source_encoding=None,
|
||||
do_linemaps=False,
|
||||
@@ -358,10 +358,12 @@ def main(
|
||||
deparsed_object.f.close()
|
||||
if PYTHON_VERSION_TRIPLE[:2] != deparsed_object.version[:2]:
|
||||
sys.stdout.write(
|
||||
f"\n# skipping running {deparsed_object.f.name}; it is"
|
||||
f"{version_tuple_to_str(deparsed_object.version, end=2)}, "
|
||||
"and we are "
|
||||
f"{version_tuple_to_str(PYTHON_VERSION_TRIPLE, end=2)}\n"
|
||||
"\n# skipping running %s; it is %s and we are %s"
|
||||
% (
|
||||
deparsed_object.f.name,
|
||||
version_tuple_to_str(deparsed_object.version, end=2),
|
||||
version_tuple_to_str(PYTHON_VERSION_TRIPLE, end=2),
|
||||
)
|
||||
)
|
||||
else:
|
||||
check_type = "syntax check"
|
||||
@@ -385,10 +387,11 @@ def main(
|
||||
if not valid:
|
||||
verify_failed_files += 1
|
||||
sys.stderr.write(
|
||||
f"\n# {check_type} failed on file {deparsed_object.f.name}\n"
|
||||
"\n# %s failed on file %s\n"
|
||||
% (check_type, deparsed_object.f.name)
|
||||
)
|
||||
|
||||
# sys.stderr.write(f"Ran {deparsed_object.f.name}\n")
|
||||
# sys.stderr.write("Ran %\n" % deparsed_object.f.name)
|
||||
pass
|
||||
tot_files += 1
|
||||
except (ValueError, SyntaxError, ParserError, pysource.SourceWalkerError) as e:
|
||||
|
@@ -22,10 +22,8 @@ scanners, e.g. for Python 2.7 or 3.4.
|
||||
"""
|
||||
|
||||
import sys
|
||||
|
||||
from array import array
|
||||
from collections import namedtuple
|
||||
from types import ModuleType
|
||||
|
||||
import xdis
|
||||
from xdis import (
|
||||
@@ -629,11 +627,12 @@ def get_scanner(version, is_pypy=False, show_asm=None):
|
||||
# If version is a string, turn that into the corresponding float.
|
||||
if isinstance(version, str):
|
||||
if version not in canonic_python_version:
|
||||
raise RuntimeError(f"Unknown Python version in xdis {version}")
|
||||
raise RuntimeError("Unknown Python version in xdis %s" % version)
|
||||
canonic_version = canonic_python_version[version]
|
||||
if canonic_version not in CANONIC2VERSION:
|
||||
raise RuntimeError(
|
||||
f"Unsupported Python version {version} (canonic {canonic_version})"
|
||||
"Unsupported Python version %s (canonic %s)"
|
||||
% (version, canonic_version)
|
||||
)
|
||||
version = CANONIC2VERSION[canonic_version]
|
||||
|
||||
|
@@ -131,7 +131,6 @@ Python.
|
||||
|
||||
import sys
|
||||
from io import StringIO
|
||||
from typing import Optional
|
||||
|
||||
from spark_parser import GenericASTTraversal
|
||||
from xdis import COMPILER_FLAG_BIT, iscode
|
||||
@@ -808,9 +807,13 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
|
||||
node[index].kind,
|
||||
)
|
||||
else:
|
||||
assert node[tup[0]] in tup[1], (
|
||||
f"at {node.kind}[{tup[0]}], expected to be in '{tup[1]}' "
|
||||
f"node; got '{node[tup[0]].kind}'"
|
||||
assert (
|
||||
node[tup[0]] in tup[1]
|
||||
), "at %s[%d], expected to be in '%s' node; got '%s'" % (
|
||||
node.kind,
|
||||
arg,
|
||||
index[1],
|
||||
node[index[0]].kind,
|
||||
)
|
||||
|
||||
else:
|
||||
@@ -1281,7 +1284,7 @@ class SourceWalker(GenericASTTraversal, NonterminalActions, ComprehensionMixin):
|
||||
def code_deparse(
|
||||
co,
|
||||
out=sys.stdout,
|
||||
version: Optional[tuple] = None,
|
||||
version=None,
|
||||
debug_opts=DEFAULT_DEBUG_OPTS,
|
||||
code_objects={},
|
||||
compile_mode="exec",
|
||||
@@ -1289,7 +1292,7 @@ def code_deparse(
|
||||
walker=SourceWalker,
|
||||
start_offset: int = 0,
|
||||
stop_offset: int = -1,
|
||||
) -> Optional[SourceWalker]:
|
||||
):
|
||||
"""
|
||||
ingests and deparses a given code block 'co'. If version is None,
|
||||
we will use the current Python interpreter version.
|
||||
|
@@ -14,7 +14,6 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from copy import copy
|
||||
from typing import Optional
|
||||
|
||||
from spark_parser import GenericASTTraversal, GenericASTTraversalPruningException
|
||||
|
||||
@@ -73,7 +72,7 @@ class TreeTransform(GenericASTTraversal, object):
|
||||
self,
|
||||
version: tuple,
|
||||
is_pypy=False,
|
||||
show_ast: Optional[dict] = None,
|
||||
show_ast=None,
|
||||
):
|
||||
self.version = version
|
||||
self.showast = show_ast
|
||||
|
Reference in New Issue
Block a user