def unpack(rv):
    """
    Convert rv to tuple(data, code, headers)

    Args:
        rv: data or tuple that contain code and headers
    Returns:
        tuple (rv, status, headers)
    """
    status = headers = None
    if isinstance(rv, tuple):
        rv, status, headers = rv + (None,) * (3 - len(rv))
    if isinstance(status, (dict, list)):
        headers, status = status, headers
    return (rv, status, headers)