Commit 09566891 authored by Nick Coghlan's avatar Nick Coghlan

Close #18538: ``python -m dis`` now uses argparse.

Patch by Michele Orrù.
parent e726ce1f
...@@ -436,25 +436,14 @@ class Bytecode: ...@@ -436,25 +436,14 @@ class Bytecode:
def _test(): def _test():
"""Simple test program to disassemble a file.""" """Simple test program to disassemble a file."""
if sys.argv[1:]: import argparse
if sys.argv[2:]:
sys.stderr.write("usage: python dis.py [-|file]\n") parser = argparse.ArgumentParser()
sys.exit(2) parser.add_argument('infile', type=argparse.FileType(), nargs='?', default='-')
fn = sys.argv[1] args = parser.parse_args()
if not fn or fn == "-": with args.infile as infile:
fn = None source = infile.read()
else: code = compile(source, args.infile.name, "exec")
fn = None
if fn is None:
f = sys.stdin
else:
f = open(fn)
source = f.read()
if fn is not None:
f.close()
else:
fn = "<stdin>"
code = compile(source, fn, "exec")
dis(code) dis(code)
if __name__ == "__main__": if __name__ == "__main__":
......
...@@ -40,6 +40,9 @@ Core and Builtins ...@@ -40,6 +40,9 @@ Core and Builtins
Library Library
------- -------
- Issue #18538: ``python -m dis`` now uses argparse for argument processing.
Patch by Michele Orrù.
- Issue #18394: Close cgi.FieldStorage's optional file. - Issue #18394: Close cgi.FieldStorage's optional file.
- Issue #17702: On error, os.environb now removes suppress the except context - Issue #17702: On error, os.environb now removes suppress the except context
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment