From 4f80f07b9acdac3d1ac0907f40b832523085121a Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Wed, 5 Feb 2025 09:48:00 +0100 Subject: [PATCH] spec.py: fix hash change due to None vs {} (#48854) * Fix hash change due to None vs {} * Enforce null for empty list of external_modules --- lib/spack/spack/spec.py | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 5faa045c0d7..15eef1a748d 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -1538,9 +1538,8 @@ def __init__( self._external_path = external_path self.external_modules = Spec._format_module_list(external_modules) - # This attribute is used to store custom information for - # external specs. None signal that it was not set yet. - self.extra_attributes = None + # This attribute is used to store custom information for external specs. + self.extra_attributes: dict = {} # This attribute holds the original build copy of the spec if it is # deployed differently than it was built. None signals that the spec @@ -2252,16 +2251,11 @@ def to_node_dict(self, hash=ht.dag_hash): ) if self.external: - if self.extra_attributes: - extra_attributes = syaml.sorted_dict(self.extra_attributes) - else: - extra_attributes = None - d["external"] = syaml.syaml_dict( [ ("path", self.external_path), - ("module", self.external_modules), - ("extra_attributes", extra_attributes), + ("module", self.external_modules or None), + ("extra_attributes", syaml.sorted_dict(self.extra_attributes)), ] )