diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-23 19:35:02 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2017-10-23 19:35:02 +0900 |
commit | 32667b24b801f9b51da026b08e89f7fc55d8ac65 (patch) | |
tree | e538ca3feab7965a9fafbaca7cd45fe6c17fde9f | |
parent | 6173a3f1ca6fd5ac6d635f4d9b5d82fccddc37a4 (diff) | |
download | buildstream-32667b24b801f9b51da026b08e89f7fc55d8ac65.tar.gz |
_options/optionpool.py: Be strict with evaluation of undefined variables.
And also ensure that expression errors are reported with provenance.
-rw-r--r-- | buildstream/_options/optionpool.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/buildstream/_options/optionpool.py b/buildstream/_options/optionpool.py index 3400ca191..c2374c542 100644 --- a/buildstream/_options/optionpool.py +++ b/buildstream/_options/optionpool.py @@ -50,7 +50,7 @@ class OptionPool(): self.element_path = element_path # jinja2 environment, with default globals cleared out of the way - self.environment = jinja2.Environment() + self.environment = jinja2.Environment(undefined=jinja2.StrictUndefined) self.environment.globals = [] # load() @@ -226,8 +226,12 @@ class OptionPool(): "{}: Conditional statement has more than one key".format(p)) expression, value = tuples[0] - if self.evaluate(expression): - _yaml.composite(node, value) + try: + if self.evaluate(expression): + _yaml.composite(node, value) + except LoadError as e: + # Prepend the provenance of the error + raise LoadError(e.reason, "{}: {}".format(p, e)) from e return True |