summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorNick Coghlan <ncoghlan@gmail.com>2008-12-30 07:29:12 (GMT)
committerNick Coghlan <ncoghlan@gmail.com>2008-12-30 07:29:12 (GMT)
commitf1f2f686fe06c651e082029d7e76a7eefdb8a2de (patch)
treeaaa7fc633fc18c3b7f17b6dc6ac5d04bbdc165b9 /Objects/object.c
parent4450dcf041523fa6752be97994a4111a803dd1fc (diff)
downloadcpython-f1f2f686fe06c651e082029d7e76a7eefdb8a2de.zip
cpython-f1f2f686fe06c651e082029d7e76a7eefdb8a2de.tar.gz
cpython-f1f2f686fe06c651e082029d7e76a7eefdb8a2de.tar.bz2
Recorded merge of revisions 68051 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r68051 | nick.coghlan | 2008-12-30 11:18:48 +1000 (Tue, 30 Dec 2008) | 1 line Issue #4701: implicitly call PyType_Ready from PyObject_Hash ........
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index b14e52a..bf0e6d1 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -846,6 +846,17 @@ PyObject_Hash(PyObject *v)
PyTypeObject *tp = Py_TYPE(v);
if (tp->tp_hash != NULL)
return (*tp->tp_hash)(v);
+ /* To keep to the general practice that inheriting
+ * solely from object in C code should work without
+ * an explicit call to PyType_Ready, we implicitly call
+ * PyType_Ready here and then check the tp_hash slot again
+ */
+ if (tp->tp_dict == NULL) {
+ if (PyType_Ready(tp) < 0)
+ return -1;
+ if (tp->tp_hash != NULL)
+ return (*tp->tp_hash)(v);
+ }
/* Otherwise, the object can't be hashed */
return PyObject_HashNotImplemented(v);
}