[Python-checkins] Correctly compare the hint against the keys in _PyDict_GetItemHint (GH-22960)

pablogsal webhook-mailer at python.org
Sun Oct 25 02:08:21 EDT 2020


https://github.com/python/cpython/commit/492d513ccbebeec40a8ba85cbd894a027ca5b2b3
commit: 492d513ccbebeec40a8ba85cbd894a027ca5b2b3
branch: master
author: Pablo Galindo <Pablogsal at gmail.com>
committer: pablogsal <Pablogsal at gmail.com>
date: 2020-10-25T06:08:17Z
summary:

Correctly compare the hint against the keys in _PyDict_GetItemHint (GH-22960)

files:
M Objects/dictobject.c

diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index 8e74962345286..42d71e56d4547 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -1448,7 +1448,7 @@ _PyDict_GetItemHint(PyDictObject *mp, PyObject *key,
     assert(PyDict_CheckExact((PyObject*)mp));
     assert(PyUnicode_CheckExact(key));
 
-    if (hint >= 0 && hint < _PyDict_KeysSize(mp->ma_keys)) {
+    if (hint >= 0 && hint < mp->ma_keys->dk_nentries) {
         PyObject *res = NULL;
 
         PyDictKeyEntry *ep = DK_ENTRIES(mp->ma_keys) + (size_t)hint;



More information about the Python-checkins mailing list