BUG: fix swallowed cast error in fancy indexing assignment (#31975) - #32115
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #31975.
PR summary
Fixes #31974.
arr[idx] = valscan swallow a cast error when the values are buffered and the cast fails while the iterator refills a buffer chunk (array bigger than one 8192-element chunk). the buffered iternext returns 0 on error which looks exactly like a normal end of iteration, somapiter_set/mapiter_getreturned success with the exception still set. depending on what runs next that's either a silent bogus success (the error surfaces at a later unrelated call) orSystemError: ... returned a result with an exception set(e.g. vianp.put_along_axis).this adds a
PyErr_Occurred()check after the iteration loops inmapiter_@name@. small arrays already raise cleanly since first-chunk failures are caught atNpyIter_Resetso this just makes big arrays consistent. kept the check unconditional (notneeds_api-gated) because non-object casts can fail too, e.g. a string -> int cast hits the same leakAI Disclosure
Used Claude to double check my work and mae sure I didn't miss anything