]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Backport:
authorGuido van Rossum <guido@python.org>
Tue, 13 Aug 2002 10:07:17 +0000 (10:07 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 13 Aug 2002 10:07:17 +0000 (10:07 +0000)
Add an improvement wrinkle to Neil Schemenauer's change to int_mul
(rev. 2.79.6.3).  The other type is only disqualified from sq_repeat when
it has the CHECKTYPES flag.  This means that for extension types that
only support "old-style" numeric ops, such as Zope 2's ExtensionClass,
sq_repeat still trumps nb_multiply.

Objects/intobject.c

index 2be563180fd6c84d070faa5de2b01332b0dbb83e..5daf699ec88d8fc4db18b4856e1b745b28a64b23 100644 (file)
@@ -348,8 +348,10 @@ product that must have overflowed.
 #define USE_SQ_REPEAT(o) (!PyInt_Check(o) && \
                          o->ob_type->tp_as_sequence && \
                          o->ob_type->tp_as_sequence->sq_repeat && \
-                         (!o->ob_type->tp_as_number || \
-                          !o->ob_type->tp_as_number->nb_multiply))
+                         !(o->ob_type->tp_as_number && \
+                            o->ob_type->tp_flags & Py_TPFLAGS_CHECKTYPES && \
+                           o->ob_type->tp_as_number->nb_multiply))
+
 static PyObject *
 int_mul(PyObject *v, PyObject *w)
 {