summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-10-12 15:26:58 (GMT)
committerGitHub <noreply@github.com>2022-10-12 15:26:58 (GMT)
commit342b1151ae7e6ae849c1ed7c8a2cbfdb4edcf51c (patch)
treeecbfbb2aa4d5223ecbaaebd223dc23e397b89e5b /Modules
parenta8c8526fd8ce2f3f50837bbbb820741e54b58512 (diff)
downloadcpython-342b1151ae7e6ae849c1ed7c8a2cbfdb4edcf51c.zip
cpython-342b1151ae7e6ae849c1ed7c8a2cbfdb4edcf51c.tar.gz
cpython-342b1151ae7e6ae849c1ed7c8a2cbfdb4edcf51c.tar.bz2
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).
Diffstat (limited to 'Modules')
-rw-r--r--Modules/signalmodule.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index b85d6d1..bdd3f4b 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -272,9 +272,8 @@ report_wakeup_write_error(void *data)
errno = (int) (intptr_t) data;
PyErr_Fetch(&exc, &val, &tb);
PyErr_SetFromErrno(PyExc_OSError);
- PySys_WriteStderr("Exception ignored when trying to write to the "
- "signal wakeup fd:\n");
- PyErr_WriteUnraisable(NULL);
+ _PyErr_WriteUnraisableMsg("when trying to write to the signal wakeup fd",
+ NULL);
PyErr_Restore(exc, val, tb);
errno = save_errno;
return 0;
@@ -284,15 +283,15 @@ report_wakeup_write_error(void *data)
static int
report_wakeup_send_error(void* data)
{
+ int send_errno = (int) (intptr_t) data;
+
PyObject *exc, *val, *tb;
PyErr_Fetch(&exc, &val, &tb);
/* PyErr_SetExcFromWindowsErr() invokes FormatMessage() which
recognizes the error codes used by both GetLastError() and
WSAGetLastError */
- PyErr_SetExcFromWindowsErr(PyExc_OSError, (int) (intptr_t) data);
- PySys_WriteStderr("Exception ignored when trying to send to the "
- "signal wakeup fd:\n");
- PyErr_WriteUnraisable(NULL);
+ PyErr_SetExcFromWindowsErr(PyExc_OSError, send_errno);
+ _PyErr_WriteUnraisableMsg("when trying to send to the signal wakeup fd", NULL);
PyErr_Restore(exc, val, tb);
return 0;
}