New submission from Dustin Boswell:
Here's a command-line that parses a json string containing a large array of
short strings:
python -c "import simplejson as json; json.loads('[' + '''\"asdfadf\", ''' *
100000000 + '\"asdfasf\"]') "
That works, but if you increase the size a little bit (so the string is > 2^31)
python -c "import simplejson as json; json.loads('[' + '''\"asdfadf\", ''' *
300000000 + '\"asdfasf\"]') "
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/pymodules/python2.6/simplejson/__init__.py", line 307, in loads
return _default_decoder.decode(s)
File "/usr/lib/pymodules/python2.6/simplejson/decoder.py", line 338, in decode
raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 1 column -994967285 - line 1 column 3300000011
(char -994967285 - 3300000011)
Here's my version:
$ python
Python 2.6.5 (r265:79063, Oct 1 2012, 22:04:36)
[GCC 4.4.3] on linux2
>>> import sys;print("%x" % sys.maxsize, sys.maxsize > 2**32)
('7fffffffffffffff', True)
Also note that the test above requires at least 20GB of memory (that's not a
bug, just a heads-up).
----------
components: Library (Lib)
messages: 176722
nosy: Dustin.Boswell
priority: normal
severity: normal
status: open
title: json library can't parse large (> 2^31) strings
type: crash
versions: Python 2.6, Python 2.7
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue16586>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com