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 @@ def load_module(self, fullname): 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: