summaryrefslogtreecommitdiff
path: root/Lib/atexit.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-07-16 19:30:59 +0000
committerTim Peters <tim.peters@gmail.com>2002-07-16 19:30:59 +0000
commiteca2668585d619a7357570a5106b714303381b7c (patch)
tree359f1df7264e3f70cdd32653e649ddb9b56f9eb0 /Lib/atexit.py
parentb29937d6311a2e5a2d24c6132fd250b6a37c03c8 (diff)
downloadcpython-eca2668585d619a7357570a5106b714303381b7c.tar.gz
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.
Diffstat (limited to 'Lib/atexit.py')
-rw-r--r--Lib/atexit.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/Lib/atexit.py b/Lib/atexit.py
index 61f2458dd0..b5929fc15a 100644
--- a/Lib/atexit.py
+++ b/Lib/atexit.py
@@ -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__":