Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 6 commits into from
Apr 8, 2025

Conversation

srinivasreddy
Copy link
Contributor

@srinivasreddy srinivasreddy commented Apr 3, 2025

@brianschubert
Copy link
Contributor

Hi! This updates the docstring for JSONEncoder.__init__ (i.e. what's shown by help(json.JSONEncoder)). Technically gh-132021 is about this passage from the docs, not the docstring, but it doesn't hurt to clarify the docstring as well. Can you make a similar change to the docs passage in Doc/library/json.rst?

@@ -108,7 +108,7 @@ 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
encoding of keys that are not bool, str, int, float or None. If
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick: json.dumps uses the order "str, int, float, bool, None" in its docstring and docs, so we might as well use the same order here for consistency

Copy link
Member

@ericvsmith ericvsmith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@python-cla-bot
Copy link

python-cla-bot bot commented Apr 6, 2025

All commit authors signed the Contributor License Agreement.

CLA signed

@picnixz picnixz changed the title gh-132021: Add bool type to the list of types that were allowed in keys of encode(...) method gh-132021: Add bool type to the list of allowed JSON key types Apr 7, 2025
@hugovk hugovk merged commit 403886c into python:main Apr 8, 2025
39 checks passed
@hugovk hugovk added needs backport to 3.12 only security fixes needs backport to 3.13 bugs and security fixes labels Apr 8, 2025
@miss-islington-app
Copy link

Thanks @srinivasreddy for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13.
🐍🍒⛏🤖

@miss-islington-app
Copy link

Thanks @srinivasreddy for the PR, and @hugovk for merging it 🌮🎉.. I'm working now to backport this PR to: 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 8, 2025
…ythonGH-132048)

(cherry picked from commit 403886c)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Apr 8, 2025
…ythonGH-132048)

(cherry picked from commit 403886c)

Co-authored-by: Srinivas Reddy Thatiparthy (తాటిపర్తి శ్రీనివాస్  రెడ్డి) <[email protected]>
Co-authored-by: Eric V. Smith <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Apr 8, 2025

GH-132255 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Apr 8, 2025
@bedevere-app
Copy link

bedevere-app bot commented Apr 8, 2025

GH-132256 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 only security fixes label Apr 8, 2025
@srinivasreddy srinivasreddy deleted the gh-132021 branch April 8, 2025 08:39
hugovk pushed a commit that referenced this pull request Apr 8, 2025
…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]>
hugovk pushed a commit that referenced this pull request Apr 8, 2025
…GH-132048) (#132255)

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants