]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Issue #21966: Respect -q command-line option when code module is ran.
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>
Sat, 12 Jul 2014 20:36:33 +0000 (16:36 -0400)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>
Sat, 12 Jul 2014 20:36:33 +0000 (16:36 -0400)
Contributed by Anton Barkovsky.

Lib/code.py
Misc/NEWS

index f8184b6c22e5632d9e372553f90d289a827dafc2..6186e0414091de004bf934b96b53e2fa7dfb6eed 100644 (file)
@@ -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)
index ed3a4dc1bfa90f74a14a88a8128250d9c86f9770..f8c6abc120913d47b5c65bb5e1d40c8944fa5ffe 100644 (file)
--- 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