8000 Inconsistency in json.JSONEncoder Description Regarding skipkeys Behavior · Issue #132021 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content
Inconsistency in json.JSONEncoder Description Regarding skipkeys Behavior #132021
Closed
@mouchen626

Description

@mouchen626

If skipkeys is false (the default), a TypeError will be raised when trying to encode keys that are not str, int, float or None. If skipkeys is true, such items are simply skipped.

However, boolean values (True and False) can be used as dictionary keys without raising a TypeError. I think this is a mistake.

json.JSONEncoder(skipkeys=False).encode({True:1})

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0