[Python-checkins] python/dist/src/Objects typeobject.c,2.226,2.227

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Wed, 16 Apr 2003 12:41:05 -0700


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

Modified Files:
	typeobject.c 
Log Message:
- super() no longer ignores data descriptors, except __class__.  See
  the thread started at
  http://mail.python.org/pipermail/python-dev/2003-April/034338.html

Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.226
retrieving revision 2.227
diff -C2 -d -r2.226 -r2.227
*** typeobject.c	15 Apr 2003 22:09:45 -0000	2.226
--- typeobject.c	16 Apr 2003 19:40:58 -0000	2.227
***************
*** 5360,5365 ****
  {
  	superobject *su = (superobject *)self;
  
! 	if (su->obj_type != NULL) {
  		PyObject *mro, *res, *tmp, *dict;
  		PyTypeObject *starttype;
--- 5360,5374 ----
  {
  	superobject *su = (superobject *)self;
+ 	int skip = su->obj_type == NULL;
  
! 	if (!skip) {
! 		/* We want __class__ to return the class of the super object
! 		   (i.e. super, or a subclass), not the class of su->obj. */
! 		skip = (PyString_Check(name) &&
! 			PyString_GET_SIZE(name) == 9 &&
! 			strcmp(PyString_AS_STRING(name), "__class__") == 0);
! 	}
! 
! 	if (!skip) {
  		PyObject *mro, *res, *tmp, *dict;
  		PyTypeObject *starttype;
***************
*** 5391,5397 ****
  				continue;
  			res = PyDict_GetItem(dict, name);
- 			/* Skip data descriptors because when obj_type is a
- 			   metaclass, we don't want to return its __class__
- 			   descriptor.  See supers() in test_descr.py. */
  			if (res != NULL && !PyDescr_IsData(res)) {
  				Py_INCREF(res);
--- 5400,5403 ----