Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
gh-104271: Fix auto() fallback in case of mixed type Enum
  • Loading branch information
itamaro committed May 7, 2023
commit 09bfba4785d031472c181f19aa335c8fcd034ad1
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