]> granicus.if.org Git - python/commitdiff
Add an improvement wrinkle to Neil Schemenauer's change to int_mul
authorGuido van Rossum <guido@python.org>
Tue, 13 Aug 2002 10:05:56 +0000 (10:05 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 13 Aug 2002 10:05:56 +0000 (10:05 +0000)
(rev. 2.86).  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 1d05a631c2a0ecd268900a323419ee1faf984f0f..a8ea6ac1f51a8ca48f16b81c4ecbaa78df6bbc64 100644 (file)
@@ -345,8 +345,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)
 {