Skip to content

Commit 8ea13ff

Browse files
authored
Apply suggestions from code review
Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent c4d6b37 commit 8ea13ff

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

Lib/json/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,8 @@ def detect_encoding(b):
275275

276276

277277
def load(fp, *, cls=None, object_hook=None, parse_float=None,
278-
parse_int=None, parse_constant=None, object_pairs_hook=None,
279-
array_hook=None, **kw):
278+
parse_int=None, parse_constant=None, object_pairs_hook=None,
279+
array_hook=None, **kw):
280280
"""Deserialize ``fp`` (a ``.read()``-supporting file-like object containing
281281
a JSON document) to a Python object.
282282
@@ -310,8 +310,8 @@ def load(fp, *, cls=None, object_hook=None, parse_float=None,
310310

311311

312312
def loads(s, *, cls=None, object_hook=None, parse_float=None,
313-
parse_int=None, parse_constant=None, object_pairs_hook=None,
314-
array_hook=None, **kw):
313+
parse_int=None, parse_constant=None, object_pairs_hook=None,
314+
array_hook=None, **kw):
315315
"""Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
316316
containing a JSON document) to a Python object.
317317

Lib/test/test_json/test_decode.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ def test_array_hook(self):
7474
t = self.loads(s, array_hook=tuple)
7575
self.assertEqual(t, (1, 2, 3))
7676
self.assertEqual(type(t), tuple)
77+
7778
# Nested array in inner structure with object_hook
7879
s = '{"xkd": [[1], [2], [3]]}'
7980
p = frozendict(xkd=((1,), (2,), (3,)))
@@ -83,6 +84,7 @@ def test_array_hook(self):
8384
self.assertEqual(type(data["xkd"]), tuple)
8485
for item in data["xkd"]:
8586
self.assertEqual(type(item), tuple)
87+
8688
self.assertEqual(self.loads('[]', array_hook=tuple), ())
8789

8890
def test_decoder_optimizations(self):

Modules/_json.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1270,8 +1270,9 @@ scanner_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
12701270
if (s->object_pairs_hook == NULL)
12711271
goto bail;
12721272
s->array_hook = PyObject_GetAttrString(ctx, "array_hook");
1273-
if (s->array_hook == NULL)
1273+
if (s->array_hook == NULL) {
12741274
goto bail;
1275+
}
12751276
s->parse_float = PyObject_GetAttrString(ctx, "parse_float");
12761277
if (s->parse_float == NULL)
12771278
goto bail;

0 commit comments

Comments
 (0)