Uh oh!
There was an error while loading. Please reload this page.
gh-108082: Use PyErr_FormatUnraisable() - #111580
Conversation
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().
| if (_PyErr_Occurred(tstate)) { | ||
| _PyErr_WriteUnraisableMsg("in tp_clear of", | ||
| (PyObject*)Py_TYPE(op)); | ||
| PyErr_FormatUnraisable("Exception ignored in tp_clear of %.200s", |
There was a problem hiding this comment.
IMO %.200s is a bug here. We should no longer truncate type names if they are too long. Many years ago, Python had an internal buffer of a fixed size and so the overall string must not be too long. But this has been fixed.
Please don't truncate type names.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
| PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V\n", | ||
| m->md_name ? " " : "", | ||
| m->md_name, ""); |
There was a problem hiding this comment.
| PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V\n", | |
| m->md_name ? " " : "", | |
| m->md_name, ""); | |
| PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V", | |
| m->md_name ? " " : "", | |
| m->md_name); |
| PyType_WatchCallback cb = interp->type_watchers[i]; | ||
| if (cb && (cb(type) < 0)) { | ||
| PyErr_WriteUnraisable((PyObject *)type); | ||
| PyErr_FormatUnraisable("Exception ignored in watcher callback for %R", i, type); |
There was a problem hiding this comment.
If you want to log i variable, you should add %i somewhere.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
vstinner
left a comment
There was a problem hiding this comment.
LGTM. I just left two minor suggestions.
| PyErr_WriteUnraisable(NULL); | ||
| PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V", | ||
| m->md_name ? " " : "", | ||
| m->md_name, ""); |
There was a problem hiding this comment.
The last "" is not used, it can be removed.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Victor Stinner <vstinner@python.org>
bedevere-bot
commented
Nov 2, 2023
|
vstinner
commented
Nov 2, 2023
I wanted to do this change for many years. It's awful to get a warning without any context :-( Thanks for this nice enhancement! I like PyErr_FormatUnraisable() API! |
serhiy-storchaka
commented
Nov 2, 2023
We both wanted it. But other tasks had higher priorities. |
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable(). Co-authored-by: Victor Stinner <vstinner@python.org>
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().