From 752c0d4fe263e8db45dd271f607a8625a6264dc9 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 30 Apr 2024 11:47:51 -0700 Subject: [PATCH] clarify comment on use of _package_hash Signed-off-by: Todd Gamblin --- lib/spack/spack/spec.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 56446e4b1c3..94f865818ee 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -2202,10 +2202,12 @@ def to_node_dict(self, hash=ht.dag_hash): d["concrete"] = False if self._concrete and hash.package_hash: - # We use the attribute here instead of `self.package_hash()` because this should - # *always* be assigned at concretization time. We don't want to try to compute a - # package hash for concrete spec where a) the package might not exist, or b) the - # `dag_hash` didn't include the package hash when the spec was concretized. + # We use the `_package_hash` attribute here instead of `self.package_hash()` + # because `_package_hash` is *always* assigned at concretization time. If + # the attribute is present, we should include it. If it isn't, we avoid + # computing it because a) the package may no longer exist, or b) this is an + # older spec and the `dag_hash` didn't include the package hash when the + # spec was concretized. if hasattr(self, "_package_hash") and self._package_hash: d["package_hash"] = self._package_hash