summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2014-07-12 20:36:33 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2014-07-12 20:36:33 (GMT)
commit007a90317d154536f68278a69743418d8301ca3f (patch)
tree775f958402c37451f7cf70187e3df767561498b4
parentde1fb6660b212fc32e38119221a667188b907d67 (diff)
downloadcpython-007a90317d154536f68278a69743418d8301ca3f.zip
cpython-007a90317d154536f68278a69743418d8301ca3f.tar.gz
cpython-007a90317d154536f68278a69743418d8301ca3f.tar.bz2
Issue #21966: Respect -q command-line option when code module is ran.
Contributed by Anton Barkovsky.
-rw-r--r--Lib/code.py11
-rw-r--r--Misc/NEWS2
2 files changed, 12 insertions, 1 deletions
diff --git a/Lib/code.py b/Lib/code.py
index f8184b6..6186e04 100644
--- a/Lib/code.py
+++ b/Lib/code.py
@@ -7,6 +7,7 @@
import sys
import traceback
+import argparse
from codeop import CommandCompiler, compile_command
__all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact",
@@ -299,4 +300,12 @@ def interact(banner=None, readfunc=None, local=None):
if __name__ == "__main__":
- interact()
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-q', action='store_true',
+ help="don't print version and copyright messages")
+ args = parser.parse_args()
+ if args.q or sys.flags.quiet:
+ banner = ''
+ else:
+ banner = None
+ interact(banner)
diff --git a/Misc/NEWS b/Misc/NEWS
index ed3a4dc..f8c6abc 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -108,6 +108,8 @@ Core and Builtins
Library
-------
+- Issue #21966: Respect -q command-line option when code module is ran.
+
- Issue #19076: Don't pass the redundant 'file' argument to self.error().
- Issue #16382: Improve exception message of warnings.warn() for bad