[Python-checkins] python/dist/src/Lib/test test_descr.py,1.156,1.157
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Mon, 14 Oct 2002 18:01:56 -0700
Update of /cvsroot/python/python/dist/src/Lib/test
In directory usw-pr-cvs1:/tmp/cvs-serv10494
Modified Files:
test_descr.py
Log Message:
For some reason (probably cut and paste), __ipow__ for new-style
classes was called with three arguments. This makes no sense, there's
no way to pass in the "modulo" 3rd argument as for __pow__, and
classic classes don't do this. [SF bug 620179]
I don't want to backport this to 2.2.2, because it could break
existing code that has developed a work-around. Code in 2.2.2 that
wants to use __ipow__ and wants to be forward compatible with 2.3
should be written like this:
def __ipow__(self, exponent, modulo=None):
...
Index: test_descr.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/test/test_descr.py,v
retrieving revision 1.156
retrieving revision 1.157
diff -C2 -d -r1.156 -r1.157
*** test_descr.py 23 Aug 2002 18:21:26 -0000 1.156
--- test_descr.py 15 Oct 2002 01:01:53 -0000 1.157
***************
*** 3307,3310 ****
--- 3307,3320 ----
vereq(2.2*a, "rmul")
+ def testipow():
+ # [SF bug 620179]
+ if verbose:
+ print "Testing correct invocation of __ipow__..."
+ class C(object):
+ def __ipow__(self, other):
+ pass
+ a = C()
+ a **= 2
+
def do_this_first():
if verbose:
***************
*** 3402,3405 ****
--- 3412,3416 ----
slotmultipleinheritance()
testrmul()
+ testipow()
if verbose: print "All OK"