-
-
Notifications
You must be signed in to change notification settings - Fork 31.8k
gh-95778: Use a note for the max digits error message #96878
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
Add _PyErr_AddNote() function to the internal C API.
@iritkatriel @Zac-HD: This PR adds the I prefer to call directly I'm not sure about the API in case of error. Currently, the function ignores any exception raised while trying to add a note to the exception :-( Do you think that an unraisable exception should be logged here? Or should we replace the currently raised exception with this new one? Maybe it would be acceptable if it's chained with the previous exception? |
I'm looking at which existing code might benefit from _PyErr_Note(). "Suggestions" added by PyErr_Display() with _Py_Offer_Suggestions() (issue #82711) is not a good fit: this code doesn't modify the exception on purpose. Or do you want to add suggestions in notes? If yes, we should maybe make sure that the note is not added multiple times if PyErr_Display() is called multiple times on the same exception ;-) |
Maybe _PyPegen_number_token() can use _PyErr_AddNote() for this code?
|
@@ -94,6 +94,11 @@ PyAPI_FUNC(PyObject *) _PyExc_PrepReraiseStar( | |||
|
|||
PyAPI_FUNC(int) _PyErr_CheckSignalsTstate(PyThreadState *tstate); | |||
|
|||
// Call add_note(note) on the current exception. | |||
// Return -1 on error, or 0 on success. | |||
// Save and restore the current exception. |
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.
Might be good to mention in the comment that there must be a current exception. I think otherwise it crashes or some assertion fails, not sure.
The intention with exception notes was that you use it to add information that is not available at the time the exception is created and raised, but only after you caught it. This doesn't follow that pattern. Why not just add one or two newlines to the msg? |
Oh, that's far from issue #95778 scope, so I created the new issue #96958 to discuss that instead. I propose to continue the discussion there. |
I close the issue to continue discussing it in #96958. |
Add _PyErr_AddNote() function to the internal C API.