[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.1.2.3,1.1.2.4

Guido van Rossum gvanrossum@users.sourceforge.net
Tue, 01 May 2001 14:04:23 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv13966/Lib/test

Modified Files:
      Tag: descr-branch
	test_descr.py 
Log Message:
There's a subtlety in type_getattr() that makes me feel the pain of
not having metaclasses -- or actually, the mistake of using
FooClass.barMethod to reference the unbound barMethod method of
FooClass instances (where Smalltalk puts the methods in
FooClass.methodDict).  To fix this, I added query functions to
determine whether a descriptor describes a method or data, and I use
this to implement the following priority rules when accessing the bar
attribute of type FooType:

1) methods in FooType.__dict__, unadorned
2) anything in FooType.__class__.__dict__, used as a descriptor
3) anything else in FooType.__dict__, unadorned

This means that if both have a __repr__, FooType.__repr__ is the
unbound __repr__ method for Foo objects, but FooType.__class__ is the
class (or type) of FooType, which is (usually) TypeType.

If you're confused by this, don't worry.  This is on a branch. :-)



Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/Attic/test_descr.py,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -C2 -r1.1.2.3 -r1.1.2.4
*** test_descr.py	2001/04/30 16:44:56	1.1.2.3
--- test_descr.py	2001/05/01 21:04:21	1.1.2.4
***************
*** 120,124 ****
      verify(l == l1)
      testunop({1:2,3:4}, 2, "len(a)", "__len__")
!     ##testunop({1:2,3:4}, "{3: 4, 1: 2}", "repr(a)", "__repr__")
      testset2op({1:2,3:4}, 2, 3, {1:2,2:3,3:4}, "a[b]=c", "__setitem__")
  
--- 120,124 ----
      verify(l == l1)
      testunop({1:2,3:4}, 2, "len(a)", "__len__")
!     testunop({1:2,3:4}, "{3: 4, 1: 2}", "repr(a)", "__repr__")
      testset2op({1:2,3:4}, 2, 3, {1:2,2:3,3:4}, "a[b]=c", "__setitem__")