From cc4094bb9b6b228ef9c3821e9e76361df50b7f94 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Sat, 20 Jul 2019 00:21:18 -0700 Subject: 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 --- lib/spack/spack/environment.py | 4 ++-- lib/spack/spack/spec_list.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'lib') 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 -- cgit v1.2.3-70-g09d2