We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef85383 commit 70b9f09Copy full SHA for 70b9f09
src/emsarray/operations/cache.py
@@ -64,7 +64,11 @@ def hash_int(hash: "hashlib._Hash", value: int) -> None:
64
Expects an int that can be represented in a numpy int32.
65
"""
66
with numpy.errstate(over='raise'):
67
- hash.update(numpy.int32(value).tobytes())
+ # Manual overflow check as older numpy versions dont throw the exception
68
+ if numpy.iinfo("int32").min <= value <= numpy.iinfo("int32").max:
69
+ hash.update(numpy.int32(value).tobytes())
70
+ else:
71
+ raise OverflowError
72
73
74
def make_cache_key(dataset: xarray.Dataset, hash: "hashlib._Hash | None" = None) -> str:
0 commit comments