mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 21:32:49 +00:00
use open() as context manager (#9579)
* use open() as context manager * add changelog frag
This commit is contained in:
@@ -146,9 +146,8 @@ class CronVar(object):
|
||||
if self.cron_file:
|
||||
# read the cronfile
|
||||
try:
|
||||
f = open(self.cron_file, 'r')
|
||||
self.lines = f.read().splitlines()
|
||||
f.close()
|
||||
with open(self.cron_file, 'r') as f:
|
||||
self.lines = f.read().splitlines()
|
||||
except IOError:
|
||||
# cron file does not exist
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user