Repository navigation
Carry integers past the JavaScript safe-integer ceiling - #27
Merged
Merged
Conversation
The ceiling came from what a double holds, not from the wire format, and Python's integers do not need it. uint is bounded by its widest form instead, and int by what that form holds after zigzag. Closes #20.
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.
MAX_SAFE_INTEGERmirrored a limit of JavaScript numbers rather than of the format. Python's integers have no such limit, so the corpus holds this port to the format's range, whichuint,intand the sized codecs all fell short of.Three guards go:
_validate_safe_uinton both decode paths,_validate_intinside_zigzag, and the upper half of_validate_uint. In their placeuintis bounded by its widest form,2**64 - 1, so an out-of-range encode still raisesValueError;intneeds no bound of its own, since zigzag has to fit that same form.Conformance against
compact-encoding-testgoes from 166 matched / 8 diverged to 171 / 3, closingint-past-range,int-past-range-min,uint-uint64-top-byte,uint-decode-ceilinganduint56-decode-ceiling. The three left are #18 and #19.Closes #20.
One deletion to flag.
test_narrow_sized_uint_decode_cannot_overflowexisted to stop this change - "Pin that reasoning so the guard is not tidied" - so removing it reverses a decision rather than tidying one. The reasoning it pinned was sound for a port whose numbers are doubles; this one's are not. Eight other tests move their bounds from the double ceiling to the width that actually binds.