[Python-checkins] CVS: python/dist/src/Objects object.c,2.124.4.16,2.124.4.17

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 29 Jun 2001 08:06:00 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv29052

Modified Files:
      Tag: descr-branch
	object.c 
Log Message:
PyObject_GenericGetAttr(): for dynamic types, use _PyType_Lookup()
instead of coding the MRO loop directly.  (This will now search the
type's own __defined__ a second time unsuccessfully; this is all
provisional anyway.)


Index: object.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/object.c,v
retrieving revision 2.124.4.16
retrieving revision 2.124.4.17
diff -C2 -r2.124.4.16 -r2.124.4.17
*** object.c	2001/06/28 16:51:27	2.124.4.16
--- object.c	2001/06/29 15:05:58	2.124.4.17
***************
*** 1152,1177 ****
  
  	if (tp->tp_flags & Py_TPFLAGS_DYNAMICTYPE) {
! 		/* Look through base classes tp_defined, in MRO,
! 		   skipping first base (which should be tp) */
! 		int i, n;
! 		PyObject *mro = tp->tp_mro;
! 		PyTypeObject *t;
! 		assert(PyTuple_Check(mro));
! 		n = PyTuple_GET_SIZE(mro);
! 		assert(n > 0 && PyTuple_GET_ITEM(mro, 0) == (PyObject *)tp);
! 		descr = NULL;
! 		for (i = 1; i < n; i++) {
! 			t = (PyTypeObject *) PyTuple_GET_ITEM(mro, i);
! 			assert(PyType_Check(t));
! 			assert(t->tp_dict && PyDict_Check(t->tp_dict));
! 			descr = PyDict_GetItem(t->tp_dict, name);
! 			if (descr != NULL) {
! 				f = descr->ob_type->tp_descr_get;
! 				if (f != NULL)
! 					return f(descr, obj);
! 				else {
! 					Py_INCREF(descr);
! 					return descr;
! 				}
  			}
  		}
--- 1152,1164 ----
  
  	if (tp->tp_flags & Py_TPFLAGS_DYNAMICTYPE) {
! 		/* Look through base classes tp_defined, in MRO */
! 		descr = _PyType_Lookup(tp, name);
! 		if (descr != NULL) {
! 			f = descr->ob_type->tp_descr_get;
! 			if (f != NULL)
! 				return f(descr, obj);
! 			else {
! 				Py_INCREF(descr);
! 				return descr;
  			}
  		}