Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c9480d5

Browse filesBrowse files
gh-96865: [Enum] fix Flag to use CONFORM boundary (GH-97528)
(cherry picked from commit b44372e) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
1 parent eecbeec commit c9480d5
Copy full SHA for c9480d5

File tree

3 files changed

+11
-2
lines changed
Filter options

3 files changed

+11
-2
lines changed

‎Lib/enum.py

Copy file name to clipboardExpand all lines: Lib/enum.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,7 @@ class FlagBoundary(StrEnum):
12921292
STRICT, CONFORM, EJECT, KEEP = FlagBoundary
12931293

12941294

1295-
class Flag(Enum, boundary=STRICT):
1295+
class Flag(Enum, boundary=CONFORM):
12961296
"""
12971297
Support for flags
12981298
"""

‎Lib/test/test_enum.py

Copy file name to clipboardExpand all lines: Lib/test/test_enum.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2878,7 +2878,7 @@ def test_bool(self):
28782878
self.assertEqual(bool(f.value), bool(f))
28792879

28802880
def test_boundary(self):
2881-
self.assertIs(enum.Flag._boundary_, STRICT)
2881+
self.assertIs(enum.Flag._boundary_, CONFORM)
28822882
class Iron(Flag, boundary=STRICT):
28832883
ONE = 1
28842884
TWO = 2
+9Lines changed: 9 additions & 0 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.