[3.14] gh-140406: Fix memory leak upon __hash__ returning a non-integer (GH-140411) (GH-140417)

gh-140406: Fix memory leak upon `__hash__` returning a non-integer (GH-140411)
(cherry picked from commit 71db05a12d)

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
This commit is contained in:
Miss Islington (bot) 2025-10-21 14:35:31 +02:00 committed by GitHub
parent 98d4c21c09
commit c0f0eca4da
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 13 additions and 0 deletions

View file

@ -10195,6 +10195,7 @@ slot_tp_hash(PyObject *self)
return PyObject_HashNotImplemented(self);
}
if (!PyLong_Check(res)) {
Py_DECREF(res);
PyErr_SetString(PyExc_TypeError,
"__hash__ method should return an integer");
return -1;