Title: json: C encoder writes str() of str subclass separators · Issue #162525 · python/cpython · GitHub
Open Graph Title: json: C encoder writes str() of str subclass separators · Issue #162525 · python/cpython
X Title: json: C encoder writes str() of str subclass separators · Issue #162525 · python/cpython
Description: 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....
Open Graph Description: 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...
X Description: 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...
Opengraph URL: https://github.com/python/cpython/issues/162525
X: @github
Domain: github.com
IPv4 address: 140.82.114.3
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"json: C encoder writes str() of str subclass separators","articleBody":"# Bug report\n\n### Bug description:\n\nThe C encoder calls `__str__()` on `str` subclass separators, so the output is invalid JSON. Same bug as gh-148241, but for separators.\n\n```python\nimport enum, json\n\nclass Sep(str, enum.Enum):\n ITEM = \",\"\n KEY = \":\"\n\nprint(json.dumps({\"a\": [1, 2]}, separators=(Sep.ITEM, Sep.KEY)))\n# 3.13: {\"a\":[1,2]}\n# 3.14: {\"a\"Sep.KEY[1Sep.ITEM2]}\n```\n\n### CPython versions tested on:\n\n3.13, 3.14, CPython main branch\n\n### Operating systems tested on:\n\nmacOS\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-162526\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/thejesh23","@type":"Person","name":"thejesh23"},"datePublished":"2026-11-24T04:43:02Z","url":"https://github.com/python/cpython/issues/162525"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:543c4c2b-1ebc-8eda-407d-c7b8e027e411 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDEA:6AD3D:CD015E:10991AA:6B0641FD |
| html-safe-nonce | 0b1c389f75113c6624f5782c6b06e8aa077dab51e191463cf7ce3aa76e80fc3e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREVBOjZBRDNEOkNEMDE1RToxMDk5MUFBOjZCMDY0MUZEIiwidmlzaXRvcl9pZCI6IjMxODY2NDkyNDMzMDYwNTAwNDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8cb5341eabe6ab093067cb92fd03c83bd7dae240b57d77fd5dec1d403c1d94ec |
| hovercard-subject-tag | issue:6574780668 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/162525/issue_layout |
| twitter:image | https://opengraph.githubassets.com/42510f2c6c9db54f059f06489b2626135e4ef9d81957f173025cec638956aaa5/python/cpython/issues/162525 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/42510f2c6c9db54f059f06489b2626135e4ef9d81957f173025cec638956aaa5/python/cpython/issues/162525 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | thejesh23 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1bff4f6bfaa96dc9c42cacf315424c24ebb548b06142ced5e3aaccb2a42dd652 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | ac613d3698d3d8565651455086e1f74da07bf277 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width