code: add ExceptionInfo.from_exception#10901
Merged
bluetech merged 2 commits intopytest-dev:mainfrom Apr 13, 2023
Merged
Conversation
bluetech
commented
Apr 12, 2023
| """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, |
Member
Author
There was a problem hiding this comment.
The only hitch here is this subtlety. An alternative is to just allow ExcInfo to have a missing traceback...
Member
There was a problem hiding this comment.
Hmm I personally prefer to get a clear error at this point, rather than make ExceptionInfo.__traceback__ be Optional.
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
nicoddemus
approved these changes
Apr 13, 2023
| """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, |
Member
There was a problem hiding this comment.
Hmm I personally prefer to get a clear error at this point, rather than make ExceptionInfo.__traceback__ be Optional.
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.