[Python-Dev] Dropping bytes "support" in json

Dirkjan Ochtman dirkjan at ochtman.nl
Thu Apr 9 14:02:43 CEST 2009


On Thu, Apr 9, 2009 at 13:10, Antoine Pitrou <solipsis at pitrou.net> wrote:
> Sure, but then:
>
>>>> json.loads('[]')
> []
>>>> json.loads(u'[]'.encode('utf16'))
> Traceback (most recent call last):
>  File "<stdin>", line 1, in <module>
>  File "/home/antoine/cpython/__svn__/Lib/json/__init__.py", line 310, in loads
>    return _default_decoder.decode(s)
>  File "/home/antoine/cpython/__svn__/Lib/json/decoder.py", line 344, in decode
>    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
>  File "/home/antoine/cpython/__svn__/Lib/json/decoder.py", line 362, in raw_decode
>    raise ValueError("No JSON object could be decoded")
> ValueError: No JSON object could be decoded

Right. :) Just wanted to point your test might not be testing what you
want to test.

Cheers,

Dirkjan


More information about the Python-Dev mailing list