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 @@ def _set_user_specs_from_lockfile(self): """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 @@ def __init__(self, name='specs', yaml_list=[], reference={}): 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