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

Jeremy Hylton python-dev@python.org
Thu, 31 Aug 2000 19:47:27 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory slayer.i.sourceforge.net:/tmp/cvs-serv2009/Modules

Modified Files:
	gcmodule.c 
Log Message:
refactor __del__ exception handler into PyErr_WriteUnraisable
add sanity check to gc: if an exception occurs during GC, call
PyErr_WriteUnraisable and then call Py_FatalEror. 


Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.8
retrieving revision 2.9
diff -C2 -r2.8 -r2.9
*** gcmodule.c	2000/08/31 15:10:24	2.8
--- gcmodule.c	2000/09/01 02:47:24	2.9
***************
*** 58,66 ****
  				DEBUG_INSTANCES | \
  				DEBUG_OBJECTS
! static int debug = 0;
  
  /* list of uncollectable objects */
  static PyObject *garbage;
  
  
  /*** list functions ***/
--- 58,68 ----
  				DEBUG_INSTANCES | \
  				DEBUG_OBJECTS
! static int debug;
  
  /* list of uncollectable objects */
  static PyObject *garbage;
  
+ /* Python string to use if unhandled exception occurs */
+ static PyObject *gc_str;
  
  /*** list functions ***/
***************
*** 436,439 ****
--- 438,445 ----
  	handle_finalizers(&finalizers, old);
  
+ 	if (PyErr_Occurred()) {
+ 		PyErr_WriteUnraisable(gc_str);
+ 		Py_FatalError("unexpected exception during garbage collection");
+ 	}
  	allocated = 0;
  	return n+m;
***************
*** 699,702 ****
--- 705,711 ----
  	if (garbage == NULL) {
  		garbage = PyList_New(0);
+ 	}
+ 	if (gc_str == NULL) {
+ 		gc_str = PyString_FromString("garbage collection");
  	}
  	PyDict_SetItemString(d, "garbage", garbage);