summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorBrett Cannon <bcannon@gmail.com>2009-11-05 01:17:22 (GMT)
committerBrett Cannon <bcannon@gmail.com>2009-11-05 01:17:22 (GMT)
commit0ae45116245d4b508672d87eb1249cbf0079f167 (patch)
treebf7a8bdcb16a2e9f5b4bbdbd63d61e3c213514e5 /Lib
parentd83f1e6d6176247efc57cdbf59215743454a3ff5 (diff)
downloadcpython-0ae45116245d4b508672d87eb1249cbf0079f167.zip
cpython-0ae45116245d4b508672d87eb1249cbf0079f167.tar.gz
cpython-0ae45116245d4b508672d87eb1249cbf0079f167.tar.bz2
importlib.test.source.util referenced variables in the 'finally' part of a
try/finally which may not have been set.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/importlib/test/source/util.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/Lib/importlib/test/source/util.py b/Lib/importlib/test/source/util.py
index ca04edf..a881d4a 100644
--- a/Lib/importlib/test/source/util.py
+++ b/Lib/importlib/test/source/util.py
@@ -55,6 +55,8 @@ def create_modules(*names):
source = 'attr = {0!r}'
created_paths = []
mapping = {}
+ state_manager = None
+ uncache_manager = None
try:
temp_dir = tempfile.gettempdir()
mapping['.root'] = temp_dir
@@ -85,8 +87,10 @@ def create_modules(*names):
state_manager.__enter__()
yield mapping
finally:
- state_manager.__exit__(None, None, None)
- uncache_manager.__exit__(None, None, None)
+ if state_manager is not None:
+ state_manager.__exit__(None, None, None)
+ if uncache_manager is not None:
+ uncache_manager.__exit__(None, None, None)
# Reverse the order for path removal to unroll directory creation.
for path in reversed(created_paths):
if file_path.endswith('.py'):