Repository navigation
BUG: restrict weak scalar handling in resolve_dtypes to input operands - #31746
Merged
Merged
Conversation
Contributor
Author
|
Just following up on this PR in case it got buried. I would really appreciate a review when possible. Thanks in advance! |
Contributor
|
Thanks, this seems to be in the right place but I don't think the fix is right; a Instead if the descriptor is an output descriptor, we should just skip the weak-scalar branches and then error (a nicer else-if error branch if |
MaanasArora
reviewed
Jul 2, 2026
MaanasArora
reviewed
Jul 5, 2026
Diamagnetic
force-pushed
the
fix-ufunc-resolve-dtypes
branch
from
July 6, 2026 11:22
7400554 to
31c72ac
Compare
- Moved the `i < ufunc->nin` check into the condition - Removed the nested if-else branches
- Raise a dedicated error for weak scalar output descriptors - Improve `resolve_dtypes` error for invalid output descriptors
Diamagnetic
force-pushed
the
fix-ufunc-resolve-dtypes
branch
from
July 6, 2026 12:54
31c72ac to
eafb576
Compare
MaanasArora
reviewed
Jul 6, 2026
- Exact matching for the error instead of regex
MaanasArora
approved these changes
Jul 6, 2026
MaanasArora
left a comment
Contributor
There was a problem hiding this comment.
Awesome thank you, looks good to me! Will put this in after CI passes.
MaanasArora
pushed a commit
to MaanasArora/numpy
that referenced
this pull request
Jul 7, 2026
ngoldbaum
pushed a commit
to ngoldbaum/numpy
that referenced
this pull request
Sep 8, 2026
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.
PR summary
This PR fixes a SegFault in
ufunc.resolve_dtypesfor calls like:np.sin.resolve_dtypes((int, int))The bug:
int/float/complexwere treated as weak scalar markers in all operand positions.Fix:
Result:
np.sin.resolve_dtypes((int, int))now raises a normal casting error (UFuncOutputCastingError) instead of crashing.np.sin.resolve_dtypes((int, None))).Tests:
First time committer introduction
Hi all, I am new to the NumPy community. I use NumPy mainly in my data science, and graph theory projects. I wanted to make contributions to open source, and my procrastination finally ended recently. I was thinking of contributing to something I use regularly, and that's how I chose NumPy (I use it regularly).
AI Disclosure
Closes #31734