Comment 5 for bug 686735

Revision history for this message
Martin Packman (gz) wrote : Re: bzr crashed with UnicodeDecodeError in run_subprocess_command()

This is a problem from the changes in r1234 (really), which blindly calls unicode() on all non-private attributes of an exception instance. If an exception has a non-ascii bytestring in its arguments, this exception will occur. Other objects that can't be stringified are also a potential issue.

The code is currently:

    try:
        return commands.run_bzr(argv)
    except Exception, e:
        d = {}
        for key, val in e.__dict__.iteritems():
            if not key.startswith('_'):
                if not isinstance(val, unicode):
                    val = unicode(val)
                d[key] = val
        print "%s%s" % (SUB_ERROR,
                        bencode.bencode((e.__class__.__name__,
                                         encode_unicode_escape(d))))
        raise

Adding more try/catch is an option, or being more careful about accessing the exception instance.