[Python-checkins] python/dist/src/Objects typeobject.c,2.210,2.211

gvanrossum@users.sourceforge.net gvanrossum@users.sourceforge.net
Tue, 18 Feb 2003 11:22:28 -0800


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

Modified Files:
	typeobject.c 
Log Message:
The recent changes to super(), in particular supercheck(), broke when
using super() for an instance in a metaclass situation.  Because the
class was a metaclass, the instance was a class, and hence the
PyType_Check() branch was taken.  But this branch didn't apply.  Make
it so that if this branch doesn't apply, the other branch is still
tried.  All tests pass.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.210
retrieving revision 2.211
diff -C2 -d -r2.210 -r2.211
*** typeobject.c	13 Feb 2003 16:24:34 -0000	2.210
--- typeobject.c	18 Feb 2003 19:22:22 -0000	2.211
***************
*** 5171,5184 ****
  	*/
  
! 	if (PyType_Check(obj)) {
! 		/* It's a new-style class */
! 		if (PyType_IsSubtype((PyTypeObject *)obj, type)) {
! 			Py_INCREF(obj);
! 			return (PyTypeObject *)obj;
! 		}
! 		else
! 			goto fail;
  	}
! 	else if (PyType_IsSubtype(obj->ob_type, type)) {
  		Py_INCREF(obj->ob_type);
  		return obj->ob_type;
--- 5171,5182 ----
  	*/
  
! 	/* Check for first bullet above (special case) */
! 	if (PyType_Check(obj) && PyType_IsSubtype((PyTypeObject *)obj, type)) {
! 		Py_INCREF(obj);
! 		return (PyTypeObject *)obj;
  	}
! 
! 	/* Normal case */
! 	if (PyType_IsSubtype(obj->ob_type, type)) {
  		Py_INCREF(obj->ob_type);
  		return obj->ob_type;