diff options
author | Guido van Rossum <guido@python.org> | 2001-01-18 23:33:37 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2001-01-18 23:33:37 (GMT) |
commit | 41c3244875dbe2a549ff1f41f8fdca66992a6994 (patch) | |
tree | e170e38b09cfa329f4108adff10042c2b2218466 /Objects | |
parent | a3af41d5646c629d19b844e094afa58fdcd129f9 (diff) | |
download | cpython-41c3244875dbe2a549ff1f41f8fdca66992a6994.zip cpython-41c3244875dbe2a549ff1f41f8fdca66992a6994.tar.gz cpython-41c3244875dbe2a549ff1f41f8fdca66992a6994.tar.bz2 |
Rich comparisons fallout: PyObject_Hash() should check for both
tp_compare and tp_richcompare NULL before deciding to do a quickie
based on the object address. (Tim Peters discovered this.)
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/object.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/Objects/object.c b/Objects/object.c index 323ed54..44344f9 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -914,7 +914,7 @@ PyObject_Hash(PyObject *v) PyTypeObject *tp = v->ob_type; if (tp->tp_hash != NULL) return (*tp->tp_hash)(v); - if (tp->tp_compare == NULL) { + if (tp->tp_compare == NULL && tp->tp_richcompare == NULL) { return _Py_HashPointer(v); /* Use address as hash value */ } /* If there's a cmp but no hash defined, the object can't be hashed */ |