Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e048797

Browse files
committed
close open file from find_module()
1 parent 1c87e29 commit e048797

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

Lib/test/test_import.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ def test_imp_module(self):
128128
orig_getenv = os.getenv
129129
with EnvironmentVarGuard():
130130
x = imp.find_module("os")
131+
self.addCleanup(x[0].close)
131132
new_os = imp.load_module("os", *x)
132133
self.assertIs(os, new_os)
133134
self.assertIs(orig_path, new_os.path)

0 commit comments

Comments
 (0)