1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

simpler safe output

This commit is contained in:
Brian Coca 2015-10-08 10:14:26 -04:00
parent de792ba3c2
commit 4463ced8ba

View file

@ -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