From 5580b2b7959b58463b4b1753ee2a166ae1010b0e Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 21 Jul 2024 12:53:34 -0400 Subject: [PATCH 1/6] Bump min xdis version --- __pkginfo__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/__pkginfo__.py b/__pkginfo__.py index 2f220105..1c9f5c84 100644 --- a/__pkginfo__.py +++ b/__pkginfo__.py @@ -79,7 +79,7 @@ entry_points = { ] } ftp_url = None -install_requires = ["click", "spark-parser >= 1.8.9, < 1.9.0", "xdis >= 6.0.8, < 6.2.0"] +install_requires = ["click", "spark-parser >= 1.8.9, < 1.9.0", "xdis >= 6.1.1, < 6.2.0"] license = "GPL3" mailing_list = "python-debugger@googlegroups.com" From 1a3f2b8ab018aab0d17ecadfc49bf2dfed5809f5 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 21 Jul 2024 17:34:06 -0400 Subject: [PATCH 2/6] Misc lint --- uncompyle6/parsers/reducecheck/except_handler.py | 5 +++-- uncompyle6/parsers/reducecheck/ifelsestmt.py | 2 +- uncompyle6/semantics/consts.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/uncompyle6/parsers/reducecheck/except_handler.py b/uncompyle6/parsers/reducecheck/except_handler.py index 8d2341d9..af64be2d 100644 --- a/uncompyle6/parsers/reducecheck/except_handler.py +++ b/uncompyle6/parsers/reducecheck/except_handler.py @@ -1,7 +1,8 @@ # Copyright (c) 2020 Rocky Bernstein + def except_handler(self, lhs, n, rule, ast, tokens, first, last): - end_token = tokens[last-1] + end_token = tokens[last - 1] # print("XXX", first, last) # for t in range(first, last): @@ -13,7 +14,7 @@ def except_handler(self, lhs, n, rule, ast, tokens, first, last): if self.version[:2] == (1, 4): return False - # Make sure come froms all come from within "except_handler". + # Make sure COME_FROMs froms come from within "except_handler". if end_token != "COME_FROM": return False return end_token.attr < tokens[first].offset diff --git a/uncompyle6/parsers/reducecheck/ifelsestmt.py b/uncompyle6/parsers/reducecheck/ifelsestmt.py index 7e7bff9e..e5f295a7 100644 --- a/uncompyle6/parsers/reducecheck/ifelsestmt.py +++ b/uncompyle6/parsers/reducecheck/ifelsestmt.py @@ -172,7 +172,7 @@ def ifelsestmt(self, lhs, n, rule, tree, tokens, first, last): if raise_stmt1 == "raise_stmt1" and raise_stmt1[0] in ("LOAD_ASSERT",): return True - # Make sure all the offsets from the "come froms" at the + # Make sure all the offsets from the "COME_FROMs" at the # end of the "if" come from somewhere inside the "if". # Since the come_froms are ordered so that lowest # offset COME_FROM is last, it is sufficient to test diff --git a/uncompyle6/semantics/consts.py b/uncompyle6/semantics/consts.py index 7ea9967b..b7e12d4f 100644 --- a/uncompyle6/semantics/consts.py +++ b/uncompyle6/semantics/consts.py @@ -433,7 +433,7 @@ TABLE_DIRECT = { # function_def_async "mkfuncdeco0": ("%|def %c\n", (0, ("mkfunc", "mkfunc_annotate"))), - # In cases where we desire an explict new line. + # In cases where we desire an explicit new line. # After docstrings which are followed by a "def" is # one situations where Python formatting desires two newlines, # and this is added, as a transformation rule. From 1d705b0451db0bfb321ddcdc95d95a073b265d6f Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 21 Jul 2024 17:37:15 -0400 Subject: [PATCH 3/6] Merge --- uncompyle6/semantics/fragments.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/uncompyle6/semantics/fragments.py b/uncompyle6/semantics/fragments.py index 38ade16a..35d43cbe 100644 --- a/uncompyle6/semantics/fragments.py +++ b/uncompyle6/semantics/fragments.py @@ -1903,9 +1903,13 @@ class FragmentsWalker(pysource.SourceWalker, object): 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, + tup[0], + tup[1], + node[index].kind, ) else: From b0dd7f57c6bb8aa5919438975337222ae0a7a47b Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 21 Jul 2024 18:36:12 -0400 Subject: [PATCH 4/6] Lint --- uncompyle6/code_fns.py | 15 ++++++++------- uncompyle6/parser.py | 2 ++ 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/uncompyle6/code_fns.py b/uncompyle6/code_fns.py index 60a21143..ff27f2a5 100644 --- a/uncompyle6/code_fns.py +++ b/uncompyle6/code_fns.py @@ -1,4 +1,4 @@ -# Copyright (c) 2015-2016, 2818-2022 by Rocky Bernstein +# Copyright (c) 2015-2016, 2818-2022, 2024 by Rocky Bernstein # Copyright (c) 2005 by Dan Pascu # Copyright (c) 2000-2002 by hartmut Goebel # Copyright (c) 1999 John Aycock @@ -17,10 +17,12 @@ # along with this program. If not, see . """ -CPython magic- and version- independent disassembly routines +CPython magic- and version-independent disassembly routines There are two reasons we can't use Python's built-in routines -from dis. First, the bytecode we are extracting may be from a different +from ``dis``. + +First, the bytecode we are extracting may be from a different version of Python (different magic number) than the version of Python that is doing the extraction. @@ -39,12 +41,12 @@ from uncompyle6.scanner import get_scanner def disco(version, co, out=None, is_pypy=False): """ - diassembles and deparses a given code block 'co' + diassembles and deparses a given code block ``co``. """ assert iscode(co) - # store final output stream for case of error + # Store final output stream in case there is an error. real_out = out or sys.stdout print("# Python %s" % version_tuple_to_str(version), file=real_out) if co.co_filename: @@ -99,7 +101,7 @@ def disco_loop(disasm, queue, real_out): def disassemble_file(filename, outstream=None): """ - disassemble Python byte-code file (.pyc) + Disassemble Python byte-code file (.pyc). If given a Python source file (".py") file, we'll try to find the corresponding compiled object. @@ -113,7 +115,6 @@ def disassemble_file(filename, outstream=None): disco(version, con, outstream) else: disco(version, co, outstream, is_pypy=is_pypy) - co = None def _test(): diff --git a/uncompyle6/parser.py b/uncompyle6/parser.py index 8a702d84..2409f9f1 100644 --- a/uncompyle6/parser.py +++ b/uncompyle6/parser.py @@ -669,6 +669,8 @@ def get_python_parser( version = version[:2] + p = None + # FIXME: there has to be a better way... # We could do this as a table lookup, but that would force us # in import all of the parsers all of the time. Perhaps there is From f9b20f6eda78ae40467c23e67cbee51b1c65bbd8 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 21 Jul 2024 18:48:32 -0400 Subject: [PATCH 5/6] Get ready for release 3.9.2 --- NEWS.md | 6 ++++++ pyproject.toml | 4 ++-- requirements.txt | 2 +- uncompyle6/version.py | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 853dd00c..6a7c2300 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +3.9.2: 2024-07-21 +================= + +- track xdis API changes +- Bug fixes and lint + 3.9.1: 2024-05-15 ================= diff --git a/pyproject.toml b/pyproject.toml index d78c173e..60afb6ef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] requires = [ - "setuptools>=61.2", + "setuptools>=71.0.3", ] build-backend = "setuptools.build_meta" @@ -15,7 +15,7 @@ description = "Python cross-version byte-code library and disassembler" dependencies = [ "click", "spark-parser >= 1.8.9, < 1.9.0", - "xdis >= 6.0.8, < 6.2.0", + "xdis >= 6.1.0, < 6.2.0", ] readme = "README.rst" license = {text = "GPL"} diff --git a/requirements.txt b/requirements.txt index fba9e512..e41efd9c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ pytest Click~=7.0 xdis>=6.0.4 configobj~=5.0.6 -setuptools~=65.5.1 +setuptools~=71.0.3 diff --git a/uncompyle6/version.py b/uncompyle6/version.py index 669350ed..2cb4ba48 100644 --- a/uncompyle6/version.py +++ b/uncompyle6/version.py @@ -14,4 +14,4 @@ # This file is suitable for sourcing inside POSIX shell as # well as importing into Python # fmt: off -__version__="3.9.1" # noqa +__version__="3.9.2" # noqa From a35a19d230871c346bda4ef6d8f7eb53e8b78928 Mon Sep 17 00:00:00 2001 From: rocky Date: Sun, 21 Jul 2024 18:57:43 -0400 Subject: [PATCH 6/6] Merge --- requirements.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index e41efd9c..58222c58 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,6 @@ pytest -e . Click~=7.0 -xdis>=6.0.4 +xdis >= 6.1.0, < 6.2.0 configobj~=5.0.6 -setuptools~=71.0.3 +setuptools~=59.6.0