geometry: clean up imOut if operation fails - #9785
Conversation
|
I understand completely that you dislike that the return value is ignored. However, the return value only indicates failure if the modes or the sizes don't match, and Is it worth considering the alternative solution of removing the mode and size checks from |
As noted, an earlier iteration of #9784 had an issue where I'd carelessly copy-pasted all checks across That in turn caused CPython RuntimeErrors because we were both returning a value from a C extension function while having set an exception, because this function wasn't checking correctly... If this function had behaved correctly CPython-API-wise, I would've spent less time debugging that exception, and more time figuring I was a dummy for copy-pasting blindly :) Given, as you note, that the |
Co-authored-by: Andrew Murray <3112309+radarhere@users.noreply.github.com>
|
Wouldn't you also want to check the return values here? Pillow/src/libImaging/BoxBlur.c Lines 281 to 289 in 11de4b9 |
Yep, good catch. This particular PR was just to fix this particular instance which bit me. I can do another pass over all of these fallible cases in another PR? |
2 similar comments
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
This comment was marked as duplicate.
| break; | ||
| default: | ||
| PyErr_SetString(PyExc_ValueError, "No such transpose operation"); | ||
| return NULL; |
There was a problem hiding this comment.
I suspect you are already aware, but op has been checked in the previous switch, so thedefault case will never run here.
There was a problem hiding this comment.
I was thinking of combining the two switch/cases even if it means duplicating the allocations, it might be clearer.
EDIT: Tried, looks ugly :)
Alternative to #9962
Sibling of #9784 - an earlier iteration of it uncovered Python complaining about a value being returned while an exception was set.
_transposedid indeed just wholesale toss out the retval of the underlying operation function...