summaryrefslogtreecommitdiffstats
path: root/Lib/json
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-10-20 23:10:55 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-10-20 23:10:55 (GMT)
commit566a2be95c3aba65302d3d5b8108b27f810e1eaf (patch)
treee093ba0634bea66fa1561c13c88eccccc0aae299 /Lib/json
parenta0e768ccc250dbe6ffab812b7964538013ae36c4 (diff)
downloadcpython-566a2be95c3aba65302d3d5b8108b27f810e1eaf.zip
cpython-566a2be95c3aba65302d3d5b8108b27f810e1eaf.tar.gz
cpython-566a2be95c3aba65302d3d5b8108b27f810e1eaf.tar.bz2
#18958: Improve error message for json.load(s) while passing a string that starts with a UTF-8 BOM.
Diffstat (limited to 'Lib/json')
-rw-r--r--Lib/json/__init__.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index 6cedb6e..a459f77 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -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):