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

If PySys_Audit() fails in PyEval_SetProfile() or PyEval_SetTrace(),
log the error as an unraisable exception.
This commit is contained in:
Victor Stinner 2020-03-16 17:41:44 +01:00 committed by GitHub
parent 356c878fbf
commit f6a5850782
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 2 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

@ -4620,7 +4620,10 @@ void
PyEval_SetProfile(Py_tracefunc func, PyObject *arg)
{
PyThreadState *tstate = _PyThreadState_GET();
(void)_PyEval_SetProfile(tstate, func, arg);
if (_PyEval_SetProfile(tstate, func, arg) < 0) {
/* Log PySys_Audit() error */
_PyErr_WriteUnraisableMsg("in PyEval_SetProfile", NULL);
}
}
int
@ -4661,7 +4664,10 @@ void
PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
{
PyThreadState *tstate = _PyThreadState_GET();
(void)_PyEval_SetTrace(tstate, func, arg);
if (_PyEval_SetTrace(tstate, func, arg) < 0) {
/* Log PySys_Audit() error */
_PyErr_WriteUnraisableMsg("in PyEval_SetTrace", NULL);
}
}