]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-35370: PyEval_SetTrace() logs unraisable error (GH-18977)
authorVictor Stinner <vstinner@python.org>
Mon, 16 Mar 2020 16:41:44 +0000 (17:41 +0100)
committerGitHub <noreply@github.com>
Mon, 16 Mar 2020 16:41:44 +0000 (17:41 +0100)
If PySys_Audit() fails in PyEval_SetProfile() or PyEval_SetTrace(),
log the error as an unraisable exception.

Misc/NEWS.d/next/C API/2020-03-13-16-44-23.bpo-35370.sXRA-r.rst [new file with mode: 0644]
Python/ceval.c

diff --git a/Misc/NEWS.d/next/C API/2020-03-13-16-44-23.bpo-35370.sXRA-r.rst b/Misc/NEWS.d/next/C API/2020-03-13-16-44-23.bpo-35370.sXRA-r.rst
new file mode 100644 (file)
index 0000000..d3f1d29
--- /dev/null
@@ -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.
index fc4f718de28dde6c56963712b64071d67fcbffd9..b359fb079841cd30aa7711cbcecc19fbe8f9282e 100644 (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);
+    }
 }