From 3e8cb852b042f8462d1049124219a0b9599f7aa3 Mon Sep 17 00:00:00 2001 From: Harmen Stoppels Date: Thu, 20 Feb 2025 17:39:07 +0100 Subject: [PATCH] spec.py: use json.dumps directly to avoid hash breakage (#48884) --- lib/spack/spack/spec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py index 3c9a2729ecb..ee75b6fd097 100644 --- a/lib/spack/spack/spec.py +++ b/lib/spack/spack/spec.py @@ -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)