Skip to content

Conversation

@ethanfurman
Copy link
Member

@ethanfurmanethanfurman commented Jul 5, 2023

For example:

class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0) 

This restores 3.10 behavior:

~Flag.A = <Flag.B: 2> (~Flag.A).value = 2 ~Flag.A is Flag.B = True ~Flag.A == Flag.B = True ~Flag.Mask = <Flag.0: 0> (~Flag.Mask).value = 0 ~Flag.Mask is Flag(0) = True ~Flag.Mask == Flag(0) = True 

For example: class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0)
@ethanfurmanethanfurman added type-bug An unexpected behavior, bug, or error stdlib Standard Library Python modules in the Lib/ directory 3.11 only security fixes 3.12 only security fixes needs backport to 3.11 only security fixes 3.13 bugs and security fixes needs backport to 3.12 only security fixes labels Jul 5, 2023
@ethanfurmanethanfurman self-assigned this Jul 5, 2023
@ethanfurmanethanfurman requested review from ambv and hugovkJuly 5, 2023 21:45
@ethanfurman
Copy link
MemberAuthor

That last commit should say IntFlag is KEEP -- Enum s don't have boundaries.

@ambvambv merged commit 95b7426 into python:mainJul 11, 2023
@miss-islington
Copy link
Contributor

Thanks @ethanfurman for the PR, and @ambv for merging it 🌮🎉.. I'm working now to backport this PR to: 3.11, 3.12.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 11, 2023
…ist (pythonGH-106468) For example: class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0) (cherry picked from commit 95b7426) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@bedevere-bot
Copy link

GH-106620 is a backport of this pull request to the 3.12 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jul 11, 2023
…ist (pythonGH-106468) For example: class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0) (cherry picked from commit 95b7426) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@bedevere-botbedevere-bot removed the needs backport to 3.12 only security fixes label Jul 11, 2023
@bedevere-bot
Copy link

GH-106621 is a backport of this pull request to the 3.11 branch.

@bedevere-botbedevere-bot removed the needs backport to 3.11 only security fixes label Jul 11, 2023
Yhg1s pushed a commit that referenced this pull request Jul 11, 2023
…xist (GH-106468) (#106620) gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (GH-106468) For example: class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0) (cherry picked from commit 95b7426) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Yhg1s pushed a commit that referenced this pull request Jul 11, 2023
…xist (GH-106468) (#106621) gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist (GH-106468) For example: class Flag(enum.Flag): A = 0x01 B = 0x02 MASK = 0xff ~Flag.MASK is Flag(0) (cherry picked from commit 95b7426) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
@ethanfurmanethanfurman deleted the enum-invert branch February 1, 2024 01:26
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants

@ethanfurman@miss-islington@bedevere-bot@ambv