diff Objects/typeobject.c @ 20021:40cc6621eddc legacy-trunk

Change the name of the __getattr__ special method for new-style classes to __getattribute__, to make it crystal-clear that it doesn't have the same semantics as overriding __getattr__ on classic classes. This is a halfway checkin -- I'll proceed to add a __getattr__ hook that works the way it works in classic classes.
author Guido van Rossum <guido@python.org>
date Fri, 21 Sep 2001 19:29:08 +0000
parents ca7af2a5d915
children df1b83fd0ebb
line wrap: on
line diff
--- a/Objects/typeobject.c	Fri Sep 21 19:22:34 2001 +0000
+++ b/Objects/typeobject.c	Fri Sep 21 19:29:08 2001 +0000
@@ -2061,8 +2061,8 @@
 };
 
 static struct wrapperbase tab_getattr[] = {
-	{"__getattr__", (wrapperfunc)wrap_binaryfunc,
-	 "x.__getattr__('name') <==> x.name"},
+	{"__getattribute__", (wrapperfunc)wrap_binaryfunc,
+	 "x.__getattribute__('name') <==> x.name"},
 	{0}
 };
 
@@ -2877,7 +2877,7 @@
 	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;
 	}
@@ -3196,7 +3196,7 @@
 	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);