summaryrefslogtreecommitdiff
path: root/msgpack/_unpacker.pyx
diff options
context:
space:
mode:
authorINADA Naoki <songofacandy@gmail.com>2014-02-13 03:24:09 +0900
committerINADA Naoki <songofacandy@gmail.com>2014-02-13 03:24:09 +0900
commit7b24d0fe5a20ce4ddd73c0128799a050b2cca9c6 (patch)
tree2364417fcb3e9f6aa0d5491f85b6e47aff979d7c /msgpack/_unpacker.pyx
parentd2fc8010342512378e01322f8871c10a5974af4f (diff)
parent9d61f243878eeabd2042bb16fe22d4325e441da6 (diff)
downloadmsgpack-python-7b24d0fe5a20ce4ddd73c0128799a050b2cca9c6.tar.gz
Merge pull request #87 from msgpack/fix-83
Feed data from file before _unpack()
Diffstat (limited to 'msgpack/_unpacker.pyx')
-rw-r--r--msgpack/_unpacker.pyx10
1 files changed, 10 insertions, 0 deletions
diff --git a/msgpack/_unpacker.pyx b/msgpack/_unpacker.pyx
index 732adef..16aca5c 100644
--- a/msgpack/_unpacker.pyx
+++ b/msgpack/_unpacker.pyx
@@ -327,8 +327,18 @@ cdef class Unpacker(object):
cdef int ret
cdef object obj
cdef size_t prev_head
+
+ if self.buf_head >= self.buf_tail and self.file_like is not None:
+ self.read_from_file()
+
while 1:
prev_head = self.buf_head
+ if prev_head >= self.buf_tail:
+ if iter:
+ raise StopIteration("No more data to unpack.")
+ else:
+ raise OutOfData("No more data to unpack.")
+
ret = execute(&self.ctx, self.buf, self.buf_tail, &self.buf_head)
if write_bytes is not None:
write_bytes(PyBytes_FromStringAndSize(self.buf + prev_head, self.buf_head - prev_head))