Skip to content

Commit

Permalink
[3.11] pythongh-104271: Fix auto() fallback in case of mixed type Enum (
Browse files Browse the repository at this point in the history
pythonGH-104809)

[3.12] pythongh-104271: Fix auto() fallback in case of mixed type Enum (pythonGH-104279)
(cherry picked from commit f4e2049)

Co-authored-by: Itamar Ostricher <itamarost@gmail.com>
  • Loading branch information
miss-islington and itamaro authored May 23, 2023
1 parent ac12a6b commit 582aadc
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 @@ -1170,7 +1170,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 @@ -4176,11 +4176,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 582aadc

Please sign in to comment.