fix(serialization): Slice 1-D multibyte data as bytes for pwrite
#181
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
1-D Multibyte Data Slicing
This change fixes a bug in
TensorSerializer
's write routine that would incorrectly slice 1-D multibyte data using its originaldtype
width rather than by individual bytes. The effect of this was that if attempting to write a buffer only wrote part of it, slicing the beginning of the buffer away to then attempt to write the rest of it would create an invalid slice, and then fail the write routine with an exception.For example, if writing a 32-byte buffer of 4x
float64
elements partially succeeded and wrote 12 bytes, it would previously essentially attempt to then continue by writingbuffer[12:]
, but mistakenly skip ahead by the width of 12xfloat64
elements (i.e. 96 bytes) instead of 12 bytes. It would then find that it had no more data to write, and then check that it wrote everything, and fail. To fix this, it now casts buffers to an unsigned byte type before slicing if it is not one already.This only affects 1-D data because multidimensional arrays passed to
TensorSerializer
's write routine were already correctly converted to 1-D arrays of bytes. Only ones that were already 1-D, but the wrong width, were missed.Code version update to v2.9.1
This change additionally updates the code version from v2.9.0 to v2.9.1 so that this fix can be published as a bugfix release.