Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork32.4k
gh-108082: Use PyErr_FormatUnraisable()#111580
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
gh-108082: Use PyErr_FormatUnraisable()#111580
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Replace most of calls of _PyErr_WriteUnraisableMsg() and somecalls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().
Modules/gcmodule.c Outdated
@@ -1032,8 +1032,8 @@ delete_garbage(PyThreadState *tstate, GCState *gcstate, | |||
Py_INCREF(op); | |||
(void) clear(op); | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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.
Objects/moduleobject.c Outdated
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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); |
Objects/typeobject.c Outdated
@@ -828,7 +828,7 @@ PyType_Modified(PyTypeObject *type) | |||
if (bits & 1) { | |||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
If you want to logi 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>
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. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
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 commentedNov 2, 2023
|
I wanted to do this change for many years. It's awful to get a warning withoutany context :-( Thanks for this nice enhancement! I like PyErr_FormatUnraisable() API! |
We both wanted it. But other tasks had higher priorities. |
Replace most of calls of _PyErr_WriteUnraisableMsg() and somecalls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().Co-authored-by: Victor Stinner <vstinner@python.org>
Replace most of calls of _PyErr_WriteUnraisableMsg() and somecalls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().Co-authored-by: Victor Stinner <vstinner@python.org>
Replace most of calls of _PyErr_WriteUnraisableMsg() and somecalls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().Co-authored-by: Victor Stinner <vstinner@python.org>
Uh oh!
There was an error while loading.Please reload this page.
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().