Skip to content

Commit b646d9d

Browse files
Merge branch '3.15' into backport-bcd29e4-3.15
2 parents 6efc3f3 + 187982a commit b646d9d

4 files changed

Lines changed: 13 additions & 3 deletions

File tree

Doc/library/inspect.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,10 +1614,11 @@ properties, will be invoked and :meth:`~object.__getattr__` and
16141614
may be called.
16151615

16161616
For cases where you want passive introspection, like documentation tools, this
1617-
can be inconvenient. :func:`getattr_static` has the same signature as :func:`getattr`
1617+
can be inconvenient. :func:`getattr_static` has a similar signature as :func:`getattr`
16181618
but avoids executing code when it fetches attributes.
16191619

1620-
.. function:: getattr_static(obj, attr, default=None)
1620+
.. function:: getattr_static(obj, attr)
1621+
getattr_static(obj, attr, default)
16211622

16221623
Retrieve attributes without triggering dynamic lookup via the
16231624
descriptor protocol, :meth:`~object.__getattr__`

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)