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 buffer assignment in compression.py #909

Merged
merged 3 commits into from
Jan 15, 2021
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 CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

- Fix bug causing test collection failures in some environments. [#889]

- Fix bug when decompressing arrays with numpy 1.20. [#901]
- Fix bug when decompressing arrays with numpy 1.20. [#901, #909]

2.7.1 (2020-08-18)
------------------
Expand Down
12 changes: 5 additions & 7 deletions asdf/compression.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,11 @@ def decompress(fd, used_size, data_size, compression):
decoded = decoder.flush()
if i + len(decoded) > data_size:
raise ValueError("Decompressed data too long")
elif i + len(decoded) < data_size:
raise ValueError("Decompressed data too short")
# Previous versions of numpy permitted assignment of an
# empty bytes object to an empty array range, but starting
# with numpy 1.20 this raises an error.
elif len(decoded) > 0:
buffer[i:i+len(decoded)] = decoded
buffer.data[i:i+len(decoded)] = decoded
i += len(decoded)

if i < data_size:
raise ValueError("Decompressed data too short")

return buffer

Expand Down