Fix ResourceWarning when reading a Python config module (#1889)

The raw open call in execfile_() did not close the file handle.
This commit is contained in:
Ryan Lopopolo 2018-10-01 23:53:26 -07:00 committed by Berker Peksag
parent df8290d153
commit eae3ef05f3

View File

@ -60,7 +60,6 @@ def execfile_(fname, *args):
if fname.endswith(".pyc"):
code = _get_codeobj(fname)
else:
code = compile(open(fname, 'rb').read(), fname, 'exec')
with open(fname, 'rb') as file:
code = compile(file.read(), fname, 'exec')
return exec(code, *args)