static int member_set(PyMemberDescrObject *descr, PyObject *obj, PyObject *value) { int res; if (descr_setcheck((PyDescrObject *)descr, obj, value, &res)) return res; return PyMember_SetOne((char *)obj, descr->d_member, value); }
int PyMember_Set(char *addr, struct memberlist *mlist, char *name, PyObject *v) { struct memberlist *l; for (l = mlist; l->name != NULL; l++) { if (strcmp(l->name, name) == 0) { PyMemberDef copy; copy.name = l->name; copy.type = l->type; copy.offset = l->offset; copy.flags = l->flags; copy.doc = NULL; return PyMember_SetOne(addr, ©, v); } } PyErr_SetString(PyExc_AttributeError, name); return -1; }
static PyObject *_drizzle_ConnectionObject_setattr( _drizzle_ConnectionObject *self, char *name, PyObject *v) { if (v == NULL) { PyErr_SetString(PyExc_AttributeError, "can't delete connection attributes"); return -1; } PyMemberDef *l; for (l = _drizzle_ConnectionObject_memberlist; l->name != NULL; l++) { if (strcmp(l->name, name) == 0) { return PyMember_SetOne((char *)self, l, v); } } PyErr_SetString(PyExc_AttributeError, name); return -1; }