Commit f028b554 authored by Guido van Rossum's avatar Guido van Rossum

When an inlined operation on two small ints causes overflow, don't

raise the exception here -- call the generic function (which may
convert the arguments to long and try again).
parent ee7dadb5
......@@ -915,16 +915,14 @@ eval_frame(PyFrameObject *f)
a = PyInt_AS_LONG(v);
b = PyInt_AS_LONG(w);
i = a + b;
if ((i^a) < 0 && (i^b) < 0) {
PyErr_SetString(PyExc_OverflowError,
"integer addition");
x = NULL;
}
else
x = PyInt_FromLong(i);
if ((i^a) < 0 && (i^b) < 0)
goto slow_add;
x = PyInt_FromLong(i);
}
else
else {
slow_add:
x = PyNumber_Add(v, w);
}
Py_DECREF(v);
Py_DECREF(w);
PUSH(x);
......@@ -940,16 +938,14 @@ eval_frame(PyFrameObject *f)
a = PyInt_AS_LONG(v);
b = PyInt_AS_LONG(w);
i = a - b;
if ((i^a) < 0 && (i^~b) < 0) {
PyErr_SetString(PyExc_OverflowError,
"integer subtraction");
x = NULL;
}
else
x = PyInt_FromLong(i);
if ((i^a) < 0 && (i^~b) < 0)
goto slow_sub;
x = PyInt_FromLong(i);
}
else
else {
slow_sub:
x = PyNumber_Subtract(v, w);
}
Py_DECREF(v);
Py_DECREF(w);
PUSH(x);
......@@ -1102,16 +1098,14 @@ eval_frame(PyFrameObject *f)
a = PyInt_AS_LONG(v);
b = PyInt_AS_LONG(w);
i = a + b;
if ((i^a) < 0 && (i^b) < 0) {
PyErr_SetString(PyExc_OverflowError,
"integer addition");
x = NULL;
}
else
x = PyInt_FromLong(i);
if ((i^a) < 0 && (i^b) < 0)
goto slow_iadd;
x = PyInt_FromLong(i);
}
else
else {
slow_iadd:
x = PyNumber_InPlaceAdd(v, w);
}
Py_DECREF(v);
Py_DECREF(w);
PUSH(x);
......@@ -1127,16 +1121,14 @@ eval_frame(PyFrameObject *f)
a = PyInt_AS_LONG(v);
b = PyInt_AS_LONG(w);
i = a - b;
if ((i^a) < 0 && (i^~b) < 0) {
PyErr_SetString(PyExc_OverflowError,
"integer subtraction");
x = NULL;
}
else
x = PyInt_FromLong(i);
if ((i^a) < 0 && (i^~b) < 0)
goto slow_isub;
x = PyInt_FromLong(i);
}
else
else {
slow_isub:
x = PyNumber_InPlaceSubtract(v, w);
}
Py_DECREF(v);
Py_DECREF(w);
PUSH(x);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment