-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Iterating over enum.Flag
types ignores zero-valued in Python 3.11
#109633
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 bisected to here:
|
From the docs, I can say that now Check how The technical reason behind this is that now Lines 313 to 319 in 712cb17
Because Lines 93 to 98 in 712cb17
So, when we use Lines 790 to 794 in 712cb17
We need @ethanfurman :) |
It is more accurate to say that
Aliases have always been omitted from iteration, and flag values with no, or more than one, bit(s) set are considered aliases since Python 3.11 -- this was considered a bug-fix. |
Oh I see. Thanks for the clarification, @ethanfurman. Looking back over the docs now, they do pretty much convey everything that you've explained here, although some of the details are subtle. The only thing that I think isn't explicitly explained there is that zero-valued flags are considered aliases. |
Why isn't |
Because |
|
Yes. |
Hi, I do have a use case where I need both alias and elements of a flag. Is there a way to explicitly iterate over either only elements and only aliases that works in both old AND new version? |
@ClundXIII You can do this
|
Bug report
Bug description:
In Python 3.10, you can iterate over
enum.Enum
andenum.Flag
types to yield their values.In Python 3.11, the same is true for
enum.Enum
types, but the behavior seems to have changed forenum.Flag
types. Now, iterating over the type only yields its nonzero values.CPython versions tested on:
3.10, 3.11
Operating systems tested on:
Linux
The text was updated successfully, but these errors were encountered: