summaryrefslogtreecommitdiff
path: root/python/msgpack/_msgpack.pyx
diff options
context:
space:
mode:
authorinada-n <omoikane@users.sourceforge.jp>2009-07-13 15:49:38 +0900
committerinada-n <omoikane@users.sourceforge.jp>2009-07-13 15:49:38 +0900
commit0db5e0439dab0445d9f84aa5f6fbf2f535cd8d0d (patch)
tree27ad8502d948cade6df1d250c988e85fc4b02bd3 /python/msgpack/_msgpack.pyx
parent6083bad5ffd646f715d756e7189041d542ee8ab0 (diff)
downloadmsgpack-python-0db5e0439dab0445d9f84aa5f6fbf2f535cd8d0d.tar.gz
Fix: Unpacker.unpack() may raise StopIteration before unpacking large object when deserializing from file.
Diffstat (limited to 'python/msgpack/_msgpack.pyx')
-rw-r--r--python/msgpack/_msgpack.pyx8
1 files changed, 7 insertions, 1 deletions
diff --git a/python/msgpack/_msgpack.pyx b/python/msgpack/_msgpack.pyx
index 7990a18..cb95146 100644
--- a/python/msgpack/_msgpack.pyx
+++ b/python/msgpack/_msgpack.pyx
@@ -265,7 +265,11 @@ cdef class Unpacker(object):
cdef Py_ssize_t add_size
if self.file_like is not None:
- self.waiting_bytes.append(self.file_like.read(self.read_size))
+ next_bytes = self.file_like.read(self.read_size)
+ if next_bytes:
+ self.waiting_bytes.append(next_bytes)
+ else:
+ self.file_like = None
if not self.waiting_bytes:
return
@@ -307,6 +311,8 @@ cdef class Unpacker(object):
if ret == 1:
return template_data(&self.ctx)
elif ret == 0:
+ if self.file_like is not None:
+ return self.unpack()
raise StopIteration, "No more unpack data."
else:
raise ValueError, "Unpack failed."