bpo-35370: PyEval_SetTrace() logs unraisable error (GH-18977) (GH-19029)

If PySys_Audit() fails in PyEval_SetProfile() or PyEval_SetTrace(),
log the error as an unraisable exception.

(cherry picked from commit f6a5850782)
This commit is contained in:
Victor Stinner 2020-03-16 18:18:20 +01:00 committed by GitHub
parent 7f5302fed4
commit 046255c40f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 0 deletions

View File

@ -0,0 +1,2 @@
If :c:func:`PySys_Audit` fails in :c:func:`PyEval_SetProfile` or
:c:func:`PyEval_SetTrace`, log the error as an unraisable exception.

View File

@ -4686,6 +4686,7 @@ void
PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
{
if (PySys_Audit("sys.setprofile", NULL) < 0) {
_PyErr_WriteUnraisableMsg("in PyEval_SetProfile", NULL);
return;
}
@ -4707,6 +4708,7 @@ void
PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
{
if (PySys_Audit("sys.settrace", NULL) < 0) {
_PyErr_WriteUnraisableMsg("in PyEval_SetTrace", NULL);
return;
}