tundish / rson

Automatically exported from code.google.com/p/rson
MIT License
0 stars 0 forks source link

Empty file should return an empty dict. #3

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

 $ touch foo.rson
 $ python
 >>> import(f.read())
 >>> f=open('foo.rson','r')
 >>> rson.loads(f.read())
 Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "rson/base/dispatcher.py", line 25, in loads
    return default_loads(s)
  File "rson/base/parser.py", line 286, in parse
    value, token = parse_recurse([next()], next, tokens)
  File "rson/base/parser.py", line 259, in parse_recurse
    value = rson_value_dispatch(firsttok[1], bad_top_value)(firsttok, next)
  File "rson/base/parser.py", line 53, in bad_top_value
    error('Expected start of object', token)
\  File "rson/base/tokenizer.py", line 187, in error
    sourcelen = len(source) - (source[-1] == '\n')
 IndexError: string index out of range

Compare to:

 $ echo "foo: bar" >bar.rson
 $ python 
 >>> import rson
 >>> f=open('bar.rson','r')
 >>> rson.loads(f.read())
 {u'foo': u'bar'}

What is the expected output? What do you see instead?

Output should be empty dict:

 >>> rson.loads(f.read())
 {}

What version of the product are you using? On what operating system?
 0.9

Please provide any additional information below.

Original issue reported on code.google.com by rob.sh...@gmail.com on 11 Feb 2013 at 8:14