spec.py: use json.dumps directly to avoid hash breakage (#48884)

This commit is contained in:
Harmen Stoppels 2025-02-20 17:39:07 +01:00 committed by GitHub
parent c8d7aa1772
commit 3e8cb852b0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -52,6 +52,7 @@
import enum
import io
import itertools
import json
import os
import pathlib
import platform
@ -2145,7 +2146,9 @@ def spec_hash(self, hash):
if hash.override is not None:
return hash.override(self)
node_dict = self.to_node_dict(hash=hash)
json_text = sjson.dump(node_dict)
json_text = json.dumps(
node_dict, ensure_ascii=True, indent=None, separators=(",", ":"), sort_keys=False
)
# This implements "frankenhashes", preserving the last 7 characters of the
# original hash when splicing so that we can avoid relocation issues
out = spack.util.hash.b32_hash(json_text)