Skip to content

bpo-42385: [Enum] add _generate_next_value_ to StrEnum#23735

Merged
ethanfurman merged 3 commits into
python:masterfrom
ethanfurman:enum-gnv-2
Dec 10, 2020
Merged

bpo-42385: [Enum] add _generate_next_value_ to StrEnum#23735
ethanfurman merged 3 commits into
python:masterfrom
ethanfurman:enum-gnv-2

Conversation

@ethanfurman
Copy link
Copy Markdown
Member

@ethanfurman ethanfurman commented Dec 10, 2020

The default for auto() is to return an integer, which doesn't work for StrEnum.

https://bugs.python.org/issue42385

@ethanfurman ethanfurman changed the title Enum gnv 2 bpo-42385: [Enum] add _generate_next_value_ to StrEnum Dec 10, 2020
@ethanfurman ethanfurman merged commit efb13be into python:master Dec 10, 2020
@ethanfurman ethanfurman deleted the enum-gnv-2 branch December 10, 2020 20:20
adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
)

The default for auto() is to return an integer, which doesn't work for `StrEnum`.  The new `_generate_next_value_` for `StrEnum` returns the member name, lower cased.
Comment thread Lib/enum.py
"""
Return the lower-cased version of the member name.
"""
return name.lower()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just name? Why .lower()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants