[Python-checkins] python/dist/src/Objects typeobject.c,2.217,2.218

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 22 Mar 2003 21:35:38 -0800


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

Modified Files:
	typeobject.c 
Log Message:
slot_sq_contains():  This leaked a reference to the result of calling
__contains__().

Bugfix candidate.


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.217
retrieving revision 2.218
diff -C2 -d -r2.217 -r2.218
*** typeobject.c	23 Mar 2003 03:33:13 -0000	2.217
--- typeobject.c	23 Mar 2003 05:35:36 -0000	2.218
***************
*** 4017,4024 ****
  {
  	PyObject *func, *res, *args;
  	static PyObject *contains_str;
  
  	func = lookup_maybe(self, "__contains__", &contains_str);
- 
  	if (func != NULL) {
  		args = Py_BuildValue("(O)", value);
--- 4017,4025 ----
  {
  	PyObject *func, *res, *args;
+ 	int result = -1;
+ 
  	static PyObject *contains_str;
  
  	func = lookup_maybe(self, "__contains__", &contains_str);
  	if (func != NULL) {
  		args = Py_BuildValue("(O)", value);
***************
*** 4030,4043 ****
  		}
  		Py_DECREF(func);
! 		if (res == NULL)
! 			return -1;
! 		return PyObject_IsTrue(res);
  	}
! 	else if (PyErr_Occurred())
! 		return -1;
! 	else {
! 		return _PySequence_IterSearch(self, value,
! 					      PY_ITERSEARCH_CONTAINS);
  	}
  }
  
--- 4031,4044 ----
  		}
  		Py_DECREF(func);
! 		if (res != NULL) {
! 			result = PyObject_IsTrue(res);
! 			Py_DECREF(res);
! 		}
  	}
! 	else if (! PyErr_Occurred()) {
! 		result = _PySequence_IterSearch(self, value,
! 						 PY_ITERSEARCH_CONTAINS);
  	}
+ 	return result;
  }
  
***************
*** 4686,4690 ****
  
  /* Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper
!    functions.  The offsets here are relative to the 'PyHeapTypeObject' 
     structure, which incorporates the additional structures used for numbers,
     sequences and mappings.
--- 4687,4691 ----
  
  /* Table mapping __foo__ names to tp_foo offsets and slot_tp_foo wrapper
!    functions.  The offsets here are relative to the 'PyHeapTypeObject'
     structure, which incorporates the additional structures used for numbers,
     sequences and mappings.
***************
*** 5217,5221 ****
  
     In the latter case, the first slotdef entry encoutered wins.  Since
!    slotdef entries are sorted by the offset of the slot in the 
     PyHeapTypeObject, this gives us some control over disambiguating
     between competing slots: the members of PyHeapTypeObject are listed from most
--- 5218,5222 ----
  
     In the latter case, the first slotdef entry encoutered wins.  Since
!    slotdef entries are sorted by the offset of the slot in the
     PyHeapTypeObject, this gives us some control over disambiguating
     between competing slots: the members of PyHeapTypeObject are listed from most