mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
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.
This commit is contained in:
parent
32a03967b7
commit
012b69cb30
3 changed files with 53 additions and 24 deletions
|
@ -29,15 +29,11 @@ def register(func, *targs, **kargs):
|
|||
_exithandlers.append((func, targs, kargs))
|
||||
|
||||
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)
|
||||
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