summaryrefslogtreecommitdiffstats
path: root/Objects/intobject.c
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-12-30 20:19:02 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-12-30 20:19:02 (GMT)
commit0df295889c79ab93743a502d36402a549559c1f1 (patch)
tree42f6db5ae9e307267e0f2797ed8c2ae7be283ffb /Objects/intobject.c
parent9911fc4a418e5a5fa2d5c6028c09cae23ea7dc0c (diff)
downloadcpython-0df295889c79ab93743a502d36402a549559c1f1.zip
cpython-0df295889c79ab93743a502d36402a549559c1f1.tar.gz
cpython-0df295889c79ab93743a502d36402a549559c1f1.tar.bz2
Consolidate the int and long sequence repeat code. Before the change,
integers checked for integer overflow but longs did not.
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r--Objects/intobject.c46
1 files changed, 0 insertions, 46 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 7242dd0..19d18d3 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -354,14 +354,6 @@ one that can lose catastrophic amounts of information, it's the native long
product that must have overflowed.
*/
-/* Return true if the sq_repeat method should be used */
-#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_flags & Py_TPFLAGS_CHECKTYPES && \
- o->ob_type->tp_as_number->nb_multiply))
-
static PyObject *
int_mul(PyObject *v, PyObject *w)
{
@@ -370,44 +362,6 @@ int_mul(PyObject *v, PyObject *w)
double doubled_longprod; /* (double)longprod */
double doubleprod; /* (double)a * (double)b */
- if (USE_SQ_REPEAT(v)) {
- repeat:
- /* sequence * int */
- a = PyInt_AsLong(w);
-#if LONG_MAX != INT_MAX
- if (a > INT_MAX) {
- PyErr_SetString(PyExc_ValueError,
- "sequence repeat count too large");
- return NULL;
- }
- else if (a < INT_MIN)
- a = INT_MIN;
- /* XXX Why don't I either
-
- - set a to -1 whenever it's negative (after all,
- sequence repeat usually treats negative numbers
- as zero(); or
-
- - raise an exception when it's less than INT_MIN?
-
- I'm thinking about a hypothetical use case where some
- sequence type might use a negative value as a flag of
- some kind. In those cases I don't want to break the
- code by mapping all negative values to -1. But I also
- don't want to break e.g. []*(-sys.maxint), which is
- perfectly safe, returning []. As a compromise, I do
- map out-of-range negative values.
- */
-#endif
- return (*v->ob_type->tp_as_sequence->sq_repeat)(v, a);
- }
- if (USE_SQ_REPEAT(w)) {
- PyObject *tmp = v;
- v = w;
- w = tmp;
- goto repeat;
- }
-
CONVERT_TO_LONG(v, a);
CONVERT_TO_LONG(w, b);
longprod = a * b;