Repository: numpy/numpy
File: numpy/_core/src/umath/ufunc_object.c (C)

Code before:
        full_args.out = PyTuple_New(nout);
        if (full_args.out == NULL) {
            goto fail;
        }
        for (int i = nin; i < nop; i++) {
            PyObject *tmp;
            if (i < (int)len_args) {
                tmp = args[i];
                if (tmp == Py_Ellipsis) {
                    PyErr_SetString(PyExc_TypeError,
                        "out=... is only allowed as a keyword argument.");
                    goto fail;
                }
                if (tmp != Py_None) {
                    all_none = NPY_FALSE;
                }
            }
            else {
                tmp = Py_None;
            }
            Py_INCREF(tmp);
            PyTuple_SET_ITEM(full_args.out, i-nin, tmp);
        }

        /* Extra positional args but *no* keywords */
        if ((ufunc == UFUNC_MAXIMUM || ufunc == UFUNC_MINIMUM) && !all_none) {
            /* DEPRECATED NumPy 2025-08-02 */
            if (ufunc == UFUNC_MAXIMUM) {
                DEPRECATE("Passing more than 2 positional arguments to np.maximum "
                        "is deprecated; use out=keyword or np.maximum.reduce.");
            }
            else if (ufunc == UFUNC_MINIMUM) {
                DEPRECATE("Passing more than 2 positional arguments to np.minimum "
                    "is deprecated; use out=keyword or np.minimum.reduce.");
            }
        }
        
        if (all_none) {
            Py_SETREF(full_args.out, NULL);
        }
    }
    else {
        full_args.out = NULL;
    }

    /*
     * We have now extracted (but not converted) the input arguments.
     * To simplify overrides, extract all other arguments (as objects only)
     */
    PyObject *out_obj = NULL, *where_obj = NULL;
    PyObject *axes_obj = NULL, *axis_obj = NULL;

Review comment (suggestion):
This is a bit tautological, you already have both `ufunc ==` checks just below.  TBH, I think it would be fine to just make one path though and don't care about the duplication.  (or use `ufunc->name`.)

Code after:
     * full_args.out is NULL for now, and the `out` kwarg may still be passed.
     */
    npy_bool out_is_passed_by_position = len_args > nin;
    if (out_is_passed_by_position) {
        npy_bool all_none = NPY_TRUE;

        full_args.out = PyTuple_New(nout);
        if (full_args.out == NULL) {
            goto fail;
        }
        for (int i = nin; i < nop; i++) {
            PyObject *tmp;
            if (i < (int)len_args) {
                tmp = args[i];
                if (tmp == Py_Ellipsis) {
                    PyErr_SetString(PyExc_TypeError,
                        "out=... is only allowed as a keyword argument.");
                    goto fail;
                }
                if (tmp != Py_None) {
                    all_none = NPY_FALSE;
                }
            }
            else {
                tmp = Py_None;
            }
            Py_INCREF(tmp);
            PyTuple_SET_ITEM(full_args.out, i-nin, tmp);
        }

        /* Extra positional args but no keywords */
        /* DEPRECATED NumPy 2.4, 2025-08 */
        if ((PyObject *)ufunc == n_ops.maximum || (PyObject *)ufunc == n_ops.minimum) {
            
            if (DEPRECATE(
                "Passing more than 2 positional arguments to np.maximum and np.minimum "
                "is deprecated. If you meant to use the third argument as an output, " 
                "use the `out` keyword argument instead. If you hoped to work with "
                "more than 2 inputs, combine them into a single array and get the extrema "
                "for the relevant axis.") < 0) {
                return NULL;
            }
        }
        
        if (all_none) {
            Py_SETREF(full_args.out, NULL);
        }
    }
    else {
        full_args.out = NULL;
    }