LCOV - code coverage report
Current view: top level - Modules/clinic - _collectionsmodule.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 16 29 55.2 %
Date: 2023-03-20 08:15:36 Functions: 1 2 50.0 %
Branches: 6 26 23.1 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(_collections__count_elements__doc__,
      12                 :            : "_count_elements($module, mapping, iterable, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Count elements in the iterable, updating the mapping");
      16                 :            : 
      17                 :            : #define _COLLECTIONS__COUNT_ELEMENTS_METHODDEF    \
      18                 :            :     {"_count_elements", _PyCFunction_CAST(_collections__count_elements), METH_FASTCALL, _collections__count_elements__doc__},
      19                 :            : 
      20                 :            : static PyObject *
      21                 :            : _collections__count_elements_impl(PyObject *module, PyObject *mapping,
      22                 :            :                                   PyObject *iterable);
      23                 :            : 
      24                 :            : static PyObject *
      25                 :          0 : _collections__count_elements(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      26                 :            : {
      27                 :          0 :     PyObject *return_value = NULL;
      28                 :            :     PyObject *mapping;
      29                 :            :     PyObject *iterable;
      30                 :            : 
      31   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("_count_elements", nargs, 2, 2)) {
                   #  # ]
      32                 :          0 :         goto exit;
      33                 :            :     }
      34                 :          0 :     mapping = args[0];
      35                 :          0 :     iterable = args[1];
      36                 :          0 :     return_value = _collections__count_elements_impl(module, mapping, iterable);
      37                 :            : 
      38                 :          0 : exit:
      39                 :          0 :     return return_value;
      40                 :            : }
      41                 :            : 
      42                 :            : static PyObject *
      43                 :            : tuplegetter_new_impl(PyTypeObject *type, Py_ssize_t index, PyObject *doc);
      44                 :            : 
      45                 :            : static PyObject *
      46                 :        255 : tuplegetter_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
      47                 :            : {
      48                 :        255 :     PyObject *return_value = NULL;
      49                 :        255 :     PyTypeObject *base_tp = &tuplegetter_type;
      50                 :            :     Py_ssize_t index;
      51                 :            :     PyObject *doc;
      52                 :            : 
      53   [ -  +  -  -  :        255 :     if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
                   -  + ]
      54         [ #  # ]:          0 :         !_PyArg_NoKeywords("_tuplegetter", kwargs)) {
      55                 :          0 :         goto exit;
      56                 :            :     }
      57   [ +  -  -  +  :        255 :     if (!_PyArg_CheckPositional("_tuplegetter", PyTuple_GET_SIZE(args), 2, 2)) {
                   -  - ]
      58                 :          0 :         goto exit;
      59                 :            :     }
      60                 :            :     {
      61                 :        255 :         Py_ssize_t ival = -1;
      62                 :        255 :         PyObject *iobj = _PyNumber_Index(PyTuple_GET_ITEM(args, 0));
      63         [ +  - ]:        255 :         if (iobj != NULL) {
      64                 :        255 :             ival = PyLong_AsSsize_t(iobj);
      65                 :        255 :             Py_DECREF(iobj);
      66                 :            :         }
      67   [ -  +  -  - ]:        255 :         if (ival == -1 && PyErr_Occurred()) {
      68                 :          0 :             goto exit;
      69                 :            :         }
      70                 :        255 :         index = ival;
      71                 :            :     }
      72                 :        255 :     doc = PyTuple_GET_ITEM(args, 1);
      73                 :        255 :     return_value = tuplegetter_new_impl(type, index, doc);
      74                 :            : 
      75                 :        255 : exit:
      76                 :        255 :     return return_value;
      77                 :            : }
      78                 :            : /*[clinic end generated code: output=91a0f221c7b1f96c input=a9049054013a1b77]*/

Generated by: LCOV version 1.14