Skip to content

Commit acc75de

Browse files
committed
feat(Lib): print the disassembled info
Issue: #2889
1 parent 9fb7070 commit acc75de

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Lib/dis.py

+17
Original file line numberDiff line numberDiff line change
@@ -1 +1,18 @@
11
from _dis import *
2+
3+
4+
# Disassembling a file by following cpython Lib/dis.py
5+
def _test():
6+
"""Simple test program to disassemble a file."""
7+
import argparse
8+
9+
parser = argparse.ArgumentParser()
10+
parser.add_argument('infile', type=argparse.FileType('rb'), nargs='?', default='-')
11+
args = parser.parse_args()
12+
with args.infile as infile:
13+
source = infile.read()
14+
code = compile(source, args.infile.name, "exec")
15+
dis(code)
16+
17+
if __name__ == "__main__":
18+
_test()

0 commit comments

Comments
 (0)