-
-
Notifications
You must be signed in to change notification settings - Fork 34.8k
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
e126cd5
7e2a600
3a60137
5f3b94a
4f3292b
6445a4a
331bcaf
c671f07
4c15b7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Replace most of calls of _PyErr_WriteUnraisableMsg() and some calls of PyErr_WriteUnraisable(NULL) with PyErr_FormatUnraisable().
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -647,7 +647,7 @@ _PyModule_ClearDict(PyObject *d) | |||||||||||||
| PyErr_Clear(); | ||||||||||||||
| } | ||||||||||||||
| if (PyDict_SetItem(d, key, Py_None) != 0) { | ||||||||||||||
| PyErr_WriteUnraisable(NULL); | ||||||||||||||
| PyErr_FormatUnraisable("Exception ignored on clearing module dict"); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -668,7 +668,7 @@ _PyModule_ClearDict(PyObject *d) | |||||||||||||
| PyErr_Clear(); | ||||||||||||||
| } | ||||||||||||||
| if (PyDict_SetItem(d, key, Py_None) != 0) { | ||||||||||||||
| PyErr_WriteUnraisable(NULL); | ||||||||||||||
| PyErr_FormatUnraisable("Exception ignored on clearing module dict"); | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
|
|
@@ -902,10 +902,9 @@ module_clear(PyModuleObject *m) | |||||||||||||
| { | ||||||||||||||
| int res = m->md_def->m_clear((PyObject*)m); | ||||||||||||||
| if (PyErr_Occurred()) { | ||||||||||||||
| PySys_FormatStderr("Exception ignored in m_clear of module%s%V\n", | ||||||||||||||
| m->md_name ? " " : "", | ||||||||||||||
| m->md_name, ""); | ||||||||||||||
| PyErr_WriteUnraisable(NULL); | ||||||||||||||
| PyErr_FormatUnraisable("Exception ignored in m_clear of module%s%V\n", | ||||||||||||||
| m->md_name ? " " : "", | ||||||||||||||
| m->md_name, ""); | ||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The last |
||||||||||||||
| } | ||||||||||||||
| if (res) | ||||||||||||||
| return res; | ||||||||||||||
|
|
||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you want to log i variable, you should add |
||
| } | ||
| } | ||
| i++; | ||
|
|
@@ -9291,7 +9291,7 @@ releasebuffer_call_python(PyObject *self, Py_buffer *buffer) | |
| // from a Python __buffer__ function. | ||
| mv = PyMemoryView_FromBuffer(buffer); | ||
| if (mv == NULL) { | ||
| PyErr_WriteUnraisable(self); | ||
| PyErr_FormatUnraisable("Exception ignored in bf_releasebuffer of %s", Py_TYPE(self)->tp_name); | ||
| goto end; | ||
| } | ||
| // Set the memoryview to restricted mode, which forbids | ||
|
|
@@ -9304,15 +9304,15 @@ releasebuffer_call_python(PyObject *self, Py_buffer *buffer) | |
| PyObject *stack[2] = {self, mv}; | ||
| PyObject *ret = vectorcall_method(&_Py_ID(__release_buffer__), stack, 2); | ||
| if (ret == NULL) { | ||
| PyErr_WriteUnraisable(self); | ||
| PyErr_FormatUnraisable("Exception ignored in __release_buffer__ of %s", Py_TYPE(self)->tp_name); | ||
| } | ||
| else { | ||
| Py_DECREF(ret); | ||
| } | ||
| if (!is_buffer_wrapper) { | ||
| PyObject *res = PyObject_CallMethodNoArgs(mv, &_Py_ID(release)); | ||
| if (res == NULL) { | ||
| PyErr_WriteUnraisable(self); | ||
| PyErr_FormatUnraisable("Exception ignored in bf_releasebuffer of %s", Py_TYPE(self)->tp_name); | ||
| } | ||
| else { | ||
| Py_DECREF(res); | ||
|
|
||
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
%.200sis 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.