summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorRaymond Hettinger <python@rcn.com>2004-12-11 02:49:40 (GMT)
committerRaymond Hettinger <python@rcn.com>2004-12-11 02:49:40 (GMT)
commita9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474 (patch)
tree0cada4fccb97a7f7a6d6dc0291bb65bc8ecc27df /Lib
parentbb4f1bdd8bcf87f9918a6e756c182de68238ae64 (diff)
downloadcpython-a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474.zip
cpython-a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474.tar.gz
cpython-a9ef5e565d3e33e3a6f410d9c610ffe5bdc6c474.tar.bz2
SF bug #1083202L UnboundLocalError raised by atexit module
The sys module could be called before being imported.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/atexit.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/Lib/atexit.py b/Lib/atexit.py
index e109eb5..c9f4cc6 100644
--- a/Lib/atexit.py
+++ b/Lib/atexit.py
@@ -7,6 +7,8 @@ One public function, register, is defined.
__all__ = ["register"]
+import sys
+
_exithandlers = []
def _run_exitfuncs():
"""run any registered exit functions
@@ -23,7 +25,7 @@ def _run_exitfuncs():
except SystemExit:
exc_info = sys.exc_info()
except:
- import sys, traceback
+ import traceback
print >> sys.stderr, "Error in atexit._run_exitfuncs:"
traceback.print_exc()
exc_info = sys.exc_info()
@@ -41,12 +43,10 @@ def register(func, *targs, **kargs):
"""
_exithandlers.append((func, targs, kargs))
-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
if __name__ == "__main__":
def x1():