Issue #22831: Use "with" to avoid possible fd leaks.

This commit is contained in:
Serhiy Storchaka 2015-04-04 11:01:02 +03:00
parent ae2d667ae8
commit 46ba6c8563
10 changed files with 107 additions and 120 deletions

View file

@ -153,9 +153,9 @@ def whichdb(filename):
except OSError:
return None
# Read the start of the file -- the magic number
s16 = f.read(16)
f.close()
with f:
# Read the start of the file -- the magic number
s16 = f.read(16)
s = s16[0:4]
# Return "" if not at least 4 bytes