Skip to content

Commit d761061

Browse files
committed
Fix hash
1 parent 256011d commit d761061

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

pytensor/link/c/cmodule.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ def is_same_entry(entry_1, entry_2):
427427
return False
428428

429429

430-
def get_module_hash(src_code, key):
430+
def get_module_hash(src_code: str, key) -> str:
431431
"""
432432
Return a SHA256 hash that uniquely identifies a module.
433433
@@ -467,13 +467,13 @@ def get_module_hash(src_code, key):
467467
if isinstance(key_element, tuple):
468468
# This should be the C++ compilation command line parameters or the
469469
# libraries to link against.
470-
to_hash += list(key_element)
470+
to_hash += [str(e) for e in key_element]
471471
elif isinstance(key_element, str):
472472
if key_element.startswith("md5:") or key_element.startswith("hash:"):
473473
# This is actually a sha256 hash of the config options.
474474
# Currently, we still keep md5 to don't break old PyTensor.
475475
# We add 'hash:' so that when we change it in
476-
# the futur, it won't break this version of PyTensor.
476+
# the future, it won't break this version of PyTensor.
477477
break
478478
elif key_element.startswith("NPY_ABI_VERSION=0x") or key_element.startswith(
479479
"c_compiler_str="

pytensor/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ def output_subprocess_Popen(command, **params):
216216
return (*out, p.returncode)
217217

218218

219-
def hash_from_code(msg):
219+
def hash_from_code(msg: str | bytes) -> str:
220220
"""Return the SHA256 hash of a string or bytes."""
221221
# hashlib.sha256() requires an object that supports buffer interface,
222222
# but Python 3 (unicode) strings don't.

0 commit comments

Comments
 (0)