summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2006-03-24 08:14:36 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2006-03-24 08:14:36 (GMT)
commitbcc0db82dc9cb474d56a4cc63748583232d9524f (patch)
tree0107d20b29b61fc7dfd9626ee7257242f8cf6302 /Objects
parented483ba63b9c03845386976bccff5d95df5b570a (diff)
downloadcpython-bcc0db82dc9cb474d56a4cc63748583232d9524f.zip
cpython-bcc0db82dc9cb474d56a4cc63748583232d9524f.tar.gz
cpython-bcc0db82dc9cb474d56a4cc63748583232d9524f.tar.bz2
Get rid of remnants of integer division
Diffstat (limited to 'Objects')
-rw-r--r--Objects/abstract.c2
-rw-r--r--Objects/boolobject.c2
-rw-r--r--Objects/classobject.c4
-rw-r--r--Objects/complexobject.c23
-rw-r--r--Objects/floatobject.c21
-rw-r--r--Objects/intobject.c27
-rw-r--r--Objects/longobject.c18
-rw-r--r--Objects/setobject.c3
-rw-r--r--Objects/stringobject.c1
-rw-r--r--Objects/typeobject.c21
-rw-r--r--Objects/unicodeobject.c1
-rw-r--r--Objects/weakrefobject.c4
12 files changed, 7 insertions, 120 deletions
diff --git a/Objects/abstract.c b/Objects/abstract.c
index 052e3ca..c755654 100644
--- a/Objects/abstract.c
+++ b/Objects/abstract.c
@@ -625,7 +625,6 @@ BINARY_FUNC(PyNumber_And, nb_and, "&")
BINARY_FUNC(PyNumber_Lshift, nb_lshift, "<<")
BINARY_FUNC(PyNumber_Rshift, nb_rshift, ">>")
BINARY_FUNC(PyNumber_Subtract, nb_subtract, "-")
-BINARY_FUNC(PyNumber_Divide, nb_divide, "/")
BINARY_FUNC(PyNumber_Divmod, nb_divmod, "divmod()")
PyObject *
@@ -765,7 +764,6 @@ INPLACE_BINOP(PyNumber_InPlaceAnd, nb_inplace_and, nb_and, "&=")
INPLACE_BINOP(PyNumber_InPlaceLshift, nb_inplace_lshift, nb_lshift, "<<=")
INPLACE_BINOP(PyNumber_InPlaceRshift, nb_inplace_rshift, nb_rshift, ">>=")
INPLACE_BINOP(PyNumber_InPlaceSubtract, nb_inplace_subtract, nb_subtract, "-=")
-INPLACE_BINOP(PyNumber_InPlaceDivide, nb_inplace_divide, nb_divide, "/=")
PyObject *
PyNumber_InPlaceFloorDivide(PyObject *v, PyObject *w)
diff --git a/Objects/boolobject.c b/Objects/boolobject.c
index f2429fe..05784e5 100644
--- a/Objects/boolobject.c
+++ b/Objects/boolobject.c
@@ -106,7 +106,6 @@ static PyNumberMethods bool_as_number = {
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
@@ -129,7 +128,6 @@ static PyNumberMethods bool_as_number = {
0, /* nb_inplace_add */
0, /* nb_inplace_subtract */
0, /* nb_inplace_multiply */
- 0, /* nb_inplace_divide */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 037252d..93acb50 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -1551,7 +1551,6 @@ BINARY(instance_rshift, "rshift", PyNumber_Rshift)
BINARY(instance_add, "add", PyNumber_Add)
BINARY(instance_sub, "sub", PyNumber_Subtract)
BINARY(instance_mul, "mul", PyNumber_Multiply)
-BINARY(instance_div, "div", PyNumber_Divide)
BINARY(instance_mod, "mod", PyNumber_Remainder)
BINARY(instance_divmod, "divmod", PyNumber_Divmod)
BINARY(instance_floordiv, "floordiv", PyNumber_FloorDivide)
@@ -1565,7 +1564,6 @@ BINARY_INPLACE(instance_irshift, "rshift", PyNumber_InPlaceRshift)
BINARY_INPLACE(instance_iadd, "add", PyNumber_InPlaceAdd)
BINARY_INPLACE(instance_isub, "sub", PyNumber_InPlaceSubtract)
BINARY_INPLACE(instance_imul, "mul", PyNumber_InPlaceMultiply)
-BINARY_INPLACE(instance_idiv, "div", PyNumber_InPlaceDivide)
BINARY_INPLACE(instance_imod, "mod", PyNumber_InPlaceRemainder)
BINARY_INPLACE(instance_ifloordiv, "floordiv", PyNumber_InPlaceFloorDivide)
BINARY_INPLACE(instance_itruediv, "truediv", PyNumber_InPlaceTrueDivide)
@@ -2054,7 +2052,6 @@ static PyNumberMethods instance_as_number = {
(binaryfunc)instance_add, /* nb_add */
(binaryfunc)instance_sub, /* nb_subtract */
(binaryfunc)instance_mul, /* nb_multiply */
- (binaryfunc)instance_div, /* nb_divide */
(binaryfunc)instance_mod, /* nb_remainder */
(binaryfunc)instance_divmod, /* nb_divmod */
(ternaryfunc)instance_pow, /* nb_power */
@@ -2077,7 +2074,6 @@ static PyNumberMethods instance_as_number = {
(binaryfunc)instance_iadd, /* nb_inplace_add */
(binaryfunc)instance_isub, /* nb_inplace_subtract */
(binaryfunc)instance_imul, /* nb_inplace_multiply */
- (binaryfunc)instance_idiv, /* nb_inplace_divide */
(binaryfunc)instance_imod, /* nb_inplace_remainder */
(ternaryfunc)instance_ipow, /* nb_inplace_power */
(binaryfunc)instance_ilshift, /* nb_inplace_lshift */
diff --git a/Objects/complexobject.c b/Objects/complexobject.c
index 5c84eff..f0915dd 100644
--- a/Objects/complexobject.c
+++ b/Objects/complexobject.c
@@ -382,27 +382,6 @@ complex_div(PyComplexObject *v, PyComplexObject *w)
}
static PyObject *
-complex_classic_div(PyComplexObject *v, PyComplexObject *w)
-{
- Py_complex quot;
-
- if (Py_DivisionWarningFlag >= 2 &&
- PyErr_Warn(PyExc_DeprecationWarning,
- "classic complex division") < 0)
- return NULL;
-
- PyFPE_START_PROTECT("complex_classic_div", return 0)
- errno = 0;
- quot = c_quot(v->cval,w->cval);
- PyFPE_END_PROTECT(quot)
- if (errno == EDOM) {
- PyErr_SetString(PyExc_ZeroDivisionError, "complex division");
- return NULL;
- }
- return PyComplex_FromCComplex(quot);
-}
-
-static PyObject *
complex_remainder(PyComplexObject *v, PyComplexObject *w)
{
Py_complex div, mod;
@@ -948,7 +927,6 @@ static PyNumberMethods complex_as_number = {
(binaryfunc)complex_add, /* nb_add */
(binaryfunc)complex_sub, /* nb_subtract */
(binaryfunc)complex_mul, /* nb_multiply */
- (binaryfunc)complex_classic_div, /* nb_divide */
(binaryfunc)complex_remainder, /* nb_remainder */
(binaryfunc)complex_divmod, /* nb_divmod */
(ternaryfunc)complex_pow, /* nb_power */
@@ -971,7 +949,6 @@ static PyNumberMethods complex_as_number = {
0, /* nb_inplace_add */
0, /* nb_inplace_subtract */
0, /* nb_inplace_multiply*/
- 0, /* nb_inplace_divide */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
diff --git a/Objects/floatobject.c b/Objects/floatobject.c
index c27a41a..20ed86e 100644
--- a/Objects/floatobject.c
+++ b/Objects/floatobject.c
@@ -642,25 +642,6 @@ float_div(PyObject *v, PyObject *w)
}
static PyObject *
-float_classic_div(PyObject *v, PyObject *w)
-{
- double a,b;
- CONVERT_TO_DOUBLE(v, a);
- CONVERT_TO_DOUBLE(w, b);
- if (Py_DivisionWarningFlag >= 2 &&
- PyErr_Warn(PyExc_DeprecationWarning, "classic float division") < 0)
- return NULL;
- if (b == 0.0) {
- PyErr_SetString(PyExc_ZeroDivisionError, "float division");
- return NULL;
- }
- PyFPE_START_PROTECT("divide", return 0)
- a = a / b;
- PyFPE_END_PROTECT(a)
- return PyFloat_FromDouble(a);
-}
-
-static PyObject *
float_rem(PyObject *v, PyObject *w)
{
double vx, wx;
@@ -1128,7 +1109,6 @@ static PyNumberMethods float_as_number = {
(binaryfunc)float_add, /*nb_add*/
(binaryfunc)float_sub, /*nb_subtract*/
(binaryfunc)float_mul, /*nb_multiply*/
- (binaryfunc)float_classic_div, /*nb_divide*/
(binaryfunc)float_rem, /*nb_remainder*/
(binaryfunc)float_divmod, /*nb_divmod*/
(ternaryfunc)float_pow, /*nb_power*/
@@ -1151,7 +1131,6 @@ static PyNumberMethods float_as_number = {
0, /* nb_inplace_add */
0, /* nb_inplace_subtract */
0, /* nb_inplace_multiply */
- 0, /* nb_inplace_divide */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
diff --git a/Objects/intobject.c b/Objects/intobject.c
index 86e2e8c..c734840 100644
--- a/Objects/intobject.c
+++ b/Objects/intobject.c
@@ -580,29 +580,8 @@ int_div(PyIntObject *x, PyIntObject *y)
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_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);
+ return PyLong_Type.tp_as_number->nb_floor_divide((PyObject *)x,
+ (PyObject *)y);
default:
return NULL;
}
@@ -1034,7 +1013,6 @@ static PyNumberMethods int_as_number = {
(binaryfunc)int_add, /*nb_add*/
(binaryfunc)int_sub, /*nb_subtract*/
(binaryfunc)int_mul, /*nb_multiply*/
- (binaryfunc)int_classic_div, /*nb_divide*/
(binaryfunc)int_mod, /*nb_remainder*/
(binaryfunc)int_divmod, /*nb_divmod*/
(ternaryfunc)int_pow, /*nb_power*/
@@ -1057,7 +1035,6 @@ static PyNumberMethods int_as_number = {
0, /*nb_inplace_add*/
0, /*nb_inplace_subtract*/
0, /*nb_inplace_multiply*/
- 0, /*nb_inplace_divide*/
0, /*nb_inplace_remainder*/
0, /*nb_inplace_power*/
0, /*nb_inplace_lshift*/
diff --git a/Objects/longobject.c b/Objects/longobject.c
index e47c292..7c5ebc4 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -2355,22 +2355,6 @@ long_div(PyObject *v, PyObject *w)
}
static PyObject *
-long_classic_div(PyObject *v, PyObject *w)
-{
- PyLongObject *a, *b, *div;
-
- CONVERT_BINOP(v, w, &a, &b);
- if (Py_DivisionWarningFlag &&
- PyErr_Warn(PyExc_DeprecationWarning, "classic long division") < 0)
- div = NULL;
- else if (l_divmod(a, b, &div, NULL) < 0)
- div = NULL;
- Py_DECREF(a);
- Py_DECREF(b);
- return (PyObject *)div;
-}
-
-static PyObject *
long_true_divide(PyObject *v, PyObject *w)
{
PyLongObject *a, *b;
@@ -3130,7 +3114,6 @@ static PyNumberMethods long_as_number = {
(binaryfunc) long_add, /*nb_add*/
(binaryfunc) long_sub, /*nb_subtract*/
(binaryfunc) long_mul, /*nb_multiply*/
- (binaryfunc) long_classic_div, /*nb_divide*/
(binaryfunc) long_mod, /*nb_remainder*/
(binaryfunc) long_divmod, /*nb_divmod*/
(ternaryfunc) long_pow, /*nb_power*/
@@ -3153,7 +3136,6 @@ static PyNumberMethods long_as_number = {
0, /* nb_inplace_add */
0, /* nb_inplace_subtract */
0, /* nb_inplace_multiply */
- 0, /* nb_inplace_divide */
0, /* nb_inplace_remainder */
0, /* nb_inplace_power */
0, /* nb_inplace_lshift */
diff --git a/Objects/setobject.c b/Objects/setobject.c
index ed3d190..89d574f 100644
--- a/Objects/setobject.c
+++ b/Objects/setobject.c
@@ -1755,7 +1755,6 @@ static PyNumberMethods set_as_number = {
0, /*nb_add*/
(binaryfunc)set_sub, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
@@ -1778,7 +1777,6 @@ static PyNumberMethods set_as_number = {
0, /*nb_inplace_add*/
(binaryfunc)set_isub, /*nb_inplace_subtract*/
0, /*nb_inplace_multiply*/
- 0, /*nb_inplace_divide*/
0, /*nb_inplace_remainder*/
0, /*nb_inplace_power*/
0, /*nb_inplace_lshift*/
@@ -1867,7 +1865,6 @@ static PyNumberMethods frozenset_as_number = {
0, /*nb_add*/
(binaryfunc)set_sub, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
diff --git a/Objects/stringobject.c b/Objects/stringobject.c
index 16d542a..32aacf5 100644
--- a/Objects/stringobject.c
+++ b/Objects/stringobject.c
@@ -3408,7 +3408,6 @@ static PyNumberMethods string_as_number = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
string_mod, /*nb_remainder*/
};
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 65bf404..c02f060 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -3014,7 +3014,6 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
COPYNUM(nb_add);
COPYNUM(nb_subtract);
COPYNUM(nb_multiply);
- COPYNUM(nb_divide);
COPYNUM(nb_remainder);
COPYNUM(nb_divmod);
COPYNUM(nb_power);
@@ -3037,7 +3036,6 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
COPYNUM(nb_inplace_add);
COPYNUM(nb_inplace_subtract);
COPYNUM(nb_inplace_multiply);
- COPYNUM(nb_inplace_divide);
COPYNUM(nb_inplace_remainder);
COPYNUM(nb_inplace_power);
COPYNUM(nb_inplace_lshift);
@@ -3045,12 +3043,11 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base)
COPYNUM(nb_inplace_and);
COPYNUM(nb_inplace_xor);
COPYNUM(nb_inplace_or);
- if (base->tp_flags & Py_TPFLAGS_CHECKTYPES) {
- COPYNUM(nb_true_divide);
- COPYNUM(nb_floor_divide);
- COPYNUM(nb_inplace_true_divide);
- COPYNUM(nb_inplace_floor_divide);
- }
+ COPYNUM(nb_true_divide);
+ COPYNUM(nb_floor_divide);
+ COPYNUM(nb_inplace_true_divide);
+ COPYNUM(nb_inplace_floor_divide);
+ /* XXX(nnorwitz): we don't need to check flags do we? */
if (base->tp_flags & Py_TPFLAGS_HAVE_INDEX) {
COPYNUM(nb_index);
}
@@ -4291,7 +4288,6 @@ slot_mp_ass_subscript(PyObject *self, PyObject *key, PyObject *value)
SLOT1BIN(slot_nb_add, nb_add, "__add__", "__radd__")
SLOT1BIN(slot_nb_subtract, nb_subtract, "__sub__", "__rsub__")
SLOT1BIN(slot_nb_multiply, nb_multiply, "__mul__", "__rmul__")
-SLOT1BIN(slot_nb_divide, nb_divide, "__div__", "__rdiv__")
SLOT1BIN(slot_nb_remainder, nb_remainder, "__mod__", "__rmod__")
SLOT1BIN(slot_nb_divmod, nb_divmod, "__divmod__", "__rdivmod__")
@@ -4470,7 +4466,6 @@ SLOT0(slot_nb_hex, "__hex__")
SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O")
SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O")
SLOT1(slot_nb_inplace_multiply, "__imul__", PyObject *, "O")
-SLOT1(slot_nb_inplace_divide, "__idiv__", PyObject *, "O")
SLOT1(slot_nb_inplace_remainder, "__imod__", PyObject *, "O")
SLOT1(slot_nb_inplace_power, "__ipow__", PyObject *, "O")
SLOT1(slot_nb_inplace_lshift, "__ilshift__", PyObject *, "O")
@@ -5077,10 +5072,6 @@ static slotdef slotdefs[] = {
"*"),
RBINSLOT("__rmul__", nb_multiply, slot_nb_multiply,
"*"),
- BINSLOT("__div__", nb_divide, slot_nb_divide,
- "/"),
- RBINSLOT("__rdiv__", nb_divide, slot_nb_divide,
- "/"),
BINSLOT("__mod__", nb_remainder, slot_nb_remainder,
"%"),
RBINSLOT("__rmod__", nb_remainder, slot_nb_remainder,
@@ -5130,8 +5121,6 @@ static slotdef slotdefs[] = {
wrap_binaryfunc, "-"),
IBSLOT("__imul__", nb_inplace_multiply, slot_nb_inplace_multiply,
wrap_binaryfunc, "*"),
- IBSLOT("__idiv__", nb_inplace_divide, slot_nb_inplace_divide,
- wrap_binaryfunc, "/"),
IBSLOT("__imod__", nb_inplace_remainder, slot_nb_inplace_remainder,
wrap_binaryfunc, "%"),
IBSLOT("__ipow__", nb_inplace_power, slot_nb_inplace_power,
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 52bff2d..7fbce14 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -6445,7 +6445,6 @@ static PyNumberMethods unicode_as_number = {
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
unicode_mod, /*nb_remainder*/
};
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index 1d68bb5..39595ae 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -471,7 +471,6 @@ proxy_compare(PyObject *proxy, PyObject *v)
WRAP_BINARY(proxy_add, PyNumber_Add)
WRAP_BINARY(proxy_sub, PyNumber_Subtract)
WRAP_BINARY(proxy_mul, PyNumber_Multiply)
-WRAP_BINARY(proxy_div, PyNumber_Divide)
WRAP_BINARY(proxy_mod, PyNumber_Remainder)
WRAP_BINARY(proxy_divmod, PyNumber_Divmod)
WRAP_TERNARY(proxy_pow, PyNumber_Power)
@@ -490,7 +489,6 @@ WRAP_UNARY(proxy_float, PyNumber_Float)
WRAP_BINARY(proxy_iadd, PyNumber_InPlaceAdd)
WRAP_BINARY(proxy_isub, PyNumber_InPlaceSubtract)
WRAP_BINARY(proxy_imul, PyNumber_InPlaceMultiply)
-WRAP_BINARY(proxy_idiv, PyNumber_InPlaceDivide)
WRAP_BINARY(proxy_imod, PyNumber_InPlaceRemainder)
WRAP_TERNARY(proxy_ipow, PyNumber_InPlacePower)
WRAP_BINARY(proxy_ilshift, PyNumber_InPlaceLshift)
@@ -591,7 +589,6 @@ static PyNumberMethods proxy_as_number = {
(binaryfunc)proxy_add, /*nb_add*/
(binaryfunc)proxy_sub, /*nb_subtract*/
(binaryfunc)proxy_mul, /*nb_multiply*/
- (binaryfunc)proxy_div, /*nb_divide*/
(binaryfunc)proxy_mod, /*nb_remainder*/
(binaryfunc)proxy_divmod, /*nb_divmod*/
(ternaryfunc)proxy_pow, /*nb_power*/
@@ -614,7 +611,6 @@ static PyNumberMethods proxy_as_number = {
(binaryfunc)proxy_iadd, /*nb_inplace_add*/
(binaryfunc)proxy_isub, /*nb_inplace_subtract*/
(binaryfunc)proxy_imul, /*nb_inplace_multiply*/
- (binaryfunc)proxy_idiv, /*nb_inplace_divide*/
(binaryfunc)proxy_imod, /*nb_inplace_remainder*/
(ternaryfunc)proxy_ipow, /*nb_inplace_power*/
(binaryfunc)proxy_ilshift, /*nb_inplace_lshift*/