def compat(data):
    """
    Check data type, transform to string if needed.

    Args:
        data: The data.

    Returns:
        The data as a string, trimmed.
    """
    if not isinstance(data, str):
        data = data.decode()
    return data.rstrip()