mirror of
https://github.com/capnproto/pycapnp.git
synced 2025-03-04 16:35:04 +01:00
Fix subtle dealloc ordering problem with MessageReader
It appears that Cython has a subtle issue in deconstruction ordering that I forgot about. Subclasses will have their deconstructors before their parent's, and in this case we were dropping a reference to a buffer that the parent deconstructor expected to exist.
This commit is contained in:
parent
c6754f84d9
commit
a62e392feb
1 changed files with 3 additions and 5 deletions
|
@ -3227,6 +3227,7 @@ cdef class _MessageReader:
|
|||
|
||||
.. warning:: Don't ever instantiate this class. It is only used for inheritance.
|
||||
"""
|
||||
cdef public object _parent
|
||||
cdef schema_cpp.MessageReader * thisptr
|
||||
def __dealloc__(self):
|
||||
del self.thisptr
|
||||
|
@ -3301,7 +3302,6 @@ cdef class _PackedMessageReader(_MessageReader):
|
|||
|
||||
:Parameters: - fd (`int`) - A file descriptor
|
||||
"""
|
||||
cdef public object _parent
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
@ -3319,7 +3319,6 @@ cdef class _PackedMessageReader(_MessageReader):
|
|||
return self
|
||||
|
||||
cdef class _PackedMessageReaderBytes(_MessageReader):
|
||||
cdef public object _parent
|
||||
cdef schema_cpp.ArrayInputStream * stream
|
||||
|
||||
def __init__(self, buf, traversal_limit_in_words = None, nesting_limit = None):
|
||||
|
@ -3355,7 +3354,6 @@ cdef class _InputMessageReader(_MessageReader):
|
|||
|
||||
:Parameters: - fd (`int`) - A file descriptor
|
||||
"""
|
||||
cdef public object _parent
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
@ -3476,8 +3474,8 @@ cdef class _MultipleBytesMessageReader:
|
|||
self.buffered_stream = new schema_cpp.BufferedInputStreamWrapper(deref(self.stream))
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.stream
|
||||
del self.buffered_stream
|
||||
del self.stream
|
||||
|
||||
def __next__(self):
|
||||
try:
|
||||
|
@ -3512,8 +3510,8 @@ cdef class _MultipleBytesPackedMessageReader:
|
|||
self.buffered_stream = new schema_cpp.BufferedInputStreamWrapper(deref(self.stream))
|
||||
|
||||
def __dealloc__(self):
|
||||
del self.stream
|
||||
del self.buffered_stream
|
||||
del self.stream
|
||||
|
||||
def __next__(self):
|
||||
try:
|
||||
|
|
Loading…
Add table
Reference in a new issue