diff options
author | Brett Cannon <brett@python.org> | 2012-08-31 15:31:20 (GMT) |
---|---|---|
committer | Brett Cannon <brett@python.org> | 2012-08-31 15:31:20 (GMT) |
commit | f7d176efe944d199f822ccdd1542f9bf06eeb850 (patch) | |
tree | 8c0e632d4e9c4fd358dadf86dd4773a352a45d42 /Lib | |
parent | 5d0612411e3812d7e851fabeb5fd7f2f103f50d2 (diff) | |
download | cpython-f7d176efe944d199f822ccdd1542f9bf06eeb850.zip cpython-f7d176efe944d199f822ccdd1542f9bf06eeb850.tar.gz cpython-f7d176efe944d199f822ccdd1542f9bf06eeb850.tar.bz2 |
Issue #15828: Don't try to close a file if imp.find_module() doesn't
return one.
Diffstat (limited to 'Lib')
-rw-r--r-- | 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 index 20e5608..65c9f25 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -211,7 +211,9 @@ class ImportTests(unittest.TestCase): # 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) |