Skip to content

Commit b44372e

Browse files
authored
gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528)
1 parent c206e53 commit b44372e

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

Lib/enum.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ class FlagBoundary(StrEnum):
12691269
STRICT, CONFORM, EJECT, KEEP = FlagBoundary
12701270

12711271

1272-
class Flag(Enum, boundary=STRICT):
1272+
class Flag(Enum, boundary=CONFORM):
12731273
"""
12741274
Support for flags
12751275
"""

Lib/test/test_enum.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2927,7 +2927,7 @@ def test_bool(self):
29272927
self.assertEqual(bool(f.value), bool(f))
29282928

29292929
def test_boundary(self):
2930-
self.assertIs(enum.Flag._boundary_, STRICT)
2930+
self.assertIs(enum.Flag._boundary_, CONFORM)
29312931
class Iron(Flag, boundary=STRICT):
29322932
ONE = 1
29332933
TWO = 2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
fix Flag to use boundary CONFORM
2+
3+
This restores previous Flag behavior of allowing flags with non-sequential values to be combined; e.g.
4+
5+
class Skip(Flag):
6+
TWO = 2
7+
EIGHT = 8
8+
9+
Skip.TWO | Skip.EIGHT -> <Skip.TWO|EIGHT: 10>

0 commit comments

Comments
 (0)