From 6e5cee2a9ef5c6785498dc3dc3f6885d3fd8731f Mon Sep 17 00:00:00 2001 From: Carl Meyer Date: Tue, 4 Oct 2022 10:12:26 -0700 Subject: [PATCH] Over-engineer the watcher bits check --- Objects/dictobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 35637d34f0fd06..395b8a77c5fafd 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -5765,11 +5765,12 @@ _PyDict_SendEvent(int watcher_bits, { PyInterpreterState *interp = _PyInterpreterState_GET(); for (int i = 0; i < DICT_MAX_WATCHERS; i++) { - if (watcher_bits & (1 << i)) { + if (watcher_bits & 1) { PyDict_WatchCallback cb = (PyDict_WatchCallback)interp->dict_watchers[i]; if (cb) { cb(event, (PyObject*)mp, key, value); } } + watcher_bits >>= 1; } }