Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Modules/_io/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Modules/_io/iobase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
Loading