summaryrefslogtreecommitdiff
path: root/Objects/object.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2008-07-15 14:27:37 +0000
committerNick Coghlan <ncoghlan@gmail.com>2008-07-15 14:27:37 +0000
commit53663a695ef2bb96ac0252cd4cc4aa40d4f953be (patch)
treee241ef71b353f8b3162179b1eed5a3f4eaae0c5f /Objects/object.c
parent9ace15ca25e1e72e1b943190a5f4efbd7d118de3 (diff)
downloadcpython-git-53663a695ef2bb96ac0252cd4cc4aa40d4f953be.tar.gz
Issue 2235: __hash__ is once again inherited by default, but inheritance can be blocked explicitly so that collections.Hashable remains meaningful
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c
index f40fd9f587..9cd34b8d4e 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1083,6 +1083,13 @@ finally:
#endif
}
+long
+PyObject_HashNotImplemented(PyObject *self)
+{
+ PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'",
+ self->ob_type->tp_name);
+ return -1;
+}
long
PyObject_Hash(PyObject *v)
@@ -1094,9 +1101,7 @@ PyObject_Hash(PyObject *v)
return _Py_HashPointer(v); /* Use address as hash value */
}
/* If there's a cmp but no hash defined, the object can't be hashed */
- PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'",
- v->ob_type->tp_name);
- return -1;
+ return PyObject_HashNotImplemented(v);
}
PyObject *