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

Code before:
        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 (strcmp(ufunc->name, "maximum") == 0 || strcmp(ufunc->name, "minimum") == 0) {
            const char *which = ufunc->name; // "maximum" or "minimum"
            char msg[256];
            snprintf(msg, sizeof(msg),
                "Passing more than 2 positional arguments to np.%s "
                "is deprecated; use out=keyword or np.%s.reduce.",
                which, which);
            
            if (DEPRECATE(msg) < 0 && PyErr_Occurred()) {
                return NULL;
            }
        }
        
        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;

Review comment (suggestion):
FWIW, I actually liked the old version of using the object, but maybe it doesn't matter on this path anyway.

Please don't use `snprintf`, `DEPRECATE` is a useful macro, but you don't need to use it, you can use `PyWarn_Format` (or whatever it was).

Code after:
        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;
    }

    /*
     * 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;