ujson.loads a big int value overflow #49

Closed
toontong opened this Issue Jun 28, 2012 · 3 comments

Comments

Projects
None yet
4 participants

Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 bit (Intel)] onwin32
the same on x86_64 x86_64 GNU/Linux

import json, ujson
ujson.version
'1.19'

ujson.loads('[18446098363113800555]')

[-645710595751061L]

json.loads('[18446098363113800555]')

[18446098363113800555L]

Member

jskorpan commented Sep 24, 2012

This has now been fixed in the sense that it now will raise a ValueError about the value being too big or too small

jskorpan closed this Sep 24, 2012

A ValueError is only raised for values between 263-1 and 264+1.
2**64 wraps around:

>>> ujson.__version__
'1.33'
>>> ujson.loads(str(2**64))
0
>>> ujson.loads(str(2**63+1))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: Value is too big
In [10]: t = '{"n": 125245234426059044438591937626407670195}'

In [11]: json.loads(t)
Out[11]: {u'n': 125245234426059044438591937626407670195L}

In [12]: ujson.loads(t)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-12-d375c8879db4> in <module>()
----> 1 ujson.loads(t)

ValueError: Value is too big

whd referenced this issue in mozilla/python_moztelemetry Nov 15, 2016

Merged

Bug 1302264 - Add support for new-style gzip-compressed objects #88

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment