]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
backport gvanrossum's patch:
authorAnthony Baxter <anthonybaxter@gmail.com>
Thu, 18 Apr 2002 04:46:49 +0000 (04:46 +0000)
committerAnthony Baxter <anthonybaxter@gmail.com>
Thu, 18 Apr 2002 04:46:49 +0000 (04:46 +0000)
SF bug 544647.

PyNumber_InPlaceMultiply insisted on calling sq_inplace_repeat if it
existed, even if nb_inplace_multiply also existed and the arguments
weren't right for sq_inplace_repeat.  Change this to only use
sq_inplace_repeat if nb_inplace_multiply isn't defined.

Bugfix candidate.

Lib/test/test_descr.py

index 953046957daa280b61ae04f7799b715084d6a4d7..2a48f12782aff0221d5867546f6585db4f453d49 100644 (file)
@@ -2862,6 +2862,32 @@ def docdescriptor():
     vereq(NewClass.__doc__, 'object=None; type=NewClass')
     vereq(NewClass().__doc__, 'object=NewClass instance; type=NewClass')
 
+def imulbug():
+    # SF bug 544647
+    if verbose: print "Testing for __imul__ problems..."
+    class C(object):
+        def __imul__(self, other):
+            return (self, other)
+    x = C()
+    y = x
+    y *= 1.0
+    vereq(y, (x, 1.0))
+    y = x
+    y *= 2
+    vereq(y, (x, 2))
+    y = x
+    y *= 3L
+    vereq(y, (x, 3L))
+    y = x
+    y *= 1L<<100
+    vereq(y, (x, 1L<<100))
+    y = x
+    y *= None
+    vereq(y, (x, None))
+    y = x
+    y *= "foo"
+    vereq(y, (x, "foo"))
+
 def test_main():
     class_docstrings()
     lists()
@@ -2920,6 +2946,7 @@ def test_main():
     modules()
     pickleslots()
     docdescriptor()
+    imulbug()
     if verbose: print "All OK"
 
 if __name__ == "__main__":