use open() as context manager (#9579)

* use open() as context manager

* add changelog frag
This commit is contained in:
Alexei Znamensky 2025-01-22 08:50:44 +13:00 committed by GitHub
parent c5cc949492
commit 0de39a6f47
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 72 additions and 102 deletions

View file

@ -103,13 +103,11 @@ def not_in_host_file(self, host):
continue
try:
host_fh = open(hf)
with open(hf) as host_fh:
data = host_fh.read()
except IOError:
hfiles_not_found += 1
continue
else:
data = host_fh.read()
host_fh.close()
for line in data.split("\n"):
if line is None or " " not in line: