#9233: Fix json.loads({}) to return a dict (instead of a list), when _json is not available.

This commit is contained in:
Ezio Melotti 2011-04-13 07:10:13 +03:00
parent 42368f9b0c
commit d210aa1ad9
2 changed files with 11 additions and 0 deletions

View file

@ -161,6 +161,12 @@ def JSONObject(s_and_end, strict, scan_once, object_hook, object_pairs_hook,
nextchar = s[end:end + 1]
# Trivial empty object
if nextchar == '}':
if object_pairs_hook is not None:
result = object_pairs_hook(pairs)
return result, end
pairs = {}
if object_hook is not None:
pairs = object_hook(pairs)
return pairs, end + 1
elif nextchar != '"':
raise ValueError(errmsg("Expecting property name", s, end))