Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ def __invert__(self):
__rxor__ = __xor__


class IntFlag(int, ReprEnum, Flag, boundary=EJECT):
class IntFlag(int, ReprEnum, Flag, boundary=KEEP):
"""
Support for integer-based Flags
"""
Expand Down
12 changes: 10 additions & 2 deletions Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -3349,7 +3349,10 @@ def test_invert(self):
self.assertIs((Open.WO|Open.CE) & ~Open.WO, Open.CE)

def test_boundary(self):
self.assertIs(enum.IntFlag._boundary_, EJECT)
self.assertIs(enum.IntFlag._boundary_, KEEP)
class Simple(IntFlag, boundary=KEEP):
SINGLE = 1
#
class Iron(IntFlag, boundary=STRICT):
ONE = 1
TWO = 2
Expand All @@ -3368,7 +3371,6 @@ class Space(IntFlag, boundary=EJECT):
EIGHT = 8
self.assertIs(Space._boundary_, EJECT)
#
#
class Bizarre(IntFlag, boundary=KEEP):
b = 3
c = 4
Expand All @@ -3385,6 +3387,12 @@ class Bizarre(IntFlag, boundary=KEEP):
self.assertEqual(list(Bizarre), [Bizarre.c])
self.assertIs(Bizarre(3), Bizarre.b)
self.assertIs(Bizarre(6), Bizarre.d)
#
simple = Simple.SINGLE | Iron.TWO
self.assertEqual(simple, 3)
self.assertIsInstance(simple, Simple)
self.assertEqual(repr(simple), '<Simple.SINGLE|<Iron.TWO: 2>: 3>')
self.assertEqual(str(simple), '3')

def test_iter(self):
Color = self.Color
Expand Down