From d11a4b2549a358b57aecab7939e8e64e9620cff1 Mon Sep 17 00:00:00 2001 From: Kamil Páral Date: Aug 25 2020 07:30:33 +0000 Subject: cli: don't silently consume all AttributeErrors The way it was written, it consumed all AttributeErrors that happened anywhere in the project, and exited the program (with a cmdline help message) without printing any traceback. Now it prints the error as it should. Merges: https://pagure.io/fedora-qa/blockerbugs/pull-request/130 --- diff --git a/blockerbugs/cli.py b/blockerbugs/cli.py index b7fb7e9..a8a0adf 100644 --- a/blockerbugs/cli.py +++ b/blockerbugs/cli.py @@ -341,13 +341,14 @@ def main(): args = parser.parse_args() - try: - args.func(args) - except AttributeError: + if not hasattr(args, 'func'): # if func attribute is missing, no command was specified, print help and exit parser.print_help() sys.exit(1) + # run the requested command + args.func(args) + if __name__ == '__main__': exit = main()