From 1406cd49ccc275ec15b8e42130fa5ed46e5f81ef Mon Sep 17 00:00:00 2001 From: Inada Naoki Date: Mon, 1 Jun 2026 18:55:47 +0900 Subject: [PATCH] add autoreset support to Packer.pack_ext_type() --- msgpack/_packer.pyx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx index 94d1462..75b3f7f 100644 --- a/msgpack/_packer.pyx +++ b/msgpack/_packer.pyx @@ -291,6 +291,10 @@ cdef class Packer: raise ValueError("ext data too large") msgpack_pack_ext(&self.pk, typecode, len(data)) msgpack_pack_raw_body(&self.pk, data, len(data)) + if self.autoreset: + buf = PyBytes_FromStringAndSize(self.pk.buf, self.pk.length) + self.pk.length = 0 + return buf @cython.critical_section def pack_array_header(self, long long size):