summaryrefslogtreecommitdiffstats
path: root/Objects/intobject.c
diff options
context:
space:
mode:
Diffstat (limited to 'Objects/intobject.c')
-rw-r--r--Objects/intobject.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/Objects/intobject.c b/Objects/intobject.c
index d1f241d..108e658 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -512,6 +512,27 @@ int_div(PyIntObject *x, PyIntObject *y)
}
static PyObject *
+int_classic_div(PyIntObject *x, PyIntObject *y)
+{
+ long xi, yi;
+ long d, m;
+ CONVERT_TO_LONG(x, xi);
+ CONVERT_TO_LONG(y, yi);
+ if (Py_DivisionWarningFlag &&
+ PyErr_Warn(PyExc_DeprecationWarning, "classic int division") < 0)
+ return NULL;
+ switch (i_divmod(xi, yi, &d, &m)) {
+ case DIVMOD_OK:
+ return PyInt_FromLong(d);
+ case DIVMOD_OVERFLOW:
+ return PyLong_Type.tp_as_number->nb_divide((PyObject *)x,
+ (PyObject *)y);
+ default:
+ return NULL;
+ }
+}
+
+static PyObject *
int_mod(PyIntObject *x, PyIntObject *y)
{
long xi, yi;
@@ -744,7 +765,7 @@ int_or(PyIntObject *v, PyIntObject *w)
static PyObject *
int_true_divide(PyObject *v, PyObject *w)
{
- return PyFloat_Type.tp_as_number->nb_divide(v, w);
+ return PyFloat_Type.tp_as_number->nb_true_divide(v, w);
}
static PyObject *
@@ -855,7 +876,7 @@ static PyNumberMethods int_as_number = {
(binaryfunc)int_add, /*nb_add*/
(binaryfunc)int_sub, /*nb_subtract*/
(binaryfunc)int_mul, /*nb_multiply*/
- (binaryfunc)int_div, /*nb_divide*/
+ (binaryfunc)int_classic_div, /*nb_divide*/
(binaryfunc)int_mod, /*nb_remainder*/
(binaryfunc)int_divmod, /*nb_divmod*/
(ternaryfunc)int_pow, /*nb_power*/