Skip to content

Commit 1df38ba

Browse files
authored
Merge branch 'main' into fix-subscr-list-int-wide-deopt
2 parents 03b4cdd + f87d960 commit 1df38ba

4 files changed

Lines changed: 25 additions & 2 deletions

File tree

Doc/reference/datamodel.rst

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ subscript notation ``a[k]`` selects the item indexed by ``k`` from the mapping
496496
:keyword:`del` statements. The built-in function :func:`len` returns the number
497497
of items in a mapping.
498498

499-
There is currently a single intrinsic mapping type:
499+
There are two intrinsic mapping types:
500500

501501

502502
Dictionaries
@@ -535,6 +535,20 @@ module.
535535
an implementation detail at that time rather than a language guarantee.
536536

537537

538+
Frozen dictionaries
539+
^^^^^^^^^^^^^^^^^^^
540+
541+
.. index:: pair: object; frozendict
542+
543+
These represent an immutable dictionary. They are created by the built-in
544+
:func:`frozendict` constructor. A frozendict is :term:`hashable` if all of
545+
its keys and values are hashable, in which case it can be used as an element
546+
of a set, or as a key in another mapping. :class:`!frozendict` is not a
547+
subclass of :class:`dict`; it inherits directly from :class:`object`.
548+
549+
.. versionadded:: 3.15
550+
551+
538552
Callable types
539553
--------------
540554

Lib/json/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
307307
cls=cls, object_hook=object_hook,
308308
parse_float=parse_float, parse_int=parse_int,
309309
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook,
310-
array_hook=None, **kw)
310+
array_hook=array_hook, **kw)
311311

312312

313313
def loads(s, *, cls=None, object_hook=None, parse_float=None,

Lib/test/test_json/test_decode.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,13 @@ def test_array_hook(self):
8787

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

90+
def test_load_array_hook(self):
91+
# json.load must forward array_hook to loads
92+
fp = StringIO('[10, 20, 30]')
93+
result = self.json.load(fp, array_hook=tuple)
94+
self.assertEqual(result, (10, 20, 30))
95+
self.assertEqual(type(result), tuple)
96+
9097
def test_decoder_optimizations(self):
9198
# Several optimizations were made that skip over calls to
9299
# the whitespace regex, so this test is designed to try and
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix :func:`json.load` not forwarding the *array_hook* argument to
2+
:func:`json.loads`. Patch by Thomas Kowalski.

0 commit comments

Comments
 (0)