[Python-checkins] python/dist/src/Objects typeobject.c,2.192,2.193

mwh@users.sourceforge.net mwh@users.sourceforge.net
Wed, 27 Nov 2002 07:40:11 -0800


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

Modified Files:
	typeobject.c 
Log Message:
I don't know why staring at the email to python-checkins made me
see problems with my code that I didn't see before the checkin, but:

When a subtype .mro() fails, we need to reset the type whose __bases__ 
are being changed, too.  Fix + test.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.192
retrieving revision 2.193
diff -C2 -d -r2.192 -r2.193
*** typeobject.c	27 Nov 2002 15:20:18 -0000	2.192
--- typeobject.c	27 Nov 2002 15:40:08 -0000	2.193
***************
*** 243,257 ****
  
  	if (mro_internal(type) < 0) {
! 		type->tp_bases = old_bases;
! 		type->tp_base = old_base;
! 		type->tp_mro = old_mro;
! 
! 		Py_DECREF(value);
! 		Py_DECREF(new_base);
! 
! 		return -1;
  	}
  
  	temp = PyList_New(0);
  
  	r = mro_subclasses(type, temp);
--- 243,252 ----
  
  	if (mro_internal(type) < 0) {
! 		goto bail;
  	}
  
  	temp = PyList_New(0);
+ 	if (!temp)
+ 		goto bail;
  
  	r = mro_subclasses(type, temp);
***************
*** 268,272 ****
  		}
  		Py_DECREF(temp);
! 		return r;
  	}
  
--- 263,267 ----
  		}
  		Py_DECREF(temp);
! 		goto bail;
  	}
  
***************
*** 304,307 ****
--- 299,312 ----
  
  	return r;
+ 
+   bail:
+ 	type->tp_bases = old_bases;
+ 	type->tp_base = old_base;
+ 	type->tp_mro = old_mro;
+ 	
+ 	Py_DECREF(value);
+ 	Py_DECREF(new_base);
+ 	
+ 	return -1;
  }