From 5aa7aeb50fcf573cc1b88a50f4db8026c2dddc81 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Tue, 8 Apr 2025 10:51:39 +0200 Subject: [PATCH] [3.13] gh-132021: Add bool type to the list of allowed JSON key types (GH-132048) (#132255) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 (తాటిపర్తి శ్రీనివాస్ రెడ్డి) Co-authored-by: Eric V. Smith --- Doc/library/json.rst | 4 ++-- Lib/json/encoder.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/json.rst b/Doc/library/json.rst index 22636027f9db..1b5bd51cce20 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 323332f064ed..bb5f584e3226 100644 --- a/Lib/json/encoder.py +++ b/Lib/json/encoder.py @@ -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 -- 2.47.3