From a40c21ecab26f9a96c54e1a664bf81e7d35be666 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 6 Jul 2017 12:45:56 +0200 Subject: [PATCH] bpo-30866: Add _testcapi.stack_pointer() --- Modules/_testcapimodule.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index a68d839a7f7de0b..dbdbae079f44207 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -2540,6 +2540,16 @@ msvcrt_CrtSetReportFile(PyObject* self, PyObject *args) #endif +static PyObject* +stack_pointer(PyObject *self, PyObject *args) +{ + int v = 5; + Py_uintptr_t sp = (Py_uintptr_t)&v; + + return PyLong_FromUnsignedLongLong(sp); +} + + static PyMethodDef TestMethods[] = { {"raise_exception", raise_exception, METH_VARARGS}, {"set_errno", set_errno, METH_VARARGS}, @@ -2656,6 +2666,7 @@ static PyMethodDef TestMethods[] = { {"CrtSetReportMode", (PyCFunction)msvcrt_CrtSetReportMode, METH_VARARGS}, {"CrtSetReportFile", (PyCFunction)msvcrt_CrtSetReportFile, METH_VARARGS}, #endif + {"stack_pointer", stack_pointer, METH_NOARGS}, {NULL, NULL} /* sentinel */ };