diff options
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 14 | ||||
-rw-r--r-- | Python/sysmodule.c | 5 |
2 files changed, 11 insertions, 8 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) { diff --git a/Python/sysmodule.c b/Python/sysmodule.c index ae6d7c2..c89f81f 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1186,12 +1186,9 @@ static PyObject * sys_set_coroutine_origin_tracking_depth_impl(PyObject *module, int depth) /*[clinic end generated code: output=0a2123c1cc6759c5 input=a1d0a05f89d2c426]*/ { - PyThreadState *tstate = _PyThreadState_GET(); - if (depth < 0) { - _PyErr_SetString(tstate, PyExc_ValueError, "depth must be >= 0"); + if (_PyEval_SetCoroutineOriginTrackingDepth(depth) < 0) { return NULL; } - _PyEval_SetCoroutineOriginTrackingDepth(tstate, depth); Py_RETURN_NONE; } |