You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Unexpected behavior change in subclassing Enum class as of 3.11 #103479
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 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
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?
By the way, this change is not noted in python docs enumeration page.
Activity
gh-103479: [Enum] require __new__ to be considered a data type (GH-10…
[3.11] pythongh-103479: [Enum] require __new__ to be considered a da…
Merge branch 'main' into superopt
[3.11] gh-103479: [Enum] require __new__ to be considered a data type (…
ethanfurman commentedon Apr 13, 2023
Thank you for the bug report; this is now fixed.