diff --git a/Lib/test/test_imp.py b/Lib/test/test_imp.py index f46a1f5863f..7b85948e94d 100644 --- a/Lib/test/test_imp.py +++ b/Lib/test/test_imp.py @@ -267,7 +267,8 @@ def test_load_module_extension_file_is_None(self): # Issue #15902 name = '_testimportmultiple' found = imp.find_module(name) - found[0].close() + if found[0] is not None: + found[0].close() if found[2][2] != imp.C_EXTENSION: return imp.load_module(name, None, *found[1:])