-
-
Notifications
You must be signed in to change notification settings - Fork 30.8k
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
enum.CONFORM behavior breaks backwards compatibility #103365
Comments
With #24215, only single-bit values will be considered in Thus You will need an element with value 4 inside of This answers "why it behaves like this". Related Issues: #82431 |
This is documented with an inconspicuous line. https://docs.python.org/3.10/library/enum.html#combining-members-of-flag I think this should be added to the API reference here: |
It's also documented there that the default for Flag in Python 3.11 is STRICT, but it's really CONFORM |
STRICT boundary: - fix bitwise operations - make default for Flag
STRICT boundary: - fix bitwise operations - make default for Flag (cherry picked from commit 2194071) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
* main: pythongh-103479: [Enum] require __new__ to be considered a data type (pythonGH-103495) pythongh-103365: [Enum] STRICT boundary corrections (pythonGH-103494) pythonGH-103488: Use return-offset, not yield-offset. (pythonGH-103502) pythongh-103088: Fix test_venv error message to avoid bytes/str warning (pythonGH-103500) pythonGH-103082: Turn on branch events for FOR_ITER instructions. (python#103507) pythongh-102978: Fix mock.patch function signatures for class and staticmethod decorators (python#103228) pythongh-103462: Ensure SelectorSocketTransport.writelines registers a writer when data is still pending (python#103463) pythongh-95299: Rework test_cppext.py to not invoke setup.py directly (python#103316)
@benburrill Thank you for the bug report. |
Encountered yet another breaking change for enums. There are two problems here:
Example to reproduce:
In Python 3.10.6, this code outputs:
In Python 3.11.2:
Having such members as C is useful to create a flags that are distinct from B but always implies B.
In a previous comment bug report it was stated that the previous behavior of Flag was CONFORM:
Originally posted by @ethanfurman in #96865 (comment)
Clearly this is incorrect. The previous behavior was more similar to STRICT, but there appears to be no precise equivalent in Python 3.11 to the old behavior. Using STRICT in Python 3.11,
SkipFlag.A | SkipFlag.C
would fail to be created completely.Linked PRs
The text was updated successfully, but these errors were encountered: