8000 [3.12] gh-104271: Fix auto() fallback in case of mixed type Enum (GH-… · python/cpython@f4e2049 · GitHub
[go: up one dir, main page]

Skip to content

Commit f4e2049

Browse files
authored
[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
1 parent 9aea1f2 commit f4e2049

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Lib/enum.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ def _generate_next_value_(name, start, count, last_values):
11851185
DeprecationWarning,
11861186
stacklevel=3,
11871187
)
1188-
for v in last_values:
1188+
for v in reversed(last_values):
11891189
try:
11901190
return v + 1
11911191
except TypeError:

Lib/test/test_enum.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4254,11 +4254,14 @@ class Color(Enum):
42544254
red = 'red'
42554255
blue = 2
42564256
green = auto()
4257+
yellow = auto()
42574258

4258-
self.assertEqual(list(Color), [Color.red, Color.blue, Color.green])
4259+
self.assertEqual(list(Color),
4260+
[Color.red, Color.blue, Color.green, Color.yellow])
42594261
self.assertEqual(Color.red.value, 'red')
42604262
self.assertEqual(Color.blue.value, 2)
42614263
self.assertEqual(Color.green.value, 3)
4264+
self.assertEqual(Color.yellow.value, 4)
42624265

42634266
@unittest.skipIf(
42644267
python_version < (3, 13),

0 commit comments

Comments
 (0)
0