]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-132021: Add bool type to the list of allowed JSON key types (GH-132048...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 8 Apr 2025 08:43:45 +0000 (10:43 +0200)
committerGitHub <noreply@github.com>
Tue, 8 Apr 2025 08:43:45 +0000 (08:43 +0000)
gh-132021: Add bool type to the list of allowed JSON key types (GH-132048)
(cherry picked from commit 403886c28ddb350bbcaea478f8d754ed14e10337)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్ రెడ్డి) <thatiparthysreenivas@gmail.com>
Co-authored-by: Eric V. Smith <ericvsmith@users.noreply.github.com>
Doc/library/json.rst
Lib/json/encoder.py

index 8d7d76c7bc5c8e8a393660dcd4a93b028bcf911d..7c4d9bb518ea16ad23dc7e6db9c3d73eef8f5bfa 100644 (file)
@@ -475,8 +475,8 @@ Encoders and Decoders
    (to raise :exc:`TypeError`).
 
    If *skipkeys* is false (the default), a :exc:`TypeError` will be raised when
-   trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`
-   or ``None``.  If *skipkeys* is true, such items are simply skipped.
+   trying to encode keys that are not :class:`str`, :class:`int`, :class:`float`,
+   :class:`bool` or ``None``.  If *skipkeys* is true, such items are simply skipped.
 
    If *ensure_ascii* is true (the default), the output is guaranteed to
    have all incoming non-ASCII characters escaped.  If *ensure_ascii* is
index 597849eca0524a33c3f495c6dd56baa94032a2d0..3595ca7e8168cbd41b11e21356d543565e61e8e1 100644 (file)
@@ -108,8 +108,8 @@ class JSONEncoder(object):
         """Constructor for JSONEncoder, with sensible defaults.
 
         If skipkeys is false, then it is a TypeError to attempt
-        encoding of keys that are not str, int, float or None.  If
-        skipkeys is True, such items are simply skipped.
+        encoding of keys that are not str, int, float, bool or None.
+        If skipkeys is True, such items are simply skipped.
 
         If ensure_ascii is true, the output is guaranteed to be str
         objects with all incoming non-ASCII characters escaped.  If