class MM(MT):
def __init__(self):
MT.__init__(self)
- def __getattr__(self, name):
+ def __getattribute__(self, name):
log.append(("getattr", name))
- return MT.__getattr__(self, name)
+ return MT.__getattribute__(self, name)
def __setattr__(self, name, value):
log.append(("setattr", name, value))
MT.__setattr__(self, name, value)
if name == "spam":
return "spam"
else:
- return object.__getattr__(self, name)
- C.__getattr__ = mygetattr
+ return object.__getattribute__(self, name)
+ C.__getattribute__ = mygetattr
verify(a.spam == "spam")
a.new = 12
verify(a.new == 12)
class C(B):
- def __getattr__(self, name):
+ def __getattribute__(self, name):
if name == "foo":
return ("getattr", name)
else:
- return B.__getattr__(self, name)
+ return B.__getattribute__(self, name)
def __setattr__(self, name, value):
if name == "foo":
self.setattr = (name, value)
};
static struct wrapperbase tab_getattr[] = {
- {"__getattr__", (wrapperfunc)wrap_binaryfunc,
- "x.__getattr__('name') <==> x.name"},
+ {"__getattribute__", (wrapperfunc)wrap_binaryfunc,
+ "x.__getattribute__('name') <==> x.name"},
{0}
};
static PyObject *getattr_str = NULL;
if (getattr_str == NULL) {
- getattr_str = PyString_InternFromString("__getattr__");
+ getattr_str = PyString_InternFromString("__getattribute__");
if (getattr_str == NULL)
return NULL;
}
TPSLOT("__hash__", tp_hash, slot_tp_hash);
TPSLOT("__call__", tp_call, slot_tp_call);
TPSLOT("__str__", tp_str, slot_tp_str);
- TPSLOT("__getattr__", tp_getattro, slot_tp_getattro);
+ TPSLOT("__getattribute__", tp_getattro, slot_tp_getattro);
TPSLOT("__setattr__", tp_setattro, slot_tp_setattro);
TPSLOT("__lt__", tp_richcompare, slot_tp_richcompare);
TPSLOT("__le__", tp_richcompare, slot_tp_richcompare);