summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorINADA Naoki <inada-n@klab.com>2013-04-08 10:52:11 +0900
committerINADA Naoki <inada-n@klab.com>2013-04-08 10:52:11 +0900
commit18215b01bb272f28d98af5c9373fac8cbb24b30e (patch)
tree08845fe9aafdf81c7350e87292b28b5b973f40c4
parent0faa1bb558ab671b9503c5e22a97c0ec24ab5a19 (diff)
downloadmsgpack-python-18215b01bb272f28d98af5c9373fac8cbb24b30e.tar.gz
Unpacker.feed() uses new buffer interface.
-rw-r--r--msgpack/_unpacker.pyx10
1 files changed, 6 insertions, 4 deletions
diff --git a/msgpack/_unpacker.pyx b/msgpack/_unpacker.pyx
index 1ad71a0..2644f15 100644
--- a/msgpack/_unpacker.pyx
+++ b/msgpack/_unpacker.pyx
@@ -254,13 +254,15 @@ cdef class Unpacker(object):
def feed(self, object next_bytes):
"""Append `next_bytes` to internal buffer."""
- cdef char* buf
- cdef Py_ssize_t buf_len
+ cdef Py_buffer pybuff
if self.file_like is not None:
raise AssertionError(
"unpacker.feed() is not be able to use with `file_like`.")
- PyObject_AsReadBuffer(next_bytes, <const_void_ptr*>&buf, &buf_len)
- self.append_buffer(buf, buf_len)
+ PyObject_GetBuffer(next_bytes, &pybuff, PyBUF_SIMPLE)
+ try:
+ self.append_buffer(<char*>pybuff.buf, pybuff.len)
+ finally:
+ PyBuffer_Release(&pybuff)
cdef append_buffer(self, void* _buf, Py_ssize_t _buf_len):
cdef: