From ed40c671dac175e437fe67689053b5fe8a269ad3 Mon Sep 17 00:00:00 2001 From: INADA Naoki Date: Mon, 10 Dec 2012 01:42:38 +0900 Subject: `pack` raise MemoryError when realloc is failed. --- msgpack/_msgpack.pyx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'msgpack/_msgpack.pyx') diff --git a/msgpack/_msgpack.pyx b/msgpack/_msgpack.pyx index 2c81cb4..b2b5222 100644 --- a/msgpack/_msgpack.pyx +++ b/msgpack/_msgpack.pyx @@ -179,7 +179,9 @@ cdef class Packer(object): cpdef pack(self, object obj): cdef int ret ret = self._pack(obj, DEFAULT_RECURSE_LIMIT) - if ret: + if ret == -1: + raise MemoryError + elif ret: # should not happen. raise TypeError buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) self.pk.length = 0 -- cgit v1.2.1