From fbc525cfb66563eedc2755e363c28206a5dc6e7d Mon Sep 17 00:00:00 2001
From: Toshio Kuratomi <toshio@fedoraproject.org>
Date: Wed, 4 Mar 2015 11:05:46 -0800
Subject: [PATCH] Use to_bytes instead of .encode().  Fixes the fact that
 errors is a positional argument, not a kw arg in .encode()

---
 lib/ansible/callbacks.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/ansible/callbacks.py b/lib/ansible/callbacks.py
index 6a15c1844e5..39d3a8d4428 100644
--- a/lib/ansible/callbacks.py
+++ b/lib/ansible/callbacks.py
@@ -28,7 +28,7 @@ import constants
 import locale
 from ansible.color import stringc
 from ansible.module_utils import basic
-from ansible.utils.unicode import to_unicode
+from ansible.utils.unicode import to_unicode, to_bytes
 
 import logging
 if constants.DEFAULT_LOG_PATH != '':
@@ -634,9 +634,9 @@ class PlaybookCallbacks(object):
                 name = utils.unicode.to_unicode(name)
             msg = u'Perform task: %s (y/n/c): ' % name
             if sys.stdout.encoding:
-                msg = msg.encode(sys.stdout.encoding, errors='replace')
+                msg = to_bytes(msg, sys.stdout.encoding)
             else:
-                msg = msg.encode('utf-8')
+                msg = to_bytes(msg)
             resp = raw_input(msg)
             if resp.lower() in ['y','yes']:
                 self.skip_task = False