mirror of
https://github.com/python/cpython.git
synced 2025-08-04 17:08:35 +00:00
Issue #22831: Use "with" to avoid possible fd leaks.
This commit is contained in:
parent
ae2d667ae8
commit
46ba6c8563
10 changed files with 107 additions and 120 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue