[3.12] gh-104271: Fix auto() fallback in case of mixed type Enum (GH-104279)

gh-104271: Fix auto() fallback in case of mixed type Enum
This commit is contained in:
Itamar Ostricher 2023-05-23 11:11:35 -07:00 committed by GitHub
parent 9aea1f28e2
commit f4e2049f14
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 2 deletions

View file

@ -1185,7 +1185,7 @@ class Enum(metaclass=EnumType):
DeprecationWarning,
stacklevel=3,
)
for v in last_values:
for v in reversed(last_values):
try:
return v + 1
except TypeError:

View file

@ -4254,11 +4254,14 @@ class TestInternals(unittest.TestCase):
red = 'red'
blue = 2
green = auto()
yellow = auto()
self.assertEqual(list(Color), [Color.red, Color.blue, Color.green])
self.assertEqual(list(Color),
[Color.red, Color.blue, Color.green, Color.yellow])
self.assertEqual(Color.red.value, 'red')
self.assertEqual(Color.blue.value, 2)
self.assertEqual(Color.green.value, 3)
self.assertEqual(Color.yellow.value, 4)
@unittest.skipIf(
python_version < (3, 13),