From 1ab58dfb12dedb7d8a92c8cc222a35bc844e8326 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Fri, 29 Oct 2010 22:36:53 +0000 Subject: [PATCH] Have pkgutil properly close files. --- Lib/pkgutil.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Lib/pkgutil.py b/Lib/pkgutil.py index 0ec6ec52654..b48627565c4 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: