Skip to content

Commit 1406cd4

Browse files
committed
add autoreset support to Packer.pack_ext_type()
1 parent b691a8e commit 1406cd4

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

msgpack/_packer.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ cdef class Packer:
291291
raise ValueError("ext data too large")
292292
msgpack_pack_ext(&self.pk, typecode, len(data))
293293
msgpack_pack_raw_body(&self.pk, data, len(data))
294+
if self.autoreset:
295+
buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length)
296+
self.pk.length = 0
297+
return buf
294298

295299
@cython.critical_section
296300
def pack_array_header(self, long long size):

0 commit comments

Comments
 (0)