[Python-checkins] CVS: python/dist/src/Lib/test test_descr.py,1.51,1.52
Tim Peters
tim_one@users.sourceforge.net
Thu, 13 Sep 2001 12:18:29 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv12520/python/Lib/test
Modified Files:
test_descr.py
Log Message:
type_call(): Change in policy. The keyword args (if any) are now passed
on to the tp_new slot (if non-NULL), as well as to the tp_init slot (if
any). A sane type implementing both tp_new and tp_init should probably
pay attention to the arguments in only one of them.
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** test_descr.py 2001/09/13 05:38:55 1.51
--- test_descr.py 2001/09/13 19:18:27 1.52
***************
*** 344,349 ****
class Number(complex):
__slots__ = ['prec']
! def __init__(self, *args, **kwds):
! self.prec = kwds.get('prec', 12)
def __repr__(self):
prec = self.prec
--- 344,351 ----
class Number(complex):
__slots__ = ['prec']
! def __new__(cls, *args, **kwds):
! result = complex.__new__(cls, *args)
! result.prec = kwds.get('prec', 12)
! return result
def __repr__(self):
prec = self.prec
***************
*** 354,360 ****
--- 356,371 ----
return "(%.*g+%.*gj)" % (prec, self.real, prec, self.imag)
__str__ = __repr__
+
a = Number(3.14, prec=6)
verify(`a` == "3.14")
verify(a.prec == 6)
+
+ a = Number(a, prec=2)
+ verify(`a` == "3.1")
+ verify(a.prec == 2)
+
+ a = Number(234.5)
+ verify(`a` == "234.5")
+ verify(a.prec == 12)
def spamlists():