Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
cls=cls, object_hook=object_hook,
parse_float=parse_float, parse_int=parse_int,
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,
array_hook=None, **kw)
array_hook=array_hook, **kw)


def loads(s, *, cls=None, object_hook=None, parse_float=None,
Expand Down
7 changes: 7 additions & 0 deletions Lib/test/test_json/test_decode.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ def test_array_hook(self):

self.assertEqual(self.loads('[]', array_hook=tuple), ())

def test_load_array_hook(self):
# json.load must forward array_hook to loads
fp = StringIO('[10, 20, 30]')
result = self.json.load(fp, array_hook=tuple)
self.assertEqual(result, (10, 20, 30))
self.assertEqual(type(result), tuple)

def test_decoder_optimizations(self):
# Several optimizations were made that skip over calls to
# the whitespace regex, so this test is designed to try and
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :func:`json.load` not forwarding the *array_hook* argument to
:func:`json.loads`. Patch by Thomas Kowalski.
Loading