-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Default enum.FlagBoundary should be KEEP? #93250
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
For some context: Python 3.11 and mixing of enum.IntFlag. Reproducer: import enum
A = enum.IntFlag("A", {"x": 1})
B = enum.IntFlag("B", {"y": 2})
val = A.x | B.y
print(val, type(val))
but
Relevant commit: 7aaeb2a ("bpo-38250: [Enum] single-bit flags are canonical (GH-24215)"). |
Are you concerned that the repr() has changed, or that the result is no longer of type |
The change in type is the problem. |
Changing the default to Out of curiosity, and ignoring backwards compatibility, do you think the default for an IntFlag should be |
I don't feel comfortable with the type being different depending on the values provided, so I don't like My use case is atypical. I am wrapping the enums of a C++ library and can't guarantee that the wrappers know about all the possible values that the library might provide. Note that my original concern was about the lack of the usual deprecation cycle for a change in behaviour rather than the change itself. |
…ibility (GH-93302) In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type. This change restores that behavior.
…compatibility (pythonGH-93302) In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type. This change restores that behavior. (cherry picked from commit 70cfe56) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
…ibility (GH-93302) (GH-93304) In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type. This change restores that behavior. (cherry picked from commit 70cfe56) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
|
The FlagBoundary added to enums in Python v3.11 has defaults that break compatibility with previous versions. Shouldn't the default initially be KEEP, with a deprecation warning that it will be changed in a future version?
The text was updated successfully, but these errors were encountered: