summaryrefslogtreecommitdiffstats
path: root/Lib/json/__init__.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-01-26 11:16:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-01-26 11:16:30 (GMT)
commit47efb4a5dc9cdf3f59362beb9a04c5c6bdd09f81 (patch)
treeb3e5115125360618a02a9615a643cbebe4aa7e75 /Lib/json/__init__.py
parent4e5d9eac2ca03debecbb9c6ed873303d04ead06a (diff)
downloadcpython-47efb4a5dc9cdf3f59362beb9a04c5c6bdd09f81.zip
cpython-47efb4a5dc9cdf3f59362beb9a04c5c6bdd09f81.tar.gz
cpython-47efb4a5dc9cdf3f59362beb9a04c5c6bdd09f81.tar.bz2
Issue #19361: JSON decoder now raises JSONDecodeError instead of ValueError.
Diffstat (limited to 'Lib/json/__init__.py')
-rw-r--r--Lib/json/__init__.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index 94f7d8c..6ce9880 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -98,12 +98,12 @@ Using json.tool from the shell to validate and pretty-print::
__version__ = '2.0.9'
__all__ = [
'dump', 'dumps', 'load', 'loads',
- 'JSONDecoder', 'JSONEncoder',
+ 'JSONDecoder', 'JSONDecodeError', 'JSONEncoder',
]
__author__ = 'Bob Ippolito <bob@redivi.com>'
-from .decoder import JSONDecoder
+from .decoder import JSONDecoder, JSONDecodeError
from .encoder import JSONEncoder
_default_encoder = JSONEncoder(
@@ -311,7 +311,8 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
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)")
+ raise JSONDecodeError("Unexpected UTF-8 BOM (decode using utf-8-sig)",
+ s, 0)
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):