diff options
author | Peter Scheibel <scheibel1@llnl.gov> | 2020-05-25 06:08:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-25 15:08:47 +0200 |
commit | 768fa6bc531379519b8bbf0222367083a37c7dd3 (patch) | |
tree | 04b67ec9abffe9458e4a4e1f2c09f75c3be1504d /lib | |
parent | a3dc9cf848088360f8f9bd02e08b991b2ff93209 (diff) | |
download | spack-768fa6bc531379519b8bbf0222367083a37c7dd3.tar.gz spack-768fa6bc531379519b8bbf0222367083a37c7dd3.tar.bz2 spack-768fa6bc531379519b8bbf0222367083a37c7dd3.tar.xz spack-768fa6bc531379519b8bbf0222367083a37c7dd3.zip |
bugfix: schema errors without line numbers (#16765)
* account for schema validation errors where the associated instance doesn't have a line number
* fix unrelated flake error (but it must be fixed because this PR touches this file and the flake rules have been updated since the last edit to this file)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/environment.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index 43e91073e3..8d3b1438e1 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -406,8 +406,12 @@ def validate(data, filename=None): try: spack.schema.Validator(spack.schema.env.schema).validate(validate_data) except jsonschema.ValidationError as e: + if hasattr(e.instance, 'lc'): + line_number = e.instance.lc.line + 1 + else: + line_number = None raise spack.config.ConfigFormatError( - e, data, filename, e.instance.lc.line + 1) + e, data, filename, line_number) return validate_data @@ -1445,9 +1449,9 @@ class Environment(object): # The primary list is handled differently continue - active_yaml_lists = [l for l in yaml_dict.get('definitions', []) - if name in l and - _eval_conditional(l.get('when', 'True'))] + active_yaml_lists = [x for x in yaml_dict.get('definitions', []) + if name in x and + _eval_conditional(x.get('when', 'True'))] # Remove any specs in yaml that are not in internal representation for ayl in active_yaml_lists: |