mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-39947: Move get_recursion_depth() to _testinternalcapi (GH-18974)
Move get_recursion_depth() function from _testcapi to _testinternalcapi to avoid accessing PyThreadState attributes directly in _testcapi.
This commit is contained in:
parent
224481a8c9
commit
3f2f4fefca
4 changed files with 19 additions and 16 deletions
|
|
@ -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 */
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue