summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbst-marge-bot <marge-bot@buildstream.build>2019-03-14 06:36:34 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-03-14 06:36:34 +0000
commit3c0aab96219c0c669daa964bd93abc384f699049 (patch)
treec70cfdaf3589ab8590c1dc64b57c11c025da6d99
parentac71ea61bc0cb551c744507d3d7f13ab85387d75 (diff)
parent8391bb6e41fedca33675a0b7196bc3056552c841 (diff)
downloadbuildstream-3c0aab96219c0c669daa964bd93abc384f699049.tar.gz
Merge branch 'tpollard/fix-complete-nonetype' into 'master'
_frontend/cli.py: Don't attempt to path NoneType in complete_target() Closes #958 See merge request BuildStream/buildstream!1228
-rw-r--r--buildstream/_frontend/cli.py19
1 files changed, 11 insertions, 8 deletions
diff --git a/buildstream/_frontend/cli.py b/buildstream/_frontend/cli.py
index d8c46ce0c..398bd85fc 100644
--- a/buildstream/_frontend/cli.py
+++ b/buildstream/_frontend/cli.py
@@ -86,15 +86,18 @@ def complete_target(args, incomplete):
# contain a project config file
base_directory, _ = utils._search_upward_for_files(base_directory, [project_conf])
- # Now parse the project.conf just to find the element path,
- # this is unfortunately a bit heavy.
- project_file = os.path.join(base_directory, project_conf)
- try:
- project = _yaml.load(project_file)
- except LoadError:
- # If there is no project directory in context, just dont
- # even bother trying to complete anything.
+ if base_directory is None:
+ # No project_conf was found in base_directory or its parents, no need
+ # to try loading any project conf and avoid os.path NoneType TypeError.
return []
+ else:
+ project_file = os.path.join(base_directory, project_conf)
+ try:
+ project = _yaml.load(project_file)
+ except LoadError:
+ # If there is no project conf in context, just dont
+ # even bother trying to complete anything.
+ return []
# The project is not required to have an element-path
element_directory = project.get('element-path')