[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.67,1.68 test_descrtut.py,1.5,1.6
Guido van Rossum
gvanrossum@users.sourceforge.net
Fri, 21 Sep 2001 12:29:10 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv23152/Lib/test
Modified Files:
test_descr.py test_descrtut.py
Log Message:
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.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.67
retrieving revision 1.68
diff -C2 -d -r1.67 -r1.68
*** test_descr.py 2001/09/20 21:49:53 1.67
--- test_descr.py 2001/09/21 19:29:08 1.68
***************
*** 679,685 ****
def __init__(self):
MT.__init__(self)
! def __getattr__(self, name):
log.append(("getattr", name))
! return MT.__getattr__(self, name)
def __setattr__(self, name, value):
log.append(("setattr", name, value))
--- 679,685 ----
def __init__(self):
MT.__init__(self)
! def __getattribute__(self, name):
log.append(("getattr", name))
! return MT.__getattribute__(self, name)
def __setattr__(self, name, value):
log.append(("setattr", name, value))
***************
*** 882,887 ****
return "spam"
else:
! return object.__getattr__(self, name)
! C.__getattr__ = mygetattr
verify(a.spam == "spam")
a.new = 12
--- 882,887 ----
return "spam"
else:
! return object.__getattribute__(self, name)
! C.__getattribute__ = mygetattr
verify(a.spam == "spam")
a.new = 12
***************
*** 1106,1114 ****
class C(B):
! def __getattr__(self, name):
if name == "foo":
return ("getattr", name)
else:
! return B.__getattr__(self, name)
def __setattr__(self, name, value):
if name == "foo":
--- 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":
Index: test_descrtut.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descrtut.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** test_descrtut.py 2001/09/09 06:12:01 1.5
--- test_descrtut.py 2001/09/21 19:29:08 1.6
***************
*** 193,197 ****
'__eq__',
'__ge__',
! '__getattr__',
'__getitem__',
'__getslice__',
--- 193,197 ----
'__eq__',
'__ge__',
! '__getattribute__',
'__getitem__',
'__getslice__',