From 327af6ebd543a7c9feef73b415a74e9b301a708b Mon Sep 17 00:00:00 2001 From: Colin D Bennett Date: Wed, 23 Dec 2015 12:08:35 -0800 Subject: [PATCH] Check for action arg before use Check that the parsed `action` attribute exists before using it. Previously, whenever the command-line tool was invoked on Python 3.4 without a bare-word argument, which is expected to be the action, the program aborts with an AttributeError in cli.py on the line assigning `arg.action` to `action`: AttributeError: 'Namespace' object has no attribute 'action' --- gitlab/cli.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/gitlab/cli.py b/gitlab/cli.py index a1109b67e..a62d49a32 100644 --- a/gitlab/cli.py +++ b/gitlab/cli.py @@ -271,7 +271,14 @@ def main(): config_files = arg.config_file gitlab_id = arg.gitlab verbose = arg.verbose - action = arg.action + + if hasattr(arg, "action"): + action = arg.action + else: + sys.stderr.write("error: an action is required\n\n") + parser.print_help() + sys.exit(1) + what = arg.what # Remove CLI behavior-related args