mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Consolidate the int and long sequence repeat code. Before the change,
integers checked for integer overflow but longs did not.
This commit is contained in:
parent
9911fc4a41
commit
0df295889c
2 changed files with 0 additions and 65 deletions
|
@ -1508,17 +1508,6 @@ long_sub(PyLongObject *v, PyLongObject *w)
|
|||
return (PyObject *)z;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
long_repeat(PyObject *v, PyLongObject *w)
|
||||
{
|
||||
/* sequence * long */
|
||||
long n = PyLong_AsLong((PyObject *) w);
|
||||
if (n == -1 && PyErr_Occurred())
|
||||
return NULL;
|
||||
else
|
||||
return (*v->ob_type->tp_as_sequence->sq_repeat)(v, n);
|
||||
}
|
||||
|
||||
/* Grade school multiplication, ignoring the signs.
|
||||
* Returns the absolute value of the product, or NULL if error.
|
||||
*/
|
||||
|
@ -1868,14 +1857,6 @@ long_mul(PyLongObject *v, PyLongObject *w)
|
|||
PyLongObject *a, *b, *z;
|
||||
|
||||
if (!convert_binop((PyObject *)v, (PyObject *)w, &a, &b)) {
|
||||
if (!PyLong_Check(v) &&
|
||||
v->ob_type->tp_as_sequence &&
|
||||
v->ob_type->tp_as_sequence->sq_repeat)
|
||||
return long_repeat((PyObject *)v, w);
|
||||
if (!PyLong_Check(w) &&
|
||||
w->ob_type->tp_as_sequence &&
|
||||
w->ob_type->tp_as_sequence->sq_repeat)
|
||||
return long_repeat((PyObject *)w, v);
|
||||
Py_INCREF(Py_NotImplemented);
|
||||
return Py_NotImplemented;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue