-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
code: add ExceptionInfo.from_exception
#10901
code: add ExceptionInfo.from_exception
#10901
Conversation
"""Return an ExceptionInfo for an existing exc_info tuple. | ||
"""Return an ExceptionInfo for an existing exception. | ||
|
||
The exception must have a non-``None`` ``__traceback__`` attribute, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only hitch here is this subtlety. An alternative is to just allow ExcInfo to have a missing traceback...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I personally prefer to get a clear error at this point, rather than make ExceptionInfo.__traceback__
be Optional
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agreed.
9fd7d5b
to
dc5dd8c
Compare
The old-style `sys.exc_info()` triplet is redundant nowadays with `(type(exc), exc, exc.__traceback__)`, and is beginning to get soft-deprecated in Python 3.12. Add a nicer API to ExceptionInfo which takes just the exc instead of the triplet. There are already a few internal uses which benefit.
dc5dd8c
to
424c3ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work!
"""Return an ExceptionInfo for an existing exc_info tuple. | ||
"""Return an ExceptionInfo for an existing exception. | ||
|
||
The exception must have a non-``None`` ``__traceback__`` attribute, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm I personally prefer to get a clear error at this point, rather than make ExceptionInfo.__traceback__
be Optional
.
The old-style
sys.exc_info()
triplet is redundant nowadays with(type(exc), exc, exc.__traceback__)
, and is beginning to get soft-deprecated in Python 3.12.Add a nicer API to ExceptionInfo which takes just the exc instead of the triplet. There are already a few internal uses which benefit.