changeset: 91662:7f8843ec34ee user: Alexander Belopolsky date: Sat Jul 12 16:36:33 2014 -0400 files: Lib/code.py Misc/NEWS description: Issue #21966: Respect -q command-line option when code module is ran. Contributed by Anton Barkovsky. diff -r d891ad8aeb80 -r 7f8843ec34ee Lib/code.py --- a/Lib/code.py Sat Jul 12 18:26:03 2014 +0300 +++ b/Lib/code.py Sat Jul 12 16:36:33 2014 -0400 @@ -7,6 +7,7 @@ import sys import traceback +import argparse from codeop import CommandCompiler, compile_command __all__ = ["InteractiveInterpreter", "InteractiveConsole", "interact", @@ -299,4 +300,12 @@ 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 -r d891ad8aeb80 -r 7f8843ec34ee Misc/NEWS --- a/Misc/NEWS Sat Jul 12 18:26:03 2014 +0300 +++ b/Misc/NEWS Sat Jul 12 16:36:33 2014 -0400 @@ -108,6 +108,8 @@ 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