diff options
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/classobject.c | 8 | ||||
-rw-r--r-- | Objects/typeobject.c | 5 |
2 files changed, 7 insertions, 6 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"); diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 67e6104..652009b 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4559,7 +4559,10 @@ slot_tp_hash(PyObject *self) 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 { |