diff options
author | inada-n <omoikane@users.sourceforge.jp> | 2009-07-13 15:49:38 +0900 |
---|---|---|
committer | inada-n <omoikane@users.sourceforge.jp> | 2009-07-13 15:49:38 +0900 |
commit | dc4e20ed35b6910211366e661382865a33fb2623 (patch) | |
tree | eb7d95c2e996bc44464060b2c78febbcb9a4a4e4 /msgpack/_msgpack.pyx | |
parent | 6e0a7bdb293e53d5c1db226759ba77caec337715 (diff) | |
download | msgpack-python-dc4e20ed35b6910211366e661382865a33fb2623.tar.gz |
Fix: Unpacker.unpack() may raise StopIteration before unpacking large object when deserializing from file.
Diffstat (limited to 'msgpack/_msgpack.pyx')
-rw-r--r-- | msgpack/_msgpack.pyx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx index 7990a18..cb95146 100644 --- a/msgpack/_msgpack.pyx +++ b/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." |