mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-06-19 06:02:09 +00:00
fix: address PR review comments
- Check PyObject_GetBuffer return value and raise on failure - Avoid unnecessary tobytes() copy for contiguous memoryviews in fallback feed()
This commit is contained in:
parent
eae29a954e
commit
7ee15a324b
2 changed files with 3 additions and 3 deletions
|
|
@ -129,7 +129,8 @@ cdef inline int get_data_from_buffer(object obj,
|
|||
PyBuffer_Release(view)
|
||||
# create a contiguous copy and get buffer
|
||||
contiguous = PyMemoryView_GetContiguous(obj, PyBUF_READ, b'C')
|
||||
PyObject_GetBuffer(contiguous, view, PyBUF_SIMPLE)
|
||||
if PyObject_GetBuffer(contiguous, view, PyBUF_SIMPLE) == -1:
|
||||
raise
|
||||
|
||||
buffer_len[0] = view.len
|
||||
buf[0] = <char*> view.buf
|
||||
|
|
|
|||
|
|
@ -328,8 +328,7 @@ class Unpacker:
|
|||
self._buf_checkpoint = 0
|
||||
|
||||
# Use extend here: INPLACE_ADD += doesn't reliably typecast memoryview in jython
|
||||
# tobytes ensures compatibility with non-contiguous memoryviews
|
||||
self._buffer.extend(view.tobytes())
|
||||
self._buffer.extend(view if view.contiguous else view.tobytes())
|
||||
view.release()
|
||||
|
||||
def _consume(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue