Skip to content

Replace calls to _report_generic_error with a more useful error message. #15316

@eric-wieser

Description

@eric-wieser

Right now, many failures of np.dtype(obj) go to this path:

/*
* Generate a vague error message when a function returned NULL but forgot
* to set an exception. We should aim to remove this eventually.
*/
static void
_report_generic_error(void) {
PyErr_SetString(PyExc_TypeError, "data type not understood");
}

For example

if (!PyTuple_Check(item) || (PyTuple_GET_SIZE(item) < 2)) {
_report_generic_error();
goto fail;
}

We should replace some or all of these calls in this file with more helpful error messages, such as in the above case:

-_report_generic_error();
+PyErr_Format(PyExc_TypeError, "Field elements must be 2-tuples, got %R", item);

If we replace all of them, then we should remove the _report_generic_error function entirely

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions