[Python-checkins] CVS: python/dist/src/Modules gcmodule.c,2.31,2.32

Martin v. L?wis loewis@users.sourceforge.net
Sun, 02 Dec 2001 04:21:36 -0800


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

Modified Files:
	gcmodule.c 
Log Message:
Patch #486743: remove bad INCREF, propagate exception in append_objects.


Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.31
retrieving revision 2.32
diff -C2 -d -r2.31 -r2.32
*** gcmodule.c	2001/11/29 18:08:31	2.31
--- gcmodule.c	2001/12/02 12:21:34	2.32
***************
*** 702,706 ****
  
  /* appending objects in a GC list to a Python list */
! static void
  append_objects(PyObject *py_list, PyGC_Head *gc_list)
  {
--- 702,706 ----
  
  /* appending objects in a GC list to a Python list */
! static int
  append_objects(PyObject *py_list, PyGC_Head *gc_list)
  {
***************
*** 709,716 ****
  		PyObject *op = FROM_GC(gc);
  		if (op != py_list) {
! 			Py_INCREF(op);
! 			PyList_Append(py_list, op);
  		}
  	}
  }
  
--- 709,718 ----
  		PyObject *op = FROM_GC(gc);
  		if (op != py_list) {
! 			if (PyList_Append(py_list, op)) {
! 				return -1; /* exception */
! 			}
  		}
  	}
+ 	return 0;
  }
  
***************
*** 723,729 ****
  		return NULL;
  	result = PyList_New(0);
! 	append_objects(result, &_PyGC_generation0);
! 	append_objects(result, &generation1);
! 	append_objects(result, &generation2);
  	return result;
  }
--- 725,734 ----
  		return NULL;
  	result = PyList_New(0);
! 	if (append_objects(result, &_PyGC_generation0) ||
! 	    append_objects(result, &generation1) ||
! 	    append_objects(result, &generation2)) {
! 		Py_DECREF(result);
! 		return NULL;
! 	}
  	return result;
  }