diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-10-16 19:34:46 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-10-16 19:34:46 (GMT) |
commit | 60192084c405292f874d886eed05ed83614d20c4 (patch) | |
tree | 390e2ac0930a866fb1a97d35b469109f09df3ecc /Objects | |
parent | aaebe1c11d0eccc067cb6e5bb4e28543441fd2df (diff) | |
download | cpython-60192084c405292f874d886eed05ed83614d20c4.zip cpython-60192084c405292f874d886eed05ed83614d20c4.tar.gz cpython-60192084c405292f874d886eed05ed83614d20c4.tar.bz2 |
remove some more references to __cmp__ #1717
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 85 |
1 files changed, 0 insertions, 85 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 8f1b389..7f9551f 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3536,7 +3536,6 @@ inherit_special(PyTypeObject *type, PyTypeObject *base) static char *hash_name_op[] = { "__eq__", - "__cmp__", "__hash__", NULL }; @@ -4227,32 +4226,6 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped) return Py_None; } -static PyObject * -wrap_cmpfunc(PyObject *self, PyObject *args, void *wrapped) -{ - cmpfunc func = (cmpfunc)wrapped; - int res; - PyObject *other; - - if (!check_num_args(args, 1)) - return NULL; - other = PyTuple_GET_ITEM(args, 0); - if (Py_TYPE(other)->tp_compare != func && - !PyType_IsSubtype(Py_TYPE(other), Py_TYPE(self))) { - PyErr_Format( - PyExc_TypeError, - "%s.__cmp__(x,y) requires y to be a '%s', not a '%s'", - Py_TYPE(self)->tp_name, - Py_TYPE(self)->tp_name, - Py_TYPE(other)->tp_name); - return NULL; - } - res = (*func)(self, other); - if (PyErr_Occurred()) - return NULL; - return PyLong_FromLong((long)res); -} - /* Helper to check for object.__setattr__ or __delattr__ applied to a type. This is called the Carlo Verre hack after its discoverer. */ static int @@ -4878,62 +4851,6 @@ SLOT1BIN(slot_nb_true_divide, nb_true_divide, "__truediv__", "__rtruediv__") SLOT1(slot_nb_inplace_floor_divide, "__ifloordiv__", PyObject *, "O") SLOT1(slot_nb_inplace_true_divide, "__itruediv__", PyObject *, "O") -static int -half_compare(PyObject *self, PyObject *other) -{ - PyObject *func, *args, *res; - static PyObject *cmp_str; - Py_ssize_t c; - - func = lookup_method(self, "__cmp__", &cmp_str); - if (func == NULL) { - PyErr_Clear(); - } - else { - args = PyTuple_Pack(1, other); - if (args == NULL) - res = NULL; - else { - res = PyObject_Call(func, args, NULL); - Py_DECREF(args); - } - Py_DECREF(func); - if (res != Py_NotImplemented) { - if (res == NULL) - return -2; - c = PyLong_AsLong(res); - Py_DECREF(res); - if (c == -1 && PyErr_Occurred()) - return -2; - return (c < 0) ? -1 : (c > 0) ? 1 : 0; - } - Py_DECREF(res); - } - return 2; -} - -/* This slot is published for the benefit of try_3way_compare in object.c */ -int -_PyObject_SlotCompare(PyObject *self, PyObject *other) -{ - int c; - - if (Py_TYPE(self)->tp_compare == _PyObject_SlotCompare) { - c = half_compare(self, other); - if (c <= 1) - return c; - } - if (Py_TYPE(other)->tp_compare == _PyObject_SlotCompare) { - c = half_compare(other, self); - if (c < -1) - return -2; - if (c <= 1) - return -c; - } - return (void *)self < (void *)other ? -1 : - (void *)self > (void *)other ? 1 : 0; -} - static PyObject * slot_tp_repr(PyObject *self) { @@ -5532,8 +5449,6 @@ static slotdef slotdefs[] = { "x.__str__() <==> str(x)"), TPSLOT("__repr__", tp_repr, slot_tp_repr, wrap_unaryfunc, "x.__repr__() <==> repr(x)"), - TPSLOT("__cmp__", tp_compare, _PyObject_SlotCompare, wrap_cmpfunc, - "x.__cmp__(y) <==> cmp(x,y)"), TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, "x.__hash__() <==> hash(x)"), FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, |