diff --git a/src-python/amazon/ion/reader_binary.py b/src-python/amazon/ion/reader_binary.py index 6b5d8d5d..7447a355 100644 --- a/src-python/amazon/ion/reader_binary.py +++ b/src-python/amazon/ion/reader_binary.py @@ -494,6 +494,9 @@ def _rslice(data, rem, size): def _int_factory(sign, data): + if sign < 0 and not any(data): + raise IonException('Negative zero is not a valid int.') + def parse_int(): value = 0 length = len(data) diff --git a/tests/test_reader_binary.py b/tests/test_reader_binary.py index f92f85ae..f36baa69 100644 --- a/tests/test_reader_binary.py +++ b/tests/test_reader_binary.py @@ -117,6 +117,8 @@ def _prepend_ivm(params): (b'\xe4\x81\x84\xb2\x21\x01', 'ANNOT LENGTH TOO SHORT - CONTAINER'), # The annotation wrapper declares 3 octets, but the subfields (including an int) take up four. (b'\xe3\x81\x84\x21\x01', 'ANNOT LENGTH TOO SHORT - SCALAR'), + # A negative int with a magnitude of zero (negative zero) is illegal. + (b'\x31\x00', 'NEGATIVE INT ZERO'), # TODO: annnotated nop is a fail # TODO: value within container is longer than container. diff --git a/tests/test_vectors.py b/tests/test_vectors.py index 431a4f91..9b98e708 100644 --- a/tests/test_vectors.py +++ b/tests/test_vectors.py @@ -113,7 +113,6 @@ def _open(file): _bad_file(u'localSymbolTableWithMultipleImportsFields.10n'), # TODO amazon-ion/ion-python#118 _bad_file(u'localSymbolTableWithMultipleSymbolsAndImportsFields.10n'), # TODO amazon-ion/ion-python#118 _bad_file(u'localSymbolTableWithMultipleSymbolsFields.10n'), # TODO amazon-ion/ion-python#118 - _bad_file(u'negativeIntZero.10n'), # TODO amazon-ion/ion-python#119 _equivs_file(u'timestampSuperfluousOffset.10n') # TODO amazon-ion/ion-python#121 )