8000 A mishandling of the Python/C API exception? · Issue #16774 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
A mishandling of the Python/C API exception? #16774
Closed
@Elaphurus

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.

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

      0