My favorites | Sign in
Project Logo
                
New issue | Search
for
| Advanced search | Search tips
Issue 43: simplejson.loads(UNICODE FLOAT WITH MORE THAN ONE FRACTIONAL DIGIT) raises ValueError
1 person starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Mar 2009
Type-Defect
Priority-Medium


Sign in to add a comment
 
Reported by gary.poster, Mar 27, 2009
If you parse a string float in 2.0.9 (Mac 10.5/Ubuntu Intrepid), everything is fine:

>>> simplejson.loads('3.14')
3.1400000000000001

Everything is also OK with unicode and a single fractional digit:

>>> simplejson.loads(u'3.1')
3.1000000000000001

Everything is also OK with unicode placed in an enclosing data structure:

>>> simplejson.loads(u'[3.14]')
[3.1400000000000001]

However, if it is a unicode float, with multiple fractional digits, with no enclosing data structure, 
there is a problem:

>>> simplejson.loads(u'3.14')
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/Users/gary/.buildout/eggs/simplejson-2.0.9-py2.4-macosx-10.5-
i386.egg/simplejson/__init__.py", line 307, in loads
    return _default_decoder.decode(s)
  File "/Users/gary/.buildout/eggs/simplejson-2.0.9-py2.4-macosx-10.5-
i386.egg/simplejson/decoder.py", line 338, in decode
    raise ValueError(errmsg("Extra data", s, end, len(s)))
ValueError: Extra data: line 1 column 3 - line 1 column 4 (char 3 - 4)

Comment 1 by bob.ippolito, Mar 27, 2009
Ouch, good catch. Fixed in r177, will be in 2.1.0
Status: Fixed
Comment 2 by caraldi, Dec 08 (2 days ago)
Why not make a release?  I'm hitting this bug with version 2.0.9 from the Debian and Ubuntu packages, and it 
appears that there is no release since march.  Thanks in advance!
Comment 3 by bob.ippolito, Dec 08 (2 days ago)
I've been busy. I'm going to try and do a release by the end of the year, but I'm not making any promises.
Sign in to add a comment

Hosted by Google Code