mirror of
https://github.com/python/cpython.git
synced 2025-07-24 03:35:53 +00:00
Fix bug 1052242. Also includes rewrite of test case using unittest and
avoiding use of popen.
This commit is contained in:
parent
ed306292d6
commit
599bd5e1e1
4 changed files with 117 additions and 54 deletions
|
@ -15,9 +15,22 @@ def _run_exitfuncs():
|
|||
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 @@ 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
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue