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