summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-08-13 10:05:56 (GMT)
committerGuido van Rossum <guido@python.org>2002-08-13 10:05:56 (GMT)
commit4571e9d42a3b1734635385eb2c4328cfe82496cd (patch)
tree6082849d2dbba310c821bf63f1e0cf188d06770f /Objects
parentd0876b859d3789e7ec8c9ec18f4a04db3fc097c0 (diff)
downloadcpython-4571e9d42a3b1734635385eb2c4328cfe82496cd.zip
cpython-4571e9d42a3b1734635385eb2c4328cfe82496cd.tar.gz
cpython-4571e9d42a3b1734635385eb2c4328cfe82496cd.tar.bz2
Add an improvement wrinkle to Neil Schemenauer's change to int_mul
(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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/intobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 1d05a63..a8ea6ac 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -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)
{