mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
gh-129354: Use PyErr_FormatUnraisable() function (#129656)
Replace PyErr_WriteUnraisable() with PyErr_FormatUnraisable().
This commit is contained in:
parent
979d766209
commit
14489c1bb4
3 changed files with 8 additions and 4 deletions
|
@ -105,8 +105,10 @@ fileio_dealloc_warn(PyObject *op, PyObject *source)
|
|||
PyObject *exc = PyErr_GetRaisedException();
|
||||
if (PyErr_ResourceWarning(source, 1, "unclosed file %R", source)) {
|
||||
/* Spurious errors can appear at shutdown */
|
||||
if (PyErr_ExceptionMatches(PyExc_Warning))
|
||||
PyErr_WriteUnraisable((PyObject *) self);
|
||||
if (PyErr_ExceptionMatches(PyExc_Warning)) {
|
||||
PyErr_FormatUnraisable("Exception ignored "
|
||||
"while finalizing file %R", self);
|
||||
}
|
||||
}
|
||||
PyErr_SetRaisedException(exc);
|
||||
}
|
||||
|
|
|
@ -314,7 +314,8 @@ iobase_finalize(PyObject *self)
|
|||
PyErr_Clear();
|
||||
res = PyObject_CallMethodNoArgs((PyObject *)self, &_Py_ID(close));
|
||||
if (res == NULL) {
|
||||
PyErr_WriteUnraisable(self);
|
||||
PyErr_FormatUnraisable("Exception ignored "
|
||||
"while finalizing file %R", self);
|
||||
}
|
||||
else {
|
||||
Py_DECREF(res);
|
||||
|
|
|
@ -5359,7 +5359,8 @@ sock_finalize(PyObject *self)
|
|||
if (PyErr_ResourceWarning((PyObject *)s, 1, "unclosed %R", s)) {
|
||||
/* Spurious errors can appear at shutdown */
|
||||
if (PyErr_ExceptionMatches(PyExc_Warning)) {
|
||||
PyErr_WriteUnraisable((PyObject *)s);
|
||||
PyErr_FormatUnraisable("Exception ignored while "
|
||||
"finalizing socket %R", s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue