summaryrefslogtreecommitdiffstats
path: root/Modules/clinic
diff options
context:
space:
mode:
authorPablo Galindo <Pablogsal@gmail.com>2019-02-23 03:02:06 (GMT)
committerInada Naoki <methane@users.noreply.github.com>2019-02-23 03:02:06 (GMT)
commit175421b58cc97a2555e474f479f30a6c5d2250b0 (patch)
tree05724237baa3c2334c7a0cd07081009cf9a7dc5b /Modules/clinic
parentdf5cdc11123a35065bbf1636251447d0bfe789a5 (diff)
downloadcpython-175421b58cc97a2555e474f479f30a6c5d2250b0.zip
cpython-175421b58cc97a2555e474f479f30a6c5d2250b0.tar.gz
cpython-175421b58cc97a2555e474f479f30a6c5d2250b0.tar.bz2
bpo-36016: Add generation option to gc.getobjects() (GH-11909)
Diffstat (limited to 'Modules/clinic')
-rw-r--r--Modules/clinic/gcmodule.c.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/Modules/clinic/gcmodule.c.h b/Modules/clinic/gcmodule.c.h
index 4fd2ea0..eece045 100644
--- a/Modules/clinic/gcmodule.c.h
+++ b/Modules/clinic/gcmodule.c.h
@@ -216,21 +216,39 @@ gc_get_count(PyObject *module, PyObject *Py_UNUSED(ignored))
}
PyDoc_STRVAR(gc_get_objects__doc__,
-"get_objects($module, /)\n"
+"get_objects($module, /, generation=None)\n"
"--\n"
"\n"
-"Return a list of objects tracked by the collector (excluding the list returned).");
+"Return a list of objects tracked by the collector (excluding the list returned).\n"
+"\n"
+" generation\n"
+" Generation to extract the objects from.\n"
+"\n"
+"If generation is not None, return only the objects tracked by the collector\n"
+"that are in that generation.");
#define GC_GET_OBJECTS_METHODDEF \
- {"get_objects", (PyCFunction)gc_get_objects, METH_NOARGS, gc_get_objects__doc__},
+ {"get_objects", (PyCFunction)(void(*)(void))gc_get_objects, METH_FASTCALL|METH_KEYWORDS, gc_get_objects__doc__},
static PyObject *
-gc_get_objects_impl(PyObject *module);
+gc_get_objects_impl(PyObject *module, Py_ssize_t generation);
static PyObject *
-gc_get_objects(PyObject *module, PyObject *Py_UNUSED(ignored))
+gc_get_objects(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
{
- return gc_get_objects_impl(module);
+ PyObject *return_value = NULL;
+ static const char * const _keywords[] = {"generation", NULL};
+ static _PyArg_Parser _parser = {"|O&:get_objects", _keywords, 0};
+ Py_ssize_t generation = -1;
+
+ if (!_PyArg_ParseStackAndKeywords(args, nargs, kwnames, &_parser,
+ _Py_convert_optional_to_ssize_t, &generation)) {
+ goto exit;
+ }
+ return_value = gc_get_objects_impl(module, generation);
+
+exit:
+ return return_value;
}
PyDoc_STRVAR(gc_get_stats__doc__,
@@ -331,4 +349,4 @@ gc_get_freeze_count(PyObject *module, PyObject *Py_UNUSED(ignored))
exit:
return return_value;
}
-/*[clinic end generated code: output=5aa5fdc259503d5f input=a9049054013a1b77]*/
+/*[clinic end generated code: output=d692bf475f0bb096 input=a9049054013a1b77]*/