-
-
Notifications
You must be signed in to change notification settings - Fork 30.9k
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-45292: [PEP 654] Update traceback display code to work with exception groups #29207
Conversation
This is almost exactly the same as I used for the PEP - I just removed the "with X sub-exceptions" line from the tracebacks because I think it clutters them and is not very useful. |
Just be sure to update the PEP examples. :-) |
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 2052c77 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
When you're done making the requested changes, leave the comment: |
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.
First round comments :) I'll take a new round on references and pointers later.
I think it's OK to always box the EGs because they're pretty special, although I'd change the very first line of the output, from:
to:
|
@1st1 - see below.
The indentation of the next line is wrong. Is this a copy-paste error or a bug?
|
Copy/paste/whitespace issue; no implementation bugs were observed! |
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.
I like the max_group_{with,depth} solution and the refactor of the chaining loop!
I didn't review the C code carefully, it looks like others are on that.
The only things left from me are nits in the formatting of some of the overflow messages. Otherwise LGTM!
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit 61fab3f 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
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.
LG!
Thank you! @gpshead @erlend-aasland @1st1 I'll wait a bit before merging in case you want to have another look. |
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.
Looks good; great job!
The only remark I have is that I find the error handling verbose and hard to read. I'm used to (and prefer):
int
func()
{
int rc = first();
if (rc < 0) {
goto error;
}
int err = second();
if (err != 0) {
goto error;
}
// etc.
// at the end:
return 0;
error:
cleanup();
return -1;
}
The current approach of always verifying that the previous step did not fail seems to lead to a lot of indenting levels. I could count 7 (!) indents in one of the functions.
I would consider simplifying the error handling for the sake of readability.
Feel free to disregard this comment; It's only personal preference :)
@erlend-aasland I agree with your comment. I tried using gotos but it was a bit delicate because you need to make sure the refcounting is still correct. This is a refactor that should be done in its own PR and not together with major functional changes. The current method preserves the control flow so it doesn't impact refcounts. |
+1 🙂 |
Thank you everyone for your help! |
# format exception group | ||
is_toplevel = (_ctx.exception_group_depth == 0) | ||
if is_toplevel: | ||
_ctx.exception_group_depth += 1 |
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.
FYI running patchcheck
for an unrelated PR just complained about this 5-space indent!
(and more in Lib/traceback.py)
https://bugs.python.org/issue45292