Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix another missed case of (str, bytes) #252

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion h5pyd/_hl/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def copyToArray(arr, rank, index, data, vlen_base=None):
copyToArray(arr, rank + 1, index, data[i], vlen_base=vlen_base)
else:
if vlen_base:
if vlen_base == str:
if vlen_base in (str, bytes):
e = str(data[i])
else:
e = np.array(data[i], dtype=vlen_base)
Expand Down
7 changes: 2 additions & 5 deletions test/hl/test_vlentype.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,8 @@ def test_variable_len_str_attr(self):
self.assertTrue("vlen" in vals.dtype.metadata)

for i in range(10):
if config.get("use_h5py"):
# TBD: why is h5py returning str and not bytes?
word = words[i].decode("utf8")
else:
word = words[i]
# TBD: why is h5py returning str and not bytes?
word = words[i].decode("utf8")
self.assertEqual(vals[i], word)

f.close()
Expand Down