File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1289,7 +1289,7 @@ PyObject *
12891289PyObject_GenericGetAttr (PyObject * obj , PyObject * name )
12901290{
12911291 PyTypeObject * tp = obj -> ob_type ;
1292- PyObject * descr ;
1292+ PyObject * descr = NULL ;
12931293 PyObject * res = NULL ;
12941294 descrgetfunc f ;
12951295 long dictoffset ;
@@ -1321,7 +1321,31 @@ PyObject_GenericGetAttr(PyObject *obj, PyObject *name)
13211321 goto done ;
13221322 }
13231323
1324- descr = _PyType_Lookup (tp , name );
1324+ /* Inline _PyType_Lookup */
1325+ {
1326+ int i , n ;
1327+ PyObject * mro , * base , * dict ;
1328+
1329+ /* Look in tp_dict of types in MRO */
1330+ mro = tp -> tp_mro ;
1331+ assert (mro != NULL );
1332+ assert (PyTuple_Check (mro ));
1333+ n = PyTuple_GET_SIZE (mro );
1334+ for (i = 0 ; i < n ; i ++ ) {
1335+ base = PyTuple_GET_ITEM (mro , i );
1336+ if (PyClass_Check (base ))
1337+ dict = ((PyClassObject * )base )-> cl_dict ;
1338+ else {
1339+ assert (PyType_Check (base ));
1340+ dict = ((PyTypeObject * )base )-> tp_dict ;
1341+ }
1342+ assert (dict && PyDict_Check (dict ));
1343+ descr = PyDict_GetItem (dict , name );
1344+ if (descr != NULL )
1345+ break ;
1346+ }
1347+ }
1348+
13251349 f = NULL ;
13261350 if (descr != NULL ) {
13271351 f = descr -> ob_type -> tp_descr_get ;
You can’t perform that action at this time.
0 commit comments