Repository navigation
fix: raise a validation error for out-of-bounds integer fill values - #4703
Open
barlowa124 wants to merge 7 commits into
Open
barlowa124 wants to merge 7 commits into
barlowa124 wants to merge 7 commits into
Conversation
from_json_scalar cast the parsed integer into the native dtype without a range check, so fill_value 300 for int8 surfaced a numpy OverflowError instead of a validation error. Bounds-check against np.iinfo before casting; int, intish float, and intish string forms are covered.
…shared bounds check
- Raise ValueError (not TypeError) for out-of-range values and drop
"Invalid type" from the message; format input with {data!r}
- Document the ValueError in the Raises sections of from_json_scalar
and cast_scalar
- Split the regression test into parametrized in-bounds and
out-of-bounds tests
- Share the bounds check with cast_scalar so create_array with an
out-of-range fill_value raises the same error (optional item)
- Changelog: single backticks, cover both read and write paths
This branch has not been deployed
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.
Supersedes #4492, which GitHub auto-closed when the branch history was rewritten to remove tooling attribution.
Summary
Partial fix for #4453, item 4 first bullet.
ArrayV3Metadata.from_dictwith an out-of-range integer fill value leaked NumPy's
OverflowErrorinstead of raising a validation error:
BaseInt.from_json_scalarnow bounds-checks the parsed integer againstnp.iinfobefore casting, so all three accepted JSON forms (int,integer-valued float, integer string) get the same
TypeErrorthenon-integer path already raises. In-range behavior is unchanged.
For reviewers
The parse path only:
cast_scalarstill uses NumPy cast semantics, so anout-of-range fill passed through the create API keeps its current
behavior. The remaining item-4 bullets (byte-array
bytesfills,r*raw-bits dtypes) are not addressed here.
Author attestation
TODO
docs/user-guide/*.mdchanges/