From: Brett Cannon Date: Fri, 29 Oct 2010 22:36:53 +0000 (+0000) Subject: Have pkgutil properly close files. X-Git-Tag: v3.2a4~284 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1ab58dfb12dedb7d8a92c8cc222a35bc844e8326;p=python Have pkgutil properly close files. --- diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index 0ec6ec5265..b48627565c 100644 --- a/Lib/pkgutil.py +++ b/Lib/pkgutil.py @@ -241,7 +241,8 @@ class ImpLoader: return mod def get_data(self, pathname): - return open(pathname, "rb").read() + with open(pathname, "rb") as file: + return file.read() def _reopen(self): if self.file and self.file.closed: