1
- # Copyright (c) 2015-2016, 2818-2022 by Rocky Bernstein
1
+ # Copyright (c) 2015-2016, 2818-2022, 2024 by Rocky Bernstein
2
2
# Copyright (c) 2005 by Dan Pascu <[email protected] >
3
3
# Copyright (c) 2000-2002 by hartmut Goebel <[email protected] >
4
4
# Copyright (c) 1999 John Aycock
17
17
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
18
19
19
"""
20
- CPython magic- and version- independent disassembly routines
20
+ CPython magic- and version-independent disassembly routines
21
21
22
22
There are two reasons we can't use Python's built-in routines
23
- from dis. First, the bytecode we are extracting may be from a different
23
+ from ``dis``.
24
+
25
+ First, the bytecode we are extracting may be from a different
24
26
version of Python (different magic number) than the version of Python
25
27
that is doing the extraction.
26
28
39
41
40
42
def disco (version , co , out = None , is_pypy = False ):
41
43
"""
42
- diassembles and deparses a given code block 'co'
44
+ diassembles and deparses a given code block ``co``.
43
45
"""
44
46
45
47
assert iscode (co )
46
48
47
- # store final output stream for case of error
49
+ # Store final output stream in case there is an error.
48
50
real_out = out or sys .stdout
49
51
print ("# Python %s" % version_tuple_to_str (version ), file = real_out )
50
52
if co .co_filename :
@@ -99,7 +101,7 @@ def disco_loop(disasm, queue, real_out):
99
101
100
102
def disassemble_file (filename , outstream = None ):
101
103
"""
102
- disassemble Python byte-code file (.pyc)
104
+ Disassemble Python byte-code file (.pyc).
103
105
104
106
If given a Python source file (".py") file, we'll
105
107
try to find the corresponding compiled object.
@@ -113,7 +115,6 @@ def disassemble_file(filename, outstream=None):
113
115
disco (version , con , outstream )
114
116
else :
115
117
disco (version , co , outstream , is_pypy = is_pypy )
116
- co = None
117
118
118
119
119
120
def _test ():
0 commit comments