diff --git a/Lib/dis.py b/Lib/dis.py index 421446e0a1..53c85555bc 100644 --- a/Lib/dis.py +++ b/Lib/dis.py @@ -1 +1,18 @@ from _dis import * + + +# Disassembling a file by following cpython Lib/dis.py +def _test(): + """Simple test program to disassemble a file.""" + import argparse + + parser = argparse.ArgumentParser() + parser.add_argument('infile', type=argparse.FileType('rb'), nargs='?', default='-') + args = parser.parse_args() + with args.infile as infile: + source = infile.read() + code = compile(source, args.infile.name, "exec") + dis(code) + +if __name__ == "__main__": + _test()