summaryrefslogtreecommitdiffstats
path: root/Lib/mimetypes.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-01-25 17:43:56 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-01-25 17:43:56 (GMT)
commitc0b0bb6e01f7ea6a1a857609e794842223c4aa5c (patch)
tree23a00341a5a15f7af05ecd0549eb729dd906788a /Lib/mimetypes.py
parenta3642b67ca2656ec6d5c10a52bbb643462236ded (diff)
parent91b0bc237c07b52c771e121098989680cfc3600d (diff)
downloadcpython-c0b0bb6e01f7ea6a1a857609e794842223c4aa5c.zip
cpython-c0b0bb6e01f7ea6a1a857609e794842223c4aa5c.tar.gz
cpython-c0b0bb6e01f7ea6a1a857609e794842223c4aa5c.tar.bz2
Issue #20331: Fixed possible FD leaks in various modules:
http.server, imghdr, mailcap, mimetypes, xml.etree.
Diffstat (limited to 'Lib/mimetypes.py')
-rw-r--r--Lib/mimetypes.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py
index d7161f8..b98c874 100644
--- a/Lib/mimetypes.py
+++ b/Lib/mimetypes.py
@@ -363,9 +363,10 @@ def read_mime_types(file):
f = open(file)
except OSError:
return None
- db = MimeTypes()
- db.readfp(f, True)
- return db.types_map[True]
+ with f:
+ db = MimeTypes()
+ db.readfp(f, True)
+ return db.types_map[True]
def _default_mime_types():