Repository navigation
Conversation
A binary int with type code 3 (negative) and a zero magnitude is invalid Ion, but the pure Python reader returned it as 0. Raise IonException instead, matching ion-c, and stop skipping the bad/negativeIntZero.10n test vector. Fixes amazon-ion#119
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.
Issue #, if available: #119
Description of changes:
Root cause: in the pure Python binary reader,
_int_factoryreturnssign * magnitudefor a type code 3 (negative int) and never checks whether the magnitude is zero. So0x31 0x00(and0x3E 0x81 0x00) loads as0, although the spec says negative zero is illegal. ion-c already rejects it withIERR_INVALID_BINARY, so the result depended on which reader was used (the pure Python one runs when the C extension is not available, whensimpleion.c_ext = False, or when acatalogis passed).Fix:
_int_factorynow raisesIonExceptionwhen a negative int's magnitude bytes are all zero.Test: added a
NEGATIVE INT ZEROcase to_BAD_VALUESintests/test_reader_binary.pyand removedbad/negativeIntZero.10nfrom the skip list intests/test_vectors.py. Both fail before the change (DID NOT RAISE) and pass after it. The rest of the suite (without the benchmark tests) still passes: 29212 passed, 5 skipped.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.