diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-10-13 00:16:07 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-10-13 00:16:07 +0200 |
commit | f7d2471260a5c0e9c957924881dbe6610c9aaf23 (patch) | |
tree | 987e4281fbf5f5487ceb6b6b79e1bd1a96394778 /Modules/_testcapimodule.c | |
parent | 397c42b8cca423b61055e1fa1e60c3f480c01df1 (diff) | |
parent | 50856d5ae745d1c9f691afbd78572bf073c941cf (diff) | |
download | cpython-git-f7d2471260a5c0e9c957924881dbe6610c9aaf23.tar.gz |
Merge 3.5 (sys.setrecursionlimit)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r-- | Modules/_testcapimodule.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 1f013c21d5..a896af0cc0 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -3520,6 +3520,15 @@ test_PyTime_AsMicroseconds(PyObject *self, PyObject *args) return _PyTime_AsNanosecondsObject(ms); } +static PyObject* +get_recursion_depth(PyObject *self, PyObject *args) +{ + PyThreadState *tstate = PyThreadState_GET(); + + /* substract one to ignore the frame of the get_recursion_depth() call */ + return PyLong_FromLong(tstate->recursion_depth - 1); +} + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, @@ -3696,6 +3705,7 @@ static PyMethodDef TestMethods[] = { #endif {"PyTime_AsMilliseconds", test_PyTime_AsMilliseconds, METH_VARARGS}, {"PyTime_AsMicroseconds", test_PyTime_AsMicroseconds, METH_VARARGS}, + {"get_recursion_depth", get_recursion_depth, METH_NOARGS}, {NULL, NULL} /* sentinel */ }; |