Issue #20331: Fixed possible FD leaks in various modules:

http.server, imghdr, mailcap, mimetypes, xml.etree.
This commit is contained in:
Serhiy Storchaka 2014-01-25 19:43:56 +02:00
commit c0b0bb6e01
5 changed files with 34 additions and 30 deletions

View file

@ -22,8 +22,8 @@ def getcaps():
fp = open(mailcap, 'r')
except OSError:
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