Skip to content

Commit 6568c28

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

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

Lib/dis.py

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

0 commit comments

Comments
 (0)