Skip to content

Commit e985804

Browse files
authored
bpo-37165: Convert _count_elements to the argument clinic (GH-13848)
1 parent c4c15ed commit e985804

File tree

3 files changed

+49
-12
lines changed

3 files changed

+49
-12
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Converted _collections._count_elements to use the Argument Clinic.

Modules/_collectionsmodule.c

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
#endif
99

1010
/*[clinic input]
11+
module _collections
1112
class _tuplegetter "_tuplegetterobject *" "&tuplegetter_type"
1213
[clinic start generated code]*/
13-
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=ee5ed5baabe35068]*/
14+
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=a8ece4ccad7e30ac]*/
1415

1516
static PyTypeObject tuplegetter_type;
1617
#include "clinic/_collectionsmodule.c.h"
@@ -2228,17 +2229,24 @@ static PyTypeObject defdict_type = {
22282229

22292230
/* helper function for Counter *********************************************/
22302231

2231-
PyDoc_STRVAR(_count_elements_doc,
2232-
"_count_elements(mapping, iterable) -> None\n\
2233-
\n\
2234-
Count elements in the iterable, updating the mapping");
2232+
/*[clinic input]
2233+
_collections._count_elements
2234+
2235+
mapping: object
2236+
iterable: object
2237+
/
2238+
2239+
Count elements in the iterable, updating the mapping
2240+
[clinic start generated code]*/
22352241

22362242
static PyObject *
2237-
_count_elements(PyObject *self, PyObject *args)
2243+
_collections__count_elements_impl(PyObject *module, PyObject *mapping,
2244+
PyObject *iterable)
2245+
/*[clinic end generated code: output=7e0c1789636b3d8f input=e79fad04534a0b45]*/
22382246
{
22392247
_Py_IDENTIFIER(get);
22402248
_Py_IDENTIFIER(__setitem__);
2241-
PyObject *it, *iterable, *mapping, *oldval;
2249+
PyObject *it, *oldval;
22422250
PyObject *newval = NULL;
22432251
PyObject *key = NULL;
22442252
PyObject *bound_get = NULL;
@@ -2247,9 +2255,6 @@ _count_elements(PyObject *self, PyObject *args)
22472255
PyObject *mapping_setitem;
22482256
PyObject *dict_setitem;
22492257

2250-
if (!PyArg_UnpackTuple(args, "_count_elements", 2, 2, &mapping, &iterable))
2251-
return NULL;
2252-
22532258
it = PyObject_GetIter(iterable);
22542259
if (it == NULL)
22552260
return NULL;
@@ -2510,7 +2515,7 @@ PyDoc_STRVAR(module_doc,
25102515
");
25112516

25122517
static struct PyMethodDef module_functions[] = {
2513-
{"_count_elements", _count_elements, METH_VARARGS, _count_elements_doc},
2518+
_COLLECTIONS__COUNT_ELEMENTS_METHODDEF
25142519
{NULL, NULL} /* sentinel */
25152520
};
25162521

Modules/clinic/_collectionsmodule.c.h

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)