Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(26444)

Unified Diff: Lib/json/__init__.py

Issue 19361: Specialize exceptions thrown by JSON parser
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Lib/json/decoder.py ('k') | Lib/test/test_json/__init__.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Lib/json/__init__.py Sun Nov 30 20:39:04 2014 +0200
+++ b/Lib/json/__init__.py Mon Dec 01 00:17:14 2014 +0200
@@ -98,12 +98,12 @@ Using json.tool from the shell to valida
__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, ob
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):
« no previous file with comments | « Lib/json/decoder.py ('k') | Lib/test/test_json/__init__.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+