diff options
author | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-03-14 04:46:25 +0000 |
---|---|---|
committer | Tom Pollard <tom.pollard@codethink.co.uk> | 2019-03-14 05:23:02 +0000 |
commit | 8391bb6e41fedca33675a0b7196bc3056552c841 (patch) | |
tree | c70cfdaf3589ab8590c1dc64b57c11c025da6d99 /buildstream | |
parent | ac71ea61bc0cb551c744507d3d7f13ab85387d75 (diff) | |
download | buildstream-8391bb6e41fedca33675a0b7196bc3056552c841.tar.gz |
_frontend/cli.py: Don't attempt to path NoneType in complete_target()
Diffstat (limited to 'buildstream')
-rw-r--r-- | buildstream/_frontend/cli.py | 19 |
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') |