Skip to content

Commit

Permalink
preserve original traceback, cause, and context
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfurman committed Nov 7, 2023
1 parent 2db65ad commit d9c8cb4
Showing 1 changed file with 4 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 @@ -573,8 +573,11 @@ def __new__(metacls, cls, bases, classdict, *, boundary=None, _simple=False, **k
# is tacked on to the error instead of raising a RuntimeError
# recreate the exception to discard
exc = type(e)(str(e))
exc.__cause__ = e.__cause__
exc.__context__ = e.__context__
tb = e.__traceback__
if exc is not None:
raise exc
raise exc.with_traceback(tb)
#
# update classdict with any changes made by __init_subclass__
classdict.update(enum_class.__dict__)
Expand Down

0 comments on commit d9c8cb4

Please sign in to comment.