mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
#18958: Improve error message for json.load(s) while passing a string that starts with a UTF-8 BOM.
This commit is contained in:
parent
a0e768ccc2
commit
566a2be95c
3 changed files with 19 additions and 0 deletions
|
@ -313,6 +313,8 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
|
|||
if not isinstance(s, str):
|
||||
raise TypeError('the JSON object must be str, not {!r}'.format(
|
||||
s.__class__.__name__))
|
||||
if s.startswith(u'\ufeff'):
|
||||
raise ValueError("Unexpected UTF-8 BOM (decode using utf-8-sig)")
|
||||
if (cls is None and object_hook is None and
|
||||
parse_int is None and parse_float is None and
|
||||
parse_constant is None and object_pairs_hook is None and not kw):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue