Skip to content

Commit 1ab58df

Browse files
committed
Have pkgutil properly close files.
1 parent 5c035c0 commit 1ab58df

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

Lib/pkgutil.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,8 @@ def load_module(self, fullname):
241241
return mod
242242

243243
def get_data(self, pathname):
244-
return open(pathname, "rb").read()
244+
with open(pathname, "rb") as file:
245+
return file.read()
245246

246247
def _reopen(self):
247248
if self.file and self.file.closed:

0 commit comments

Comments
 (0)