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

Guido van Rossum gvanrossum@users.sourceforge.net
2001年10月18日 08:49:23 -0700


Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv23792/Lib/test
Modified Files:
	test_descr.py 
Log Message:
Fix SF bug #472234: type(obj) calls type->tp_init (Roeland Rengelink)
The fix is a band-aid: type_call() now makes the same exception for a
single-argument call to type() as type_new() was already making.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.90
retrieving revision 1.91
diff -C2 -d -r1.90 -r1.91
*** test_descr.py	2001年10月16日 20:18:24	1.90
--- test_descr.py	2001年10月18日 15:49:21	1.91
***************
*** 717,720 ****
--- 717,732 ----
 vereq(D().x, "DCBA")
 
+ # Make sure type(x) doesn't call x.__class__.__init__
+ class T(type):
+ counter = 0
+ def __init__(self, *args):
+ T.counter += 1
+ class C:
+ __metaclass__ = T
+ vereq(T.counter, 1)
+ a = C()
+ vereq(type(a), C)
+ vereq(T.counter, 1)
+ 
 def pymods():
 if verbose: print "Testing Python subclass of module..."

AltStyle によって変換されたページ (->オリジナル) /