mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Explicitly close some files (from issue #10093)
This commit is contained in:
parent
d9f57630fe
commit
b86680e299
6 changed files with 31 additions and 14 deletions
|
@ -199,9 +199,8 @@ class MimeTypes:
|
|||
list of standard types, else to the list of non-standard
|
||||
types.
|
||||
"""
|
||||
fp = open(filename)
|
||||
self.readfp(fp, strict)
|
||||
fp.close()
|
||||
with open(filename) as fp:
|
||||
self.readfp(fp, strict)
|
||||
|
||||
def readfp(self, fp, strict=True):
|
||||
"""
|
||||
|
@ -348,7 +347,7 @@ def init(files=None):
|
|||
files = knownfiles
|
||||
for file in files:
|
||||
if os.path.isfile(file):
|
||||
db.readfp(open(file))
|
||||
db.read(file)
|
||||
encodings_map = db.encodings_map
|
||||
suffix_map = db.suffix_map
|
||||
types_map = db.types_map[True]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue