Given a unicode/str/bytes always return str.

    We prefer to work with the 'native' string type for the version of python
    we run on, and this gets us that.

def astext(data):
    """
    Given a unicode/str/bytes always return str.

    We prefer to work with the 'native' string type for the version of python
    we run on, and this gets us that.
    """
    if isinstance(data, str):
        return data
    elif isinstance(data, text_type):
        return data.encode("utf-8", "ignore")
    elif isinstance(data, binary_type):
        return data.decode("utf-8", "ignore")
    raise TypeError('{!r} not a string'.format(data))