summaryrefslogtreecommitdiffstats
path: root/Python/ceval.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-03-21 01:24:00 (GMT)
committerGitHub <noreply@github.com>2022-03-21 01:24:00 (GMT)
commit9087243e2c167e38570e819b228efc3492c38c9c (patch)
treed59acfac968561a9518027489f8478dfccdf0607 /Python/ceval.c
parent332b04bac35cd7305c60da2d5733940dc089949a (diff)
downloadcpython-9087243e2c167e38570e819b228efc3492c38c9c.zip
cpython-9087243e2c167e38570e819b228efc3492c38c9c.tar.gz
cpython-9087243e2c167e38570e819b228efc3492c38c9c.tar.bz2
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.
Diffstat (limited to 'Python/ceval.c')
-rw-r--r--Python/ceval.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index 1a120bb..04f2dde 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -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)
{