We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 0faa1bb commit 18215b0Copy full SHA for 18215b0
msgpack/_unpacker.pyx
@@ -254,13 +254,15 @@ cdef class Unpacker(object):
254
255
def feed(self, object next_bytes):
256
"""Append `next_bytes` to internal buffer."""
257
- cdef char* buf
258
- cdef Py_ssize_t buf_len
+ cdef Py_buffer pybuff
259
if self.file_like is not None:
260
raise AssertionError(
261
"unpacker.feed() is not be able to use with `file_like`.")
262
- PyObject_AsReadBuffer(next_bytes, <const_void_ptr*>&buf, &buf_len)
263
- self.append_buffer(buf, buf_len)
+ PyObject_GetBuffer(next_bytes, &pybuff, PyBUF_SIMPLE)
+ try:
+ self.append_buffer(<char*>pybuff.buf, pybuff.len)
264
+ finally:
265
+ PyBuffer_Release(&pybuff)
266
267
cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len):
268
cdef:
0 commit comments