def _append_object_entry(obj, list_name, entry):
    """
    Appends the given entry in the given object list.
    Creates the list field if needed.

    :param obj: The object that contains the list
    :param list_name: The name of the list member in *obj*
    :param entry: The entry to be added to the list
    :raise ValueError: Invalid attribute content
    """
    obj_list = getattr(obj, list_name, None)
    if obj_list is None:
        obj_list = []
        setattr(obj, list_name, obj_list)
    assert isinstance(obj_list, list)
    if entry not in obj_list:
        obj_list.append(entry)
