From 7df7136e20933fd3a498bd58bff7975a24790516 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Wed, 3 Jun 2026 16:22:40 +0900 Subject: [PATCH] Guard `Packer` buffer protocol hooks with Cython critical sections (#686) --- msgpack/_packer.pyx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/msgpack/_packer.pyx b/msgpack/_packer.pyx index 2d92e8a..277239d 100644 --- a/msgpack/_packer.pyx +++ b/msgpack/_packer.pyx @@ -360,9 +360,11 @@ cdef class Packer: """ return memoryview(self) + @cython.critical_section def __getbuffer__(self, Py_buffer *buffer, int flags): PyBuffer_FillInfo(buffer, self, self.pk.buf, self.pk.length, 1, flags) self.exports += 1 + @cython.critical_section def __releasebuffer__(self, Py_buffer *buffer): self.exports -= 1