From 4463ced8ba706f22cebbc7d1316ebf841151200c Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 8 Oct 2015 10:14:26 -0400 Subject: [PATCH] simpler safe output --- lib/ansible/utils/display.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index fb4b5321a98..63f5fc4c53b 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -236,12 +236,13 @@ class Display: def _safe_output(self, msg, stderr=False): + encoding='utf-8' if not stderr and sys.stdout.encoding: - msg = to_bytes(msg, sys.stdout.encoding) + encoding = sys.stdout.encoding elif stderr and sys.stderr.encoding: - msg = to_bytes(msg, sys.stderr.encoding) - else: - msg = to_bytes(msg) + encoding = sys.stderr.encoding + + msg = to_bytes(msg, encoding) return msg