Title: String enums in dicts/lists are json serialized differently in Python 3.15 · Issue #148241 · python/cpython · GitHub
Open Graph Title: String enums in dicts/lists are json serialized differently in Python 3.15 · Issue #148241 · python/cpython
X Title: String enums in dicts/lists are json serialized differently in Python 3.15 · Issue #148241 · python/cpython
Description: Bug report Bug description: Cross posting from cattrs: python-attrs/cattrs#744 There's a difference in how Python 3.14 and Pytthon 3.15 handle json serialization of string enum values stored in other types which is exposed by cattrs test...
Open Graph Description: Bug report Bug description: Cross posting from cattrs: python-attrs/cattrs#744 There's a difference in how Python 3.14 and Pytthon 3.15 handle json serialization of string enum values stored in oth...
X Description: Bug report Bug description: Cross posting from cattrs: python-attrs/cattrs#744 There's a difference in how Python 3.14 and Pytthon 3.15 handle json serialization of string enum values stored in...
Opengraph URL: https://github.com/python/cpython/issues/148241
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"String enums in dicts/lists are json serialized differently in Python 3.15","articleBody":"# Bug report\n\n### Bug description:\n\nCross posting from cattrs: https://github.com/python-attrs/cattrs/issues/744\nThere's a difference in how Python 3.14 and Pytthon 3.15 handle json serialization of string enum values stored in other types which is exposed by cattrs tests.\nI have failed to find any track record for this behavior in the available docs.\n\nSee:\n\nPython 3.15.0a7\n```pytb\n>>> import json\n>>> from enum import Enum\n>>> class AStringEnum(str, Enum):\n... A = \"a\"\n... \n>>> val = AStringEnum.A\n>>> json.dumps(val)\n'\"a\"'\n>>> in_dict = json.dumps({\"key\": val})\n>>> in_dict\n'{\"key\": \"AStringEnum.A\"}'\n>>> parsed = json.loads(in_dict)\n>>> type(parsed['key'])\n\u003cclass 'str'>\n>>> repr(parsed['key'])\n\"'AStringEnum.A'\"\n>>> AStringEnum(parsed['key'])\nTraceback (most recent call last):\n File \"\u003cpython-input-15>\", line 1, in \u003cmodule>\n AStringEnum(parsed['key'])\n ~~~~~~~~~~~^^^^^^^^^^^^^^^\n File \"/usr/lib64/python3.15/enum.py\", line 732, in __call__\n return cls.__new__(cls, value)\n ~~~~~~~~~~~^^^^^^^^^^^^\n File \"/usr/lib64/python3.15/enum.py\", line 1221, in __new__\n raise ve_exc\nValueError: 'AStringEnum.A' is not a valid AStringEnum\n```\n\nPython 3.14.3\n```pycon\n>>> import json\n>>> from enum import Enum\n>>> class AStringEnum(str, Enum):\n... A = \"a\"\n... \n>>> val = AStringEnum.A\n>>> json.dumps(val)\n'\"a\"'\n>>> json.dumps({\"key\": val})\n'{\"key\": \"a\"}'\n>>> in_dict = json.dumps({\"key\": val})\n>>> parsed = json.loads(in_dict)\n>>> type(parsed['key'])\n\u003cclass 'str'>\n>>> repr(parsed['key'])\n\"'a'\"\n>>> AStringEnum(parsed['key'])\n\u003cAStringEnum.A: 'a'>\n```\n\n### CPython versions tested on:\n\n3.15\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-148249\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/befeleme","@type":"Person","name":"befeleme"},"datePublished":"2026-04-08T10:07:07Z","url":"https://github.com/python/cpython/issues/148241"}
| 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:3444ad74-7a39-c8c5-a4ce-1840aa39fcea |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A536:ADA9D:3C89F72:4D9A5B4:6B020164 |
| html-safe-nonce | 21a1f4eb6fe240f30be8575ee7da6c9cbb6627d02b7e9dc5e9e40dbce998b7a6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNTM2OkFEQTlEOjNDODlGNzI6NEQ5QTVCNDo2QjAyMDE2NCIsInZpc2l0b3JfaWQiOiI2ODY4ODczOTk4MjA3NTUzMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 70348ecd9b122cecd13b326bd9a4a24e0edcc78b87b569348fdba80ee161a867 |
| hovercard-subject-tag | issue:4223720581 |
| 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/148241/issue_layout |
| twitter:image | https://opengraph.githubassets.com/74dcbc578b54ddcd312dc280d7a9dc582199b35b59fa9c0115be9a0b830bab6b/python/cpython/issues/148241 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/74dcbc578b54ddcd312dc280d7a9dc582199b35b59fa9c0115be9a0b830bab6b/python/cpython/issues/148241 |
| og:image:alt | Bug report Bug description: Cross posting from cattrs: python-attrs/cattrs#744 There's a difference in how Python 3.14 and Pytthon 3.15 handle json serialization of string enum values stored in oth... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | befeleme |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width