Merged 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
........
This commit is contained in:
Nick Coghlan 2008-12-30 01:36:00 +00:00
parent 0edab54cdf
commit d465640eb2
4 changed files with 139 additions and 1 deletions

View file

@ -1100,6 +1100,17 @@ PyObject_Hash(PyObject *v)
PyTypeObject *tp = v->ob_type;
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);
}
if (tp->tp_compare == NULL && RICHCOMPARE(tp) == NULL) {
return _Py_HashPointer(v); /* Use address as hash value */
}