[issue20453] json.load() error message changed in 3.4

Serhiy Storchaka report at bugs.python.org
Sun Feb 2 13:49:36 CET 2014


Serhiy Storchaka added the comment:

"No JSON object could be decoded, expecting value" is too expensive and second part of this message just repeat first part. The message can be shortened to "No JSON object could be decoded". But this is not fully correct. JSON term "object" corresponds to Python dict. But this error raised when arbitrary JSON value expected: "object", "array" (corresponded to Python list), string, number or boolean. That is why I had changed "object" to "value". So may be the "No JSON value could be decoded" is more correct.

Also note other differences between 3.3 and 3.4:

json.loads('[')
3.3: Expecting object: line 1 column 1 (char 0)
3.4: Expecting value: line 1 column 2 (char 1)

json.loads('[,')
3.3: No JSON object could be decoded
3.4: Expecting value: line 1 column 2 (char 1)

json.loads('[42')
3.3: Expecting object: line 1 column 3 (char 2)
3.4: Expecting ',' delimiter: line 1 column 4 (char 3)

json.loads('[42,')
3.3: Expecting object: line 1 column 4 (char 3)
3.4: Expecting value: line 1 column 5 (char 4)

json.loads('["')
3.3: end is out of bounds
3.4: Unterminated string starting at: line 1 column 2 (char 1)

json.loads('["foo')
3.3: Unterminated string starting at: line 1 column 2 (char 1)
3.4: Unterminated string starting at: line 1 column 2 (char 1)

To me new error messages look more informative and more correct.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20453>
_______________________________________


More information about the Python-bugs-list mailing list