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.
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
bpo-45711: Change exc_info related APIs to derive type and traceback from the exception instance #29780
bpo-45711: Change exc_info related APIs to derive type and traceback from the exception instance #29780
Changes from 1 commit
04407ce
e8645ff
971887a
995ec59
92835f0
4602710
7bc139f
05af230
f17222d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
Isn't this a bug and that particular change should therefore be backported? I recently got surprised by this behavior of
raise
when usingBaseException.with_traceback
in Python 3.10: I was able to sete.__traceback__
to a custom traceback withe.with_traceback(my_custom_tb)
, even verified withe.__traceback__ == my_custom_tb
, yet a bareraise
raised the exception like no changes had been made. (Also adding to this confusion: Changes to the original traceback likee.__traceback__.tb_next = None
did successfully show up with bareraise
.)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.
So I originally wanted to post this as an issue but discovered that the behavior seemingly disappeared when using Python 3.11. With some help I found out about this PR where one of the changes fixes the behavior of bare
raise
. So I thought it would be the best idea to ask here via comment since @iritkatriel is also listed as the maintainer for the traceback module anyway? I hope that's okay.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.
Here's a short example to explain what I mean:
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.
We can't backport this change, it's way too invasive for that. This behaviour existed since 3.0, unfortunately.
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.
If you "raise e" instead of "raise" then you will see the edited traceback (but with the current frame added).
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 use of
sys.exc_info()[1]
always puts me off -- it's just too cryptic. Maybe "the traceback attached to this exception is now always its__traceback__
attribute? Or use the phrasing from the reference manual above?