Skip to content

Commit 1c77793

Browse files
committed
Change implementation of hashing to be compatible with Python 3.10
1 parent be58a95 commit 1c77793

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

tools/tests/generate_reference_results.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,14 @@ def render_reference_results_info(
5353
arguments_used: SystemtestArguments,
5454
time: str):
5555
def sha256sum(filename):
56+
# Implementation from https://stackoverflow.com/a/44873382/2254346,
57+
# compatible with Python 3.10.
58+
h = hashlib.sha256()
59+
mv = memoryview(bytearray(128 * 1024))
5660
with open(filename, 'rb', buffering=0) as f:
57-
return hashlib.file_digest(f, 'sha256').hexdigest()
61+
while n := f.readinto(mv):
62+
h.update(mv[:n])
63+
return h.hexdigest()
5864

5965
files = []
6066
for reference_result in reference_results:

0 commit comments

Comments
 (0)