Index: Python/traceback.c =================================================================== --- Python/traceback.c (Revision 67635) +++ Python/traceback.c (Arbeitskopie) @@ -72,7 +72,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Python/ast.c =================================================================== --- Python/ast.c (Revision 67635) +++ Python/ast.c (Arbeitskopie) @@ -367,7 +367,7 @@ const char **p; assert(PyUnicode_Check(e->v.Name.id)); for (p = FORBIDDEN; *p; p++) { - if (PyUnicode_CompareWithASCIIString(e->v.Name.id, *p) == 0) { + if (PyUnicode_EqualToASCIIString(e->v.Name.id, *p)) { ast_error(n, "assignment to keyword"); return 1; } @@ -2020,7 +2020,7 @@ key = e->v.Name.id; for (k = 0; k < nkeywords; k++) { tmp = ((keyword_ty)asdl_seq_GET(keywords, k))->arg; - if (!PyUnicode_Compare(tmp, key)) { + if (PyObject_RichCompareBool(tmp, key, Py_EQ) != 0) { ast_error(CHILD(ch, 0), "keyword argument repeated"); return NULL; } Index: Python/import.c =================================================================== --- Python/import.c (Revision 67635) +++ Python/import.c (Arbeitskopie) @@ -3243,7 +3243,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Python/symtable.c =================================================================== --- Python/symtable.c (Revision 67635) +++ Python/symtable.c (Arbeitskopie) @@ -130,7 +130,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)ste_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -494,7 +494,7 @@ if (!PySet_Contains(free, name)) continue; if (restricted != NULL && - PyUnicode_CompareWithASCIIString(name, restricted)) + !PyUnicode_EqualToASCIIString(name, restricted)) continue; /* Replace LOCAL with CELL for this name, and remove from free. It is safe to replace the value of name @@ -1326,7 +1326,7 @@ /* Special-case super: it counts as a use of __class__ */ if (e->v.Name.ctx == Load && st->st_cur->ste_type == FunctionBlock && - !PyUnicode_CompareWithASCIIString(e->v.Name.id, "super")) { + PyUnicode_EqualToASCIIString(e->v.Name.id, "super")) { if (!GET_IDENTIFIER(__class__) || !symtable_add_def(st, __class__, USE)) return 0; @@ -1466,7 +1466,7 @@ store_name = name; Py_INCREF(store_name); } - if (PyUnicode_CompareWithASCIIString(name, "*")) { + if (!PyUnicode_EqualToASCIIString(name, "*")) { int r = symtable_add_def(st, store_name, DEF_IMPORT); Py_DECREF(store_name); return r; Index: Python/compile.c =================================================================== --- Python/compile.c (Revision 67635) +++ Python/compile.c (Arbeitskopie) @@ -2195,8 +2195,8 @@ } if (s->lineno > c->c_future->ff_lineno) { - if (!PyUnicode_CompareWithASCIIString(s->v.ImportFrom.module, - "__future__")) { + if (PyUnicode_EqualToASCIIString(s->v.ImportFrom.module, + "__future__")) { Py_DECREF(level); Py_DECREF(names); return compiler_error(c, Index: Python/Python-ast.c =================================================================== --- Python/Python-ast.c (Revision 67635) +++ Python/Python-ast.c (Arbeitskopie) @@ -479,7 +479,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Python/bltinmodule.c =================================================================== --- Python/bltinmodule.c (Revision 67635) +++ Python/bltinmodule.c (Arbeitskopie) @@ -417,7 +417,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -494,25 +494,6 @@ ; -static PyObject * -builtin_cmp(PyObject *self, PyObject *args) -{ - PyObject *a, *b; - int c; - - if (!PyArg_UnpackTuple(args, "cmp", 2, 2, &a, &b)) - return NULL; - if (PyObject_Cmp(a, b, &c) < 0) - return NULL; - return PyLong_FromLong((long)c); -} - -PyDoc_STRVAR(cmp_doc, -"cmp(x, y) -> integer\n\ -\n\ -Return negative if xy."); - - static char * source_as_string(PyObject *cmd, char *funcname, char *what) { @@ -1037,7 +1018,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2190,7 +2171,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2235,7 +2216,6 @@ {"ascii", builtin_ascii, METH_O, ascii_doc}, {"bin", builtin_bin, METH_O, bin_doc}, {"chr", builtin_chr, METH_VARARGS, chr_doc}, - {"cmp", builtin_cmp, METH_VARARGS, cmp_doc}, {"compile", (PyCFunction)builtin_compile, METH_VARARGS | METH_KEYWORDS, compile_doc}, {"delattr", builtin_delattr, METH_VARARGS, delattr_doc}, {"dir", builtin_dir, METH_VARARGS, dir_doc}, Index: Include/unicodeobject.h =================================================================== --- Include/unicodeobject.h (Revision 67635) +++ Include/unicodeobject.h (Arbeitskopie) @@ -152,7 +152,6 @@ # define PyUnicode_AsUnicode PyUnicodeUCS2_AsUnicode # define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS2_AsUnicodeEscapeString # define PyUnicode_AsWideChar PyUnicodeUCS2_AsWideChar -# define PyUnicode_Compare PyUnicodeUCS2_Compare # define PyUnicode_Concat PyUnicodeUCS2_Concat # define PyUnicode_Append PyUnicodeUCS2_Append # define PyUnicode_AppendAndDel PyUnicodeUCS2_AppendAndDel @@ -250,7 +249,6 @@ # define PyUnicode_AsUnicode PyUnicodeUCS4_AsUnicode # define PyUnicode_AsUnicodeEscapeString PyUnicodeUCS4_AsUnicodeEscapeString # define PyUnicode_AsWideChar PyUnicodeUCS4_AsWideChar -# define PyUnicode_Compare PyUnicodeUCS4_Compare # define PyUnicode_Concat PyUnicodeUCS4_Concat # define PyUnicode_Append PyUnicodeUCS4_Append # define PyUnicode_AppendAndDel PyUnicodeUCS4_AppendAndDel @@ -1399,15 +1397,10 @@ -1 = all */ ); -/* Compare two strings and return -1, 0, 1 for less than, equal, - greater than resp. */ +/* Compare two strings and return 1 if both are equal, otherwise 0 + */ -PyAPI_FUNC(int) PyUnicode_Compare( - PyObject *left, /* Left string */ - PyObject *right /* Right string */ - ); - -PyAPI_FUNC(int) PyUnicode_CompareWithASCIIString( +PyAPI_FUNC(int) PyUnicode_EqualToASCIIString( PyObject *left, const char *right ); Index: Include/object.h =================================================================== --- Include/object.h (Revision 67635) +++ Include/object.h (Arbeitskopie) @@ -272,7 +272,6 @@ typedef PyObject *(*getattrofunc)(PyObject *, PyObject *); typedef int (*setattrfunc)(PyObject *, char *, PyObject *); typedef int (*setattrofunc)(PyObject *, PyObject *, PyObject *); -typedef int (*cmpfunc)(PyObject *, PyObject *); typedef PyObject *(*reprfunc)(PyObject *); typedef long (*hashfunc)(PyObject *); typedef PyObject *(*richcmpfunc) (PyObject *, PyObject *, int); @@ -295,7 +294,7 @@ printfunc tp_print; getattrfunc tp_getattr; setattrfunc tp_setattr; - cmpfunc tp_compare; + void *tp_reserved; /* formaly known as tp_compare */ reprfunc tp_repr; /* Method suites for standard classes */ @@ -424,7 +423,6 @@ PyAPI_FUNC(PyObject *) PyObject_Str(PyObject *); PyAPI_FUNC(PyObject *) PyObject_ASCII(PyObject *); PyAPI_FUNC(PyObject *) PyObject_Bytes(PyObject *); -PyAPI_FUNC(int) PyObject_Compare(PyObject *, PyObject *); PyAPI_FUNC(PyObject *) PyObject_RichCompare(PyObject *, PyObject *, int); PyAPI_FUNC(int) PyObject_RichCompareBool(PyObject *, PyObject *, int); PyAPI_FUNC(PyObject *) Py_CmpToRich(int op, int cmp); Index: Objects/complexobject.c =================================================================== --- Objects/complexobject.c (Revision 67635) +++ Objects/complexobject.c (Arbeitskopie) @@ -1095,7 +1095,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)complex_repr, /* tp_repr */ &complex_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/codeobject.c =================================================================== --- Objects/codeobject.c (Revision 67635) +++ Objects/codeobject.c (Arbeitskopie) @@ -399,7 +399,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)code_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/abstract.c =================================================================== --- Objects/abstract.c (Revision 67635) +++ Objects/abstract.c (Arbeitskopie) @@ -25,24 +25,6 @@ return NULL; } -/* Operations on any object */ - -int -PyObject_Cmp(PyObject *o1, PyObject *o2, int *result) -{ - int r; - - if (o1 == NULL || o2 == NULL) { - null_error(); - return -1; - } - r = PyObject_Compare(o1, o2); - if (PyErr_Occurred()) - return -1; - *result = r; - return 0; -} - PyObject * PyObject_Type(PyObject *o) { Index: Objects/object.c =================================================================== --- Objects/object.c (Revision 67635) +++ Objects/object.c (Arbeitskopie) @@ -494,24 +494,24 @@ /* The new comparison philosophy is: we completely separate three-way comparison from rich comparison. That is, PyObject_Compare() and - PyObject_Cmp() *just* use the tp_compare slot. And PyObject_RichCompare() + PyObject_Cmp() *just* use the tp_reserved slot. And PyObject_RichCompare() and PyObject_RichCompareBool() *just* use the tp_richcompare slot. See (*) below for practical amendments. - IOW, only cmp() uses tp_compare; the comparison operators (==, !=, <=, <, + IOW, only cmp() uses tp_reserved; the comparison operators (==, !=, <=, <, >=, >) only use tp_richcompare. Note that list.sort() only uses <. - (And yes, eventually we'll rip out cmp() and tp_compare.) + (And yes, eventually we'll rip out cmp() and tp_reserved.) - The calling conventions are different: tp_compare only gets called with two + The calling conventions are different: tp_reserved only gets called with two objects of the appropriate type; tp_richcompare gets called with a first argument of the appropriate type and a second object of an arbitrary type. We never do any kind of coercion. The return conventions are also different. - The tp_compare slot should return a C int, as follows: + The tp_reserved slot should return a C int, as follows: -1 if a < b or if an exception occurred 0 if a == b @@ -541,68 +541,6 @@ */ -/* Forward */ -static PyObject *do_richcompare(PyObject *v, PyObject *w, int op); - -/* Perform a three-way comparison, raising TypeError if three-way comparison - is not supported. */ -static int -do_compare(PyObject *v, PyObject *w) -{ - cmpfunc f; - int ok; - - if (v->ob_type == w->ob_type && - (f = v->ob_type->tp_compare) != NULL) { - return (*f)(v, w); - } - - /* Now try three-way compare before giving up. This is intentionally - elaborate; if you have a it will raise TypeError if it detects two - objects that aren't ordered with respect to each other. */ - ok = PyObject_RichCompareBool(v, w, Py_LT); - if (ok < 0) - return -1; /* Error */ - if (ok) - return -1; /* Less than */ - ok = PyObject_RichCompareBool(v, w, Py_GT); - if (ok < 0) - return -1; /* Error */ - if (ok) - return 1; /* Greater than */ - ok = PyObject_RichCompareBool(v, w, Py_EQ); - if (ok < 0) - return -1; /* Error */ - if (ok) - return 0; /* Equal */ - - /* Give up */ - PyErr_Format(PyExc_TypeError, - "unorderable types: '%.100s' != '%.100s'", - v->ob_type->tp_name, - w->ob_type->tp_name); - return -1; -} - -/* Perform a three-way comparison. This wraps do_compare() with a check for - NULL arguments and a recursion check. */ -int -PyObject_Compare(PyObject *v, PyObject *w) -{ - int res; - - if (v == NULL || w == NULL) { - if (!PyErr_Occurred()) - PyErr_BadInternalCall(); - return -1; - } - if (Py_EnterRecursiveCall(" in cmp")) - return -1; - res = do_compare(v, w); - Py_LeaveRecursiveCall(); - return res < 0 ? -1 : res; -} - /* Map rich comparison operators to their swapped version, e.g. LT <--> GT */ int _Py_SwappedOp[] = {Py_GT, Py_GE, Py_EQ, Py_NE, Py_LT, Py_LE}; @@ -1519,7 +1457,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ none_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -1550,7 +1488,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ NotImplemented_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Objects/cellobject.c =================================================================== --- Objects/cellobject.c (Revision 67635) +++ Objects/cellobject.c (Arbeitskopie) @@ -51,18 +51,6 @@ PyObject_GC_Del(op); } -static int -cell_compare(PyCellObject *a, PyCellObject *b) -{ - if (a->ob_ref == NULL) { - if (b->ob_ref == NULL) - return 0; - return -1; - } else if (b->ob_ref == NULL) - return 1; - return PyObject_Compare(a->ob_ref, b->ob_ref); -} - static PyObject * cell_repr(PyCellObject *op) { @@ -114,7 +102,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)cell_compare, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)cell_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/methodobject.c =================================================================== --- Objects/methodobject.c (Revision 67635) +++ Objects/methodobject.c (Arbeitskopie) @@ -254,7 +254,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)meth_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/typeobject.c =================================================================== --- Objects/typeobject.c (Revision 67635) +++ Objects/typeobject.c (Arbeitskopie) @@ -656,7 +656,7 @@ if (name == NULL) return NULL; - if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) + if (mod != NULL && !PyUnicode_EqualToASCIIString(mod, "builtins")) rtn = PyUnicode_FromFormat("", mod, name); else rtn = PyUnicode_FromFormat("", type->tp_name); @@ -2029,7 +2029,7 @@ if (!valid_identifier(tmp)) goto bad_slots; assert(PyUnicode_Check(tmp)); - if (PyUnicode_CompareWithASCIIString(tmp, "__dict__") == 0) { + if (PyUnicode_EqualToASCIIString(tmp, "__dict__")) { if (!may_add_dict || add_dict) { PyErr_SetString(PyExc_TypeError, "__dict__ slot disallowed: " @@ -2038,7 +2038,7 @@ } add_dict++; } - if (PyUnicode_CompareWithASCIIString(tmp, "__weakref__") == 0) { + if (PyUnicode_EqualToASCIIString(tmp, "__weakref__")) { if (!may_add_weak || add_weak) { PyErr_SetString(PyExc_TypeError, "__weakref__ slot disallowed: " @@ -2060,9 +2060,9 @@ for (i = j = 0; i < nslots; i++) { tmp = PyTuple_GET_ITEM(slots, i); if ((add_dict && - PyUnicode_CompareWithASCIIString(tmp, "__dict__") == 0) || + PyUnicode_EqualToASCIIString(tmp, "__dict__")) || (add_weak && - PyUnicode_CompareWithASCIIString(tmp, "__weakref__") == 0)) + PyUnicode_EqualToASCIIString(tmp, "__weakref__"))) continue; tmp =_Py_Mangle(name, tmp); if (!tmp) @@ -2584,7 +2584,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)type_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2791,11 +2791,12 @@ name = type_name(type, NULL); if (name == NULL) return NULL; - if (mod != NULL && PyUnicode_CompareWithASCIIString(mod, "builtins")) + if (mod != NULL && !PyUnicode_EqualToASCIIString(mod, "builtins")) rtn = PyUnicode_FromFormat("<%U.%U object at %p>", mod, name, self); else rtn = PyUnicode_FromFormat("<%s object at %p>", type->tp_name, self); + Py_XDECREF(mod); Py_DECREF(name); return rtn; @@ -2897,7 +2898,7 @@ slots_a = ((PyHeapTypeObject *)a)->ht_slots; slots_b = ((PyHeapTypeObject *)b)->ht_slots; if (slots_a && slots_b) { - if (PyObject_Compare(slots_a, slots_b) != 0) + if (PyObject_RichCompareBool(slots_a, slots_b, Py_NE) == 1) return 0; size += sizeof(PyObject *) * PyTuple_GET_SIZE(slots_a); } @@ -3357,7 +3358,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ object_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3663,7 +3664,7 @@ type->tp_setattr = base->tp_setattr; type->tp_setattro = base->tp_setattro; } - /* tp_compare see tp_richcompare */ + /* tp_reserved is ignored, see tp_richcompare */ COPYSLOT(tp_repr); /* tp_hash see tp_richcompare */ COPYSLOT(tp_call); @@ -3671,12 +3672,10 @@ { /* Copy comparison-related slots only when not overriding them anywhere */ - if (type->tp_compare == NULL && - type->tp_richcompare == NULL && + if (type->tp_richcompare == NULL && type->tp_hash == NULL && !overrides_hash(type)) { - type->tp_compare = base->tp_compare; type->tp_richcompare = base->tp_richcompare; type->tp_hash = base->tp_hash; } @@ -3889,6 +3888,13 @@ goto error; } + /* Check reserved slots */ + if (type->tp_reserved) { + PyErr_Format(PyExc_TypeError, + "type %s has tp_reserved", + type->tp_name); + } + /* All done -- set the ready flag */ assert(type->tp_dict != NULL); type->tp_flags = @@ -5971,7 +5977,7 @@ (i.e. super, or a subclass), not the class of su->obj. */ skip = (PyUnicode_Check(name) && PyUnicode_GET_SIZE(name) == 9 && - PyUnicode_CompareWithASCIIString(name, "__class__") == 0); + PyUnicode_EqualToASCIIString(name, "__class__")); } if (!skip) { @@ -6168,8 +6174,8 @@ for (i = 0; i < n; i++) { PyObject *name = PyTuple_GET_ITEM(co->co_freevars, i); assert(PyUnicode_Check(name)); - if (!PyUnicode_CompareWithASCIIString(name, - "__class__")) { + if (PyUnicode_EqualToASCIIString(name, + "__class__")) { Py_ssize_t index = co->co_nlocals + PyTuple_GET_SIZE(co->co_cellvars) + i; PyObject *cell = f->f_localsplus[index]; @@ -6252,7 +6258,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ super_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/dictobject.c =================================================================== --- Objects/dictobject.c (Revision 67635) +++ Objects/dictobject.c (Arbeitskopie) @@ -2032,7 +2032,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)dict_repr, /* tp_repr */ 0, /* tp_as_number */ &dict_as_sequence, /* tp_as_sequence */ @@ -2217,7 +2217,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2289,7 +2289,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2375,7 +2375,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2682,7 +2682,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ &dictviews_as_number, /* tp_as_number */ &dictkeys_as_sequence, /* tp_as_sequence */ @@ -2766,7 +2766,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ &dictviews_as_number, /* tp_as_number */ &dictitems_as_sequence, /* tp_as_sequence */ @@ -2831,7 +2831,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &dictvalues_as_sequence, /* tp_as_sequence */ Index: Objects/weakrefobject.c =================================================================== --- Objects/weakrefobject.c (Revision 67635) +++ Objects/weakrefobject.c (Arbeitskopie) @@ -342,7 +342,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ (reprfunc)weakref_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -643,7 +643,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)proxy_repr, /* tp_repr */ &proxy_as_number, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ @@ -676,7 +676,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (unaryfunc)proxy_repr, /* tp_repr */ &proxy_as_number, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (Revision 67635) +++ Objects/unicodeobject.c (Arbeitskopie) @@ -6477,21 +6477,8 @@ #endif -int PyUnicode_Compare(PyObject *left, - PyObject *right) -{ - if (PyUnicode_Check(left) && PyUnicode_Check(right)) - return unicode_compare((PyUnicodeObject *)left, - (PyUnicodeObject *)right); - PyErr_Format(PyExc_TypeError, - "Can't compare %.100s and %.100s", - left->ob_type->tp_name, - right->ob_type->tp_name); - return -1; -} - int -PyUnicode_CompareWithASCIIString(PyObject* uni, const char* str) +PyUnicode_EqualToASCIIString(PyObject* uni, const char* str) { int i; Py_UNICODE *id; @@ -6500,12 +6487,10 @@ /* Compare Unicode string and source character set string */ for (i = 0; id[i] && str[i]; i++) if (id[i] != str[i]) - return ((int)id[i] < (int)str[i]) ? -1 : 1; - if (id[i]) - return 1; /* uni is longer */ - if (str[i]) - return -1; /* str is longer */ - return 0; + return 0; + if (id[i] || str[i]) + return 0; + return 1; } PyObject *PyUnicode_RichCompare(PyObject *left, @@ -6514,9 +6499,13 @@ { int result; - result = PyUnicode_Compare(left, right); - if (result == -1 && PyErr_Occurred()) - goto onError; + if (PyUnicode_Check(left) && PyUnicode_Check(right)) { + result = unicode_compare((PyUnicodeObject *)left, + (PyUnicodeObject *)right); + } else { + Py_INCREF(Py_NotImplemented); + return Py_NotImplemented; + } /* Convert the return value to a Boolean */ switch (op) { @@ -6540,49 +6529,6 @@ break; } return PyBool_FromLong(result); - - onError: - - /* Standard case - - Type errors mean that PyUnicode_FromObject() could not convert - one of the arguments (usually the right hand side) to Unicode, - ie. we can't handle the comparison request. However, it is - possible that the other object knows a comparison method, which - is why we return Py_NotImplemented to give the other object a - chance. - - */ - if (PyErr_ExceptionMatches(PyExc_TypeError)) { - PyErr_Clear(); - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if (op != Py_EQ && op != Py_NE) - return NULL; - - /* Equality comparison. - - This is a special case: we silence any PyExc_UnicodeDecodeError - and instead turn it into a PyErr_UnicodeWarning. - - */ - if (!PyErr_ExceptionMatches(PyExc_UnicodeDecodeError)) - return NULL; - PyErr_Clear(); - if (PyErr_WarnEx(PyExc_UnicodeWarning, - (op == Py_EQ) ? - "equal comparison " - "failed to convert both arguments to str - " - "interpreting them as being unequal" - : - "Unicode unequal comparison " - "failed to convert both arguments to str - " - "interpreting them as being unequal", - 1) < 0) - return NULL; - result = (op == Py_NE); - return PyBool_FromLong(result); } int PyUnicode_Contains(PyObject *container, Index: Objects/tupleobject.c =================================================================== --- Objects/tupleobject.c (Revision 67635) +++ Objects/tupleobject.c (Arbeitskopie) @@ -727,7 +727,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)tuplerepr, /* tp_repr */ 0, /* tp_as_number */ &tuple_as_sequence, /* tp_as_sequence */ @@ -930,7 +930,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/boolobject.c =================================================================== --- Objects/boolobject.c (Revision 67635) +++ Objects/boolobject.c (Arbeitskopie) @@ -139,7 +139,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ bool_repr, /* tp_repr */ &bool_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/rangeobject.c =================================================================== --- Objects/rangeobject.c (Revision 67635) +++ Objects/rangeobject.c (Arbeitskopie) @@ -123,7 +123,7 @@ Algorithm is equal to that of get_len_of_range(), but it operates on PyObjects (which are assumed to be PyLong or PyInt objects). ---------------------------------------------------------------*/ - int cmp_result, cmp_call; + int cmp_result; PyObject *lo, *hi; PyObject *step = NULL; PyObject *diff = NULL; @@ -134,13 +134,11 @@ PyObject *zero = PyLong_FromLong(0); if (zero == NULL) return NULL; - cmp_call = PyObject_Cmp(r->step, zero, &cmp_result); - Py_DECREF(zero); - if (cmp_call == -1) + if ((cmp_result = PyObject_RichCompareBool(r->step, zero, Py_GT)) == -1) { + Py_DECREF(zero); return NULL; - - assert(cmp_result != 0); - if (cmp_result > 0) { + } + if (cmp_result == 1) { lo = r->start; hi = r->stop; step = r->step; @@ -154,7 +152,7 @@ } /* if (lo >= hi), return length of 0. */ - if (PyObject_Compare(lo, hi) >= 0) { + if (PyObject_RichCompareBool(lo, hi, Py_GE) == 1) { Py_XDECREF(step); return PyLong_FromLong(0); } @@ -290,7 +288,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)range_repr, /* tp_repr */ 0, /* tp_as_number */ &range_as_sequence, /* tp_as_sequence */ @@ -386,7 +384,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -538,7 +536,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/descrobject.c =================================================================== --- Objects/descrobject.c (Revision 67635) +++ Objects/descrobject.c (Arbeitskopie) @@ -392,7 +392,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)method_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -430,7 +430,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)method_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -467,7 +467,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)member_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -504,7 +504,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)getset_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -541,7 +541,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)wrapperdescr_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -774,12 +774,6 @@ return 0; } -static int -proxy_compare(proxyobject *v, PyObject *w) -{ - return PyObject_Compare(v->dict, w); -} - static PyObject * proxy_richcompare(proxyobject *v, PyObject *w, int op) { @@ -796,7 +790,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)proxy_compare, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &proxy_as_sequence, /* tp_as_sequence */ @@ -861,15 +855,6 @@ Py_TRASHCAN_SAFE_END(wp) } -static int -wrapper_compare(wrapperobject *a, wrapperobject *b) -{ - if (a->descr == b->descr) - return PyObject_Compare(a->self, b->self); - else - return (a->descr < b->descr) ? -1 : 1; -} - static long wrapper_hash(wrapperobject *wp) { @@ -977,7 +962,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)wrapper_compare, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)wrapper_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1309,7 +1294,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/memoryobject.c =================================================================== --- Objects/memoryobject.c (Revision 67635) +++ Objects/memoryobject.c (Arbeitskopie) @@ -799,7 +799,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)memory_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/genobject.c =================================================================== --- Objects/genobject.c (Revision 67635) +++ Objects/genobject.c (Arbeitskopie) @@ -333,7 +333,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)gen_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/listobject.c =================================================================== --- Objects/listobject.c (Revision 67635) +++ Objects/listobject.c (Arbeitskopie) @@ -1784,7 +1784,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2565,7 +2565,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)list_repr, /* tp_repr */ 0, /* tp_as_number */ &list_as_sequence, /* tp_as_sequence */ @@ -2631,7 +2631,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2753,7 +2753,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/fileobject.c =================================================================== --- Objects/fileobject.c (Revision 67635) +++ Objects/fileobject.c (Arbeitskopie) @@ -490,7 +490,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)stdprinter_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/cobject.c =================================================================== --- Objects/cobject.c (Revision 67635) +++ Objects/cobject.c (Arbeitskopie) @@ -137,7 +137,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Objects/stringlib/string_format.h =================================================================== --- Objects/stringlib/string_format.h (Revision 67635) +++ Objects/stringlib/string_format.h (Arbeitskopie) @@ -1064,7 +1064,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1197,7 +1197,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/moduleobject.c =================================================================== --- Objects/moduleobject.c (Revision 67635) +++ Objects/moduleobject.c (Arbeitskopie) @@ -377,7 +377,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)module_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/bytesobject.c =================================================================== --- Objects/bytesobject.c (Revision 67635) +++ Objects/bytesobject.c (Arbeitskopie) @@ -3094,7 +3094,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)string_repr, /* tp_repr */ 0, /* tp_as_number */ &string_as_sequence, /* tp_as_sequence */ @@ -3428,7 +3428,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/frameobject.c =================================================================== --- Objects/frameobject.c (Revision 67635) +++ Objects/frameobject.c (Arbeitskopie) @@ -546,7 +546,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/exceptions.c =================================================================== --- Objects/exceptions.c (Revision 67635) +++ Objects/exceptions.c (Arbeitskopie) @@ -320,7 +320,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /* tp_compare; */ + 0, /* tp_reserved; */ (reprfunc)BaseException_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Objects/setobject.c =================================================================== --- Objects/setobject.c (Revision 67635) +++ Objects/setobject.c (Arbeitskopie) @@ -869,7 +869,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1816,13 +1816,6 @@ return Py_NotImplemented; } -static int -set_nocmp(PyObject *self, PyObject *other) -{ - PyErr_SetString(PyExc_TypeError, "cannot compare sets using cmp()"); - return -1; -} - static PyObject * set_add(PySetObject *so, PyObject *key) { @@ -2103,7 +2096,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - set_nocmp, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)set_repr, /* tp_repr */ &set_as_number, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ @@ -2200,7 +2193,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - set_nocmp, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)set_repr, /* tp_repr */ &frozenset_as_number, /* tp_as_number */ &set_as_sequence, /* tp_as_sequence */ Index: Objects/funcobject.c =================================================================== --- Objects/funcobject.c (Revision 67635) +++ Objects/funcobject.c (Arbeitskopie) @@ -659,7 +659,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)func_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -805,7 +805,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -952,7 +952,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/longobject.c =================================================================== --- Objects/longobject.c (Revision 67635) +++ Objects/longobject.c (Arbeitskopie) @@ -3758,7 +3758,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ long_repr, /* tp_repr */ &long_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/sliceobject.c =================================================================== --- Objects/sliceobject.c (Revision 67635) +++ Objects/sliceobject.c (Arbeitskopie) @@ -31,7 +31,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ ellipsis_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -352,7 +352,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)slice_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/bytearrayobject.c =================================================================== --- Objects/bytearrayobject.c (Revision 67635) +++ Objects/bytearrayobject.c (Arbeitskopie) @@ -3173,7 +3173,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)bytes_repr, /* tp_repr */ 0, /* tp_as_number */ &bytes_as_sequence, /* tp_as_sequence */ @@ -3282,7 +3282,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/iterobject.c =================================================================== --- Objects/iterobject.c (Revision 67635) +++ Objects/iterobject.c (Arbeitskopie) @@ -103,7 +103,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -207,7 +207,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/enumobject.c =================================================================== --- Objects/enumobject.c (Revision 67635) +++ Objects/enumobject.c (Arbeitskopie) @@ -176,7 +176,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -326,7 +326,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/classobject.c =================================================================== --- Objects/classobject.c (Revision 67635) +++ Objects/classobject.c (Arbeitskopie) @@ -348,7 +348,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)method_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -614,7 +614,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)instancemethod_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/floatobject.c =================================================================== --- Objects/floatobject.c (Revision 67635) +++ Objects/floatobject.c (Arbeitskopie) @@ -1825,7 +1825,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)float_repr, /* tp_repr */ &float_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Objects/structseq.c =================================================================== --- Objects/structseq.c (Revision 67635) +++ Objects/structseq.c (Arbeitskopie) @@ -440,7 +440,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)structseq_repr, /* tp_repr */ 0, /* tp_as_number */ &structseq_as_sequence, /* tp_as_sequence */ Index: Misc/NEWS =================================================================== --- Misc/NEWS (Revision 67635) +++ Misc/NEWS (Arbeitskopie) @@ -12,6 +12,13 @@ Core and Builtins ----------------- +- Issue #1717: Removed builtin cmp() function, dropped tp_compare + slot, the C API functions PyObject_Compare and PyUnicode_Compare + and the type definition cmpfunc. PyUnicode_CompareWithASCIIString + was replaced PyUnicode_EqualToASCIIString. + The tp_compare slot is reserved for future usage. A type definition + with an assigned tp_compare slot will raise a TypeError. + - Issue #4445: Replace "sizeof(PyBytesObject)" with "offsetof(PyBytesObject, ob_sval) + 1" when allocating memory for bytes instances. On a typical machine this saves 3 bytes of memory Index: PC/_subprocess.c =================================================================== --- PC/_subprocess.c (Revision 67635) +++ PC/_subprocess.c (Arbeitskopie) @@ -133,7 +133,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ &sp_handle_as_number, /*tp_as_number */ 0, /*tp_as_sequence */ Index: PC/winreg.c =================================================================== --- PC/winreg.c (Revision 67635) +++ PC/winreg.c (Arbeitskopie) @@ -326,7 +326,7 @@ "Operations:\n" "__bool__ - Handles with an open object return true, otherwise false.\n" "__int__ - Converting a handle to an integer returns the Win32 handle.\n" -"__cmp__ - Handle objects are compared using the handle value."); +"rich comparison - Handle objects are compared using the handle value."); PyDoc_STRVAR(PyHKEY_Close_doc, @@ -485,7 +485,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - PyHKEY_compareFunc, /* tp_compare */ + PyHKEY_compareFunc, /* tp_reserved */ 0, /* tp_repr */ &PyHKEY_NumberMethods, /* tp_as_number */ 0, /* tp_as_sequence */ Index: PC/_msi.c =================================================================== --- PC/_msi.c (Revision 67635) +++ PC/_msi.c (Arbeitskopie) @@ -473,7 +473,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -643,7 +643,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -791,7 +791,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -908,7 +908,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Doc/extending/newtypes.rst =================================================================== --- Doc/extending/newtypes.rst (Revision 67635) +++ Doc/extending/newtypes.rst (Arbeitskopie) @@ -80,7 +80,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1253,7 +1253,7 @@ greater than, respectively; as of Python 2.2, this is no longer allowed. In the future, other return values may be assigned a different meaning.) - A :attr:`tp_compare` handler may raise an exception. In this case it should + A :attr:`tp_reserved` handler may raise an exception. In this case it should return a negative value. The caller has to test for the exception using :cfunc:`PyErr_Occurred`. @@ -1486,7 +1486,7 @@ In order to learn how to implement any specific method for your new data type, do the following: Download and unpack the Python source distribution. Go the :file:`Objects` directory, then search the C source files for ``tp_`` plus the -function you want (for example, ``tp_compare``). You will find examples of the +function you want (for example, ``tp_reserved``). You will find examples of the function you want to implement. When you need to verify that an object is an instance of the type you are Index: Doc/c-api/object.rst =================================================================== --- Doc/c-api/object.rst (Revision 67635) +++ Doc/c-api/object.rst (Arbeitskopie) @@ -89,27 +89,6 @@ *opid*. -.. cfunction:: int PyObject_Cmp(PyObject *o1, PyObject *o2, int *result) - - .. index:: builtin: cmp - - Compare the values of *o1* and *o2* using a routine provided by *o1*, if one - exists, otherwise with a routine provided by *o2*. The result of the comparison - is returned in *result*. Returns ``-1`` on failure. This is the equivalent of - the Python statement ``result = cmp(o1, o2)``. - - -.. cfunction:: int PyObject_Compare(PyObject *o1, PyObject *o2) - - .. index:: builtin: cmp - - Compare the values of *o1* and *o2* using a routine provided by *o1*, if one - exists, otherwise with a routine provided by *o2*. Returns the result of the - comparison on success. On error, the value returned is undefined; use - :cfunc:`PyErr_Occurred` to detect an error. This is equivalent to the Python - expression ``cmp(o1, o2)``. - - .. cfunction:: PyObject* PyObject_Repr(PyObject *o) .. index:: builtin: repr Index: Doc/c-api/typeobj.rst =================================================================== --- Doc/c-api/typeobj.rst (Revision 67635) +++ Doc/c-api/typeobj.rst (Arbeitskopie) @@ -244,21 +244,11 @@ the subtype's :attr:`tp_setattr` and :attr:`tp_setattro` are both *NULL*. -.. cmember:: cmpfunc PyTypeObject.tp_compare +.. cmember:: void PyTypeObject.tp_reserved - An optional pointer to the three-way comparison function. + Reserved slot, formaly known as tp_compare. - The signature is the same as for :cfunc:`PyObject_Compare`. The function should - return ``1`` if *self* greater than *other*, ``0`` if *self* is equal to - *other*, and ``-1`` if *self* less than *other*. It should return ``-1`` and - set an exception condition when an error occurred during the comparison. - This field is inherited by subtypes together with :attr:`tp_richcompare` and - :attr:`tp_hash`: a subtypes inherits all three of :attr:`tp_compare`, - :attr:`tp_richcompare`, and :attr:`tp_hash` when the subtype's - :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. - - .. cmember:: reprfunc PyTypeObject.tp_repr .. index:: builtin: repr @@ -329,14 +319,14 @@ the Python level will result in the ``tp_hash`` slot being set to :cfunc:`PyObject_HashNotImplemented`. - When this field is not set, two possibilities exist: if the :attr:`tp_compare` + When this field is not set, two possibilities exist: if the :attr:`tp_reserved` and :attr:`tp_richcompare` fields are both *NULL*, a default hash value based on the object's address is returned; otherwise, a :exc:`TypeError` is raised. This field is inherited by subtypes together with :attr:`tp_richcompare` and - :attr:`tp_compare`: a subtypes inherits all three of :attr:`tp_compare`, + :attr:`tp_reserved`: a subtypes inherits all three of :attr:`tp_reserved`, :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's - :attr:`tp_compare`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*. + :attr:`tp_reserved`, :attr:`tp_richcompare` and :attr:`tp_hash` are all *NULL*. .. cmember:: ternaryfunc PyTypeObject.tp_call @@ -596,10 +586,10 @@ comparisons makes sense (e.g. ``==`` and ``!=``, but not ``<`` and friends), directly raise :exc:`TypeError` in the rich comparison function. - This field is inherited by subtypes together with :attr:`tp_compare` and - :attr:`tp_hash`: a subtype inherits all three of :attr:`tp_compare`, + This field is inherited by subtypes together with :attr:`tp_reserved` and + :attr:`tp_hash`: a subtype inherits all three of :attr:`tp_reserved`, :attr:`tp_richcompare`, and :attr:`tp_hash`, when the subtype's - :attr:`tp_compare`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. + :attr:`tp_reserved`, :attr:`tp_richcompare`, and :attr:`tp_hash` are all *NULL*. The following constants are defined to be used as the third argument for :attr:`tp_richcompare` and for :cfunc:`PyObject_RichCompare`: Index: Doc/c-api/unicode.rst =================================================================== --- Doc/c-api/unicode.rst (Revision 67635) +++ Doc/c-api/unicode.rst (Arbeitskopie) @@ -863,18 +863,12 @@ occurrences. -.. cfunction:: int PyUnicode_Compare(PyObject *left, PyObject *right) +.. cfunction:: int PyUnicode_EqualToASCIIString(PyObject *uni, char *string) - Compare two strings and return -1, 0, 1 for less than, equal, and greater than, - respectively. + Compare a unicode object, *uni*, with *string* and return 1 if equal, + otherwise 0. -.. cfunction:: int PyUnicode_CompareWithASCIIString(PyObject *uni, char *string) - - Compare a unicode object, *uni*, with *string* and return -1, 0, 1 for less - than, equal, and greater than, respectively. - - .. cfunction:: int PyUnicode_RichCompare(PyObject *left, PyObject *right, int op) Rich compare two unicode strings and return one of the following: Index: Doc/includes/noddy2.c =================================================================== --- Doc/includes/noddy2.c (Revision 67635) +++ Doc/includes/noddy2.c (Arbeitskopie) @@ -131,7 +131,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Doc/includes/noddy3.c =================================================================== --- Doc/includes/noddy3.c (Revision 67635) +++ Doc/includes/noddy3.c (Arbeitskopie) @@ -184,7 +184,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Doc/includes/noddy4.c =================================================================== --- Doc/includes/noddy4.c (Revision 67635) +++ Doc/includes/noddy4.c (Arbeitskopie) @@ -165,7 +165,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Doc/includes/noddy.c =================================================================== --- Doc/includes/noddy.c (Revision 67635) +++ Doc/includes/noddy.c (Arbeitskopie) @@ -14,7 +14,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Doc/includes/shoddy.c =================================================================== --- Doc/includes/shoddy.c (Revision 67635) +++ Doc/includes/shoddy.c (Arbeitskopie) @@ -39,7 +39,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Doc/includes/typestruct.h =================================================================== --- Doc/includes/typestruct.h (Revision 67635) +++ Doc/includes/typestruct.h (Arbeitskopie) @@ -9,7 +9,7 @@ printfunc tp_print; getattrfunc tp_getattr; setattrfunc tp_setattr; - cmpfunc tp_compare; + cmpfunc tp_reserved; reprfunc tp_repr; /* Method suites for standard classes */ Index: Lib/distutils/version.py =================================================================== --- Lib/distutils/version.py (Revision 67635) +++ Lib/distutils/version.py (Arbeitskopie) @@ -21,7 +21,7 @@ an equivalent string -- ie. one that will generate an equivalent version number instance) * __repr__ generates Python code to recreate the version number instance - * __cmp__ compares the current instance with either another instance + * _cmp compares the current instance with either another instance of the same class or a string (which will be parsed to an instance of the same class, thus must follow the same rules) """ @@ -32,7 +32,7 @@ """Abstract base class for version numbering classes. Just provides constructor (__init__) and reproducer (__repr__), because those seem to be the same for all version numbering classes; and route - rich comparisons to __cmp__. + rich comparisons to _cmp. """ def __init__ (self, vstring=None): @@ -43,37 +43,37 @@ return "%s ('%s')" % (self.__class__.__name__, str(self)) def __eq__(self, other): - c = self.__cmp__(other) + c = self._cmp(other) if c is NotImplemented: return c return c == 0 def __ne__(self, other): - c = self.__cmp__(other) + c = self._cmp(other) if c is NotImplemented: return c return c != 0 def __lt__(self, other): - c = self.__cmp__(other) + c = self._cmp(other) if c is NotImplemented: return c return c < 0 def __le__(self, other): - c = self.__cmp__(other) + c = self._cmp(other) if c is NotImplemented: return c return c <= 0 def __gt__(self, other): - c = self.__cmp__(other) + c = self._cmp(other) if c is NotImplemented: return c return c > 0 def __ge__(self, other): - c = self.__cmp__(other) + c = self._cmp(other) if c is NotImplemented: return c return c >= 0 @@ -91,7 +91,7 @@ # (if not identical to) the string supplied to parse # __repr__ (self) - generate Python code to recreate # the instance -# __cmp__ (self, other) - compare two version numbers ('other' may +# _cmp (self, other) - compare two version numbers ('other' may # be an unparsed version string, or another # instance of your version class) @@ -169,31 +169,40 @@ return vstring - def __cmp__ (self, other): + def _cmp (self, other): if isinstance(other, str): other = StrictVersion(other) - compare = cmp(self.version, other.version) - if (compare == 0): # have to compare prerelease + if self.version != other.version: + # numeric versions don't match + # prerelease stuff doesn't matter + if self.version < other.version: + return -1 + else: + return 1 - # case 1: neither has prerelease; they're equal - # case 2: self has prerelease, other doesn't; other is greater - # case 3: self doesn't have prerelease, other does: self is greater - # case 4: both have prerelease: must compare them! + # have to compare prerelease + # case 1: neither has prerelease; they're equal + # case 2: self has prerelease, other doesn't; other is greater + # case 3: self doesn't have prerelease, other does: self is greater + # case 4: both have prerelease: must compare them! - if (not self.prerelease and not other.prerelease): + if (not self.prerelease and not other.prerelease): + return 0 + elif (self.prerelease and not other.prerelease): + return -1 + elif (not self.prerelease and other.prerelease): + return 1 + elif (self.prerelease and other.prerelease): + if self.prerelease == other.prerelease: return 0 - elif (self.prerelease and not other.prerelease): + elif self.prerelease < other.prerelease: return -1 - elif (not self.prerelease and other.prerelease): + else: return 1 - elif (self.prerelease and other.prerelease): - return cmp(self.prerelease, other.prerelease) + else: + assert False, "never get here" - else: # numeric versions don't match -- - return compare # prerelease stuff doesn't matter - - # end class StrictVersion @@ -325,7 +334,7 @@ return "LooseVersion ('%s')" % str(self) - def __cmp__ (self, other): + def _cmp (self, other): if isinstance(other, str): other = LooseVersion(other) Index: Lib/decimal.py =================================================================== --- Lib/decimal.py (Revision 67635) +++ Lib/decimal.py (Arbeitskopie) @@ -761,9 +761,16 @@ if self > other. This routine is for internal use only.""" if self._is_special or other._is_special: - return cmp(self._isinfinity(), other._isinfinity()) + self_inf = self._isinfinity() + other_inf = other._isinfinity() + if self_inf == other_inf: + return 0 + elif self_inf < other_inf: + return -1 + else: + return 1 - # check for zeros; note that cmp(0, -0) should return 0 + # check for zeros; note that _cmp(0, -0) should return 0 if not self: if not other: return 0 @@ -783,7 +790,12 @@ if self_adjusted == other_adjusted: self_padded = self._int + '0'*(self._exp - other._exp) other_padded = other._int + '0'*(other._exp - self._exp) - return cmp(self_padded, other_padded) * (-1)**self._sign + if self_padded == other_padded: + return 0 + elif self_padded < other_padded: + return -((-1)**self._sign) + else: + return (-1)**self._sign elif self_adjusted > other_adjusted: return (-1)**self._sign else: # self_adjusted < other_adjusted Index: Lib/heapq.py =================================================================== --- Lib/heapq.py (Revision 67635) +++ Lib/heapq.py (Arbeitskopie) @@ -34,7 +34,7 @@ __about__ = """Heap queues -[explanation by François Pinard] +[explanation by Fran�ois Pinard] Heaps are arrays for which a[k] <= a[2*k+1] and a[k] <= a[2*k+2] for all k, counting elements from 0. For the sake of comparison, @@ -262,7 +262,7 @@ # # Cutting the # of comparisons is important, since these routines have no # way to extract "the priority" from an array element, so that intelligence -# is likely to be hiding in custom __cmp__ methods, or in array elements +# is likely to be hiding in custom _cmp__ methods, or in array elements # storing (priority, record) tuples. Comparisons are thus potentially # expensive. # Index: Lib/collections.py =================================================================== --- Lib/collections.py (Revision 67635) +++ Lib/collections.py (Arbeitskopie) @@ -191,8 +191,6 @@ def __ge__(self, other): return self.data >= self.__cast(other) def __cast(self, other): return other.data if isinstance(other, UserList) else other - def __cmp__(self, other): - return cmp(self.data, self.__cast(other)) def __contains__(self, item): return item in self.data def __len__(self): return len(self.data) def __getitem__(self, i): return self.data[i] Index: Lib/ctypes/test/test_libc.py =================================================================== --- Lib/ctypes/test/test_libc.py (Revision 67635) +++ Lib/ctypes/test/test_libc.py (Arbeitskopie) @@ -5,6 +5,9 @@ lib = CDLL(_ctypes_test.__file__) +def twcmp(x, y): + return (x > y) - (x < y) + class LibTest(unittest.TestCase): def test_sqrt(self): lib.my_sqrt.argtypes = c_double, @@ -19,7 +22,7 @@ lib.my_qsort.restype = None def sort(a, b): - return cmp(a[0], b[0]) + return twcmp(a[0], b[0]) chars = create_string_buffer("spam, spam, and spam") lib.my_qsort(chars, len(chars)-1, sizeof(c_char), comparefunc(sort)) Index: Lib/sqlite3/test/hooks.py =================================================================== --- Lib/sqlite3/test/hooks.py (Revision 67635) +++ Lib/sqlite3/test/hooks.py (Arbeitskopie) @@ -42,7 +42,7 @@ def CheckCreateCollationNotAscii(self): con = sqlite.connect(":memory:") try: - con.create_collation("collä", cmp) + con.create_collation("collä", lambda x, y: (x > y) - (x < y)) self.fail("should have raised a ProgrammingError") except sqlite.ProgrammingError as e: pass @@ -52,7 +52,7 @@ return def mycoll(x, y): # reverse order - return -cmp(x, y) + return -((x > y) - (x < y)) con = sqlite.connect(":memory:") con.create_collation("mycoll", mycoll) @@ -82,8 +82,8 @@ Verify that the last one is actually used. """ con = sqlite.connect(":memory:") - con.create_collation("mycoll", cmp) - con.create_collation("mycoll", lambda x, y: -cmp(x, y)) + con.create_collation("mycoll", lambda x, y: (x > y) - (x < y)) + con.create_collation("mycoll", lambda x, y: -((x > y) - (x < y))) result = con.execute(""" select x from (select 'a' as x union select 'b' as x) order by x collate mycoll """).fetchall() @@ -96,7 +96,7 @@ to use it. """ con = sqlite.connect(":memory:") - con.create_collation("mycoll", cmp) + con.create_collation("mycoll", lambda x, y: (x > y) - (x < y)) con.create_collation("mycoll", None) try: con.execute("select 'a' as x union select 'b' as x order by x collate mycoll") Index: Lib/unittest.py =================================================================== --- Lib/unittest.py (Revision 67635) +++ Lib/unittest.py (Arbeitskopie) @@ -53,6 +53,7 @@ import traceback import os import types +import operator ############################################################################## # Exported classes and functions @@ -510,7 +511,7 @@ def __init__(self, obj, *args): self.obj = obj def __lt__(self, other): - return mycmp(self.obj, other.obj) == -1 + return not mycmp(self.obj, other.obj) return K class TestLoader: @@ -518,7 +519,7 @@ criteria and returning them wrapped in a TestSuite """ testMethodPrefix = 'test' - sortTestMethodsUsing = cmp + sortTestMethodsUsing = operator.gt suiteClass = TestSuite def loadTestsFromTestCase(self, testCaseClass): @@ -626,13 +627,13 @@ if suiteClass: loader.suiteClass = suiteClass return loader -def getTestCaseNames(testCaseClass, prefix, sortUsing=cmp): +def getTestCaseNames(testCaseClass, prefix, sortUsing=operator.gt): return _makeLoader(prefix, sortUsing).getTestCaseNames(testCaseClass) -def makeSuite(testCaseClass, prefix='test', sortUsing=cmp, suiteClass=TestSuite): +def makeSuite(testCaseClass, prefix='test', sortUsing=operator.gt, suiteClass=TestSuite): return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromTestCase(testCaseClass) -def findTestCases(module, prefix='test', sortUsing=cmp, suiteClass=TestSuite): +def findTestCases(module, prefix='test', sortUsing=operator.gt, suiteClass=TestSuite): return _makeLoader(prefix, sortUsing, suiteClass).loadTestsFromModule(module) Index: Lib/test/test_set.py =================================================================== --- Lib/test/test_set.py (Revision 67635) +++ Lib/test/test_set.py (Arbeitskopie) @@ -1023,16 +1023,6 @@ result = self.set ^ set([8]) self.assertEqual(result, set([2, 4, 6, 8])) - def test_cmp(self): - a, b = set('a'), set('b') - self.assertRaises(TypeError, cmp, a, b) - - # In py3k, this works! - self.assertRaises(TypeError, cmp, a, a) - - self.assertRaises(TypeError, cmp, a, 12) - self.assertRaises(TypeError, cmp, "abc", a) - #============================================================================== class TestUpdateOps(unittest.TestCase): Index: Lib/test/test_descr.py =================================================================== --- Lib/test/test_descr.py (Revision 67635) +++ Lib/test/test_descr.py (Arbeitskopie) @@ -172,7 +172,6 @@ def test_dicts(self): # Testing dict operations... - ## self.binop_test({1:2}, {2:1}, -1, "cmp(a,b)", "__cmp__") self.binop_test({1:2,3:4}, 1, 1, "b in a", "__contains__") self.binop_test({1:2,3:4}, 2, 0, "b in a", "__contains__") self.binop_test({1:2,3:4}, 1, 2, "a[b]", "__getitem__") @@ -332,8 +331,6 @@ # This is an ugly hack: copy._deepcopy_dispatch[spam.spamdict] = spamdict - ## self.binop_test(spamdict({1:2}), spamdict({2:1}), -1, "cmp(a,b)", - ## "__cmp__") self.binop_test(spamdict({1:2,3:4}), 1, 1, "b in a", "__contains__") self.binop_test(spamdict({1:2,3:4}), 2, 0, "b in a", "__contains__") self.binop_test(spamdict({1:2,3:4}), 1, 2, "a[b]", "__getitem__") @@ -1610,23 +1607,6 @@ self.assert_(i in p10) self.assertFalse(10 in p10) - ## # Safety test for __cmp__ - ## def unsafecmp(a, b): - ## try: - ## a.__class__.__cmp__(a, b) - ## except TypeError: - ## pass - ## else: - ## self.fail("shouldn't allow %s.__cmp__(%r, %r)" % ( - ## a.__class__, a, b)) - ## - ## unsafecmp("123", "123") - ## unsafecmp("123", "123") - ## unsafecmp(1, 1.0) - ## unsafecmp(1.0, 1) - ## unsafecmp(1, 1) - ## unsafecmp(1, 1) - def test_weakrefs(self): # Testing weak references... import weakref Index: Lib/test/test_kqueue.py =================================================================== --- Lib/test/test_kqueue.py (Revision 67635) +++ Lib/test/test_kqueue.py (Arbeitskopie) @@ -22,6 +22,7 @@ self.assertRaises(ValueError, kq.fileno) def test_create_event(self): + from operator import lt, le, gt, ge fd = sys.stderr.fileno() ev = select.kevent(fd) other = select.kevent(1000) @@ -33,12 +34,12 @@ self.assertEqual(ev.udata, 0) self.assertEqual(ev, ev) self.assertNotEqual(ev, other) - self.assertEqual(cmp(ev, other), -1) self.assert_(ev < other) self.assert_(other >= ev) - self.assertRaises(TypeError, cmp, ev, None) - self.assertRaises(TypeError, cmp, ev, 1) - self.assertRaises(TypeError, cmp, ev, "ev") + for op in lt, le, gt, ge: + self.assertRaises(TypeError, op, ev, None) + self.assertRaises(TypeError, op, ev, 1) + self.assertRaises(TypeError, op, ev, "ev") ev = select.kevent(fd, select.KQ_FILTER_WRITE) self.assertEqual(ev.ident, fd) Index: Lib/test/test_contains.py =================================================================== --- Lib/test/test_contains.py (Revision 67635) +++ Lib/test/test_contains.py (Arbeitskopie) @@ -57,7 +57,7 @@ works when the list is modified during the check. """ aList = range(15) - def __cmp__(self, other): + def __lt__(self, other): if other == 12: self.aList.remove(12) self.aList.remove(13) @@ -72,7 +72,7 @@ This class raises an exception during comparison. That in turn causes the comparison to fail with a TypeError. """ - def __cmp__(self, other): + def __lt__(self, other): if other == 4: raise RuntimeError("gotcha") Index: Lib/test/test_heapq.py =================================================================== --- Lib/test/test_heapq.py (Revision 67635) +++ Lib/test/test_heapq.py (Arbeitskopie) @@ -234,9 +234,9 @@ class CmpErr: "Dummy element that always raises an error during comparison" - def __cmp__(self, other): + def __eq__(self, other): raise ZeroDivisionError - __eq__ = __ne__ = __lt__ = __le__ = __gt__ = __ge__ = __cmp__ + __ne__ = __lt__ = __le__ = __gt__ = __ge__ = __eq__ def R(seqn): 'Regular generator' Index: Lib/test/test_long.py =================================================================== --- Lib/test/test_long.py (Revision 67635) +++ Lib/test/test_long.py (Arbeitskopie) @@ -672,7 +672,8 @@ def _cmp__(self, other): if not isinstance(other, Rat): other = Rat(other) - return cmp(self.n * other.d, self.d * other.n) + x, y = self.n * other.d, self.d * other.n + return (x > y) - (x < y) def __eq__(self, other): return self._cmp__(other) == 0 def __ne__(self, other): @@ -702,8 +703,8 @@ Rx = Rat(x) for y in cases: Ry = Rat(y) - Rcmp = cmp(Rx, Ry) - xycmp = cmp(x, y) + Rcmp = (Rx > Ry) - (Rx < Ry) + xycmp = (x > y) - (x < y) eq(Rcmp, xycmp, Frm("%r %r %d %d", x, y, Rcmp, xycmp)) eq(x == y, Rcmp == 0, Frm("%r == %r %d", x, y, Rcmp)) eq(x != y, Rcmp != 0, Frm("%r != %r %d", x, y, Rcmp)) Index: Lib/test/list_tests.py =================================================================== --- Lib/test/list_tests.py (Revision 67635) +++ Lib/test/list_tests.py (Arbeitskopie) @@ -439,13 +439,24 @@ self.assertRaises(TypeError, u.sort, 42, 42) def revcmp(a, b): - return cmp(b, a) + if a == b: + return 0 + elif a < b: + return 1 + else: # a > b + return -1 u.sort(key=CmpToKey(revcmp)) self.assertEqual(u, self.type2test([2,1,0,-1,-2])) # The following dumps core in unpatched Python 1.5: def myComparison(x,y): - return cmp(x%3, y%7) + xmod, ymod = x%3, y%7 + if xmod == ymod: + return 0 + elif xmod < ymod: + return -1 + else: # xmod > ymod + return 1 z = self.type2test(range(12)) z.sort(key=CmpToKey(myComparison)) @@ -453,7 +464,12 @@ def selfmodifyingComparison(x,y): z.append(1) - return cmp(x, y) + if x == y: + return 0 + elif x < y: + return -1 + else: # x > y + return 1 self.assertRaises(ValueError, z.sort, key=CmpToKey(selfmodifyingComparison)) self.assertRaises(TypeError, z.sort, 42, 42, 42, 42) Index: Lib/test/test_sort.py =================================================================== --- Lib/test/test_sort.py (Revision 67635) +++ Lib/test/test_sort.py (Arbeitskopie) @@ -102,7 +102,7 @@ y = x[:] y.reverse() s = x[:] - check("reversed via function", y, s, lambda a, b: cmp(b, a)) + check("reversed via function", y, s, lambda a, b: (b>a)-(b y) - (x < y) L = [1,2] self.assertRaises(ValueError, L.sort, key=CmpToKey(mutating_cmp)) def mutating_cmp(x, y): L.append(3) del L[:] - return cmp(x, y) + return (x > y) - (x < y) self.assertRaises(ValueError, L.sort, key=CmpToKey(mutating_cmp)) memorywaster = [memorywaster] @@ -176,7 +176,10 @@ copy = data[:] random.shuffle(data) data.sort(key=str.lower) - copy.sort(key=CmpToKey(lambda x,y: cmp(x.lower(), y.lower()))) + def my_cmp(x, y): + xlower, ylower = x.lower(), y.lower() + return (xlower > ylower) - (xlower < ylower) + copy.sort(key=CmpToKey(my_cmp)) def test_baddecorator(self): data = 'The quick Brown fox Jumped over The lazy Dog'.split() @@ -246,8 +249,14 @@ data = [(random.randrange(100), i) for i in range(200)] copy1 = data[:] copy2 = data[:] - data.sort(key=CmpToKey(lambda x,y: cmp(x[0],y[0])), reverse=True) - copy1.sort(key=CmpToKey(lambda x,y: cmp(y[0],x[0]))) + def my_cmp(x, y): + x0, y0 = x[0], y[0] + return (x0 > y0) - (x0 < y0) + def my_cmp_reversed(x, y): + x0, y0 = x[0], y[0] + return (y0 > x0) - (y0 < x0) + data.sort(key=CmpToKey(my_cmp), reverse=True) + copy1.sort(key=CmpToKey(my_cmp_reversed)) self.assertEqual(data, copy1) copy2.sort(key=lambda x: x[0], reverse=True) self.assertEqual(data, copy2) Index: Lib/test/test_deque.py =================================================================== --- Lib/test/test_deque.py (Revision 67635) +++ Lib/test/test_deque.py (Arbeitskopie) @@ -102,7 +102,6 @@ self.assertEqual(x <= y, list(x) <= list(y), (x,y)) self.assertEqual(x > y, list(x) > list(y), (x,y)) self.assertEqual(x >= y, list(x) >= list(y), (x,y)) - self.assertEqual(cmp(x,y), cmp(list(x),list(y)), (x,y)) def test_extend(self): d = deque('a') Index: Lib/test/test_datetime.py =================================================================== --- Lib/test/test_datetime.py (Revision 67635) +++ Lib/test/test_datetime.py (Arbeitskopie) @@ -8,6 +8,7 @@ import unittest from test import support +from test.support import fcmp from datetime import MINYEAR, MAXYEAR from datetime import timedelta @@ -156,9 +157,6 @@ self.assertRaises(TypeError, lambda: () > me) self.assertRaises(TypeError, lambda: () >= me) - self.assertRaises(TypeError, cmp, (), me) - self.assertRaises(TypeError, cmp, me, ()) - ############################################################################# # timedelta tests @@ -309,8 +307,6 @@ self.failUnless(not t1 != t2) self.failUnless(not t1 < t2) self.failUnless(not t1 > t2) - self.assertEqual(cmp(t1, t2), 0) - self.assertEqual(cmp(t2, t1), 0) for args in (3, 3, 3), (2, 4, 4), (2, 3, 5): t2 = timedelta(*args) # this is larger than t1 @@ -326,8 +322,6 @@ self.failUnless(not t2 < t1) self.failUnless(not t1 >= t2) self.failUnless(not t2 <= t1) - self.assertEqual(cmp(t1, t2), -1) - self.assertEqual(cmp(t2, t1), 1) for badarg in OTHERSTUFF: self.assertEqual(t1 == badarg, False) @@ -936,8 +930,6 @@ self.failUnless(not t1 != t2) self.failUnless(not t1 < t2) self.failUnless(not t1 > t2) - self.assertEqual(cmp(t1, t2), 0) - self.assertEqual(cmp(t2, t1), 0) for args in (3, 3, 3), (2, 4, 4), (2, 3, 5): t2 = self.theclass(*args) # this is larger than t1 @@ -953,8 +945,6 @@ self.failUnless(not t2 < t1) self.failUnless(not t1 >= t2) self.failUnless(not t2 <= t1) - self.assertEqual(cmp(t1, t2), -1) - self.assertEqual(cmp(t2, t1), 1) for badarg in OTHERSTUFF: self.assertEqual(t1 == badarg, False) @@ -982,8 +972,6 @@ # But the ordering is undefined self.assertRaises(TypeError, lambda: our < 1) self.assertRaises(TypeError, lambda: 1 < our) - self.assertRaises(TypeError, cmp, our, 1) - self.assertRaises(TypeError, cmp, 1, our) # Repeat those tests with a different class @@ -997,8 +985,6 @@ self.assertEqual(their != our, True) self.assertRaises(TypeError, lambda: our < their) self.assertRaises(TypeError, lambda: their < our) - self.assertRaises(TypeError, cmp, our, their) - self.assertRaises(TypeError, cmp, their, our) # However, if the other class explicitly defines ordering # relative to our class, it is allowed to do so @@ -1024,8 +1010,6 @@ self.assertEqual(their != our, True) self.assertEqual(our < their, True) self.assertEqual(their < our, False) - self.assertEqual(cmp(our, their), -1) - self.assertEqual(cmp(their, our), 1) def test_bool(self): # All dates are considered true. @@ -1423,8 +1407,6 @@ self.failUnless(not t1 != t2) self.failUnless(not t1 < t2) self.failUnless(not t1 > t2) - self.assertEqual(cmp(t1, t2), 0) - self.assertEqual(cmp(t2, t1), 0) for i in range(len(args)): newargs = args[:] @@ -1442,8 +1424,6 @@ self.failUnless(not t2 < t1) self.failUnless(not t1 >= t2) self.failUnless(not t2 <= t1) - self.assertEqual(cmp(t1, t2), -1) - self.assertEqual(cmp(t2, t1), 1) # A helper for timestamp constructor tests. @@ -1711,8 +1691,6 @@ self.failUnless(not t1 != t2) self.failUnless(not t1 < t2) self.failUnless(not t1 > t2) - self.assertEqual(cmp(t1, t2), 0) - self.assertEqual(cmp(t2, t1), 0) for i in range(len(args)): newargs = args[:] @@ -1730,8 +1708,6 @@ self.failUnless(not t2 < t1) self.failUnless(not t1 >= t2) self.failUnless(not t2 <= t1) - self.assertEqual(cmp(t1, t2), -1) - self.assertEqual(cmp(t2, t1), 1) for badarg in OTHERSTUFF: self.assertEqual(t1 == badarg, False) @@ -2105,8 +2081,8 @@ d2 = base.replace(minute=11) for x in d0, d1, d2: for y in d0, d1, d2: - got = cmp(x, y) - expected = cmp(x.minute, y.minute) + got = fcmp(x, y) + expected = fcmp(x.minute, y.minute) self.assertEqual(got, expected) # However, if they're different members, uctoffset is not ignored. @@ -2119,7 +2095,7 @@ d2 = base.replace(minute=11, tzinfo=OperandDependentOffset()) for x in d0, d1, d2: for y in d0, d1, d2: - got = cmp(x, y) + got = fcmp(x, y) if (x is d0 or x is d1) and (y is d0 or y is d1): expected = 0 elif x is y is d2: Index: Lib/test/test_decimal.py =================================================================== --- Lib/test/test_decimal.py (Revision 67635) +++ Lib/test/test_decimal.py (Arbeitskopie) @@ -1013,17 +1013,11 @@ self.failUnless(da != dc) self.failUnless(da <= db) self.failUnless(da >= db) - self.assertEqual(cmp(dc,da), 1) - self.assertEqual(cmp(da,dc), -1) - self.assertEqual(cmp(da,db), 0) #a Decimal and an int self.failUnless(dc > 23) self.failUnless(23 < dc) self.assertEqual(dc, 45) - self.assertEqual(cmp(dc,23), 1) - self.assertEqual(cmp(23,dc), -1) - self.assertEqual(cmp(dc,45), 0) #a Decimal and uncomparable self.assertNotEqual(da, 'ugly') Index: Lib/test/test_uuid.py =================================================================== --- Lib/test/test_uuid.py (Revision 67635) +++ Lib/test/test_uuid.py (Arbeitskopie) @@ -1,5 +1,6 @@ from unittest import TestCase from test import support +from test.support import fcmp import uuid def importable(name): @@ -181,7 +182,7 @@ # Test comparison of UUIDs. for i in range(len(ascending)): for j in range(len(ascending)): - equal(cmp(i, j), cmp(ascending[i], ascending[j])) + equal(fcmp(i, j), fcmp(ascending[i], ascending[j])) # Test sorting of UUIDs (above list is in ascending order). resorted = ascending[:] Index: Lib/test/test_unittest.py =================================================================== --- Lib/test/test_unittest.py (Revision 67635) +++ Lib/test/test_unittest.py (Arbeitskopie) @@ -1103,7 +1103,7 @@ # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromTestCase(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) class Foo(unittest.TestCase): def test_1(self): pass @@ -1119,7 +1119,7 @@ # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromModule(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): @@ -1137,7 +1137,7 @@ # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromName(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): @@ -1155,7 +1155,7 @@ # getTestCaseNames() and all the loadTestsFromX() methods" def test_sortTestMethodsUsing__loadTestsFromNames(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) m = types.ModuleType('m') class Foo(unittest.TestCase): @@ -1175,7 +1175,7 @@ # Does it actually affect getTestCaseNames()? def test_sortTestMethodsUsing__getTestCaseNames(self): def reversed_cmp(x, y): - return -cmp(x, y) + return -((x > y) - (x < y)) class Foo(unittest.TestCase): def test_1(self): pass Index: Lib/test/test_copy.py =================================================================== --- Lib/test/test_copy.py (Revision 67635) +++ Lib/test/test_copy.py (Arbeitskopie) @@ -5,6 +5,7 @@ import unittest from test import support +from test.support import fcmp class TestCopy(unittest.TestCase): @@ -271,7 +272,7 @@ x = [] x.append(x) y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + self.assertRaises(RuntimeError, fcmp, y, x) self.assert_(y is not x) self.assert_(y[0] is y) self.assertEqual(len(y), 1) @@ -287,7 +288,7 @@ x = ([],) x[0].append(x) y = copy.deepcopy(x) - self.assertRaises(RuntimeError, cmp, y, x) + self.assertRaises(RuntimeError, fcmp, y, x) self.assert_(y is not x) self.assert_(y[0] is not x[0]) self.assert_(y[0][0] is y) @@ -303,7 +304,7 @@ x = {} x['foo'] = x y = copy.deepcopy(x) - self.assertRaises(TypeError, cmp, y, x) + self.assertRaises(TypeError, fcmp, y, x) self.assert_(y is not x) self.assert_(y['foo'] is y) self.assertEqual(len(y), 1) Index: Lib/test/test_hash.py =================================================================== --- Lib/test/test_hash.py (Revision 67635) +++ Lib/test/test_hash.py (Arbeitskopie) @@ -55,13 +55,8 @@ def __ne__(self, other): return self is not other -class OnlyCmp(object): - def __cmp__(self, other): - return cmp(id(self), id(other)) - class InheritedHashWithEquality(FixedHash, OnlyEquality): pass class InheritedHashWithInequality(FixedHash, OnlyInequality): pass -class InheritedHashWithCmp(FixedHash, OnlyCmp): pass class NoHash(object): __hash__ = None @@ -74,7 +69,6 @@ fixed_expected = [FixedHash(), InheritedHashWithEquality(), InheritedHashWithInequality(), - InheritedHashWithCmp(), ] error_expected = [NoHash(), OnlyEquality(), Index: Lib/test/test_userdict.py =================================================================== --- Lib/test/test_userdict.py (Revision 67635) +++ Lib/test/test_userdict.py (Arbeitskopie) @@ -47,7 +47,7 @@ self.assertEqual(repr(u1), repr(d1)) self.assertEqual(repr(u2), repr(d2)) - # Test __cmp__ and __len__ + # Test rich comparison and __len__ all = [d0, d1, d2, u, u0, u1, u2, uu, uu0, uu1, uu2] for a in all: for b in all: Index: Lib/test/test_builtin.py =================================================================== --- Lib/test/test_builtin.py (Revision 67635) +++ Lib/test/test_builtin.py (Arbeitskopie) @@ -10,6 +10,7 @@ FutureWarning, __name__) warnings.filterwarnings("ignore", "integer argument expected", DeprecationWarning, "unittest") +import builtins class Squares: @@ -219,21 +220,7 @@ self.assertRaises((OverflowError, ValueError), chr, 2**32) def test_cmp(self): - self.assertEqual(cmp(-1, 1), -1) - self.assertEqual(cmp(1, -1), 1) - self.assertEqual(cmp(1, 1), 0) - # verify that circular objects are not handled - a = []; a.append(a) - b = []; b.append(b) - from collections import UserList - c = UserList(); c.append(c) - self.assertRaises(RuntimeError, cmp, a, b) - self.assertRaises(RuntimeError, cmp, b, c) - self.assertRaises(RuntimeError, cmp, c, a) - self.assertRaises(RuntimeError, cmp, a, c) - # okay, now break the cycles - a.pop(); b.pop(); c.pop() - self.assertRaises(TypeError, cmp) + self.assert_(not hasattr(builtins, "cmp")) def test_compile(self): compile('print(1)\n', '', 'exec') @@ -736,10 +723,6 @@ def __getitem__(self, index): raise ValueError self.assertRaises(ValueError, min, BadSeq()) - class BadNumber: - def __cmp__(self, other): - raise ValueError - self.assertRaises(TypeError, min, (42, BadNumber())) for stmt in ( "min(key=int)", # no args Index: Modules/_ssl.c =================================================================== --- Modules/_ssl.c (Revision 67635) +++ Modules/_ssl.c (Arbeitskopie) @@ -1432,7 +1432,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/bz2module.c =================================================================== --- Modules/bz2module.c (Revision 67635) +++ Modules/bz2module.c (Arbeitskopie) @@ -1307,7 +1307,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -1590,7 +1590,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -1819,7 +1819,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_pickle.c =================================================================== --- Modules/_pickle.c (Revision 67635) +++ Modules/_pickle.c (Arbeitskopie) @@ -715,7 +715,7 @@ i = 0; module_name = NULL; while ((j = PyDict_Next(modules_dict, &i, &module_name, &module))) { - if (PyObject_Compare(module_name, main_str) == 0) + if (PyObject_RichCompareBool(module_name, main_str, Py_EQ) == 1) continue; obj = PyObject_GetAttr(module, global_name); @@ -2041,7 +2041,7 @@ } else { use_newobj = PyUnicode_Check(name_str) && - PyUnicode_Compare(name_str, newobj_str) == 0; + PyObject_RichCompareBool(name_str, newobj_str, Py_EQ) == 1; Py_DECREF(name_str); } } @@ -2645,7 +2645,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -4493,7 +4493,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_gdbmmodule.c =================================================================== --- Modules/_gdbmmodule.c (Revision 67635) +++ Modules/_gdbmmodule.c (Arbeitskopie) @@ -390,7 +390,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ &dbm_as_sequence, /*tp_as_sequence*/ Index: Modules/_tkinter.c =================================================================== --- Modules/_tkinter.c (Revision 67635) +++ Modules/_tkinter.c (Arbeitskopie) @@ -788,17 +788,6 @@ self->value->typePtr->name, self->value); } -static int -PyTclObject_cmp(PyTclObject *self, PyTclObject *other) -{ - int res; - res = strcmp(Tcl_GetString(self->value), - Tcl_GetString(other->value)); - if (res < 0) return -1; - if (res > 0) return 1; - return 0; -} - PyDoc_STRVAR(get_typename__doc__, "name of the Tcl type"); static PyObject* @@ -825,7 +814,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - (cmpfunc)PyTclObject_cmp, /*tp_compare*/ + 0, /*tp_reserved*/ (reprfunc)PyTclObject_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -2331,7 +2320,7 @@ 0, /*tp_print */ 0, /*tp_getattr */ 0, /*tp_setattr */ - 0, /*tp_compare */ + 0, /*tp_reserved */ Tktt_Repr, /*tp_repr */ 0, /*tp_as_number */ 0, /*tp_as_sequence */ @@ -2683,7 +2672,7 @@ 0, /*tp_print */ 0, /*tp_getattr */ 0, /*tp_setattr */ - 0, /*tp_compare */ + 0, /*tp_reserved */ 0, /*tp_repr */ 0, /*tp_as_number */ 0, /*tp_as_sequence */ Index: Modules/_curses_panel.c =================================================================== --- Modules/_curses_panel.c (Revision 67635) +++ Modules/_curses_panel.c (Arbeitskopie) @@ -341,7 +341,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_ctypes/callproc.c =================================================================== --- Modules/_ctypes/callproc.c (Revision 67635) +++ Modules/_ctypes/callproc.c (Arbeitskopie) @@ -512,7 +512,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)PyCArg_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_ctypes/stgdict.c =================================================================== --- Modules/_ctypes/stgdict.c (Revision 67635) +++ Modules/_ctypes/stgdict.c (Arbeitskopie) @@ -111,7 +111,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_ctypes/_ctypes.c =================================================================== --- Modules/_ctypes/_ctypes.c (Revision 67635) +++ Modules/_ctypes/_ctypes.c (Arbeitskopie) @@ -179,7 +179,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -713,7 +713,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &CDataType_as_sequence, /* tp_as_sequence */ @@ -755,7 +755,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &CDataType_as_sequence, /* tp_as_sequence */ @@ -988,7 +988,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &CDataType_as_sequence, /* tp_as_sequence */ @@ -1390,7 +1390,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &CDataType_as_sequence, /* tp_as_sequence */ @@ -2059,7 +2059,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &CDataType_as_sequence, /* tp_as_sequence */ @@ -2277,7 +2277,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &CDataType_as_sequence, /* tp_as_sequence */ @@ -2560,7 +2560,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3889,7 +3889,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)CFuncPtr_repr, /* tp_repr */ &CFuncPtr_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4032,7 +4032,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4074,7 +4074,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4383,7 +4383,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &Array_as_sequence, /* tp_as_sequence */ @@ -4615,7 +4615,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)&Simple_repr, /* tp_repr */ &Simple_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4992,7 +4992,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ &Pointer_as_number, /* tp_as_number */ &Pointer_as_sequence, /* tp_as_sequence */ @@ -5086,7 +5086,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_ctypes/callbacks.c =================================================================== --- Modules/_ctypes/callbacks.c (Revision 67635) +++ Modules/_ctypes/callbacks.c (Arbeitskopie) @@ -50,7 +50,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_ctypes/cfield.c =================================================================== --- Modules/_ctypes/cfield.c (Revision 67635) +++ Modules/_ctypes/cfield.c (Arbeitskopie) @@ -289,7 +289,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)CField_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_stringio.c =================================================================== --- Modules/_stringio.c (Revision 67635) +++ Modules/_stringio.c (Arbeitskopie) @@ -322,7 +322,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/socketmodule.c =================================================================== --- Modules/socketmodule.c (Revision 67635) +++ Modules/socketmodule.c (Arbeitskopie) @@ -2860,7 +2860,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)sock_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/mmapmodule.c =================================================================== --- Modules/mmapmodule.c (Revision 67635) +++ Modules/mmapmodule.c (Arbeitskopie) @@ -930,7 +930,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ &mmap_as_sequence, /*tp_as_sequence*/ Index: Modules/datetimemodule.c =================================================================== --- Modules/datetimemodule.c (Revision 67635) +++ Modules/datetimemodule.c (Arbeitskopie) @@ -1427,7 +1427,7 @@ * Miscellaneous helpers. */ -/* For various reasons, we need to use tp_richcompare instead of tp_compare. +/* For various reasons, we need to use tp_richcompare instead of tp_reserved. * The comparisons here all most naturally compute a cmp()-like result. * This little helper turns that into a bool result for rich comparisons. */ @@ -2138,7 +2138,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)delta_repr, /* tp_repr */ &delta_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2709,7 +2709,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)date_repr, /* tp_repr */ &date_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2963,7 +2963,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3478,7 +3478,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)time_repr, /* tp_repr */ &time_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -4606,7 +4606,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)datetime_repr, /* tp_repr */ &datetime_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_lsprof.c =================================================================== --- Modules/_lsprof.c (Revision 67635) +++ Modules/_lsprof.c (Arbeitskopie) @@ -820,7 +820,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_multiprocessing/semaphore.c =================================================================== --- Modules/_multiprocessing/semaphore.c (Revision 67635) +++ Modules/_multiprocessing/semaphore.c (Arbeitskopie) @@ -592,7 +592,7 @@ /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, - /* tp_compare */ 0, + /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, Index: Modules/_multiprocessing/connection.h =================================================================== --- Modules/_multiprocessing/connection.h (Revision 67635) +++ Modules/_multiprocessing/connection.h (Arbeitskopie) @@ -487,7 +487,7 @@ /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, - /* tp_compare */ 0, + /* tp_reserved */ 0, /* tp_repr */ (reprfunc)connection_repr, /* tp_as_number */ 0, /* tp_as_sequence */ 0, Index: Modules/xxmodule.c =================================================================== --- Modules/xxmodule.c (Revision 67635) +++ Modules/xxmodule.c (Arbeitskopie) @@ -106,7 +106,7 @@ 0, /*tp_print*/ (getattrfunc)0, /*tp_getattr*/ (setattrfunc)Xxo_setattr, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -224,7 +224,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -279,7 +279,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/cjkcodecs/multibytecodec.c =================================================================== --- Modules/cjkcodecs/multibytecodec.c (Revision 67635) +++ Modules/cjkcodecs/multibytecodec.c (Arbeitskopie) @@ -705,7 +705,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -990,7 +990,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1199,7 +1199,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1529,7 +1529,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1749,7 +1749,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_dbmmodule.c =================================================================== --- Modules/_dbmmodule.c (Revision 67635) +++ Modules/_dbmmodule.c (Arbeitskopie) @@ -336,7 +336,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ &dbm_as_sequence, /*tp_as_sequence*/ Index: Modules/sha512module.c =================================================================== --- Modules/sha512module.c (Revision 67635) +++ Modules/sha512module.c (Arbeitskopie) @@ -611,7 +611,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -645,7 +645,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_bytesio.c =================================================================== --- Modules/_bytesio.c (Revision 67635) +++ Modules/_bytesio.c (Arbeitskopie) @@ -698,7 +698,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/unicodedata.c =================================================================== --- Modules/unicodedata.c (Revision 67635) +++ Modules/unicodedata.c (Arbeitskopie) @@ -1144,7 +1144,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/arraymodule.c =================================================================== --- Modules/arraymodule.c (Revision 67635) +++ Modules/arraymodule.c (Arbeitskopie) @@ -2063,7 +2063,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)array_repr, /* tp_repr */ 0, /* tp_as_number*/ &array_as_sequence, /* tp_as_sequence*/ @@ -2166,7 +2166,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_randommodule.c =================================================================== --- Modules/_randommodule.c (Revision 67635) +++ Modules/_randommodule.c (Arbeitskopie) @@ -459,7 +459,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/selectmodule.c =================================================================== --- Modules/selectmodule.c (Revision 67635) +++ Modules/selectmodule.c (Arbeitskopie) @@ -639,7 +639,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -1097,7 +1097,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1310,7 +1310,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)kqueue_event_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1665,7 +1665,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/operator.c =================================================================== --- Modules/operator.c (Revision 67635) +++ Modules/operator.c (Arbeitskopie) @@ -349,7 +349,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -523,7 +523,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -654,7 +654,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/zipimport.c =================================================================== --- Modules/zipimport.c (Revision 67635) +++ Modules/zipimport.c (Arbeitskopie) @@ -566,7 +566,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)zipimporter_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_fileio.c =================================================================== --- Modules/_fileio.c (Revision 67635) +++ Modules/_fileio.c (Arbeitskopie) @@ -871,7 +871,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)fileio_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/zlibmodule.c =================================================================== --- Modules/zlibmodule.c (Revision 67635) +++ Modules/zlibmodule.c (Arbeitskopie) @@ -977,7 +977,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -1008,7 +1008,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_sqlite/connection.c =================================================================== --- Modules/_sqlite/connection.c (Revision 67635) +++ Modules/_sqlite/connection.c (Arbeitskopie) @@ -1350,7 +1350,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_sqlite/cache.c =================================================================== --- Modules/_sqlite/cache.c (Revision 67635) +++ Modules/_sqlite/cache.c (Arbeitskopie) @@ -282,7 +282,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -324,7 +324,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_sqlite/statement.c =================================================================== --- Modules/_sqlite/statement.c (Revision 67635) +++ Modules/_sqlite/statement.c (Arbeitskopie) @@ -464,7 +464,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_sqlite/row.c =================================================================== --- Modules/_sqlite/row.c (Revision 67635) +++ Modules/_sqlite/row.c (Arbeitskopie) @@ -210,7 +210,7 @@ (printfunc)pysqlite_row_print, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_sqlite/cursor.c =================================================================== --- Modules/_sqlite/cursor.c (Revision 67635) +++ Modules/_sqlite/cursor.c (Arbeitskopie) @@ -1066,7 +1066,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_sqlite/prepare_protocol.c =================================================================== --- Modules/_sqlite/prepare_protocol.c (Revision 67635) +++ Modules/_sqlite/prepare_protocol.c (Arbeitskopie) @@ -42,7 +42,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_struct.c =================================================================== --- Modules/_struct.c (Revision 67635) +++ Modules/_struct.c (Arbeitskopie) @@ -1853,7 +1853,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_sre.c =================================================================== --- Modules/_sre.c (Revision 67635) +++ Modules/_sre.c (Arbeitskopie) @@ -2625,7 +2625,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3635,7 +3635,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -3819,7 +3819,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/pyexpat.c =================================================================== --- Modules/pyexpat.c (Revision 67635) +++ Modules/pyexpat.c (Arbeitskopie) @@ -1622,7 +1622,7 @@ (printfunc)0, /*tp_print*/ 0, /*tp_getattr*/ (setattrfunc)xmlparse_setattr, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ + 0, /*tp_reserved*/ (reprfunc)0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/parsermodule.c =================================================================== --- Modules/parsermodule.c (Revision 67635) +++ Modules/parsermodule.c (Arbeitskopie) @@ -169,7 +169,6 @@ static void parser_free(PyST_Object *st); -static int parser_compare(PyST_Object *left, PyST_Object *right); static PyObject* parser_compilest(PyST_Object *, PyObject *, PyObject *); static PyObject* parser_isexpr(PyST_Object *, PyObject *, PyObject *); static PyObject* parser_issuite(PyST_Object *, PyObject *, PyObject *); @@ -203,7 +202,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - (cmpfunc)parser_compare, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -231,56 +230,6 @@ }; /* PyST_Type */ -static int -parser_compare_nodes(node *left, node *right) -{ - int j; - - if (TYPE(left) < TYPE(right)) - return (-1); - - if (TYPE(right) < TYPE(left)) - return (1); - - if (ISTERMINAL(TYPE(left))) - return (strcmp(STR(left), STR(right))); - - if (NCH(left) < NCH(right)) - return (-1); - - if (NCH(right) < NCH(left)) - return (1); - - for (j = 0; j < NCH(left); ++j) { - int v = parser_compare_nodes(CHILD(left, j), CHILD(right, j)); - - if (v != 0) - return (v); - } - return (0); -} - - -/* int parser_compare(PyST_Object* left, PyST_Object* right) - * - * Comparison function used by the Python operators ==, !=, <, >, <=, >= - * This really just wraps a call to parser_compare_nodes() with some easy - * checks and protection code. - * - */ -static int -parser_compare(PyST_Object *left, PyST_Object *right) -{ - if (left == right) - return (0); - - if ((left == 0) || (right == 0)) - return (-1); - - return (parser_compare_nodes(left->st_node, right->st_node)); -} - - /* parser_newstobject(node* st) * * Allocates a new Python object representing an ST. This is simply the Index: Modules/sha1module.c =================================================================== --- Modules/sha1module.c (Revision 67635) +++ Modules/sha1module.c (Arbeitskopie) @@ -452,7 +452,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_elementtree.c =================================================================== --- Modules/_elementtree.c (Revision 67635) +++ Modules/_elementtree.c (Arbeitskopie) @@ -761,7 +761,7 @@ for (i = 0; i < self->extra->length; i++) { PyObject* item = self->extra->children[i]; if (Element_CheckExact(item) && - PyObject_Compare(((ElementObject*)item)->tag, tag) == 0) { + PyObject_RichCompareBool(((ElementObject*)item)->tag, tag, Py_EQ) == 1) { Py_INCREF(item); return item; } @@ -792,7 +792,8 @@ for (i = 0; i < self->extra->length; i++) { ElementObject* item = (ElementObject*) self->extra->children[i]; - if (Element_CheckExact(item) && !PyObject_Compare(item->tag, tag)) { + if (Element_CheckExact(item) && (PyObject_RichCompareBool(item->tag, tag, Py_EQ) == 1)) { + PyObject* text = element_get_text(item); if (text == Py_None) return PyBytes_FromString(""); @@ -830,7 +831,7 @@ for (i = 0; i < self->extra->length; i++) { PyObject* item = self->extra->children[i]; if (Element_CheckExact(item) && - PyObject_Compare(((ElementObject*)item)->tag, tag) == 0) { + PyObject_RichCompareBool(((ElementObject*)item)->tag, tag, Py_EQ) == 1) { if (PyList_Append(out, item) < 0) { Py_DECREF(out); return NULL; @@ -1102,7 +1103,7 @@ for (i = 0; i < self->extra->length; i++) { if (self->extra->children[i] == element) break; - if (PyObject_Compare(self->extra->children[i], element) == 0) + if (PyObject_RichCompareBool(self->extra->children[i], element, Py_EQ) == 1) break; } @@ -1378,7 +1379,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ (setattrfunc)element_setattr, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)element_repr, /* tp_repr */ 0, /* tp_as_number */ &element_as_sequence, /* tp_as_sequence */ @@ -1802,7 +1803,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2558,7 +2559,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_cursesmodule.c =================================================================== --- Modules/_cursesmodule.c (Revision 67635) +++ Modules/_cursesmodule.c (Arbeitskopie) @@ -1662,7 +1662,7 @@ 0, /*tp_print*/ (getattrfunc)0, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/xxsubtype.c =================================================================== --- Modules/xxsubtype.c (Revision 67635) +++ Modules/xxsubtype.c (Arbeitskopie) @@ -109,7 +109,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -200,7 +200,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_threadmodule.c =================================================================== --- Modules/_threadmodule.c (Revision 67635) +++ Modules/_threadmodule.c (Arbeitskopie) @@ -129,7 +129,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -358,7 +358,7 @@ /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ 0, - /* tp_compare */ 0, + /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, Index: Modules/sha256module.c =================================================================== --- Modules/sha256module.c (Revision 67635) +++ Modules/sha256module.c (Arbeitskopie) @@ -545,7 +545,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -579,7 +579,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_functoolsmodule.c =================================================================== --- Modules/_functoolsmodule.c (Revision 67635) +++ Modules/_functoolsmodule.c (Arbeitskopie) @@ -206,7 +206,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_testcapimodule.c =================================================================== --- Modules/_testcapimodule.c (Revision 67635) +++ Modules/_testcapimodule.c (Arbeitskopie) @@ -1156,7 +1156,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_collectionsmodule.c =================================================================== --- Modules/_collectionsmodule.c (Revision 67635) +++ Modules/_collectionsmodule.c (Arbeitskopie) @@ -848,7 +848,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ deque_repr, /* tp_repr */ 0, /* tp_as_number */ &deque_as_sequence, /* tp_as_sequence */ @@ -970,7 +970,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1052,7 +1052,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1309,7 +1309,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)defdict_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/ossaudiodev.c =================================================================== --- Modules/ossaudiodev.c (Revision 67635) +++ Modules/ossaudiodev.c (Arbeitskopie) @@ -849,7 +849,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -881,7 +881,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/_hashopenssl.c =================================================================== --- Modules/_hashopenssl.c (Revision 67635) +++ Modules/_hashopenssl.c (Arbeitskopie) @@ -339,7 +339,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ EVP_repr, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/itertoolsmodule.c =================================================================== --- Modules/itertoolsmodule.c (Revision 67635) +++ Modules/itertoolsmodule.c (Arbeitskopie) @@ -148,7 +148,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -279,7 +279,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -432,7 +432,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -588,7 +588,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -783,7 +783,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -926,7 +926,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1066,7 +1066,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1261,7 +1261,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1393,7 +1393,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1561,7 +1561,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -1808,7 +1808,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2034,7 +2034,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2309,7 +2309,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2453,7 +2453,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2604,7 +2604,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)count_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2739,7 +2739,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)repeat_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -2967,7 +2967,7 @@ 0, /* tp_print */ 0, /* tp_getattr */ 0, /* tp_setattr */ - 0, /* tp_compare */ + 0, /* tp_reserved */ 0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ Index: Modules/_csv.c =================================================================== --- Modules/_csv.c (Revision 67635) +++ Modules/_csv.c (Arbeitskopie) @@ -443,7 +443,7 @@ (printfunc)0, /* tp_print */ (getattrfunc)0, /* tp_getattr */ (setattrfunc)0, /* tp_setattr */ - (cmpfunc)0, /* tp_compare */ + 0, /* tp_reserved */ (reprfunc)0, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ @@ -864,7 +864,7 @@ (printfunc)0, /*tp_print*/ (getattrfunc)0, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ + 0, /*tp_reserved*/ (reprfunc)0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ @@ -1286,7 +1286,7 @@ (printfunc)0, /*tp_print*/ (getattrfunc)0, /*tp_getattr*/ (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)0, /*tp_compare*/ + 0, /*tp_reserved*/ (reprfunc)0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/ Index: Modules/md5module.c =================================================================== --- Modules/md5module.c (Revision 67635) +++ Modules/md5module.c (Arbeitskopie) @@ -476,7 +476,7 @@ 0, /*tp_print*/ 0, /*tp_getattr*/ 0, /*tp_setattr*/ - 0, /*tp_compare*/ + 0, /*tp_reserved*/ 0, /*tp_repr*/ 0, /*tp_as_number*/ 0, /*tp_as_sequence*/