diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2019-07-20 00:21:18 -0700 |
---|---|---|
committer | Greg Becker <becker33@llnl.gov> | 2019-07-22 13:45:34 -0500 |
commit | cc4094bb9b6b228ef9c3821e9e76361df50b7f94 (patch) | |
tree | 1e71dd051a46452af4a62d628a33144719fba3f5 | |
parent | 7ec1d320a82f28e465557046e4b75385bebda77e (diff) | |
download | spack-cc4094bb9b6b228ef9c3821e9e76361df50b7f94.tar.gz spack-cc4094bb9b6b228ef9c3821e9e76361df50b7f94.tar.bz2 spack-cc4094bb9b6b228ef9c3821e9e76361df50b7f94.tar.xz spack-cc4094bb9b6b228ef9c3821e9e76361df50b7f94.zip |
bugfix: env.write() should stringify Spec lists.
- Setting specs from lockfiles was not correctly stringifying concretized
user specs.
- Fix `_set_user_specs_from_lockfile`
- Add some validation code to `SpecList` constructor
-rw-r--r-- | lib/spack/spack/environment.py | 4 | ||||
-rw-r--r-- | lib/spack/spack/spec_list.py | 6 |
2 files changed, 8 insertions, 2 deletions
diff --git a/lib/spack/spack/environment.py b/lib/spack/spack/environment.py index 824f60d338..16f745f9e8 100644 --- a/lib/spack/spack/environment.py +++ b/lib/spack/spack/environment.py @@ -600,8 +600,8 @@ class Environment(object): """Copy user_specs from a read-in lockfile.""" self.spec_lists = { user_speclist_name: SpecList( - user_speclist_name, [Spec(s) - for s in self.concretized_user_specs] + user_speclist_name, + [str(s) for s in self.concretized_user_specs] ) } diff --git a/lib/spack/spack/spec_list.py b/lib/spack/spack/spec_list.py index 460e7846ed..88b4dd7e96 100644 --- a/lib/spack/spack/spec_list.py +++ b/lib/spack/spack/spec_list.py @@ -28,6 +28,12 @@ class SpecList(object): self.name = name self._reference = reference # TODO: Do we need defensive copy here? + # Validate yaml_list before assigning + if not all(isinstance(s, string_types) or isinstance(s, (list, dict)) + for s in yaml_list): + raise ValueError( + "yaml_list can contain only valid YAML types! Found:\n %s" + % [type(s) for s in yaml_list]) self.yaml_list = yaml_list[:] # Expansions can be expensive to compute and difficult to keep updated |