https://github.com/python/cpython/commit/403886c28ddb350bbcaea478f8d754ed14e10337
commit: 403886c28ddb350bbcaea478f8d754ed14e10337
branch: main
author: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) 
<thatiparthysreeni...@gmail.com>
committer: hugovk <1324225+hug...@users.noreply.github.com>
date: 2025-04-08T11:25:46+03:00
summary:

gh-132021: Add bool type to the list of allowed JSON key types (#132048)

Co-authored-by: Eric V. Smith <ericvsm...@users.noreply.github.com>

files:
M Doc/library/json.rst
M Lib/json/encoder.py

diff --git a/Doc/library/json.rst b/Doc/library/json.rst
index 4e7046d6d8f6ac..26579ec6328860 100644
--- a/Doc/library/json.rst
+++ b/Doc/library/json.rst
@@ -486,8 +486,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
diff --git a/Lib/json/encoder.py b/Lib/json/encoder.py
index b804224098e14f..016638549aa59b 100644
--- a/Lib/json/encoder.py
+++ b/Lib/json/encoder.py
@@ -108,8 +108,8 @@ def __init__(self, *, skipkeys=False, ensure_ascii=True,
         """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

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to