diff options
Diffstat (limited to 'Modules/_testinternalcapi.c')
-rw-r--r-- | Modules/_testinternalcapi.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c index 3ea77e6..394b870 100644 --- a/Modules/_testinternalcapi.c +++ b/Modules/_testinternalcapi.c @@ -9,7 +9,7 @@ #define PY_SSIZE_T_CLEAN #include "Python.h" -#include "pycore_initconfig.h" +#include "pycore_initconfig.h" // _Py_GetConfigsAsDict() static PyObject * @@ -19,8 +19,19 @@ get_configs(PyObject *self, PyObject *Py_UNUSED(args)) } +static PyObject* +get_recursion_depth(PyObject *self, PyObject *args) +{ + PyThreadState *tstate = PyThreadState_Get(); + + /* subtract one to ignore the frame of the get_recursion_depth() call */ + return PyLong_FromLong(tstate->recursion_depth - 1); +} + + static PyMethodDef TestMethods[] = { {"get_configs", get_configs, METH_NOARGS}, + {"get_recursion_depth", get_recursion_depth, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; |