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
This commit is contained in:
Todd Gamblin 2019-07-20 00:21:18 -07:00 committed by Greg Becker
parent 7ec1d320a8
commit cc4094bb9b
2 changed files with 8 additions and 2 deletions

View file

@ -600,8 +600,8 @@ def _set_user_specs_from_lockfile(self):
"""Copy user_specs from a read-in lockfile.""" """Copy user_specs from a read-in lockfile."""
self.spec_lists = { self.spec_lists = {
user_speclist_name: SpecList( user_speclist_name: SpecList(
user_speclist_name, [Spec(s) user_speclist_name,
for s in self.concretized_user_specs] [str(s) for s in self.concretized_user_specs]
) )
} }

View file

@ -28,6 +28,12 @@ def __init__(self, name='specs', yaml_list=[], reference={}):
self.name = name self.name = name
self._reference = reference # TODO: Do we need defensive copy here? 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[:] self.yaml_list = yaml_list[:]
# Expansions can be expensive to compute and difficult to keep updated # Expansions can be expensive to compute and difficult to keep updated