Repository: numpy/numpy
File: numpy/_core/src/multiarray/getset.c (C)

Code before:
        PyArray_ITER_NEXT(selfit);
        PyArray_ITER_NEXT(arrit);
        if (arrit->index == arrit->size) {
            PyArray_ITER_RESET(arrit);
        }
    }
    retval = 0;

 exit:
    Py_XDECREF(selfit);
    Py_XDECREF(arrit);
    Py_XDECREF(arr);
    return retval;
}

static PyObject *
array_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
    int ndim = PyArray_NDIM(self);
    if (ndim != 2) {
        /* Deprecated 2025-04-19, NumPy 2.3 */
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "In the future `.T` property will be supported for "
                "2-dim arrays only. Received %d-dim array. Either "
                "`arr.transpose()` or `.mT` (which swaps the last "
                "two axes only) should be used instead."
                "(Deprecated NumPy 2.3)", ndim) < 0) {
            return NULL;
        }
    }
    return PyArray_Transpose(self, NULL);
}

static PyObject *
array_matrix_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
    return PyArray_MatrixTranspose(self);
}

static PyObject *
array_ptp(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
    PyErr_SetString(PyExc_AttributeError,
                    "`ptp` was removed from the ndarray class in NumPy 2.0. "
                    "Use np.ptp(arr, ...) instead.");
    return NULL;
}

static PyObject *
array_newbyteorder(PyArrayObject *self, PyObject *args)
{

Review comment (suggestion):
```suggestion
                "In the future, the `.T` property will be supported for "
                "2-dimensional arrays only. Received %d-dimensional "
                "array. Either `arr.transpose()` or `.mT` (which swaps "
                "the last two axes only) should be used instead."
```

Code after:
        PyArray_ITER_NEXT(selfit);
        PyArray_ITER_NEXT(arrit);
        if (arrit->index == arrit->size) {
            PyArray_ITER_RESET(arrit);
        }
    }
    retval = 0;

 exit:
    Py_XDECREF(selfit);
    Py_XDECREF(arrit);
    Py_XDECREF(arr);
    return retval;
}

static PyObject *
array_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
    int ndim = PyArray_NDIM(self);
    if (ndim != 2) {
        /* Deprecated 2025-04-19, NumPy 2.3 */
        if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
                "In the future, the `.T` property will be supported for "
                "2-dimensional arrays only. Received %d-dimensional "
                "array. Either `arr.transpose()` or `.mT` (which swaps "
                "the last two axes only) should be used instead."
                "(Deprecated NumPy 2.3)", ndim) < 0) {
            return NULL;
        }
    }
    return PyArray_Transpose(self, NULL);
}

static PyObject *
array_matrix_transpose_get(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
    return PyArray_MatrixTranspose(self);
}

static PyObject *
array_ptp(PyArrayObject *self, void *NPY_UNUSED(ignored))
{
    PyErr_SetString(PyExc_AttributeError,
                    "`ptp` was removed from the ndarray class in NumPy 2.0. "
                    "Use np.ptp(arr, ...) instead.");
    return NULL;
}

static PyObject *
array_newbyteorder(PyArrayObject *self, PyObject *args)
{