Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
fix: address PR review comments
- Check PyObject_GetBuffer return value and raise on failure
- Avoid unnecessary tobytes() copy for contiguous memoryviews in fallback feed()
  • Loading branch information
KowalskiThomas committed May 27, 2026
commit 7ee15a324b50feb2c86fc31152b099045f5fd02e
3 changes: 2 additions & 1 deletion msgpack/_unpacker.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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

Comment thread
KowalskiThomas marked this conversation as resolved.
buffer_len[0] = view.len
buf[0] = <char*> view.buf
Expand Down
3 changes: 1 addition & 2 deletions msgpack/fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ def feed(self, next_bytes):
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()
Comment thread
KowalskiThomas marked this conversation as resolved.

def _consume(self):
Expand Down
Loading