Skip to content

Commit 00155ab

Browse files
authored
Merge pull request #3473 from tai271828/pr-issue-2889-dis
feat(Lib): print the disassembled info
2 parents 2ceeea8 + acc75de commit 00155ab

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)