Skip to content

Commit e63894b

Browse files
authored
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.
1 parent 9087243 commit e63894b

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

Include/cpython/ceval.h

-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
# error "this header file must not be included directly"
33
#endif
44

5-
PyAPI_FUNC(PyObject *) _PyEval_CallTracing(PyObject *func, PyObject *args);
6-
75
PyAPI_FUNC(void) PyEval_SetProfile(Py_tracefunc, PyObject *);
86
PyAPI_DATA(int) _PyEval_SetProfile(PyThreadState *tstate, Py_tracefunc func, PyObject *arg);
97
PyAPI_FUNC(void) PyEval_SetTrace(Py_tracefunc, PyObject *);

Include/internal/pycore_ceval.h

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ PyAPI_FUNC(void) _PyEval_SignalAsyncExc(PyInterpreterState *interp);
3434
extern PyStatus _PyEval_ReInitThreads(PyThreadState *tstate);
3535
#endif
3636

37+
// Used by sys.call_tracing()
38+
extern PyObject* _PyEval_CallTracing(PyObject *func, PyObject *args);
39+
3740
// Used by sys.get_asyncgen_hooks()
3841
extern PyObject* _PyEval_GetAsyncGenFirstiter(void);
3942
extern PyObject* _PyEval_GetAsyncGenFinalizer(void);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove the private undocumented function ``_PyEval_CallTracing()`` from the
2+
C API. Call the public :func:`sys.call_tracing` function instead. Patch by
3+
Victor Stinner.

Python/ceval.c

+7-4
Original file line numberDiff line numberDiff line change
@@ -6708,16 +6708,19 @@ call_trace(Py_tracefunc func, PyObject *obj,
67086708
return result;
67096709
}
67106710

6711-
PyObject *
6711+
PyObject*
67126712
_PyEval_CallTracing(PyObject *func, PyObject *args)
67136713
{
6714+
// Save and disable tracing
67146715
PyThreadState *tstate = _PyThreadState_GET();
67156716
int save_tracing = tstate->tracing;
67166717
int save_use_tracing = tstate->cframe->use_tracing;
6717-
PyObject *result;
6718-
67196718
tstate->tracing = 0;
6720-
result = PyObject_Call(func, args, NULL);
6719+
6720+
// Call the tracing function
6721+
PyObject *result = PyObject_Call(func, args, NULL);
6722+
6723+
// Restore tracing
67216724
tstate->tracing = save_tracing;
67226725
tstate->cframe->use_tracing = save_use_tracing;
67236726
return result;

0 commit comments

Comments
 (0)