-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Enum _missing_
function changes __contains__
behaviour
#132684
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am fairly certain this is a side effect of #131053, but I'm not sure what the correct behavior should be. |
Arf... this is something I didn't think of. This can be pretty annoying and we could also need to revert it in 3.12 :< I'll mark it as a release-blocker for now to draw attention. |
Actually, Ethan said on the previous issue:
Now, here |
I guess it makes total sense, because usually you only check that the value is present in the enum to create its member. But if you really want to mimic the behavior of 3.12 then you can use this workaround: >>> 'blue' in {color.name for color in Color}
False |
Perhaps we should simply document the change in behavior? |
If possible, yes, but it's also sad that the behavior of some constructions have been broken in a stable release. |
The change was for Flags -- i'll look at narrowing the code to reflect that. |
3.12 is in security-only mode, unfortunately. |
We can still ask @Yhg1s if he would consider the bugfix as an incomplete bugfix then (considering we broke something =/) and backport your recent bugfix. |
…32790) Co-authored-by: Bénédikt Tran <[email protected]>
…pythonGH-132790) (cherry picked from commit 22bc953) Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
GH-132790) (GH-132896) gh-132684: [Enum] only call _missing_ in __contains__ for Flags (GH-132790) (cherry picked from commit 22bc953) Co-authored-by: Ethan Furman <[email protected]> Co-authored-by: Bénédikt Tran <[email protected]>
Bug report
Bug description:
I observed different behavior for Enum
__contains__
in 3.13.2 and 3.13.3 if there is_missing_
method implemented:IMO
_missing_
should only influence the__call__
method:CPython versions tested on:
3.13
Operating systems tested on:
macOS
Linked PRs
The text was updated successfully, but these errors were encountered: