[Python-checkins] python/dist/src/Lib atexit.py,1.7,1.8
montanaro at users.sourceforge.net
montanaro at users.sourceforge.net
Thu Nov 4 05:31:33 CET 2004
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29401/Lib
Modified Files:
atexit.py
Log Message:
Fix bug 1052242. Also includes rewrite of test case using unittest and
avoiding use of popen.
Index: atexit.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/atexit.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- atexit.py 12 Feb 2004 17:35:05 -0000 1.7
+++ atexit.py 4 Nov 2004 04:31:30 -0000 1.8
@@ -15,9 +15,22 @@
last in, first out.
"""
+ exc_info = None
while _exithandlers:
func, targs, kargs = _exithandlers.pop()
- func(*targs, **kargs)
+ try:
+ func(*targs, **kargs)
+ except SystemExit:
+ exc_info = sys.exc_info()
+ except:
+ import sys, traceback
+ print >> sys.stderr, "Error in atexit._run_exitfuncs:"
+ traceback.print_exc()
+ exc_info = sys.exc_info()
+
+ if exc_info is not None:
+ raise exc_info[0], exc_info[1], exc_info[2]
+
def register(func, *targs, **kargs):
"""register a function to be executed upon normal program termination
@@ -33,7 +46,6 @@
# Assume it's another registered exit function - append it to our list
register(sys.exitfunc)
sys.exitfunc = _run_exitfuncs
-
del sys
if __name__ == "__main__":
More information about the Python-checkins
mailing list