Repository navigation
BUG: write bytes to canonical byteorder in StringDType casts - #32474
Merged
Merged
Conversation
mhvk
approved these changes
Sep 2, 2026
mhvk
left a comment
Contributor
There was a problem hiding this comment.
Nice catch by the AI, and the fix looks right: the loop descriptors should describe what the loop actually expects.
Member
Author
|
I'm pretty sure the docs build failures are unrelated (scipy/docs.scipy.org#102). Thanks for the review @mhvk! |
Member
|
@ngoldbaum I note that all the string tests are new, none of them are in 2.5.x. That makes me wonder about the backport. |
Member
Author
|
This bug has existed since NumPy 2.0. If you feel like a fix for NumPy writing garbage output isn't backportable that's your call though. |
Member
|
The fix is fine, it is the tests I worry about, since they are all new and might depend on developments in main. |
Member
Author
ngoldbaum
added a commit
to ngoldbaum/numpy
that referenced
this pull request
Sep 8, 2026
ngoldbaum
added 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
Currently we're using the exact output descriptor for casts from string to types that support byte ordering. That's wrong and leads to incorrect answers when casting to an explicitly byteswapped dtype instance. See the new tests, which all fail with incorrect answers on
main.AI Disclosure
An AI spotted the bug and I used an AI to review the fix.