From 91b0bc237c07b52c771e121098989680cfc3600d Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sat, 25 Jan 2014 19:43:02 +0200 Subject: Issue #20331: Fixed possible FD leaks in various modules: http.server, imghdr, mailcap, mimetypes, xml.etree. --- Lib/mailcap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Lib/mailcap.py') diff --git a/Lib/mailcap.py b/Lib/mailcap.py index 99f4958bf7..0c0b19c47c 100644 --- a/Lib/mailcap.py +++ b/Lib/mailcap.py @@ -22,8 +22,8 @@ def getcaps(): fp = open(mailcap, 'r') except IOError: continue - morecaps = readmailcapfile(fp) - fp.close() + with fp: + morecaps = readmailcapfile(fp) for key, value in morecaps.items(): if not key in caps: caps[key] = value -- cgit v1.2.1