bpo-42482: remove reference to exc_traceback from TracebackException#23531
Conversation
132b460 to
3233ecd
Compare
Wait, I made a mistake in the refcount test. The TracebackException object is an intermediate, I need to assign it to something. |
gvanrossum
left a comment
There was a problem hiding this comment.
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. |
gvanrossum
left a comment
There was a problem hiding this comment.
Okay, though I am curious why the original fixer didn't do it that way...
| 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.
Maybe indent this line too then?
gvanrossum
left a comment
There was a problem hiding this comment.
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