FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist by ethanfurman · Pull Request #106468 · python/cpython · GitHub

/ cpython Public

gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist - #106468

Merged
ambv merged 2 commits into
python:mainfrom
ethanfurman:enum-invert
Jul 11, 2023
Merged

gh-105497: [Enum] Fix flag mask inversion when unnamed flags exist#106468
ambv merged 2 commits into
python:mainfrom
ethanfurman:enum-invert

Conversation

ethanfurman commented Jul 5, 2023
edited by bedevere-bot
Loading

Copy link
Copy Markdown
Member

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)
ethanfurman 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
ethanfurman self-assigned this Jul 5, 2023
ethanfurman requested review from ambv and hugovk July 5, 2023 21:45

Copy link
Copy Markdown
Member Author

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

ambv merged commit 95b7426 into python:main Jul 11, 2023

Copy link
Copy Markdown
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>

Copy link
Copy Markdown

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-bot removed the needs backport to 3.12 only security fixes label Jul 11, 2023

Copy link
Copy Markdown

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

bedevere-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>
ethanfurman deleted the enum-invert branch February 1, 2024 01:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.11 only security fixes 3.12 only security fixes 3.13 bugs and security fixes stdlib Standard Library Python modules in the Lib/ directory type-bug An unexpected behavior, bug, or error

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL