|
|
@@ -122,6 +122,8 @@ int py_next(py_Ref val) {
|
|
|
bool py_getattr(py_Ref self, py_Name name) {
|
|
|
// https://docs.python.org/3/howto/descriptor.html#invocation-from-an-instance
|
|
|
py_TypeInfo* ti = pk_typeinfo(self->type);
|
|
|
+ if(ti->getattribute) return ti->getattribute(self, name);
|
|
|
+
|
|
|
py_Ref cls_var = pk_tpfindname(ti, name);
|
|
|
if(cls_var) {
|
|
|
// handle descriptor
|
|
|
@@ -212,8 +214,10 @@ bool py_getattr(py_Ref self, py_Name name) {
|
|
|
}
|
|
|
|
|
|
bool py_setattr(py_Ref self, py_Name name, py_Ref val) {
|
|
|
- py_Type type = self->type;
|
|
|
- py_Ref cls_var = py_tpfindname(type, name);
|
|
|
+ py_TypeInfo* ti = pk_typeinfo(self->type);
|
|
|
+ if(ti->setattribute) return ti->setattribute(self, name, val);
|
|
|
+
|
|
|
+ py_Ref cls_var = pk_tpfindname(ti, name);
|
|
|
if(cls_var) {
|
|
|
// handle descriptor
|
|
|
if(py_istype(cls_var, tp_property)) {
|
|
|
@@ -239,6 +243,9 @@ bool py_setattr(py_Ref self, py_Name name, py_Ref val) {
|
|
|
}
|
|
|
|
|
|
bool py_delattr(py_Ref self, py_Name name) {
|
|
|
+ py_TypeInfo* ti = pk_typeinfo(self->type);
|
|
|
+ if(ti->delattribute) return ti->delattribute(self, name);
|
|
|
+
|
|
|
if(self->is_ptr && self->_obj->slots == -1) {
|
|
|
if(py_deldict(self, name)) return true;
|
|
|
return AttributeError(self, name);
|