From d7c6cf10c220564cda5722fedd0e77f67ec40e58 Mon Sep 17 00:00:00 2001 From: Antti Salminen Date: Thu, 4 Jul 2013 23:16:38 +0300 Subject: [PATCH] Use .encode() instead of str() to support unicode arguments. str() throws an UnicodeEncodeError for code points that cannot be represented in 7-bit ASCII. This makes it impossible to use any non-ASCII characters in module arguments. Using encode('utf-8') gives the desired result. --- lib/ansible/runner/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index e1d8cc8c2a..d163a44513 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -729,7 +729,7 @@ class Runner(object): complex_args_json = utils.jsonify(complex_args) # We force conversion of module_args to str because module_common calls shlex.split, # a standard library function that incorrectly handles Unicode input before Python 2.7.3. - encoded_args = repr(str(module_args)) + encoded_args = repr(module_args.encode('utf-8')) encoded_lang = repr(C.DEFAULT_MODULE_LANG) encoded_complex = repr(complex_args_json)