Skip to content

Commit

Permalink
simpler safe output
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoca committed Oct 8, 2015
1 parent de792ba commit 4463ced
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/ansible/utils/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,13 @@ def prompt(self, msg):

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

Expand Down

0 comments on commit 4463ced

Please sign in to comment.