From bf7b8615544059c075df814b2792e7b7fa4dcf24 Mon Sep 17 00:00:00 2001 From: alalazo Date: Mon, 28 Aug 2017 20:16:32 +0200 Subject: Fixed bug in Spec._dup, updated docstring The private method `Spec._dup` was missing a line (when setting compiler flags the parent spec was not set to `self`). This resulted in an inconsistent state of the duplicated Spec. This problem has been fixed here. The docstring of `Spec._dup` has been updated. --- lib/spack/spack/spec.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 2e61e88ddb..7bc0dce12a 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2543,15 +2543,24 @@ class Spec(object): def _dup(self, other, deps=True, cleardeps=True): """Copy the spec other into self. This is an overwriting - copy. It does not copy any dependents (parents), but by default - copies dependencies. + copy. It does not copy any dependents (parents), but by default + copies dependencies. - To duplicate an entire DAG, call _dup() on the root of the DAG. + To duplicate an entire DAG, call _dup() on the root of the DAG. + + Args: + other (Spec): spec to be copied onto ``self`` + deps (bool or Sequence): if True copies all the dependencies. If + False copies None. If a sequence of dependency types copy + only those types. + cleardeps (bool): if True clears the dependencies of ``self``, + before possibly copying the dependencies of ``other`` onto + ``self`` + + Returns: + True if ``self`` changed because of the copy operation, + False otherwise. - Options: - dependencies[=True] - Whether deps should be copied too. Set to False to copy a - spec but not its dependencies. """ # We don't count dependencies as changes here changed = True @@ -2577,6 +2586,7 @@ class Spec(object): self._dependents = DependencyMap(self) self._dependencies = DependencyMap(self) self.compiler_flags = other.compiler_flags.copy() + self.compiler_flags.spec = self self.variants = other.variants.copy() self.variants.spec = self self.external_path = other.external_path -- cgit v1.2.3-60-g2f50