summaryrefslogtreecommitdiffstats
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-10-12 22:16:07 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-10-12 22:16:07 (GMT)
commitf7d2471260a5c0e9c957924881dbe6610c9aaf23 (patch)
tree987e4281fbf5f5487ceb6b6b79e1bd1a96394778 /Modules/_testcapimodule.c
parent397c42b8cca423b61055e1fa1e60c3f480c01df1 (diff)
parent50856d5ae745d1c9f691afbd78572bf073c941cf (diff)
downloadcpython-f7d2471260a5c0e9c957924881dbe6610c9aaf23.zip
cpython-f7d2471260a5c0e9c957924881dbe6610c9aaf23.tar.gz
cpython-f7d2471260a5c0e9c957924881dbe6610c9aaf23.tar.bz2
Merge 3.5 (sys.setrecursionlimit)
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 1f013c2..a896af0 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 */
};