-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
bpo-45635: Do not suppress errors in functions called from _PyErr_Display #30073
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
Makes sense to me. |
erlend-aasland
left a 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.
Looks very good! I want to go over this once more in a day or two, if that's ok with you.
|
Of course, this is not urgent at all. |
Co-authored-by: Erlend Egeberg Aasland <[email protected]>
erlend-aasland
left a 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.
LGTM, but AFAICT we are unable to actually test this because we must fail in something like PyFile_WriteString (or OOM) for print_exception_recursive to actually return -1. I'm wondering if we could provoke a write error in some kind of way.
| // the end of that one since we don't support multi-line error | ||
| // messages. | ||
| if (end_lineno > lineno) { | ||
| end_offset = (error_line != NULL) ? line_size : -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.
This branch is not covered by the test suite, AFAICS.
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 make a bpo about this? I just copied this piece of code around, so it's not a new problem.
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.
This code is fairly recent:
commit a77aac4
Author: Pablo Galindo [email protected]
Date: Fri Apr 23 14:27:05 2021 +0100
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 the test is added in a separate PR it can be backported to 3.10.
iritkatriel
left a 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.
I was also thinking how one could test these error conditions. I think we would require some debug-mode-only macro that fails on the Nth time, and then run the test for all relevant values of N. It could be quite slow.
| // the end of that one since we don't support multi-line error | ||
| // messages. | ||
| if (end_lineno > lineno) { | ||
| end_offset = (error_line != NULL) ? line_size : -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.
Maybe make a bpo about this? I just copied this piece of code around, so it's not a new problem.
|
🤖 New build scheduled with the buildbot fleet by @iritkatriel for commit d6f6bbb 🤖 If you want to schedule another build, you need to add the ":hammer: test-with-buildbots" label again. |
Previously print_exception_recursive, and some other functions, called PyErr_Clear before returning. Now each of these functions returns the error so that we go back to the topmost _PyErr_Display and the PyErr_Clear happens there. So the whole thing exits, rather than just this one recursive call.
https://bugs.python.org/issue45635