mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-06 17:59:52 +00:00
add the hook for unknown types also to the cython Packer
This commit is contained in:
parent
5467515065
commit
a7485eccb2
1 changed files with 6 additions and 0 deletions
|
|
@ -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))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue