Commit 848cdfdf authored by Brett Cannon's avatar Brett Cannon

Issue #15828: Don't try to close a file if imp.find_module() doesn't

return one.
parent 91b9f139
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment