[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.68,1.69
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 21 Sep 2001 14:24:51 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv21933/Lib/test
Modified Files:
test_descr.py
Log Message:
Add the __getattr__ hook back. The rules are now:
- if __getattribute__ exists, it is called first;
if it doesn't exists, PyObject_GenericGetAttr is called first.
- if the above raises AttributeError, and __getattr__ exists,
it is called.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.68
retrieving revision 1.69
diff -C2 -d -r1.68 -r1.69
*** test_descr.py 2001/09/21 19:29:08 1.68
--- test_descr.py 2001/09/21 21:24:49 1.69
***************
*** 881,887 ****
if name == "spam":
return "spam"
! else:
! return object.__getattribute__(self, name)
! C.__getattribute__ = mygetattr
verify(a.spam == "spam")
a.new = 12
--- 881,886 ----
if name == "spam":
return "spam"
! raise AttributeError
! C.__getattr__ = mygetattr
verify(a.spam == "spam")
a.new = 12
***************
*** 1106,1114 ****
class C(B):
! def __getattribute__(self, name):
if name == "foo":
return ("getattr", name)
else:
! return B.__getattribute__(self, name)
def __setattr__(self, name, value):
if name == "foo":
--- 1105,1113 ----
class C(B):
! def __getattr__(self, name):
if name == "foo":
return ("getattr", name)
else:
! raise AttributeError
def __setattr__(self, name, value):
if name == "foo":