Title: Unexpected behavior change in subclassing `Enum` class as of 3.11 · Issue #103479 · python/cpython · GitHub
Open Graph Title: Unexpected behavior change in subclassing `Enum` class as of 3.11 · Issue #103479 · python/cpython
X Title: Unexpected behavior change in subclassing `Enum` class as of 3.11 · Issue #103479 · python/cpython
Description: I had a question regarding changes in subclassing Enum in 3.11. As of 3.11, if enum class has a mixin parent apart from Enum which has defined __init__ or __new__, member._value_ is set to be another instance of the mixin class unless us...
Open Graph Description: I had a question regarding changes in subclassing Enum in 3.11. As of 3.11, if enum class has a mixin parent apart from Enum which has defined __init__ or __new__, member._value_ is set to be anoth...
X Description: I had a question regarding changes in subclassing Enum in 3.11. As of 3.11, if enum class has a mixin parent apart from Enum which has defined __init__ or __new__, member._value_ is set to be anoth...
Opengraph URL: https://github.com/python/cpython/issues/103479
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Unexpected behavior change in subclassing `Enum` class as of 3.11","articleBody":"I had a question regarding changes in subclassing `Enum` in 3.11. As of 3.11, if enum class has a mixin parent apart from `Enum` which has defined `__init__` or `__new__`, `member._value_` is set to be another instance of the mixin class\r\nunless user defines `__new__` in the enum class and set `_value_`. However user naturally expects `_value_` to be the value assigned to the member in class definition. In the example below\r\n\r\n```python\r\nclass mixin:\r\n def __init__(self):\r\n pass\r\n\r\nclass CustomEnum(mixin, Enum):\r\n MEMBER = \"member\"\r\n```\r\n\r\n`CustomEnum.MEMBER` is an instance of mixin and `CustomEnum.MEMBER.value` is another instance of it (with different id), while it was expected that `CustomEnum.MEMBER.value` would be `\"member\"`. What has been the rationale for this change?\r\n\r\nBy the way, this change is not noted in python docs enumeration page.\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-103495\n* gh-103514\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sadra-barikbin","@type":"Person","name":"sadra-barikbin"},"datePublished":"2023-04-12T18:27:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/103479/cpython/issues/103479"}
| 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:4cbe92fa-3514-f047-d94f-543b0774c7a3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C2AE:C8A64:7FDFAE:B0F75C:696A8019 |
| html-safe-nonce | 3ab45feec82025bb739069ff2ae0e3dbecf02932b696adb18e926c0cd544c30b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMkFFOkM4QTY0OjdGREZBRTpCMEY3NUM6Njk2QTgwMTkiLCJ2aXNpdG9yX2lkIjoiMzQxNDM1NzYzNzUzNTAwNjc0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | f8038271c1b7db9effe30affc65acde6f7645313fe000e1c018d3f226ed7dce0 |
| hovercard-subject-tag | issue:1665044514 |
| 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/103479/issue_layout |
| twitter:image | https://opengraph.githubassets.com/152f2987f638db48d0e5ea8416b918c4c6e2cf499968168a32260007a5027e0e/python/cpython/issues/103479 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/152f2987f638db48d0e5ea8416b918c4c6e2cf499968168a32260007a5027e0e/python/cpython/issues/103479 |
| og:image:alt | I had a question regarding changes in subclassing Enum in 3.11. As of 3.11, if enum class has a mixin parent apart from Enum which has defined __init__ or __new__, member._value_ is set to be anoth... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sadra-barikbin |
| hostname | github.com |
| expected-hostname | github.com |
| None | 913560fa317c3c5a71e34f9b19253c9f09d02b4b958a86c2a56f4c8541116377 |
| 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 | 5998c30593994bf2589055aef7b22d368a499367 |
| ui-target | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width