Skip to content

Commit 327af6e

Browse files
author
Colin D Bennett
committed
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'
1 parent acc1511 commit 327af6e

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

gitlab/cli.py

+8-1
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,14 @@ def main():
271271
config_files = arg.config_file
272272
gitlab_id = arg.gitlab
273273
verbose = arg.verbose
274-
action = arg.action
274+
275+
if hasattr(arg, "action"):
276+
action = arg.action
277+
else:
278+
sys.stderr.write("error: an action is required\n\n")
279+
parser.print_help()
280+
sys.exit(1)
281+
275282
what = arg.what
276283

277284
# Remove CLI behavior-related args

0 commit comments

Comments
 (0)