From d1e0719e4cd16fdd9d85dcf59a5c5c3741fa6583 Mon Sep 17 00:00:00 2001 From: qqo Date: Wed, 16 Mar 2016 23:47:16 +0300 Subject: [PATCH 1/3] fix TypeError: coercing to Unicode: need string or buffer, AnsibleParserError found --- lib/ansible/utils/display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index e94c8f0397..220bbd381d 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -108,7 +108,7 @@ class Display: """ Display a message to the user Note: msg *must* be a unicode string to prevent UnicodeError tracebacks. - """ + """ # FIXME: this needs to be implemented #msg = utils.sanitize_output(msg) @@ -273,7 +273,7 @@ class Display: wrapped = textwrap.wrap(new_msg, self.columns) new_msg = u"\n".join(wrapped) + u"\n" else: - new_msg = u"ERROR! " + msg + new_msg = u"ERROR! %s" % msg if new_msg not in self._errors: self.display(new_msg, color=C.COLOR_ERROR, stderr=True) self._errors[new_msg] = 1 From 85e843baeeeb2f88dd17c7c987dcdbb992b29553 Mon Sep 17 00:00:00 2001 From: qqo Date: Thu, 17 Mar 2016 00:50:47 +0300 Subject: [PATCH 2/3] Revert "fix TypeError: coercing to Unicode: need string or buffer, AnsibleParserError found" This reverts commit d1e0719e4cd16fdd9d85dcf59a5c5c3741fa6583. --- lib/ansible/utils/display.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/ansible/utils/display.py b/lib/ansible/utils/display.py index 220bbd381d..e94c8f0397 100644 --- a/lib/ansible/utils/display.py +++ b/lib/ansible/utils/display.py @@ -108,7 +108,7 @@ class Display: """ Display a message to the user Note: msg *must* be a unicode string to prevent UnicodeError tracebacks. - """ + """ # FIXME: this needs to be implemented #msg = utils.sanitize_output(msg) @@ -273,7 +273,7 @@ class Display: wrapped = textwrap.wrap(new_msg, self.columns) new_msg = u"\n".join(wrapped) + u"\n" else: - new_msg = u"ERROR! %s" % msg + new_msg = u"ERROR! " + msg if new_msg not in self._errors: self.display(new_msg, color=C.COLOR_ERROR, stderr=True) self._errors[new_msg] = 1 From a7f89cac63d22c2b33f7ce7c6f0846c47e77d8a8 Mon Sep 17 00:00:00 2001 From: qqo Date: Thu, 17 Mar 2016 00:56:47 +0300 Subject: [PATCH 3/3] fix TypeError: coercing to Unicode: need string or buffer, AnsibleParserError found --- lib/ansible/plugins/strategy/linear.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/plugins/strategy/linear.py b/lib/ansible/plugins/strategy/linear.py index 0d4faf6149..750f154051 100644 --- a/lib/ansible/plugins/strategy/linear.py +++ b/lib/ansible/plugins/strategy/linear.py @@ -29,6 +29,7 @@ from ansible.playbook.task import Task from ansible.plugins import action_loader from ansible.plugins.strategy import StrategyBase from ansible.template import Templar +from ansible.utils.unicode import to_unicode try: from __main__ import display @@ -330,7 +331,7 @@ class StrategyModule(StrategyBase): for host in included_file._hosts: self._tqm._failed_hosts[host.name] = True iterator.mark_host_failed(host) - display.error(e, wrap_text=False) + display.error(to_unicode(e), wrap_text=False) include_failure = True continue