Repository navigation
MAINT: Ensure that parsing errors are passed on even in tests. - #11173
Conversation
There was a problem hiding this comment.
Multiline comments like so:
/*
* blah
* blah
*/
cdac054 to
a72fb26
Compare
|
Can you change |
There was a problem hiding this comment.
Not sure this comment is necessary - any PyObject * allocation can fail due to memory limits, so we should always check results like this.
There was a problem hiding this comment.
Well, I'll maybe leave this as a breadcrump for the future - or to remind myself of hours waster...
There was a problem hiding this comment.
In multiarraymodule.c we use
#if defined(NPY_PY3K)
#define RETVAL(x) x
PyMODINIT_FUNC PyInit_multiarray(void) {
#else
#define RETVAL(x)
PyMODINIT_FUNC initmultiarray(void) {
#endif
would be nice to have a consistent macro here
There was a problem hiding this comment.
Wasn't aware of that - like it much better, so will change.
6aaed56 to
4a47c42
Compare
There was a problem hiding this comment.
Either:
- Testing
PyErr_Occurred()is pointless - There is a bug in
PyUFunc_FromFuncAndDataAndSignaturewhich fails to set an exception correctly
I'm assuming the former, meaning you can just call PyErr_Print() unconditionally
There was a problem hiding this comment.
Maybe I was being overly defensive here, but the docs for PyErr_Print are very specific that one should be sure an error is set otherwise bad things happen. Normally, of course, we'd just return NULL here and let downstream take care of it, but here we're setting a new error and I thought it was useful to at least print the old one.
But if you think this really doesn't make sense, I'll take it out (I had it out when I first added the return value).
There was a problem hiding this comment.
I suppose my point is that addUfuncs() < 0 is already our test to be sure that an error is set. If we returned -1 but forgot to set an error, that's a bug.
Also it seems that PyErr_Print is perfectly ok with there being no error anyway. So I'd say keep the PyErr_Print(), but drop the condition guarding it.
There was a problem hiding this comment.
So much for trusting the documentation... OK, condition dropped.
There was a problem hiding this comment.
In principle we should be checking the return value of PyDict_SetItemString too, but I'm happy for you to declare that out of scope for this PR.
There was a problem hiding this comment.
Yes, let's do that - I think if we're just calling standard python interface routines, we can be a bit more cavalier; we mostly need to guard against our own mistakes!
4a47c42 to
e88c23e
Compare
To avoid it wasting a few hours of someone else's time if they edit the gufunc signature parser.
e88c23e to
0091127
Compare
|
Thanks Marten |
To avoid it wasting a few hours of someone else's time if they edit the gufunc signature parser....
cc @mattip, since he may just have suffered similar problems...