From b921dbc46ba09cae5ae9c2cfb2d33bfb6553b6ca Mon Sep 17 00:00:00 2001 From: Ethan Furman Date: Sat, 24 Sep 2022 11:46:01 -0700 Subject: [PATCH 1/2] fix Flag to use CONFORM boundary --- Lib/enum.py | 2 +- Lib/test/test_enum.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/enum.py b/Lib/enum.py index c3aafc283719ab..a66c344dbc3db2 100644 --- a/Lib/enum.py +++ b/Lib/enum.py @@ -1269,7 +1269,7 @@ class FlagBoundary(StrEnum): STRICT, CONFORM, EJECT, KEEP = FlagBoundary -class Flag(Enum, boundary=STRICT): +class Flag(Enum, boundary=CONFORM): """ Support for flags """ diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py index ad421f87d6d07c..f50017d916f5e3 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -2927,7 +2927,7 @@ def test_bool(self): self.assertEqual(bool(f.value), bool(f)) def test_boundary(self): - self.assertIs(enum.Flag._boundary_, STRICT) + self.assertIs(enum.Flag._boundary_, CONFORM) class Iron(Flag, boundary=STRICT): ONE = 1 TWO = 2 From af9493bef68ccf35b82103fe23b6a595e645de9c Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 24 Sep 2022 18:56:24 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../2022-09-24-18-56-23.gh-issue-96865.o9WUkW.rst | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2022-09-24-18-56-23.gh-issue-96865.o9WUkW.rst diff --git a/Misc/NEWS.d/next/Library/2022-09-24-18-56-23.gh-issue-96865.o9WUkW.rst b/Misc/NEWS.d/next/Library/2022-09-24-18-56-23.gh-issue-96865.o9WUkW.rst new file mode 100644 index 00000000000000..b054fdeee0785c --- /dev/null +++ b/Misc/NEWS.d/next/Library/2022-09-24-18-56-23.gh-issue-96865.o9WUkW.rst @@ -0,0 +1,9 @@ +fix Flag to use boundary CONFORM + +This restores previous Flag behavior of allowing flags with non-sequential values to be combined; e.g. + + class Skip(Flag): + TWO = 2 + EIGHT = 8 + + Skip.TWO | Skip.EIGHT ->