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

* 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>
(cherry picked from commit cc293f90a2)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot] 2021-05-22 22:42:02 +02:00 committed by GitHub
parent 3a076fd585
commit c12be67a69
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: