summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-05-27 22:43:13 (GMT)
committerGitHub <noreply@github.com>2022-05-27 22:43:13 (GMT)
commit647426d4fa272da33269a9c183f3949a3477202d (patch)
treeaf541096833aeed5600b3ff9ca4449bd9102b853 /Lib/test
parent3f7abff97bf6472f35d23a00656e88d77c93feea (diff)
downloadcpython-647426d4fa272da33269a9c183f3949a3477202d.zip
cpython-647426d4fa272da33269a9c183f3949a3477202d.tar.gz
cpython-647426d4fa272da33269a9c183f3949a3477202d.tar.bz2
gh-93250: [Enum] Change IntEnum boundary to KEEP for backwards compatibility (GH-93302) (GH-93304)
In previous versions of Python if an IntEnum member was combined with another integer type value using a bit-wise operation, the resulting value would still be the IntEnum type. This change restores that behavior. (cherry picked from commit 70cfe56cafb2b549983f63d5d1a54654fe63c15c) Co-authored-by: Ethan Furman <ethan@stoneleaf.us>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_enum.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/test/test_enum.py b/Lib/test/test_enum.py
index c9ed083..56cebfe 100644
--- a/Lib/test/test_enum.py
+++ b/Lib/test/test_enum.py
@@ -3349,7 +3349,10 @@ class OldTestIntFlag(unittest.TestCase):
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
@@ -3368,7 +3371,6 @@ class OldTestIntFlag(unittest.TestCase):
EIGHT = 8
self.assertIs(Space._boundary_, EJECT)
#
- #
class Bizarre(IntFlag, boundary=KEEP):
b = 3
c = 4
@@ -3385,6 +3387,12 @@ class OldTestIntFlag(unittest.TestCase):
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