summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-13 21:53:38 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2020-05-13 21:53:38 +0900
commite6134500df5f122d16e70dfbd6a82b891cebf601 (patch)
treed73aea51e7da2490dd0450c1a6d77ef828bf50a1
parentbe45827bd4521eba286c8f8c5786c1d9a4ff83b4 (diff)
downloadbuildstream-e6134500df5f122d16e70dfbd6a82b891cebf601.tar.gz
utils.py: Improve error handling of _parse_version().
This was not reporting errors if not given a string, since we don't only pass strings parsed from project.conf but also pass plugin defined Plugin.BST_MIN_VERSION definitions, we should be more fault tolerant here.
-rw-r--r--src/buildstream/utils.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/buildstream/utils.py b/src/buildstream/utils.py
index 9f7690f7f..29b3bf484 100644
--- a/src/buildstream/utils.py
+++ b/src/buildstream/utils.py
@@ -1598,14 +1598,14 @@ def _is_single_threaded():
#
def _parse_version(version: str) -> Tuple[int, int]:
- versions = version.split(".")
try:
+ versions = version.split(".")
major = int(versions[0])
minor = int(versions[1])
- except (IndexError, ValueError):
- raise UtilError("Malformed version string: {}".format(version),)
+ except (IndexError, ValueError, AttributeError) as e:
+ raise UtilError("Malformed version string: {}".format(version),) from e
- return (major, minor)
+ return major, minor
# _get_bst_api_version():