Ezio Melotti added the comment:

I'm not sure this should be documented in json.load/loads, and I'm not sure 
people will look there once they get this exception.
The error is raised because the wrong codec is used (either by open() before 
passing the file object to json.load or by json.loads), so it's a user error 
rather than a problem with the json module.  The error turns out to be 
particularly misleading because the decoding is successful even though it 
produces a wrong result, and the problem becomes apparent only once it reaches 
json.
ISTM that the documentation is already clear enough that json doesn't 
auto-detect encodings and uses UTF-8 by default, and that different encodings 
should be specified explicitly.
I think that a better and backward-compatible solution would be to detect the 
UTF-8 BOM and provide a better error message hinting at utf-8-sig.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue18958>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to