Guard Packer buffer protocol hooks with Cython critical sections (#686)

This commit is contained in:
Copilot 2026-06-03 16:22:40 +09:00 committed by GitHub
parent d627d308ef
commit 7df7136e20
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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