[Python-checkins] python/dist/src/Lib atexit.py,1.4,1.5

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Tue, 16 Jul 2002 12:31:00 -0700


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

Modified Files:
	atexit.py 
Log Message:
The atexit module effectively turned itself off if sys.exitfunc already
existed at the time atexit first got imported.  That's a bug, and this
fixes it.

Also reworked test_atexit.py to test for this too, and to stop using
an "expected output" file, and to test what actually happens at exit
instead of just simulating what it thinks atexit will do at exit.

Bugfix candidate, but it's messy so I'll backport to 2.2 myself.


Index: atexit.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/atexit.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** atexit.py	21 Jan 2001 03:40:37 -0000	1.4
--- atexit.py	16 Jul 2002 19:30:58 -0000	1.5
***************
*** 30,42 ****
  
  import sys
! try:
!     x = sys.exitfunc
! except AttributeError:
!     sys.exitfunc = _run_exitfuncs
! else:
!     # if x isn't our own exit func executive, assume it's another
!     # registered exit function - append it to our list...
!     if x != _run_exitfuncs:
!         register(x)
  del sys
  
--- 30,38 ----
  
  import sys
! if hasattr(sys, "exitfunc"):
!     # Assume it's another registered exit function - append it to our list
!     register(sys.exitfunc)
! sys.exitfunc = _run_exitfuncs
! 
  del sys