fix memory leak in property and staticmethod.

This commit is contained in:
ykiko 2024-08-28 01:01:38 +08:00
parent 2e4a248e2c
commit 7070fa5352

View File

@ -585,24 +585,14 @@ class cpp_function : public function {
class property : public object { class property : public object {
PKBIND_TYPE_IMPL(object, property, tp_property); PKBIND_TYPE_IMPL(object, property, tp_property);
property(handle getter, handle setter = none()) : object() { property(handle getter, handle setter = none()) :
auto start = py_peek(0); object(type::of<property>()(getter, setter)) {}
py_push(getter.ptr());
py_push(setter.ptr());
raise_call<py_tpcall>(type::of<property>().index(), 2, start);
*this = object::from_ret();
}
}; };
class staticmethod : public object { class staticmethod : public object {
PKBIND_TYPE_IMPL(object, staticmethod, tp_staticmethod); PKBIND_TYPE_IMPL(object, staticmethod, tp_staticmethod);
staticmethod(handle method) : object() { staticmethod(handle method) : object(type::of<staticmethod>()(method)) {}
auto start = py_peek(0);
py_push(method.ptr());
raise_call<py_tpcall>(type::of<staticmethod>().index(), 1, start);
*this = object::from_ret();
}
}; };
namespace impl { namespace impl {