summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2001-09-25 21:16:33 (GMT)
committerGuido van Rossum <guido@python.org>2001-09-25 21:16:33 (GMT)
commit874f15aa289e30e32a74379749cf9b6bea674fde (patch)
tree02b2fc5c01b5cd0e36bddda6fb46f9dc5e93d1f3 /Objects
parent29a67ced727feaeb62656f485929aa2d4d9ed1d3 (diff)
downloadcpython-874f15aa289e30e32a74379749cf9b6bea674fde.zip
cpython-874f15aa289e30e32a74379749cf9b6bea674fde.tar.gz
cpython-874f15aa289e30e32a74379749cf9b6bea674fde.tar.bz2
add_operators(): the __floordiv__ and __truediv__ descriptors (and
their 'i' and 'r' variants) were not being generated if the corresponding nb_ slots were present in the type object. I bet this is because floor and true division were introduced after I last looked at that part of the code.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/typeobject.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index 1354b81..0e6099c 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -1837,6 +1837,8 @@ BINARY(rshift, "x>>y");
BINARY(and, "x&y");
BINARY(xor, "x^y");
BINARY(or, "x|y");
+BINARY(floordiv, "x//y");
+BINARY(truediv, "x/y # true division");
static PyObject *
wrap_ternaryfunc(PyObject *self, PyObject *args, void *wrapped)
@@ -1915,6 +1917,8 @@ IBINARY(irshift, "x>>=y");
IBINARY(iand, "x&=y");
IBINARY(ixor, "x^=y");
IBINARY(ior, "x|=y");
+IBINARY(ifloordiv, "x//=y");
+IBINARY(itruediv, "x/=y # true division");
#undef ITERNARY
#define ITERNARY(NAME, OP) \
@@ -2586,6 +2590,12 @@ add_operators(PyTypeObject *type)
ADD(nb->nb_inplace_and, tab_iand);
ADD(nb->nb_inplace_xor, tab_ixor);
ADD(nb->nb_inplace_or, tab_ior);
+ if (type->tp_flags & Py_TPFLAGS_CHECKTYPES) {
+ ADD(nb->nb_floor_divide, tab_floordiv);
+ ADD(nb->nb_true_divide, tab_truediv);
+ ADD(nb->nb_inplace_floor_divide, tab_ifloordiv);
+ ADD(nb->nb_inplace_true_divide, tab_itruediv);
+ }
}
ADD(type->tp_getattro, tab_getattr);