Skip to content

Commit aab69a8

Browse files
miss-islingtonsrinivasreddyericvsmith
authored
[3.12] gh-132021: Add bool type to the list of allowed JSON key types (GH-132048) (#132256)
gh-132021: Add bool type to the list of allowed JSON key types (GH-132048) (cherry picked from commit 403886c) Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <[email protected]> Co-authored-by: Eric V. Smith <[email protected]>
1 parent 3fc57f8 commit aab69a8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Doc/library/json.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -475,8 +475,8 @@ Encoders and Decoders
475475
(to raise :exc:`TypeError`).
476476

477477
If *skipkeys* is false (the default), a :exc:`TypeError` will be raised when
478-
trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`
479-
or ``None``. If *skipkeys* is true, such items are simply skipped.
478+
trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`,
479+
:class:`bool` or ``None``. If *skipkeys* is true, such items are simply skipped.
480480

481481
If *ensure_ascii* is true (the default), the output is guaranteed to
482482
have all incoming non-ASCII characters escaped. If *ensure_ascii* is

Lib/json/encoder.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ def __init__(self, *, skipkeys=False, ensure_ascii=True,
108108
"""Constructor for JSONEncoder, with sensible defaults.
109109
110110
If skipkeys is false, then it is a TypeError to attempt
111-
encoding of keys that are not str, int, float or None. If
112-
skipkeys is True, such items are simply skipped.
111+
encoding of keys that are not str, int, float, bool or None.
112+
If skipkeys is True, such items are simply skipped.
113113
114114
If ensure_ascii is true, the output is guaranteed to be str
115115
objects with all incoming non-ASCII characters escaped. If

0 commit comments

Comments
 (0)