Skip to content

Commit

Permalink
Allow non-dict types for the class dict when looking up names and cal…
Browse files Browse the repository at this point in the history
…l PyObject_GetItem() for them.
  • Loading branch information
Stefan Behnel committed Sep 11, 2017
1 parent 85fb3ae commit 09e716a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Objects/typeobject.c
Expand Up @@ -2989,8 +2989,12 @@ find_name_in_mro(PyTypeObject *type, PyObject *name, int *error)
base = PyTuple_GET_ITEM(mro, i);
assert(PyType_Check(base));
dict = ((PyTypeObject *)base)->tp_dict;
assert(dict && PyDict_Check(dict));
res = _PyDict_GetItem_KnownHash(dict, name, hash);
assert(dict);
if (PyDict_CheckExact(dict)) {
res = _PyDict_GetItem_KnownHash(dict, name, hash);
} else {
res = PyObject_GetItem(dict, name);
}
if (res != NULL)
break;
if (PyErr_Occurred()) {
Expand Down

0 comments on commit 09e716a

Please sign in to comment.