summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cuni <anto.cuni@gmail.com>2013-10-18 17:46:42 +0200
committerAntonio Cuni <anto.cuni@gmail.com>2013-10-18 17:46:42 +0200
commita7485eccb2e5fcebbd76612a658f2e18bdebe745 (patch)
tree6f6c84b201ea13fcde5442ff020186053da4db80
parent5467515065b95496b9f5b9d842ffc73c9ccb806e (diff)
downloadmsgpack-python-a7485eccb2e5fcebbd76612a658f2e18bdebe745.tar.gz
add the hook for unknown types also to the cython Packer
-rw-r--r--msgpack/_packer.pyx6
1 files changed, 6 insertions, 0 deletions
diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx
index 985559c..f2a0f76 100644
--- a/msgpack/_packer.pyx
+++ b/msgpack/_packer.pyx
@@ -176,6 +176,9 @@ cdef class Packer(object):
for v in o:
ret = self._pack(v, nest_limit-1)
if ret != 0: break
+ elif self.handle_unknown_type(o):
+ # it means that obj was succesfully packed, so we are done
+ return 0
elif self._default:
o = self._default(o)
ret = self._pack(o, nest_limit-1)
@@ -195,6 +198,9 @@ cdef class Packer(object):
self.pk.length = 0
return buf
+ def handle_unknown_type(self, obj):
+ return None
+
def pack_extended_type(self, typecode, data):
msgpack_pack_ext(&self.pk, typecode, len(data))
msgpack_pack_raw_body(&self.pk, data, len(data))