[Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.38,2.126.4.39

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Mon, 16 Jun 2003 16:38:03 -0700


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

Modified Files:
      Tag: release22-maint
	typeobject.c 
Log Message:
Backport 2.237 by Guido:
- SF patch 751998 fixes an unwanted side effect of the previous fix
  for SF bug 742860 (the next item).



Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.126.4.38
retrieving revision 2.126.4.39
diff -C2 -d -r2.126.4.38 -r2.126.4.39
*** typeobject.c	29 May 2003 15:13:18 -0000	2.126.4.38
--- typeobject.c	16 Jun 2003 23:38:00 -0000	2.126.4.39
***************
*** 432,447 ****
  	/* This function exists so we can DECREF self->ob_type */
  
! 	/* Find the nearest base with a different tp_dealloc
! 	   and clear slots while we're at it */
  	type = self->ob_type;
  	base = type;
  	while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
- 		if (base->ob_size)
- 			clear_slots(base, self);
  		base = base->tp_base;
  		assert(base);
  	}
  
! 	/* If we added weaklist, we clear it */
  	if (type->tp_weaklistoffset && !base->tp_weaklistoffset)
  		PyObject_ClearWeakRefs(self);
--- 432,447 ----
  	/* This function exists so we can DECREF self->ob_type */
  
! 	/* Find the nearest base with a different tp_dealloc */
  	type = self->ob_type;
  	base = type;
  	while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
  		base = base->tp_base;
  		assert(base);
  	}
  
! 	/* If we added a weaklist, we clear it.  Do this *before* calling
! 	   the finalizer (__del__), clearing slots, or clearing the instance
! 	   dict. */
! 
  	if (type->tp_weaklistoffset && !base->tp_weaklistoffset)
  		PyObject_ClearWeakRefs(self);
***************
*** 449,452 ****
--- 449,461 ----
  	if (call_finalizer(self) < 0)
  		return;
+ 
+ 	/*  Clear slots up to the nearest base with a different tp_dealloc */
+ 	base = type;
+ 	while ((basedealloc = base->tp_dealloc) == subtype_dealloc) {
+ 		if (base->ob_size)
+ 			clear_slots(base, self);
+ 		base = base->tp_base;
+ 		assert(base);
+ 	}
  
  	/* If we added a dict, DECREF it */