[Python-checkins] python/dist/src/Objects typeobject.c,2.126.4.32,2.126.4.33

nnorwitz@users.sourceforge.net nnorwitz@users.sourceforge.net
Sun, 23 Mar 2003 06:36:53 -0800


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

Modified Files:
      Tag: release22-maint
	typeobject.c 
Log Message:
Backport Tim's checkin 2.218:
    slot_sq_contains():  This leaked a reference to the result of calling
    __contains__().


Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.126.4.32
retrieving revision 2.126.4.33
diff -C2 -d -r2.126.4.32 -r2.126.4.33
*** typeobject.c	2 Feb 2003 19:59:59 -0000	2.126.4.32
--- typeobject.c	23 Mar 2003 14:36:50 -0000	2.126.4.33
***************
*** 3026,3033 ****
  {
  	PyObject *func, *res, *args;
  	static PyObject *contains_str;
  
  	func = lookup_maybe(self, "__contains__", &contains_str);
- 
  	if (func != NULL) {
  		args = Py_BuildValue("(O)", value);
--- 3026,3034 ----
  {
  	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);
***************
*** 3039,3052 ****
  		}
  		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);
  	}
  }
  
--- 3040,3053 ----
  		}
  		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;
  }