-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-42482: remove reference to exc_traceback from TracebackException #23531
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
Conversation
132b460
to
3233ecd
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.
Yeah!
Wait, I made a mistake in the refcount test. The TracebackException object is an intermediate, I need to assign it to something. |
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.
Sorry I didn't catch that. :-(
Let me know when you are confident enough that I can merge this.
I think it’s ready now. |
BTW - the faulty test did fail on the old code. It must be that the exc_traceback field was closing a cycle with the test function’s frame or something like that. |
Actually it might make more sense to move the line that prints the "traceback header" to StackSummary.format(), where the traceback itself is being formatted. |
Except that would change the behavior of |
Yes, I'm adding a with_header=False arg to format(). Alternatively, we could leave the header line where it is but under "if self.stack:" and remove the _print_traceback_header boolean. |
This is the cause - the TracebackException was not really intermediate because format() returns a generator: (Pdb) gc.get_referrers(gc.get_referrers(exc_info[2])[2]) |
I went for just removing the boolean. At this point moving the header line (as an opt-in) won't make the code clearer than this. |
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.
Okay, though I am curious why the original fixer didn't do it that way...
Lib/traceback.py
Outdated
@@ -627,7 +626,7 @@ def format(self, *, chain=True): | |||
not self.__suppress_context__): | |||
yield from self.__context__.format(chain=chain) | |||
yield _context_message | |||
if self._print_traceback_header: | |||
if self.stack: | |||
yield 'Traceback (most recent call last):\n' | |||
yield from self.stack.format() |
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.
Maybe indent this line too then?
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.
Let's sit on this for a day...
Thanks @iritkatriel for the PR 🌮🎉.. I'm working now to backport this PR to: 3.8, 3.9. |
GH-23578 is a backport of this pull request to the 3.9 branch. |
GH-23579 is a backport of this pull request to the 3.8 branch. |
…ythonGH-23531) (cherry picked from commit 427613f) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
…ythonGH-23531) (cherry picked from commit 427613f) Co-authored-by: Irit Katriel <iritkatriel@yahoo.com>
https://bugs.python.org/issue42482
Automerge-Triggered-By: GH:gvanrossum