mirror of
https://github.com/python/cpython.git
synced 2025-10-13 10:23:28 +00:00
Manual forward port of 64962 - use PyObject_HashNotImplemented as a tp_hash level indicator that the default hash implementation has not been inherited
This commit is contained in:
parent
e65282114e
commit
d1abd25ed8
12 changed files with 122 additions and 94 deletions
|
@ -781,17 +781,22 @@ finally:
|
|||
#endif
|
||||
}
|
||||
|
||||
long
|
||||
PyObject_HashNotImplemented(PyObject *v)
|
||||
{
|
||||
PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'",
|
||||
Py_TYPE(v)->tp_name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
long
|
||||
PyObject_Hash(PyObject *v)
|
||||
{
|
||||
PyTypeObject *tp = v->ob_type;
|
||||
PyTypeObject *tp = Py_TYPE(v);
|
||||
if (tp->tp_hash != NULL)
|
||||
return (*tp->tp_hash)(v);
|
||||
/* Otherwise, the object can't be hashed */
|
||||
PyErr_Format(PyExc_TypeError, "unhashable type: '%.200s'",
|
||||
v->ob_type->tp_name);
|
||||
return -1;
|
||||
return PyObject_HashNotImplemented(v);
|
||||
}
|
||||
|
||||
PyObject *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue