[Python-checkins] CVS: python/dist/src/Objects typeobject.c,2.56,2.57

Guido van Rossum gvanrossum@users.sourceforge.net
Fri, 07 Sep 2001 11:52:16 -0700


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

Modified Files:
	typeobject.c 
Log Message:
PyType_IsSubtype(): test tp_flags for HAVE_CLASS bit before accessing
a->tp_mro.  If a doesn't have class, it's considered a subclass only
of itself or of 'object'.

This one fix is enough to prevent the ExtensionClass test suite from
dumping core, but that doesn't say much (it's a rather small test
suite).  Also note that for ExtensionClass-defined types, a different
subclass test may be needed.  But I haven't checked whether
PyType_IsSubtype() is actually used in situations where this matters
-- probably it doesn't, since we also don't check for classic classes.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.56
retrieving revision 2.57
diff -C2 -d -r2.56 -r2.57
*** typeobject.c	2001/08/30 23:13:11	2.56
--- typeobject.c	2001/09/07 18:52:13	2.57
***************
*** 274,277 ****
--- 274,280 ----
  	PyObject *mro;
  
+ 	if (!(a->tp_flags & Py_TPFLAGS_HAVE_CLASS))
+ 		return b == a || b == &PyBaseObject_Type;
+ 
  	mro = a->tp_mro;
  	if (mro != NULL) {