[Python-checkins] python/dist/src/Objects abstract.c,2.111,2.112 classobject.c,2.165,2.166

doerwalter@users.sourceforge.net doerwalter@users.sourceforge.net
Thu, 12 Dec 2002 11:14:11 -0800


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

Modified Files:
	abstract.c classobject.c 
Log Message:
Change issubclass() so that recursive tuples (directly or indirectly
containing class objects) are allowed as the second argument.
This makes issubclass() more similar to isinstance() where recursive
tuples are allowed too.


Index: abstract.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/abstract.c,v
retrieving revision 2.111
retrieving revision 2.112
diff -C2 -d -r2.111 -r2.112
*** abstract.c	12 Dec 2002 16:41:41 -0000	2.111
--- abstract.c	12 Dec 2002 19:14:07 -0000	2.112
***************
*** 2022,2030 ****
  			int n = PyTuple_GET_SIZE(cls);
  			for (i = 0; i < n; ++i) {
! 				if (!check_class(PyTuple_GET_ITEM(cls, i),
! 						"issubclass() arg 2 must be a class"
! 						" or tuple of classes"))
! 					return -1;
  			}
  		}
  		else {
--- 2022,2030 ----
  			int n = PyTuple_GET_SIZE(cls);
  			for (i = 0; i < n; ++i) {
! 				retval = PyObject_IsSubclass(derived, PyTuple_GET_ITEM(cls, i));
! 				if (retval != 0) /* either found it, or got an error */
! 					return retval;
  			}
+ 			return 0;
  		}
  		else {

Index: classobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/classobject.c,v
retrieving revision 2.165
retrieving revision 2.166
diff -C2 -d -r2.165 -r2.166
*** classobject.c	12 Dec 2002 16:41:42 -0000	2.165
--- classobject.c	12 Dec 2002 19:14:08 -0000	2.166
***************
*** 491,497 ****
  		n = PyTuple_GET_SIZE(base);
  		for (i = 0; i < n; i++) {
! 			if (class == PyTuple_GET_ITEM(base, i))
  				return 1;
  		}
  	}
  	if (class == NULL || !PyClass_Check(class))
--- 491,498 ----
  		n = PyTuple_GET_SIZE(base);
  		for (i = 0; i < n; i++) {
! 			if (PyClass_IsSubclass(class, PyTuple_GET_ITEM(base, i)))
  				return 1;
  		}
+ 		return 0;
  	}
  	if (class == NULL || !PyClass_Check(class))