# Buggy code
def stop_criteria(
    state,
    x,
    last_iteration_failed,
    tr_radius,
    constr_penalty,
    cg_info,
    barrier_parameter,
    barrier_tolerance,
):
    state = update_state_ip(
        state,
        x,
        last_iteration_failed,
        objective,
        prepared_constraints,
        start_time,
        tr_radius,
        constr_penalty,
        cg_info,
        barrier_parameter,
        barrier_tolerance,
    )
    if verbose == 2:
        BasicReport.print_iteration(
            state.niter,
            state.nfev,
            state.cg_niter,
            state.fun,
            state.tr_radius,
            state.optimality,
            state.constr_violation,
        )
    elif verbose > 2:
        IPReport.print_iteration(
            state.niter,
            state.nfev,
            state.cg_niter,
            state.fun,
            state.tr_radius,
            state.optimality,
            state.constr_violation,
            state.constr_penalty,
            state.barrier_parameter,
            state.cg_stop_cond,
        )
    state.status = None
    if callback is not None and callback(np.copy(state.x), state):
        state.status = 3
    elif state.optimality < gtol and state.constr_violation < gtol:
        state.status = 1
    elif state.tr_radius < xtol and state.barrier_parameter < barrier_tol:
        state.status = 2
    elif state.niter > maxiter:
        state.status = 0
    return state.status in (0, 1, 2, 3)


# Traceback (AttributeError)
['cg_niter', 'cg_stop_cond', 'constr', 'constr_nfev', 'constr_nhev',
'constr_njev', 'constr_penalty', 'constr_violation', 'execution_time',
'fun', 'grad', 'jac', 'lagrangian_grad', 'message', 'method', 'nfev',
'nhev', 'niter', 'njev', 'optimality', 'status', 'tr_radius', 'v', 'x']
Traceback (most recent call last):
File "<ipython-input-13-492cf8a99d03>", line 3, in <module>
assert sol.success
File "/home/pauli/.local/lib/python3.6/site-packages/scipy/optimize/optimize.py", line 116, in __getattr__
raise AttributeError(name)
AttributeError: success

# Fixed code
def stop_criteria(
    state,
    x,
    last_iteration_failed,
    tr_radius,
    constr_penalty,
    cg_info,
    barrier_parameter,
    barrier_tolerance,
):
    state = update_state_ip(
        state,
        x,
        last_iteration_failed,
        objective,
        prepared_constraints,
        start_time,
        tr_radius,
        constr_penalty,
        cg_info,
        barrier_parameter,
        barrier_tolerance,
    )
    if verbose == 2:
        BasicReport.print_iteration(
            state.nit,
            state.nfev,
            state.cg_niter,
            state.fun,
            state.tr_radius,
            state.optimality,
            state.constr_violation,
        )
    elif verbose > 2:
        IPReport.print_iteration(
            state.nit,
            state.nfev,
            state.cg_niter,
            state.fun,
            state.tr_radius,
            state.optimality,
            state.constr_violation,
            state.constr_penalty,
            state.barrier_parameter,
            state.cg_stop_cond,
        )
    state.status = None
    if callback is not None and callback(np.copy(state.x), state):
        state.status = 3
    elif state.optimality < gtol and state.constr_violation < gtol:
        state.status = 1
    elif state.tr_radius < xtol and state.barrier_parameter < barrier_tol:
        state.status = 2
    elif state.nit > maxiter:
        state.status = 0
    return state.status in (0, 1, 2, 3)