diff options
author | Guido van Rossum <guido@python.org> | 2001-09-15 03:14:32 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-09-15 03:14:32 (GMT) |
commit | 7e35d57c0cd94b136d613129cb22a2b4252aa008 (patch) | |
tree | 04cbba26e20c258dff63ab627b21906641d5c58a /Objects/intobject.c | |
parent | 0891ac017dd02f9c592c40940dff6b050523be00 (diff) | |
download | cpython-7e35d57c0cd94b136d613129cb22a2b4252aa008.zip cpython-7e35d57c0cd94b136d613129cb22a2b4252aa008.tar.gz cpython-7e35d57c0cd94b136d613129cb22a2b4252aa008.tar.bz2 |
A fix for SF bug #461546 (bug in long_mul).
Both int and long multiplication are changed to be more careful in
their assumptions about when one of the arguments is a sequence: the
assumption that at least one of the arguments must be an int (or long,
respectively) is still held, but the assumption that these don't smell
like sequences is no longer true: a subtype of int or long may well
have a sequence-repeat thingie!
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r-- | Objects/intobject.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c index c93b384..16e4336 100644 --- a/Objects/intobject.c +++ b/Objects/intobject.c @@ -344,14 +344,16 @@ int_mul(PyObject *v, PyObject *w) long a, b, ah, bh, x, y; int s = 1; - if (v->ob_type->tp_as_sequence && - v->ob_type->tp_as_sequence->sq_repeat) { + if (!PyInt_Check(v) && + v->ob_type->tp_as_sequence && + v->ob_type->tp_as_sequence->sq_repeat) { /* sequence * int */ a = PyInt_AsLong(w); return (*v->ob_type->tp_as_sequence->sq_repeat)(v, a); } - else if (w->ob_type->tp_as_sequence && - w->ob_type->tp_as_sequence->sq_repeat) { + if (!PyInt_Check(w) && + w->ob_type->tp_as_sequence && + w->ob_type->tp_as_sequence->sq_repeat) { /* int * sequence */ a = PyInt_AsLong(v); return (*w->ob_type->tp_as_sequence->sq_repeat)(w, a); |