[Python-checkins] bpo-35370: PyEval_SetTrace() logs unraisable error (GH-18977) (GH-19029)

Victor Stinner webhook-mailer at python.org
Mon Mar 16 13:18:25 EDT 2020


https://github.com/python/cpython/commit/046255c40fc0d9c5a4c528eb5955792fa08df66f
commit: 046255c40fc0d9c5a4c528eb5955792fa08df66f
branch: 3.8
author: Victor Stinner <vstinner at python.org>
committer: GitHub <noreply at github.com>
date: 2020-03-16T18:18:20+01:00
summary:

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 f6a58507820c67e8d0fb07875cd1b1d9f5e510a8)

files:
A Misc/NEWS.d/next/C API/2020-03-13-16-44-23.bpo-35370.sXRA-r.rst
M 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
index 0000000000000..d3f1d293b6938
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2020-03-13-16-44-23.bpo-35370.sXRA-r.rst	
@@ -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.
diff --git a/Python/ceval.c b/Python/ceval.c
index 5d78d5a39357d..2db6e6bf8ebdb 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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;
     }
 



More information about the Python-checkins mailing list