From 2adc3354816c9c52c4d8e60fee1acb95b7a56d45 Mon Sep 17 00:00:00 2001 From: Les Aker Date: Sun, 19 May 2013 11:57:08 -0400 Subject: [PATCH 1/2] ignore unicode errors in stdout --- lib/ansible/utils/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 8448eb09c06..8beb8ff1d6b 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -127,6 +127,9 @@ def jsonify(result, format=False): if result is None: return "{}" result2 = result.copy() + for key, value in result2.items(): + if type(value) is str: + result2[key] = value.decode('utf-8', 'ignore') if format: return json.dumps(result2, sort_keys=True, indent=4) else: From 1179d1bbd8b1545fac2dad9e75c9789194a8ce09 Mon Sep 17 00:00:00 2001 From: Les Aker Date: Sun, 19 May 2013 12:25:19 -0400 Subject: [PATCH 2/2] corrected indentation --- lib/ansible/utils/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/__init__.py b/lib/ansible/utils/__init__.py index 8beb8ff1d6b..f3c1b470dab 100644 --- a/lib/ansible/utils/__init__.py +++ b/lib/ansible/utils/__init__.py @@ -128,8 +128,8 @@ def jsonify(result, format=False): return "{}" result2 = result.copy() for key, value in result2.items(): - if type(value) is str: - result2[key] = value.decode('utf-8', 'ignore') + if type(value) is str: + result2[key] = value.decode('utf-8', 'ignore') if format: return json.dumps(result2, sort_keys=True, indent=4) else: