summaryrefslogtreecommitdiff
path: root/Modules/_testcapimodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-13 13:07:31 +0100
committerGitHub <noreply@github.com>2020-03-13 13:07:31 +0100
commit3f2f4fefca388bc62fc2a7d07cb6ef24197c84bd (patch)
tree7f4c00316acc193d3a00daf660af48dd67f6ad48 /Modules/_testcapimodule.c
parent224481a8c988fca12f488544edd2f01c0af2a91d (diff)
downloadcpython-git-3f2f4fefca388bc62fc2a7d07cb6ef24197c84bd.tar.gz
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.
Diffstat (limited to 'Modules/_testcapimodule.c')
-rw-r--r--Modules/_testcapimodule.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 3132f52158..3cc558689b 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -5,9 +5,11 @@
* standard Python regression test, via Lib/test/test_capi.py.
*/
-/* The Visual Studio projects builds _testcapi with Py_BUILD_CORE_MODULE
- define, but we only want to test the public C API, not the internal
- C API. */
+/* This module tests the public (Include/ and Include/cpython/) C API.
+ The internal C API must not be used here: use _testinternalcapi for that.
+
+ The Visual Studio projects builds _testcapi with Py_BUILD_CORE_MODULE
+ macro defined, but only the public C API must be tested here. */
#undef Py_BUILD_CORE_MODULE
#define PY_SSIZE_T_CLEAN
@@ -4524,15 +4526,6 @@ test_PyTime_AsMicroseconds(PyObject *self, PyObject *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 PyObject*
pymem_buffer_overflow(PyObject *self, PyObject *args)
{
char *buffer;
@@ -5486,7 +5479,6 @@ 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},
{"pymem_buffer_overflow", pymem_buffer_overflow, METH_NOARGS},
{"pymem_api_misuse", pymem_api_misuse, METH_NOARGS},
{"pymem_malloc_without_gil", pymem_malloc_without_gil, METH_NOARGS},