Skip to content

Commit 09e716a

Browse files
author
Stefan Behnel
committed
Allow non-dict types for the class dict when looking up names and call PyObject_GetItem() for them.
1 parent 85fb3ae commit 09e716a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Objects/typeobject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2989,8 +2989,12 @@ find_name_in_mro(PyTypeObject *type, PyObject *name, int *error)
29892989
base = PyTuple_GET_ITEM(mro, i);
29902990
assert(PyType_Check(base));
29912991
dict = ((PyTypeObject *)base)->tp_dict;
2992-
assert(dict && PyDict_Check(dict));
2993-
res = _PyDict_GetItem_KnownHash(dict, name, hash);
2992+
assert(dict);
2993+
if (PyDict_CheckExact(dict)) {
2994+
res = _PyDict_GetItem_KnownHash(dict, name, hash);
2995+
} else {
2996+
res = PyObject_GetItem(dict, name);
2997+
}
29942998
if (res != NULL)
29952999
break;
29963000
if (PyErr_Occurred()) {

0 commit comments

Comments
 (0)