diff --git a/CHANGES.rst b/CHANGES.rst index ddba2e124..8b8748121 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,7 +3,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) ------------------ diff --git a/asdf/compression.py b/asdf/compression.py index 5b59bd416..ad257d5e2 100644 --- a/asdf/compression.py +++ b/asdf/compression.py @@ -201,13 +201,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