For some integers that are too large, UltraJSON will raise a ValueError. For others, it will parse, but parse to the wrong value. This happens both for numbers that are too large in the positive direction, and numbers that are too large in the negative direction.
What did you do?
Encoded an integer that was too big or too small.
What did you expect to happen?
I expected UltraJSON to raise a ValueError.
What actually happened?
UltraJSON parsed the integer...into the wrong value.
What versions are you using?
- OS: Debian 5.7.17-1rodete4 (2020-10-01) x86_64 GNU/Linux
- Python: 3.8.5
- UltraJSON: HEAD as of Nov 9 2020 (commit hash f26f967)
Please include code that reproduces the issue.
import ujson
ujson.loads("18446744073709551615") # Parses fine, max 64-bit value
ujson.loads("18446744073709551616") # Raises a ValueError: Value is too big!
# This value is even bigger:
ujson.loads("33333333303333333333") # Parses, but parses into the wrong value, 14886589229623781717
# The same thing happens for negative numbers. For example:
ujson.loads("-80888888888888888888") # Parses to the wrong value, -7101912594050682424
For some integers that are too large, UltraJSON will raise a ValueError. For others, it will parse, but parse to the wrong value. This happens both for numbers that are too large in the positive direction, and numbers that are too large in the negative direction.
What did you do?
Encoded an integer that was too big or too small.
What did you expect to happen?
I expected UltraJSON to raise a ValueError.
What actually happened?
UltraJSON parsed the integer...into the wrong value.
What versions are you using?
Please include code that reproduces the issue.