# Buggy code
def display(self, ret, indent, prefix, out):
    """
    Recursively iterate down through data structures to determine output
    """
    if isinstance(ret, bytes):
        ret = salt.utils.stringutils.to_unicode(ret)

    if ret is None or ret is True or ret is False:
        out.append(self.ustring(indent, self.LIGHT_YELLOW, ret, prefix=prefix))
    # Number includes all python numbers types
    #  (float, int, long, complex, ...)
    elif isinstance(ret, Number):
        out.append(self.ustring(indent, self.LIGHT_YELLOW, ret, prefix=prefix))
    elif isinstance(ret, six.string_types):
        first_line = True
        for line in ret.splitlines():
            if self.strip_colors:
                line = salt.output.strip_esc_sequence(line)
            line_prefix = " " * len(prefix) if not first_line else prefix
            out.append(self.ustring(indent, self.GREEN, line, prefix=line_prefix))
            first_line = False
    elif isinstance(ret, (list, tuple)):
        color = self.GREEN
        if self.retcode != 0:
            color = self.RED
        for ind in ret:
            if isinstance(ind, (list, tuple, dict)):
                out.append(self.ustring(indent, color, "|_"))
                prefix = "" if isinstance(ind, dict) else "- "
                self.display(ind, indent + 2, prefix, out)
            else:
                self.display(ind, indent, "- ", out)
    elif isinstance(ret, dict):
        if indent:
            color = self.CYAN
            if self.retcode != 0:
                color = self.RED
            out.append(self.ustring(indent, color, "----------"))

        # respect key ordering of ordered dicts
        if isinstance(ret, salt.utils.odict.OrderedDict):
            keys = ret.keys()
        else:
            keys = sorted(ret)
        color = self.CYAN
        if self.retcode != 0:
            color = self.RED
        for key in keys:
            val = ret[key]
            out.append(self.ustring(indent, color, key, suffix=":", prefix=prefix))
            self.display(val, indent + 4, "", out)
    return out


# Traceback (UnicodeDecodeError)
Traceback (most recent call last):
File "/usr/local/bin/salt", line 6, in <module>
exec(compile(open(__file__).read(), __file__, 'exec'))
File "/root/salt/scripts/salt", line 10, in <module>
salt_main()
File "/root/salt/salt/scripts.py", line 480, in salt_main
client.run()
File "/root/salt/salt/cli/salt.py", line 195, in run
self._output_ret(ret_, out, retcode=retcode)
File "/root/salt/salt/cli/salt.py", line 374, in _output_ret
_retcode=retcode)
File "/root/salt/salt/output/__init__.py", line 94, in display_output
display_data = try_printout(data, out, opts, **kwargs)
File "/root/salt/salt/output/__init__.py", line 41, in try_printout
printout = get_printout(out, opts)(data, **kwargs)
File "/root/salt/salt/output/highstate.py", line 146, in output
for host, hostdata in six.iteritems(data)
File "/root/salt/salt/output/highstate.py", line 225, in _format_host
schanged, ctext = _format_changes(ret['changes'], orchestration)
File "/root/salt/salt/output/highstate.py", line 516, in _format_changes
ctext = _nested_changes(changes)
File "/root/salt/salt/output/highstate.py", line 489, in _nested_changes
nested_indent=14)
File "/root/salt/salt/output/__init__.py", line 203, in out_format
return try_printout(data, out, opts, **kwargs)
File "/root/salt/salt/output/__init__.py", line 41, in try_printout
printout = get_printout(out, opts)(data, **kwargs)
File "/root/salt/salt/output/nested.py", line 186, in output
return '\n'.join(nest.display(ret, base_indent, '', []))
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 173, in display
self.display(val, indent + 4, '', out)
File "/root/salt/salt/output/nested.py", line 87, in display
ret = salt.utils.stringutils.to_unicode(ret)
File "/root/salt/salt/utils/stringutils.py", line 110, in to_unicode
return s.decode('utf-8', errors)
File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 13-14: invalid continuation byte

# Fixed code
def display(self, ret, indent, prefix, out):
    """
    Recursively iterate down through data structures to determine output
    """
    if isinstance(ret, bytes):
        try:
            ret = salt.utils.stringutils.to_unicode(ret)
        except UnicodeDecodeError:
            # ret contains binary data that can't be decoded
            pass

    if ret is None or ret is True or ret is False:
        out.append(self.ustring(indent, self.LIGHT_YELLOW, ret, prefix=prefix))
    # Number includes all python numbers types
    #  (float, int, long, complex, ...)
    elif isinstance(ret, Number):
        out.append(self.ustring(indent, self.LIGHT_YELLOW, ret, prefix=prefix))
    elif isinstance(ret, six.string_types):
        first_line = True
        for line in ret.splitlines():
            if self.strip_colors:
                line = salt.output.strip_esc_sequence(line)
            line_prefix = " " * len(prefix) if not first_line else prefix
            out.append(self.ustring(indent, self.GREEN, line, prefix=line_prefix))
            first_line = False
    elif isinstance(ret, (list, tuple)):
        color = self.GREEN
        if self.retcode != 0:
            color = self.RED
        for ind in ret:
            if isinstance(ind, (list, tuple, dict)):
                out.append(self.ustring(indent, color, "|_"))
                prefix = "" if isinstance(ind, dict) else "- "
                self.display(ind, indent + 2, prefix, out)
            else:
                self.display(ind, indent, "- ", out)
    elif isinstance(ret, dict):
        if indent:
            color = self.CYAN
            if self.retcode != 0:
                color = self.RED
            out.append(self.ustring(indent, color, "----------"))

        # respect key ordering of ordered dicts
        if isinstance(ret, salt.utils.odict.OrderedDict):
            keys = ret.keys()
        else:
            keys = sorted(ret)
        color = self.CYAN
        if self.retcode != 0:
            color = self.RED
        for key in keys:
            val = ret[key]
            out.append(self.ustring(indent, color, key, suffix=":", prefix=prefix))
            self.display(val, indent + 4, "", out)
    return out