summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-11-23 11:37:20 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-11-23 11:37:20 (GMT)
commit3728d6ced09eb3adac2e9fec6be38e1598720067 (patch)
tree70008dae2aea975cb3604173bdccfd66ac2d79cc /Modules
parented3b0bca3ef9d7bdbb8bd8e67e60e85f5a336da0 (diff)
downloadcpython-3728d6ced09eb3adac2e9fec6be38e1598720067.zip
cpython-3728d6ced09eb3adac2e9fec6be38e1598720067.tar.gz
cpython-3728d6ced09eb3adac2e9fec6be38e1598720067.tar.bz2
Issue #18874: Remove tracemalloc.set_traceback_limit()
tracemalloc.start() now has an option nframe parameter
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_tracemalloc.c49
1 files changed, 18 insertions, 31 deletions
diff --git a/Modules/_tracemalloc.c b/Modules/_tracemalloc.c
index 15ed734..9dd4b19 100644
--- a/Modules/_tracemalloc.c
+++ b/Modules/_tracemalloc.c
@@ -1151,13 +1151,27 @@ done:
}
PyDoc_STRVAR(tracemalloc_start_doc,
- "start()\n"
+ "start(nframe: int=1)\n"
"\n"
- "Start tracing Python memory allocations.");
+ "Start tracing Python memory allocations. Set also the maximum number \n"
+ "of frames stored in the traceback of a trace to nframe.");
static PyObject*
-py_tracemalloc_start(PyObject *self)
+py_tracemalloc_start(PyObject *self, PyObject *args)
{
+ Py_ssize_t nframe = 1;
+
+ if (!PyArg_ParseTuple(args, "|n:start", &nframe))
+ return NULL;
+
+ if (nframe < 1 || nframe > MAX_NFRAME) {
+ PyErr_Format(PyExc_ValueError,
+ "the number of frames must be in range [1; %i]",
+ MAX_NFRAME);
+ return NULL;
+ }
+ tracemalloc_config.max_nframe = Py_SAFE_DOWNCAST(nframe, Py_ssize_t, int);
+
if (tracemalloc_start() < 0)
return NULL;
@@ -1192,31 +1206,6 @@ py_tracemalloc_get_traceback_limit(PyObject *self)
return PyLong_FromLong(tracemalloc_config.max_nframe);
}
-PyDoc_STRVAR(tracemalloc_set_traceback_limit_doc,
- "set_traceback_limit(nframe: int)\n"
- "\n"
- "Set the maximum number of frames stored in the traceback of a trace.");
-
-static PyObject*
-tracemalloc_set_traceback_limit(PyObject *self, PyObject *args)
-{
- Py_ssize_t nframe;
-
- if (!PyArg_ParseTuple(args, "n:set_traceback_limit",
- &nframe))
- return NULL;
-
- if (nframe < 1 || nframe > MAX_NFRAME) {
- PyErr_Format(PyExc_ValueError,
- "the number of frames must be in range [1; %i]",
- MAX_NFRAME);
- return NULL;
- }
- tracemalloc_config.max_nframe = Py_SAFE_DOWNCAST(nframe, Py_ssize_t, int);
-
- Py_RETURN_NONE;
-}
-
PyDoc_STRVAR(tracemalloc_get_tracemalloc_memory_doc,
"get_tracemalloc_memory() -> int\n"
"\n"
@@ -1275,13 +1264,11 @@ static PyMethodDef module_methods[] = {
{"_get_object_traceback", (PyCFunction)py_tracemalloc_get_object_traceback,
METH_O, tracemalloc_get_object_traceback_doc},
{"start", (PyCFunction)py_tracemalloc_start,
- METH_NOARGS, tracemalloc_start_doc},
+ METH_VARARGS, tracemalloc_start_doc},
{"stop", (PyCFunction)py_tracemalloc_stop,
METH_NOARGS, tracemalloc_stop_doc},
{"get_traceback_limit", (PyCFunction)py_tracemalloc_get_traceback_limit,
METH_NOARGS, tracemalloc_get_traceback_limit_doc},
- {"set_traceback_limit", (PyCFunction)tracemalloc_set_traceback_limit,
- METH_VARARGS, tracemalloc_set_traceback_limit_doc},
{"get_tracemalloc_memory", (PyCFunction)tracemalloc_get_tracemalloc_memory,
METH_NOARGS, tracemalloc_get_tracemalloc_memory_doc},
{"get_traced_memory", (PyCFunction)tracemalloc_get_traced_memory,