]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-46850: Remove _PyEval_CallTracing() function (GH-32019)
authorVictor Stinner <vstinner@python.org>
Mon, 21 Mar 2022 02:03:22 +0000 (03:03 +0100)
committerGitHub <noreply@github.com>
Mon, 21 Mar 2022 02:03:22 +0000 (03:03 +0100)
Remove the private undocumented function _PyEval_CallTracing() from
the C API. Call the public sys.call_tracing() function instead.

Include/cpython/ceval.h
Include/internal/pycore_ceval.h
Misc/NEWS.d/next/C API/2022-03-21-02-26-27.bpo-46850.hU3c-O.rst [new file with mode: 0644]
Python/ceval.c

index e0a68876015d606f36b98360f58d84e8a06c0a49..9d4eeafb427eb28b376bc7116b4d56dfff16b9d9 100644 (file)
@@ -2,8 +2,6 @@
 #  error "this header file must not be included directly"
 #endif
 
-PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
-
 PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
 PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
 PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);
index 59a3453f9fd3bccba469b11252e584c607a2031c..45d26a37a34c695751b6d5af39300913d24ec063 100644 (file)
@@ -34,6 +34,9 @@ PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
 extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
 #endif
 
+// Used by sys.call_tracing()
+extern PyObject* _PyEval_CallTracing(PyObject *func, PyObject *args);
+
 // Used by sys.get_asyncgen_hooks()
 extern PyObject* _PyEval_GetAsyncGenFirstiter(void);
 extern PyObject* _PyEval_GetAsyncGenFinalizer(void);
diff --git a/Misc/NEWS.d/next/C API/2022-03-21-02-26-27.bpo-46850.hU3c-O.rst b/Misc/NEWS.d/next/C API/2022-03-21-02-26-27.bpo-46850.hU3c-O.rst
new file mode 100644 (file)
index 0000000..f600ea8
--- /dev/null
@@ -0,0 +1,3 @@
+Remove the private undocumented function ``_PyEval_CallTracing()`` from the
+C API. Call the public :func:`sys.call_tracing` function instead. Patch by
+Victor Stinner.
index 04f2dde3cbdf91c80be227419e35e7eb03f7f7b0..6f449e3172d0836dd01a9e818d3270c8e75cd0d9 100644 (file)
@@ -6708,16 +6708,19 @@ call_trace(Py_tracefunc func, PyObject *obj,
     return result;
 }
 
-PyObject *
+PyObject*
 _PyEval_CallTracing(PyObject *func, PyObject *args)
 {
+    // Save and disable tracing
     PyThreadState *tstate = _PyThreadState_GET();
     int save_tracing = tstate->tracing;
     int save_use_tracing = tstate->cframe->use_tracing;
-    PyObject *result;
-
     tstate->tracing = 0;
-    result = PyObject_Call(func, args, NULL);
+
+    // Call the tracing function
+    PyObject *result = PyObject_Call(func, args, NULL);
+
+    // Restore tracing
     tstate->tracing = save_tracing;
     tstate->cframe->use_tracing = save_use_tracing;
     return result;