Skip to content

json: C encoder writes str() of str subclass separators #162525

Backlog

Description

@thejesh23

Bug report

Bug description:

The C encoder calls __str__() on str subclass separators, so the output is invalid JSON. Same bug as gh-148241, but for separators.

import enum, json

class Sep(str, enum.Enum):
    ITEM = ","
    KEY = ":"

print(json.dumps({"a": [1, 2]}, separators=(Sep.ITEM, Sep.KEY)))
# 3.13: {"a":[1,2]}
# 3.14: {"a"Sep.KEY[1Sep.ITEM2]}

CPython versions tested on:

3.13, 3.14, CPython main branch

Operating systems tested on:

macOS

Linked PRs

Activity

  1. thejesh23 commented on Nov 24, 2026

    @thejesh23
    ContributorAuthor

    @vstinner can you pls take a look as you triaged previous issue

  2. added
    type-bug
    extension-modules
    on Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    extension-modulestype-bug

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions