Skip to content

A mishandling of the Python/C API exception? #16774

Description

@Elaphurus

Exceptions threw using the Python/C API like PyErr_SetString should be followed by a return statement, NumPy follows this almost everywhere, but is the following one I found a carelessness?
(numpy/numpy/core/src/multiarray/methods.c#L736)

if (n == 0) {
    if (PyArray_SIZE(self) == 1) {
        for (idim = 0; idim < ndim; ++idim) {
            multi_index[idim] = 0;
        }
    }
    else {
        PyErr_SetString(PyExc_ValueError,
                "can only convert an array of size 1 to a Python scalar");
        // should have a `return NULL;` here?
    }
}

If this is a wrong issue for my limited understanding, please give me some hints, I will appreciate that.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions