summaryrefslogtreecommitdiffstats
path: root/Lib/json
diff options
context:
space:
mode:
authorEzio Melotti <ezio.melotti@gmail.com>2013-10-20 22:52:33 (GMT)
committerEzio Melotti <ezio.melotti@gmail.com>2013-10-20 22:52:33 (GMT)
commita0e768ccc250dbe6ffab812b7964538013ae36c4 (patch)
tree80630a60d1c6dc489f7fd398e7ac6227fe34a1c1 /Lib/json
parent4ea16e56ebd39e95392e3549c7dad2dd4d6ed602 (diff)
downloadcpython-a0e768ccc250dbe6ffab812b7964538013ae36c4.zip
cpython-a0e768ccc250dbe6ffab812b7964538013ae36c4.tar.gz
cpython-a0e768ccc250dbe6ffab812b7964538013ae36c4.tar.bz2
#19307: Improve error message for json.load(s) while passing objects of the wrong type.
Diffstat (limited to 'Lib/json')
-rw-r--r--Lib/json/__init__.py3
1 files changed, 3 insertions, 0 deletions
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
index 3f95cc3..6cedb6e 100644
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -310,6 +310,9 @@ def loads(s, encoding=None, cls=None, object_hook=None, parse_float=None,
The ``encoding`` argument is ignored and deprecated.
"""
+ if not isinstance(s, str):
+ raise TypeError('the JSON object must be str, not {!r}'.format(
+ s.__class__.__name__))
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):