bpo-46850: Remove _PyEval_GetCoroutineOriginTrackingDepth() (GH-32018)

Remove the private undocumented function
_PyEval_GetCoroutineOriginTrackingDepth() from the C API. Call the
public sys.get_coroutine_origin_tracking_depth() function instead.

Change the internal function
_PyEval_SetCoroutineOriginTrackingDepth():

* Remove the 'tstate' parameter;
* Add return value and raises an exception if depth is negative;
* No longer export the function: call the public
  sys.set_coroutine_origin_tracking_depth() function instead.

Uniformize also function declarations in pycore_ceval.h.
This commit is contained in:
Victor Stinner 2022-03-21 02:24:00 +01:00 committed by GitHub
parent 332b04bac3
commit 9087243e2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 17 deletions

View file

@ -6852,13 +6852,19 @@ PyEval_SetTrace(Py_tracefunc func, PyObject *arg)
}
void
_PyEval_SetCoroutineOriginTrackingDepth(PyThreadState *tstate, int new_depth)
int
_PyEval_SetCoroutineOriginTrackingDepth(int depth)
{
assert(new_depth >= 0);
tstate->coroutine_origin_tracking_depth = new_depth;
PyThreadState *tstate = _PyThreadState_GET();
if (depth < 0) {
_PyErr_SetString(tstate, PyExc_ValueError, "depth must be >= 0");
return -1;
}
tstate->coroutine_origin_tracking_depth = depth;
return 0;
}
int
_PyEval_GetCoroutineOriginTrackingDepth(void)
{