Skip to content

gh-117826: Remove lookdict_index from delitemif_lock_held #117869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Objects/dictobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -2603,7 +2603,7 @@ static int
delitemif_lock_held(PyObject *op, PyObject *key,
int (*predicate)(PyObject *value))
{
Py_ssize_t hashpos, ix;
Py_ssize_t ix;
PyDictObject *mp;
Py_hash_t hash;
PyObject *old_value;
Expand Down Expand Up @@ -2632,14 +2632,11 @@ delitemif_lock_held(PyObject *op, PyObject *key,
if (res == -1)
return -1;

hashpos = lookdict_index(mp->ma_keys, hash, ix);
assert(hashpos >= 0);

if (res > 0) {
PyInterpreterState *interp = _PyInterpreterState_GET();
uint64_t new_version = _PyDict_NotifyEvent(
interp, PyDict_EVENT_DELETED, mp, key, NULL);
return delitem_common(mp, hashpos, ix, old_value, new_version);
return delitem_common(mp, hash, ix, old_value, new_version);
} else {
return 0;
}
Expand Down