mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make sure that args are interpreted as utf8 on python3
This commit is contained in:
parent
197d3dfe97
commit
7b5d2d3bec
1 changed files with 3 additions and 0 deletions
|
@ -1438,6 +1438,7 @@ class AnsibleModule(object):
|
||||||
# debug overrides to read args from file or cmdline
|
# debug overrides to read args from file or cmdline
|
||||||
|
|
||||||
# Avoid tracebacks when locale is non-utf8
|
# Avoid tracebacks when locale is non-utf8
|
||||||
|
# We control the args and we pass them as utf8
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
if os.path.isfile(sys.argv[1]):
|
if os.path.isfile(sys.argv[1]):
|
||||||
fd = open(sys.argv[1], 'rb')
|
fd = open(sys.argv[1], 'rb')
|
||||||
|
@ -1445,6 +1446,8 @@ class AnsibleModule(object):
|
||||||
fd.close()
|
fd.close()
|
||||||
else:
|
else:
|
||||||
buffer = sys.argv[1]
|
buffer = sys.argv[1]
|
||||||
|
if sys.version_info >= (3,):
|
||||||
|
buffer = buffer.encode('utf-8', errors='surrogateescape')
|
||||||
# default case, read from stdin
|
# default case, read from stdin
|
||||||
else:
|
else:
|
||||||
if sys.version_info < (3,):
|
if sys.version_info < (3,):
|
||||||
|
|
Loading…
Reference in a new issue