]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.13] gh-142454: Make the JIT digest more deterministic by sorting the files in...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 9 Dec 2025 18:50:32 +0000 (19:50 +0100)
committerGitHub <noreply@github.com>
Tue, 9 Dec 2025 18:50:32 +0000 (18:50 +0000)
gh-142454: Make the JIT digest more deterministic by sorting the files in Tools/jit (GH-142455)
(cherry picked from commit bcf90de8ba2ea087540a5f632656ef880ee46b5c)

Co-authored-by: Miro HronĨok <miro@hroncok.cz>
Co-authored-by: Ken Jin <kenjin4096@gmail.com>
Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst [new file with mode: 0644]
Tools/jit/_targets.py

diff --git a/Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst b/Misc/NEWS.d/next/Build/2025-12-09-13-33-46.gh-issue-142454.cqUxzQ.rst
new file mode 100644 (file)
index 0000000..4de1686
--- /dev/null
@@ -0,0 +1,4 @@
+When calculating the digest of the JIT stencils input, sort the hashed files
+by filenames before adding their content to the hasher. This ensures
+deterministic hash input and hence deterministic hash, independent on
+filesystem order.
index fe953ddddcfc080afe69fae6b05b86b8b183b533..c50bd63545c2fe40c918e1a1f46f6d1252e70b39 100644 (file)
@@ -56,7 +56,7 @@ class _Target(typing.Generic[_S, _R]):
             # Exclude cache files from digest computation to ensure reproducible builds.
             if dirpath.endswith("__pycache__"):
                 continue
-            for filename in filenames:
+            for filename in sorted(filenames):
                 hasher.update(pathlib.Path(dirpath, filename).read_bytes())
         return hasher.hexdigest()