[Python-checkins] bpo-46850: Remove _PyEval_CallTracing() function (GH-32019)
vstinner
webhook-mailer at python.org
Sun Mar 20 22:03:36 EDT 2022
https://github.com/python/cpython/commit/e63894b3eed8ad2dd7690695f7f07bfbff59c05a
commit: e63894b3eed8ad2dd7690695f7f07bfbff59c05a
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-03-21T03:03:22+01:00
summary:
bpo-46850: Remove _PyEval_CallTracing() function (GH-32019)
Remove the private undocumented function _PyEval_CallTracing() from
the C API. Call the public sys.call_tracing() function instead.
files:
A Misc/NEWS.d/next/C API/2022-03-21-02-26-27.bpo-46850.hU3c-O.rst
M Include/cpython/ceval.h
M Include/internal/pycore_ceval.h
M Python/ceval.c
diff --git a/Include/cpython/ceval.h b/Include/cpython/ceval.h
index e0a68876015d6..9d4eeafb427eb 100644
--- a/Include/cpython/ceval.h
+++ b/Include/cpython/ceval.h
@@ -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 *);
diff --git a/Include/internal/pycore_ceval.h b/Include/internal/pycore_ceval.h
index 59a3453f9fd3b..45d26a37a34c6 100644
--- a/Include/internal/pycore_ceval.h
+++ b/Include/internal/pycore_ceval.h
@@ -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
index 0000000000000..f600ea8ea24f3
--- /dev/null
+++ b/Misc/NEWS.d/next/C API/2022-03-21-02-26-27.bpo-46850.hU3c-O.rst
@@ -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.
diff --git a/Python/ceval.c b/Python/ceval.c
index 04f2dde3cbdf9..6f449e3172d08 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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;
More information about the Python-checkins
mailing list