Repository navigation
MAINT: parse nditer flags as unicode directly (gh-15317) - #32232
Merged
Merged
Conversation
ngoldbaum
reviewed
Aug 10, 2026
ngoldbaum
reviewed
Aug 13, 2026
ngoldbaum
left a comment
Member
There was a problem hiding this comment.
I think the mac conda CI failure is unrelated but I also spotted some minor cleanups in the docstring.
Co-authored-by: Nathan Goldbaum <[email protected]>
Contributor
Author
|
regards to the macos failure, it seems that it's due to trunk. ill rebase once that seems to be resolved. |
Member
|
Thanks @nakasan617 and for your patience as well. |
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
Part of gh-15317 (cleaning up internal callers of
PyUnicode_AsASCIIString).NpyIter_GlobalFlagsConverterandNpyIter_OpFlagsConverterencoded unicode flag strings to bytes withPyUnicode_AsASCIIStringbefore inspecting them. That allocates a throwaway bytes object for every flag, and for non-ASCII input it raisesUnicodeEncodeError— which doesn't describe what the user actually did wrong. This should be a value error instead of Unicode Encode Error.I created the test cases to raise ValueErrors when flags are not correct Unicode or not strings. I have also added the positive test cases when byte strings are passed as well.
First time committer introduction
Hello! My name is Yuta Nakamura, and I'm a backend software engineer. It made me curious how NumPy was created, and realized it was open source, and now it's easier than ever to contribute, so I decided to contribute to the project. I did a Ph.D. in computer science at DePaul University (in Chicago) specializing in program analysis. I'm originally from Japan but spent half of my life in the US.
AI Disclosure
I discussed the code with Claude to understand it and what changes need to be made, and I wrote the code myself to fix them. Tests are written by me (but discussed with claude where I should write and what I should write).