mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-06-03 14:59:09 -07:00
Close all open filehandle (#50544)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
94a1d86d70
commit
db8702cdb8
21 changed files with 81 additions and 47 deletions
|
@ -79,7 +79,9 @@ def main():
|
|||
if not os.access(source, os.R_OK):
|
||||
module.fail_json(msg="file is not readable: %s" % source)
|
||||
|
||||
data = base64.b64encode(open(source, 'rb').read())
|
||||
with open(source, 'rb') as source_fh:
|
||||
source_content = source_fh.read()
|
||||
data = base64.b64encode(source_content)
|
||||
|
||||
module.exit_json(content=data, source=source, encoding='base64')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue