Commit 35321ec6 by Toshio Kuratomi

ansible.utils to_unicode/to_bytes isn't robust in the face of

non-strings.  Do some value checking in the calling code
parent 418e24cc
...@@ -27,6 +27,7 @@ import fcntl ...@@ -27,6 +27,7 @@ import fcntl
import constants import constants
import locale import locale
from ansible.color import stringc from ansible.color import stringc
from ansible.module_utils import basic
import logging import logging
if constants.DEFAULT_LOG_PATH != '': if constants.DEFAULT_LOG_PATH != '':
...@@ -456,8 +457,12 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks): ...@@ -456,8 +457,12 @@ class PlaybookRunnerCallbacks(DefaultRunnerCallbacks):
item = None item = None
if type(results) == dict: if type(results) == dict:
item = results.get('item', None) item = results.get('item', None)
if isinstance(item, unicode):
item = utils.to_bytes(item)
results = basic.json_dict_unicode_to_bytes(results)
else:
results = utils.to_bytes(results)
host = utils.to_bytes(host) host = utils.to_bytes(host)
results = utils.to_bytes(results)
if item: if item:
msg = "fatal: [%s] => (item=%s) => %s" % (host, item, results) msg = "fatal: [%s] => (item=%s) => %s" % (host, item, results)
else: else:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment