]> granicus.if.org Git - python/commitdiff
Have pkgutil properly close files.
authorBrett Cannon <bcannon@gmail.com>
Fri, 29 Oct 2010 22:36:53 +0000 (22:36 +0000)
committerBrett Cannon <bcannon@gmail.com>
Fri, 29 Oct 2010 22:36:53 +0000 (22:36 +0000)
Lib/pkgutil.py

index 0ec6ec5265480c80043e03e5bc7c9176abc3776a..b48627565c474d0c7bdf769dc0f7c3b859a5fcc7 100644 (file)
@@ -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: