summaryrefslogtreecommitdiffstats
path: root/Objects/classobject.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2006-08-09 07:57:39 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2006-08-09 07:57:39 (GMT)
commitab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311 (patch)
tree173d0b8612bd7a76a7fc9c8105e8a53370dbd7ab /Objects/classobject.c
parent209307eb3bca9aeb9b842014edcfe8df9cbb7f91 (diff)
downloadcpython-ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311.zip
cpython-ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311.tar.gz
cpython-ab2f8f7bd556c16a2b30aa8ec05d4c9d8c50d311.tar.bz2
__hash__ may now return long int; the final hash
value is obtained by invoking hash on the long int. Fixes #1536021.
Diffstat (limited to 'Objects/classobject.c')
-rw-r--r--Objects/classobject.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/Objects/classobject.c b/Objects/classobject.c
index c69ba74..56bf29c 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -934,11 +934,9 @@ instance_hash(PyInstanceObject *inst)
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");