[Python-checkins] cpython: Issue #15828: Don't try to close a file if imp.find_module() doesn't
georg.brandl
python-checkins at python.org
Sun Sep 9 11:19:07 CEST 2012
http://hg.python.org/cpython/rev/a4a9c5717204
changeset: 78903:a4a9c5717204
user: Brett Cannon <brett at python.org>
date: Fri Aug 31 11:31:20 2012 -0400
summary:
Issue #15828: Don't try to close a file if imp.find_module() doesn't
return one.
files:
Lib/test/test_imp.py | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py
--- a/Lib/test/test_imp.py
+++ b/Lib/test/test_imp.py
@@ -211,7 +211,9 @@
# and importlib couldn't handle C extensions
example = "_heapq"
x = imp.find_module(example)
- self.addCleanup(x[0].close)
+ file_ = x[0]
+ if file_ is not None:
+ self.addCleanup(file_.close)
mod = imp.load_module(example, *x)
self.assertEqual(mod.__name__, example)
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list