From 7b5d2d3bec32f00ef0176f976b5f8fd6f0fb98bc Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Tue, 19 Apr 2016 09:37:17 -0700 Subject: [PATCH] Make sure that args are interpreted as utf8 on python3 --- lib/ansible/module_utils/basic.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/module_utils/basic.py b/lib/ansible/module_utils/basic.py index 60f38708748..c27fa416218 100644 --- a/lib/ansible/module_utils/basic.py +++ b/lib/ansible/module_utils/basic.py @@ -1438,6 +1438,7 @@ class AnsibleModule(object): # debug overrides to read args from file or cmdline # Avoid tracebacks when locale is non-utf8 + # We control the args and we pass them as utf8 if len(sys.argv) > 1: if os.path.isfile(sys.argv[1]): fd = open(sys.argv[1], 'rb') @@ -1445,6 +1446,8 @@ class AnsibleModule(object): fd.close() else: buffer = sys.argv[1] + if sys.version_info >= (3,): + buffer = buffer.encode('utf-8', errors='surrogateescape') # default case, read from stdin else: if sys.version_info < (3,):