Skip to content

Commit

Permalink
pythongh-104271: Fix auto() fallback in case of mixed type Enum
Browse files Browse the repository at this point in the history
  • Loading branch information
itamaro committed May 7, 2023
1 parent 8d95012 commit 09bfba4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -1185,7 +1185,7 @@ def _generate_next_value_(name, start, count, last_values):
DeprecationWarning,
stacklevel=3,
)
for v in last_values:
for v in reversed(last_values):
try:
return v + 1
except TypeError:
Expand Down
5 changes: 4 additions & 1 deletion Lib/test/test_enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -4254,11 +4254,14 @@ class Color(Enum):
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),
Expand Down

0 comments on commit 09bfba4

Please sign in to comment.