mirror of
https://github.com/python/cpython.git
synced 2025-11-25 21:11:09 +00:00
signalmodule.c uses _PyErr_WriteUnraisableMsg() (#98217)
Signal wakeup fd errors are now logged with _PyErr_WriteUnraisableMsg(), rather than PySys_WriteStderr() and PyErr_WriteUnraisable(), to pass the error message to sys.unraisablehook. By default, it's still written into stderr (unless sys.unraisablehook is overriden).
This commit is contained in:
parent
a8c8526fd8
commit
342b1151ae
1 changed files with 6 additions and 7 deletions
|
|
@ -272,9 +272,8 @@ report_wakeup_write_error(void *data)
|
||||||
errno = (int) (intptr_t) data;
|
errno = (int) (intptr_t) data;
|
||||||
PyErr_Fetch(&exc, &val, &tb);
|
PyErr_Fetch(&exc, &val, &tb);
|
||||||
PyErr_SetFromErrno(PyExc_OSError);
|
PyErr_SetFromErrno(PyExc_OSError);
|
||||||
PySys_WriteStderr("Exception ignored when trying to write to the "
|
_PyErr_WriteUnraisableMsg("when trying to write to the signal wakeup fd",
|
||||||
"signal wakeup fd:\n");
|
NULL);
|
||||||
PyErr_WriteUnraisable(NULL);
|
|
||||||
PyErr_Restore(exc, val, tb);
|
PyErr_Restore(exc, val, tb);
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -284,15 +283,15 @@ report_wakeup_write_error(void *data)
|
||||||
static int
|
static int
|
||||||
report_wakeup_send_error(void* data)
|
report_wakeup_send_error(void* data)
|
||||||
{
|
{
|
||||||
|
int send_errno = (int) (intptr_t) data;
|
||||||
|
|
||||||
PyObject *exc, *val, *tb;
|
PyObject *exc, *val, *tb;
|
||||||
PyErr_Fetch(&exc, &val, &tb);
|
PyErr_Fetch(&exc, &val, &tb);
|
||||||
/* PyErr_SetExcFromWindowsErr() invokes FormatMessage() which
|
/* PyErr_SetExcFromWindowsErr() invokes FormatMessage() which
|
||||||
recognizes the error codes used by both GetLastError() and
|
recognizes the error codes used by both GetLastError() and
|
||||||
WSAGetLastError */
|
WSAGetLastError */
|
||||||
PyErr_SetExcFromWindowsErr(PyExc_OSError, (int) (intptr_t) data);
|
PyErr_SetExcFromWindowsErr(PyExc_OSError, send_errno);
|
||||||
PySys_WriteStderr("Exception ignored when trying to send to the "
|
_PyErr_WriteUnraisableMsg("when trying to send to the signal wakeup fd", NULL);
|
||||||
"signal wakeup fd:\n");
|
|
||||||
PyErr_WriteUnraisable(NULL);
|
|
||||||
PyErr_Restore(exc, val, tb);
|
PyErr_Restore(exc, val, tb);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue