binaryfunc nb_add;
binaryfunc nb_subtract;
binaryfunc nb_multiply;
- binaryfunc nb_divide;
binaryfunc nb_remainder;
binaryfunc nb_divmod;
ternaryfunc nb_power;
binaryfunc nb_inplace_add;
binaryfunc nb_inplace_subtract;
binaryfunc nb_inplace_multiply;
- binaryfunc nb_inplace_divide;
binaryfunc nb_inplace_remainder;
ternaryfunc nb_inplace_power;
binaryfunc nb_inplace_lshift;
binaryfunc nb_inplace_or;
/* Added in release 2.2 */
- /* The following require the Py_TPFLAGS_HAVE_CLASS flag */
binaryfunc nb_floor_divide;
binaryfunc nb_true_divide;
binaryfunc nb_inplace_floor_divide;
return ans
__rmul__ = __mul__
- def __div__(self, other, context=None):
+ def __truediv__(self, other, context=None):
"""Return self / other."""
return self._divide(other, context=context)
- __truediv__ = __div__
def _divide(self, other, divmod = 0, context=None):
"""Return a / b, to context.prec precision.
ans = ans._fix(context)
return ans
- def __rdiv__(self, other, context=None):
- """Swaps self/other and returns __div__."""
+ def __rtruediv__(self, other, context=None):
+ """Swaps self/other and returns __truediv__."""
other = _convert_other(other)
if other is NotImplemented:
return other
- return other.__div__(self, context=context)
- __rtruediv__ = __rdiv__
+ return other.__truediv__(self, context=context)
def __divmod__(self, other, context=None):
"""
rounding = context._set_rounding_decision(NEVER_ROUND)
if other._sign:
- comparison = other.__div__(Decimal(-2), context=context)
+ comparison = other.__truediv__(Decimal(-2), context=context)
else:
- comparison = other.__div__(Decimal(2), context=context)
+ comparison = other.__truediv__(Decimal(2), context=context)
context._set_rounding_decision(rounding)
context._regard_flags(*flags)
if n < 0:
#n is a long now, not Decimal instance
n = -n
- mul = Decimal(1).__div__(mul, context=context)
+ mul = Decimal(1).__truediv__(mul, context=context)
spot = 1
while spot <= n:
rounding = context._set_rounding(ROUND_HALF_EVEN)
while 1:
context.prec = min(2*context.prec - 2, maxp)
- ans = half.__mul__(ans.__add__(tmp.__div__(ans, context=context),
+ ans = half.__mul__(ans.__add__(tmp.__truediv__(ans, context=context),
context=context), context=context)
if context.prec == maxp:
break
>>> ExtendedContext.divide(Decimal('2.40E+6'), Decimal('2'))
Decimal("1.20E+6")
"""
- return a.__div__(b, context=self)
+ return a.__truediv__(b, context=self)
def divide_int(self, a, b):
"""Divides two numbers and returns the integer part of the result.
x *= 2
x **= 2
x -= 8
-x //= 2
+x /= 2
x //= 1
x %= 12
x &= 2
x[0] *= 2
x[0] **= 2
x[0] -= 8
-x[0] //= 2
+x[0] /= 2
x[0] //= 2
x[0] %= 12
x[0] &= 2
x[0] *= 2
x[0] **= 2
x[0] -= 8
-x[0] //= 2
+x[0] /= 2
x[0] //= 1
x[0] %= 12
x[0] &= 2
print "__imul__ called"
return self
- def __div__(self, val):
- print "__div__ called"
- def __rdiv__(self, val):
- print "__rdiv__ called"
- def __idiv__(self, val):
- print "__idiv__ called"
- return self
-
def __floordiv__(self, val):
print "__floordiv__ called"
return self
def __itruediv__(self, val):
print "__itruediv__ called"
return self
+ def __rtruediv__(self, val):
+ print "__rtruediv__ called"
+ return self
def __mod__(self, val):
print "__mod__ called"
1 * x
x *= 1
-if 1/2 == 0:
- x / 1
- 1 / x
- x /= 1
-else:
- # True division is in effect, so "/" doesn't map to __div__ etc;
- # but the canned expected-output file requires that those get called.
- x.__div__(1)
- x.__rdiv__(1)
- x.__idiv__(1)
+x / 1
+1 / x
+x /= 1
x // 1
1 // x
return float(self) / other
return NotImplemented
- __div__ = __truediv__
-
def __rtruediv__(self, other):
"""Divide two Rats, or a Rat and a number (reversed args)."""
if isRat(other):
return other / float(self)
return NotImplemented
- __rdiv__ = __rtruediv__
-
def __floordiv__(self, other):
"""Divide two Rats, returning the floored result."""
if isint(other):
"rsub",
"mul",
"rmul",
- "div",
- "rdiv",
+ "truediv",
+ "rtruediv",
"mod",
"rmod",
"divmod",
testme * 1
1 * testme
-if 1/2 == 0:
- testme / 1
- 1 / testme
-else:
- # True division is in effect, so "/" doesn't map to __div__ etc; but
- # the canned expected-output file requires that __div__ etc get called.
- testme.__coerce__(1)
- testme.__div__(1)
- testme.__coerce__(1)
- testme.__rdiv__(1)
+testme / 1
+1 / testme
testme % 1
1 % testme
def __rmul__(self,other):
return other * self.arg
- def __div__(self,other):
+ def __truediv__(self,other):
return self.arg / other
- def __rdiv__(self,other):
+ def __rtruediv__(self,other):
return other / self.arg
def __pow__(self,other):
if x != 0:
q = z / x
self.assertClose(q, y)
- q = z.__div__(x)
- self.assertClose(q, y)
q = z.__truediv__(x)
self.assertClose(q, y)
if y != 0:
q = z / y
self.assertClose(q, x)
- q = z.__div__(y)
- self.assertClose(q, x)
q = z.__truediv__(y)
self.assertClose(q, x)
- def test_div(self):
+ def test_truediv(self):
simple_real = [float(i) for i in xrange(-5, 6)]
simple_complex = [complex(x, y) for x in simple_real for y in simple_real]
for x in simple_complex:
self.check_div(complex(random(), random()),
complex(random(), random()))
- self.assertRaises(ZeroDivisionError, complex.__div__, 1+1j, 0+0j)
+ self.assertRaises(ZeroDivisionError, complex.__truediv__, 1+1j, 0+0j)
# FIXME: The following currently crashes on Alpha
# self.assertRaises(OverflowError, pow, 1e200+1j, 1e200+1j)
('+', '__add__', '__radd__'),
('-', '__sub__', '__rsub__'),
('*', '__mul__', '__rmul__'),
- ('/', '__div__', '__rdiv__'),
+ ('/', '__truediv__', '__rtruediv__'),
('%', '__mod__', '__rmod__'),
('//', '__floordiv__', '__rfloordiv__'),
('**', '__pow__', '__rpow__'),
checkSameDec("__abs__")
checkSameDec("__add__", True)
- checkSameDec("__div__", True)
checkSameDec("__divmod__", True)
checkSameDec("__cmp__", True)
checkSameDec("__float__")
checkSameDec("__pos__")
checkSameDec("__pow__", True)
checkSameDec("__radd__", True)
- checkSameDec("__rdiv__", True)
checkSameDec("__rdivmod__", True)
checkSameDec("__repr__")
checkSameDec("__rfloordiv__", True)
if verbose: print "checking", expr
dict = {'a': a, 'b': b}
- # XXX Hack so this passes before 2.3 when -Qnew is specified.
- if meth == "__div__" and 1/2 == 0.5:
- meth = "__truediv__"
-
vereq(eval(expr, dict), res)
t = type(a)
m = getattr(t, meth)
('__add__', 'x + y', 'x += y'),
('__sub__', 'x - y', 'x -= y'),
('__mul__', 'x * y', 'x *= y'),
- ('__truediv__', 'operator.truediv(x, y)', None),
- ('__floordiv__', 'operator.floordiv(x, y)', None),
- ('__div__', 'x / y', 'x /= y'),
+ ('__truediv__', 'x / y', None),
+ ('__floordiv__', 'x // y', None),
('__mod__', 'x % y', 'x %= y'),
('__divmod__', 'divmod(x, y)', None),
('__pow__', 'x ** y', 'x **= y'),
self.failUnless(operator.delslice(a, 2, 8) is None)
self.assert_(a == [0, 1, 8, 9])
- def test_div(self):
- self.failUnlessRaises(TypeError, operator.div, 5)
- self.failUnlessRaises(TypeError, operator.div, None, None)
- self.failUnless(operator.floordiv(5, 2) == 2)
-
def test_floordiv(self):
self.failUnlessRaises(TypeError, operator.floordiv, 5)
self.failUnlessRaises(TypeError, operator.floordiv, None, None)
class C(object):
def __iadd__ (self, other): return "iadd"
def __iand__ (self, other): return "iand"
- def __idiv__ (self, other): return "idiv"
def __ifloordiv__(self, other): return "ifloordiv"
def __ilshift__ (self, other): return "ilshift"
def __imod__ (self, other): return "imod"
c = C()
self.assertEqual(operator.iadd (c, 5), "iadd")
self.assertEqual(operator.iand (c, 5), "iand")
- self.assertEqual(operator.idiv (c, 5), "idiv")
self.assertEqual(operator.ifloordiv(c, 5), "ifloordiv")
self.assertEqual(operator.ilshift (c, 5), "ilshift")
self.assertEqual(operator.imod (c, 5), "imod")
self.assertEqual(operator.irepeat (c, 5), "imul")
self.assertEqual(operator.__iadd__ (c, 5), "iadd")
self.assertEqual(operator.__iand__ (c, 5), "iand")
- self.assertEqual(operator.__idiv__ (c, 5), "idiv")
self.assertEqual(operator.__ifloordiv__(c, 5), "ifloordiv")
self.assertEqual(operator.__ilshift__ (c, 5), "ilshift")
self.assertEqual(operator.__imod__ (c, 5), "imod")
- Exceptions *must* derive from BaseException.
- Integer division always returns a float. The -Q option is no more.
+ All the following are gone:
+ * PyNumber_Divide and PyNumber_InPlaceDivide
+ * __div__, __rdiv__, and __idiv__
+ * nb_divide, nb_inplace_divide
+ * operator.div, operator.idiv, operator.__div__, operator.__idiv__
+ (Only __truediv__ and __floordiv__ remain, not sure how to handle them
+ if we want to re-use __div__ and friends. If we do, it will make
+ it harder to write code for both 2.x and 3.x.)
- 'as' and 'with' are keywords.
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
delta_add, /* nb_add */
delta_subtract, /* nb_subtract */
delta_multiply, /* nb_multiply */
- delta_divide, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
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*/
date_add, /* nb_add */
date_subtract, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
datetime_add, /* nb_add */
datetime_subtract, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
return NULL;
}
- ans = PyNumber_Divide(num, den);
+ ans = PyNumber_TrueDivide(num, den);
Py_DECREF(num);
Py_DECREF(den);
return ans;
spam2(op_add , PyNumber_Add)
spam2(op_sub , PyNumber_Subtract)
spam2(op_mul , PyNumber_Multiply)
-spam2(op_div , PyNumber_Divide)
spam2(op_floordiv , PyNumber_FloorDivide)
spam2(op_truediv , PyNumber_TrueDivide)
spam2(op_mod , PyNumber_Remainder)
spam2(op_iadd , PyNumber_InPlaceAdd)
spam2(op_isub , PyNumber_InPlaceSubtract)
spam2(op_imul , PyNumber_InPlaceMultiply)
-spam2(op_idiv , PyNumber_InPlaceDivide)
spam2(op_ifloordiv , PyNumber_InPlaceFloorDivide)
spam2(op_itruediv , PyNumber_InPlaceTrueDivide)
spam2(op_imod , PyNumber_InPlaceRemainder)
spam2(add,__add__, "add(a, b) -- Same as a + b.")
spam2(sub,__sub__, "sub(a, b) -- Same as a - b.")
spam2(mul,__mul__, "mul(a, b) -- Same as a * b.")
-spam2(div,__div__, "div(a, b) -- Same as a / b when __future__.division is not in effect.")
spam2(floordiv,__floordiv__, "floordiv(a, b) -- Same as a // b.")
-spam2(truediv,__truediv__, "truediv(a, b) -- Same as a / b when __future__.division is in effect.")
+spam2(truediv,__truediv__, "truediv(a, b) -- Same as a / b.")
spam2(mod,__mod__, "mod(a, b) -- Same as a % b.")
spam2o(neg,__neg__, "neg(a) -- Same as -a.")
spam2o(pos,__pos__, "pos(a) -- Same as +a.")
spam2(iadd,__iadd__, "iadd(a, b) -- Same as a += b.")
spam2(isub,__isub__, "isub(a, b) -- Same as a -= b.")
spam2(imul,__imul__, "imul(a, b) -- Same as a *= b.")
-spam2(idiv,__idiv__, "idiv(a, b) -- Same as a /= b when __future__.division is not in effect.")
spam2(ifloordiv,__ifloordiv__, "ifloordiv(a, b) -- Same as a //= b.")
-spam2(itruediv,__itruediv__, "itruediv(a, b) -- Same as a /= b when __future__.division is in effect.")
+spam2(itruediv,__itruediv__, "itruediv(a, b) -- Same as a /= b.")
spam2(imod,__imod__, "imod(a, b) -- Same as a %= b.")
spam2(ilshift,__ilshift__, "ilshift(a, b) -- Same as a <<= b.")
spam2(irshift,__irshift__, "irshift(a, b) -- Same as a >>= b.")
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 *
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)
0, /* nb_add */
0, /* nb_subtract */
0, /* nb_multiply */
- 0, /* nb_divide */
0, /* nb_remainder */
0, /* nb_divmod */
0, /* nb_power */
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 */
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)
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)
(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 */
(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 */
return PyComplex_FromCComplex(quot);
}
-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)
{
(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 */
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 */
return PyFloat_FromDouble(a);
}
-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)
{
(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*/
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 */
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;
}
(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*/
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*/
return (PyObject *)div;
}
-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)
{
(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*/
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 */
0, /*nb_add*/
(binaryfunc)set_sub, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
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*/
0, /*nb_add*/
(binaryfunc)set_sub, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
0, /*nb_remainder*/
0, /*nb_divmod*/
0, /*nb_power*/
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
string_mod, /*nb_remainder*/
};
COPYNUM(nb_add);
COPYNUM(nb_subtract);
COPYNUM(nb_multiply);
- COPYNUM(nb_divide);
COPYNUM(nb_remainder);
COPYNUM(nb_divmod);
COPYNUM(nb_power);
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);
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);
}
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__")
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")
"*"),
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,
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,
0, /*nb_add*/
0, /*nb_subtract*/
0, /*nb_multiply*/
- 0, /*nb_divide*/
unicode_mod, /*nb_remainder*/
};
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)
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)
(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*/
(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*/
PyHKEY_binaryFailureFunc, /* nb_add */
PyHKEY_binaryFailureFunc, /* nb_subtract */
PyHKEY_binaryFailureFunc, /* nb_multiply */
- PyHKEY_binaryFailureFunc, /* nb_divide */
PyHKEY_binaryFailureFunc, /* nb_remainder */
PyHKEY_binaryFailureFunc, /* nb_divmod */
PyHKEY_ternaryFailureFunc, /* nb_power */