Skip to content

Commit

Permalink
pythongh-118650: Exclude _repr_* methods from Enum's _sunder_ reser…
Browse files Browse the repository at this point in the history
…vation (pythonGH-118651)
  • Loading branch information
chrysn authored May 7, 2024
1 parent 6cf7067 commit 1e42842
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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.

0 comments on commit 1e42842

Please sign in to comment.