Python 3 compliance: ensure two strings are the same type (unicode or binary)

def _sync_string_to(bin_or_str, string):
    """ Python 3 compliance: ensure two strings are the same type (unicode or binary) """

    if isinstance(string, type(bin_or_str)):
        return string
    elif isinstance(string, binary_type):
        return string.decode(DEFAULT_ENCODING)
    else:
        return string.encode(DEFAULT_ENCODING)