| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…rrays The :mod:`asyncio` code is writing binary data to a :class:`socket.socket`, and advancing through the buffer after a partial write by doing ``memoryview(data)[n:]``, where ``n`` is the number of bytes written. This assumes the :class:`memoryview` is a one dimensional buffer of bytes, which is not the case e.g. for a :class:`memoryview` of an :class:`array.array` of non-bytes, or an ``ndarray`` with more than one dimension. Partial writes of such :class:`memoryview`s will corrupt the stream, repeating or omitting some data. When creating a :class:`memoryview` from a :class:`memoryview`, first convert it to a one-dimensional array of bytes before taking the remaining slice, thus avoiding these issues. Add an assertion that the remaining data is bytes, to guard against possible regressions if additional types of data are allowed in the future.
Hopefully this will fix the windows compile failures...
| Back | FazBrowse Home | New Git URL |
The asyncio code is writing binary data to a socket.socket, and advancing through the buffer after a partial write by doing memoryview(data)[n:], where n is the number of bytes written.
This assumes the memoryview is a one dimensional buffer of bytes, which is not the case e.g. for a memoryview of an array.array of non-bytes, or an ndarray with more than one dimension. Partial writes of such memoryviews will corrupt the stream, repeating or omitting some data.
When creating a memoryview from a memoryview, first convert it to a one-dimensional array of bytes before taking the remaining slice, thus avoiding these issues.
Add an assertion that the remaining data is bytes, to guard against possible regressions if additional types of data are allowed in the future.