[Python-3000-checkins] r59636 - python/branches/py3k/Objects/typeobject.c
guido.van.rossum
python-3000-checkins at python.org
Tue Jan 1 05:06:48 CET 2008
Author: guido.van.rossum
Date: Tue Jan 1 05:06:48 2008
New Revision: 59636
Modified:
python/branches/py3k/Objects/typeobject.c
Log:
Merge changes from 59576 from trunk to p3yk branch; these were skipped
in the regular merge. Fixes issue #1693.
Modified: python/branches/py3k/Objects/typeobject.c
==============================================================================
--- python/branches/py3k/Objects/typeobject.c (original)
+++ python/branches/py3k/Objects/typeobject.c Tue Jan 1 05:06:48 2008
@@ -3167,28 +3167,22 @@
type->tp_flags |= Py_TPFLAGS_DICT_SUBCLASS;
}
-/* Map rich comparison operators to their __xx__ namesakes */
-static char *name_op[] = {
- "__lt__",
- "__le__",
+static char *hash_name_op[] = {
"__eq__",
- "__ne__",
- "__gt__",
- "__ge__",
- /* These are only for overrides_cmp_or_hash(): */
"__cmp__",
"__hash__",
+ NULL
};
static int
-overrides_cmp_or_hash(PyTypeObject *type)
+overrides_hash(PyTypeObject *type)
{
- int i;
+ char **p;
PyObject *dict = type->tp_dict;
assert(dict != NULL);
- for (i = 0; i < 8; i++) {
- if (PyDict_GetItemString(dict, name_op[i]) != NULL)
+ for (p = hash_name_op; *p; p++) {
+ if (PyDict_GetItemString(dict, *p) != NULL)
return 1;
}
return 0;
@@ -3314,7 +3308,7 @@
if (type->tp_compare == NULL &&
type->tp_richcompare == NULL &&
type->tp_hash == NULL &&
- !overrides_cmp_or_hash(type))
+ !overrides_hash(type))
{
type->tp_compare = base->tp_compare;
type->tp_richcompare = base->tp_richcompare;
@@ -4739,6 +4733,15 @@
return 0;
}
+static char *name_op[] = {
+ "__lt__",
+ "__le__",
+ "__eq__",
+ "__ne__",
+ "__gt__",
+ "__ge__",
+};
+
static PyObject *
half_richcompare(PyObject *self, PyObject *other, int op)
{
More information about the Python-3000-checkins
mailing list