mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix crash in py3: 'TypeError: a bytes-like object is required, not 'str' (#37504)
* Fix crash in py3: 'TypeError: a bytes-like object is required, not 'str' Fixes #37387 * Review applied https://github.com/ansible/ansible/pull/37504#pullrequestreview-104799823
This commit is contained in:
parent
8c4f349743
commit
b7aa41b9b9
1 changed files with 2 additions and 1 deletions
|
@ -141,6 +141,7 @@ import re
|
|||
import tempfile
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_bytes
|
||||
|
||||
|
||||
def lineDict(line):
|
||||
|
@ -321,7 +322,7 @@ def write_changes(module, lines, dest):
|
|||
|
||||
tmpfd, tmpfile = tempfile.mkstemp()
|
||||
f = os.fdopen(tmpfd, 'wb')
|
||||
f.writelines(lines)
|
||||
f.writelines(to_bytes(lines, errors='surrogate_or_strict'))
|
||||
f.close()
|
||||
module.atomic_move(tmpfile, os.path.realpath(dest))
|
||||
|
||||
|
|
Loading…
Reference in a new issue