diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-05-29 00:57:56 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-29 00:57:56 (GMT) |
commit | 8b09500345d998f3ff1e363a5210bc87f42ff306 (patch) | |
tree | 3f03ee8d5f60fece00d48ae305253328413ae9d0 /Modules/_threadmodule.c | |
parent | b76302ddd0896cb39ce69909349b53db6e7776e2 (diff) | |
download | cpython-8b09500345d998f3ff1e363a5210bc87f42ff306.zip cpython-8b09500345d998f3ff1e363a5210bc87f42ff306.tar.gz cpython-8b09500345d998f3ff1e363a5210bc87f42ff306.tar.bz2 |
bpo-37076: _thread.start_new_thread() calls _PyErr_WriteUnraisableMsg() (GH-13617)
_thread.start_new_thread() now logs uncaught exception raised by the
function using sys.unraisablehook(), rather than sys.excepthook(), so
the hook gets access to the function which raised the exception.
Diffstat (limited to 'Modules/_threadmodule.c')
-rw-r--r-- | Modules/_threadmodule.c | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 680e8ca..2b1a98f 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -1002,25 +1002,15 @@ t_bootstrap(void *boot_raw) res = PyObject_Call(boot->func, boot->args, boot->keyw); if (res == NULL) { if (PyErr_ExceptionMatches(PyExc_SystemExit)) + /* SystemExit is ignored silently */ PyErr_Clear(); else { - PyObject *file; - PyObject *exc, *value, *tb; - PySys_WriteStderr( - "Unhandled exception in thread started by "); - PyErr_Fetch(&exc, &value, &tb); - file = _PySys_GetObjectId(&PyId_stderr); - if (file != NULL && file != Py_None) - PyFile_WriteObject(boot->func, file, 0); - else - PyObject_Print(boot->func, stderr, 0); - PySys_WriteStderr("\n"); - PyErr_Restore(exc, value, tb); - PyErr_PrintEx(0); + _PyErr_WriteUnraisableMsg("in thread started by", boot->func); } } - else + else { Py_DECREF(res); + } Py_DECREF(boot->func); Py_DECREF(boot->args); Py_XDECREF(boot->keyw); |