diff --git a/src/object.rs b/src/object.rs index 5b0f4ffb..8948f8bc 100644 --- a/src/object.rs +++ b/src/object.rs @@ -206,6 +206,7 @@ impl PyObject { let ptr = ffi::PyObject_GetAttr(self.as_ptr(), name); let result = PyObject::from_borrowed_ptr_or_err( py, ffi::PyObject_Call(ptr, t.as_ptr(), kwargs.as_ptr())); + ffi::Py_DECREF(ptr); py.release(t); result }) diff --git a/src/objectprotocol.rs b/src/objectprotocol.rs index 1999554c..44d8deb1 100644 --- a/src/objectprotocol.rs +++ b/src/objectprotocol.rs @@ -267,6 +267,7 @@ impl ObjectProtocol for T where T: PyObjectWithToken + ToPyPointer { let ptr = ffi::PyObject_GetAttr(self.as_ptr(), name); let result = self.py().cast_from_borrowed_ptr_or_err( ffi::PyObject_Call(ptr, t.as_ptr(), kwargs.as_ptr())); + ffi::Py_DECREF(ptr); self.py().release(t); result })