[3.14] gh-142664: fix PyObject_Hash invokation post GH-143217 (GH-143223) (#143224)

gh-142664: fix `PyObject_Hash` invokation post GH-143217 (GH-143223)
(cherry picked from commit 84fcdbd86e)

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
This commit is contained in:
Miss Islington (bot) 2025-12-27 15:55:45 +01:00 committed by GitHub
parent 93029e45b7
commit bbe9ed95d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3232,9 +3232,9 @@ memory_hash(PyObject *_self)
// Prevent 'self' from being freed when computing the item's hash.
// See https://github.com/python/cpython/issues/142664.
self->exports++;
int rc = PyObject_Hash(view->obj);
Py_hash_t h = PyObject_Hash(view->obj);
self->exports--;
if (rc == -1) {
if (h == -1) {
/* Keep the original error message */
return -1;
}