Thanks to visit codestin.com
Credit goes to github.com

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
1 change: 0 additions & 1 deletion Doc/howto/enum.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1439,7 +1439,6 @@ alias::
Traceback (most recent call last):
...
ValueError: aliases not allowed in DuplicateFreeEnum: 'GRENE' --> 'GREEN'
Error calling __set_name__ on '_proto_member' instance 'GRENE' in 'Color'

.. note::

Expand Down
9 changes: 5 additions & 4 deletions Lib/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,10 +568,11 @@ def __new__(metacls, cls, bases, classdict, *, boundary=None, _simple=False, **k
try:
exc = None
enum_class = super().__new__(metacls, cls, bases, classdict, **kwds)
except RuntimeError as e:
# any exceptions raised by member.__new__ will get converted to a
# RuntimeError, so get that original exception back and raise it instead
exc = e.__cause__ or e
except Exception as e:
Comment thread
ethanfurman marked this conversation as resolved.
# since 3.12 the line "Error calling __set_name__ on '_proto_member' instance ..."
# is tacked on to the error instead of raising a RuntimeError
# recreate the exception to discard
exc = type(e)(str(e))
Comment thread
ethanfurman marked this conversation as resolved.
if exc is not None:
raise exc
#
Expand Down