MAINT: Further small return value validation fixes#20990
Conversation
| *result = (PyObject*)PyArray_DescrNewByteorder(descr, byte_order); | ||
| Py_DECREF(descr); | ||
| if (result == NULL) { | ||
| if (*result == NULL) { |
There was a problem hiding this comment.
Well, clang is smart enough to notice that it was always false, to bad GCC running in CI is not :)
|
Ping @charris, can you smuggle this into the release you are currently preparing? |
| Py_XDECREF(fields); | ||
| Py_XDECREF(nameslist); | ||
| return NULL; | ||
| goto fail; |
There was a problem hiding this comment.
I had not realized we had a goto here that could be used.
| %#endif | ||
| if (!PyArray_IsScalar(obj,Integer)) return SWIG_TypeError; | ||
| PyArray_Descr * longDescr = PyArray_DescrNewFromType(NPY_LONG); | ||
| PyArray_Descr * longDescr = PyArray_DescrFromType(NPY_LONG); |
There was a problem hiding this comment.
PyArray_DescrFromType cannot fail for builtin types (except char)... No idea if it matters, but this is fine.
There was a problem hiding this comment.
Makes me wonder about the use of PyArray_DescrNewFromType. AFAICT, almost all uses are with builtin types.
There was a problem hiding this comment.
It is used mostly for voids/strings that are "mutable" so to speak (e.g. adjusting the elsize), sometimes with others to adjust byte-order.
(Or at least those are the places where it should and must be used)
There was a problem hiding this comment.
There are about 14 uses for types that aren't mutable. Looks like an opportunity for some cleanup.
Yes. |
|
Thanks Sebastian. |
Half of these were probably just multiple versions of the same pattern, so it got lost.