mirror of
https://github.com/python/cpython.git
synced 2025-07-30 22:54:16 +00:00
__hash__ may now return long int; the final hash
value is obtained by invoking hash on the long int. Fixes #1536021.
This commit is contained in:
parent
209307eb3b
commit
ab2f8f7bd5
5 changed files with 24 additions and 6 deletions
|
@ -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");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue