Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES/162.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed reference leak caused by ``Py_INCREF`` because Cython has its own reference counter systems -- by :user:`Vizonex`.
9 changes: 4 additions & 5 deletions src/propcache/_helpers_c.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ cdef extern from "Python.h":
int PyDict_SetItem(
object dict, object key, PyObject* value
) except -1
void Py_INCREF(PyObject*)
void Py_DECREF(PyObject*)


cdef class under_cached_property:
"""Use as a class method decorator. It operates almost exactly like
Expand Down Expand Up @@ -46,8 +47,7 @@ cdef class under_cached_property:
if val == NULL:
val = PyObject_CallOneArg(self.wrapped, inst)
PyDict_SetItem(cache, self.name, val)
else:
Py_INCREF(val)
Py_DECREF(val)
return <object>val

def __set__(self, inst, value):
Expand Down Expand Up @@ -97,8 +97,7 @@ cdef class cached_property:
if val is NULL:
val = PyObject_CallOneArg(self.func, inst)
PyDict_SetItem(cache, self.name, val)
else:
Py_INCREF(val)
Py_DECREF(val)
return <object>val

__class_getitem__ = classmethod(GenericAlias)
Loading