Tim Peters schrieb: > It sounds fine to me, except I'm not immediately clear on which code > needs to be changed.
My change would essentially be the code below, in instance_hash and slot_tp_hash; I have yet to add test cases and check for documentation changes. Regards, Martin Index: Objects/typeobject.c =================================================================== --- Objects/typeobject.c (Revision 51155) +++ Objects/typeobject.c (Arbeitskopie) @@ -4559,7 +4559,10 @@ Py_DECREF(func); if (res == NULL) return -1; - h = PyInt_AsLong(res); + if (PyLong_Check(res)) + h = res->ob_type->tp_hash(res); + else + h = PyInt_AsLong(res); Py_DECREF(res); } else { Index: Objects/classobject.c =================================================================== --- Objects/classobject.c (Revision 51155) +++ Objects/classobject.c (Arbeitskopie) @@ -934,11 +934,9 @@ Py_DECREF(func); if (res == NULL) return -1; - if (PyInt_Check(res)) { - outcome = PyInt_AsLong(res); - if (outcome == -1) - outcome = -2; - } + if (PyInt_Check(res) || PyLong_Check(res)) + /* This already converts a -1 result to -2. */ + outcome = res->ob_type->tp_hash(res); else { PyErr_SetString(PyExc_TypeError, "__hash__() should return an int"); _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com