8000 gh-118650: Exclude `_repr_*` methods from Enum's _sunder_ reservation by chrysn · Pull Request #118651 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-118650: Exclude _repr_* methods from Enum's _sunder_ reservation #118651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 4 additions & 1 deletion Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,10 @@ def __setitem__(self, key, value):
'_generate_next_value_', '_numeric_repr_', '_missing_', '_ignore_',
'_iter_member_', '_iter_member_by_value_', '_iter_member_by_def_',
'_add_alias_', '_add_value_alias_',
):
# While not in use internally, those are common for pretty
# printing and thus excluded from Enum's reservation of
# _sunder_ names
) and not key.startswith('_repr_'):
raise ValueError(
'_sunder_ names, such as %r, are reserved for future Enum use'
% (key, )
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
The ``enum`` module allows method named ``_repr_*`` to be defined on
``Enum`` types.
Loading
0