ini_file - opening file as utf-8-sig (#2578)

* opening file as utf-8-sig

* added changelog fragment

* using io.open()

* Update tests/integration/targets/ini_file/tasks/main.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2021-05-23 08:20:37 +12:00 committed by GitHub
parent d7e55db99b
commit cc293f90a2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 1 deletions

View file

@ -104,6 +104,7 @@ EXAMPLES = r'''
backup: yes
'''
import io
import os
import re
import tempfile
@ -141,7 +142,7 @@ def do_ini(module, filename, section=None, option=None, value=None,
os.makedirs(destpath)
ini_lines = []
else:
with open(filename, 'r') as ini_file:
with io.open(filename, 'r', encoding="utf-8-sig") as ini_file:
ini_lines = ini_file.readlines()
if module._diff: