Skip to content

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

Closed

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

Activity

  1. faizan2700 commented on Jan 16, 2020

    @faizan2700

    Hello I want to contribute to this issue but I am having one problem please help.
    After forking repo I have cloned it on my laptop and now from numpy directory I am trying to import numpy but it is giving error that I can't import numpy from there and exit from there and then import it. if I am in some other directory and the numpy directory path to sys.path and then import numpy it gives the same error. but if I have made some changes in source code and want to test the effect of it in interpreter or test numpy how do I do that when I can not import it?

    My question is when you make changes in numpy how do you import the source of numpy and check that ?

  2. eric-wieser commented on Jan 16, 2020

    @eric-wieser
    MemberAuthor

    how do you import the source of numpy and check that ?

    I (on windows) normally uses py -3.8 runtests.py -i, which opens an ipython shell with your in-development numpy

  3. hasansajedi commented on Jan 18, 2020

    @hasansajedi

    When this error occured?
    Can you leave here an input example?

  4. ericmariasis commented on Feb 1, 2020

    @ericmariasis
    Contributor

    I created a pull request for the enhancement.

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

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