From: Ethan Furman Date: Wed, 5 Oct 2022 22:25:55 +0000 (-0700) Subject: gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528) X-Git-Tag: v3.12.0a1~230 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b44372e03c5461b6ad3d89763a9eb6cb82df07a4;p=thirdparty%2FPython%2Fcpython.git gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528) --- diff --git a/Lib/enum.py b/Lib/enum.py index c3aafc283719..a66c344dbc3d 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 ad421f87d6d0..f50017d916f5 100644 --- a/Lib/test/test_enum.py +++ b/Lib/test/test_enum.py @@ -2927,7 +2927,7 @@ class OldTestFlag(unittest.TestCase): 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 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 000000000000..b054fdeee078 --- /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 ->