[Python-checkins] python/dist/src/Python pythonrun.c,2.201,2.202

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Mon Dec 1 16:35:30 EST 2003


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

Modified Files:
	pythonrun.c 
Log Message:
Py_Finalize():  disabled the second call of cyclic gc, and added extensive
comments about why both calls to cyclic gc here can cause problems.

I'll backport to 2.3 maint.  Since the calls were introduced in 2.3,
that will be the end of it.


Index: pythonrun.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/pythonrun.c,v
retrieving revision 2.201
retrieving revision 2.202
diff -C2 -d -r2.201 -r2.202
*** pythonrun.c	20 Nov 2003 01:44:58 -0000	2.201
--- pythonrun.c	1 Dec 2003 21:35:27 -0000	2.202
***************
*** 330,334 ****
  
  	/* Collect garbage.  This may call finalizers; it's nice to call these
! 	   before all modules are destroyed. */
  	PyGC_Collect();
  
--- 330,344 ----
  
  	/* Collect garbage.  This may call finalizers; it's nice to call these
! 	 * before all modules are destroyed.
! 	 * XXX If a __del__ or weakref callback is triggered here, and tries to
! 	 * XXX import a module, bad things can happen, because Python no
! 	 * XXX longer believes it's initialized.
! 	 * XXX     Fatal Python error: Interpreter not initialized (version mismatch?)
! 	 * XXX is easy to provoke that way.  I've also seen, e.g.,
! 	 * XXX     Exception exceptions.ImportError: 'No module named sha'
! 	 * XXX         in <function callback at 0x008F5718> ignored
! 	 * XXX but I'm unclear on exactly how that one happens.  In any case,
! 	 * XXX I haven't seen a real-life report of either of these.
!          */
  	PyGC_Collect();
  
***************
*** 337,342 ****
  
  	/* Collect final garbage.  This disposes of cycles created by
! 	   new-style class definitions, for example. */
  	PyGC_Collect();
  
  	/* Destroy the database used by _PyImport_{Fixup,Find}Extension */
--- 347,367 ----
  
  	/* Collect final garbage.  This disposes of cycles created by
! 	 * new-style class definitions, for example.
! 	 * XXX This is disabled because it caused too many problems.  If
! 	 * XXX a __del__ or weakref callback triggers here, Python code has
! 	 * XXX a hard time running, because even the sys module has been
! 	 * XXX cleared out (sys.stdout is gone, sys.excepthook is gone, etc).
! 	 * XXX One symptom is a sequence of information-free messages
! 	 * XXX coming from threads (if a __del__ or callback is invoked,
! 	 * XXX other threads can execute too, and any exception they encounter
! 	 * XXX triggers a comedy of errors as subsystem after subsystem
! 	 * XXX fails to find what it *expects* to find in sys to help report
! 	 * XXX the exception and consequent unexpected failures).  I've also
! 	 * XXX seen segfaults then, after adding print statements to the
! 	 * XXX Python code getting called.
! 	 */
! #if 0
  	PyGC_Collect();
+ #endif
  
  	/* Destroy the database used by _PyImport_{Fixup,Find}Extension */





More information about the Python-checkins mailing list