From 6ba93817a947fe344881bbd86cb22bb3e6542700 Mon Sep 17 00:00:00 2001 From: Wanderlei Antonio Cavassin Date: Fri, 6 Dec 2013 12:59:43 -0200 Subject: [PATCH] Avoid UnicodeDecodeError exception when passing module args --- lib/ansible/module_common.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ansible/module_common.py b/lib/ansible/module_common.py index 3133ab26ba8..7beac36bee7 100644 --- a/lib/ansible/module_common.py +++ b/lib/ansible/module_common.py @@ -136,7 +136,10 @@ class ModuleReplacer(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(module_args.encode('utf-8')) + try: + encoded_args = repr(module_args.encode('utf-8')) + except UnicodeDecodeError: + encoded_args = repr(module_args) encoded_lang = repr(C.DEFAULT_MODULE_LANG) encoded_complex = repr(complex_args_json)