Skip to content

Commit 7e5297b

Browse files
committed
Check ensure_bytes has a non-object array
Add a check for an `object` array in `ensure_bytes` and error if one is provided. Otherwise continue coercing it to `bytes`.
1 parent 23b8d50 commit 7e5297b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

numcodecs/compat.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ def ensure_bytes(buf):
152152
# go via numpy, for convenience
153153
arr = ensure_ndarray(buf)
154154

155+
# check for object arrays, these are just memory pointers,
156+
# actual memory holding item data is scattered elsewhere
157+
if arr.dtype == object:
158+
raise TypeError('object arrays are not supported')
159+
155160
# create bytes
156161
buf = arr.tobytes(order='A')
157162

0 commit comments

Comments
 (0)