Coverage Report

Created: 2026-01-13 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython3/Objects/clinic/tupleobject.c.h
Line
Count
Source
1
/*[clinic input]
2
preserve
3
[clinic start generated code]*/
4
5
#include "pycore_modsupport.h"    // _PyArg_CheckPositional()
6
7
PyDoc_STRVAR(tuple_index__doc__,
8
"index($self, value, start=0, stop=sys.maxsize, /)\n"
9
"--\n"
10
"\n"
11
"Return first index of value.\n"
12
"\n"
13
"Raises ValueError if the value is not present.");
14
15
#define TUPLE_INDEX_METHODDEF    \
16
    {"index", _PyCFunction_CAST(tuple_index), METH_FASTCALL, tuple_index__doc__},
17
18
static PyObject *
19
tuple_index_impl(PyTupleObject *self, PyObject *value, Py_ssize_t start,
20
                 Py_ssize_t stop);
21
22
static PyObject *
23
tuple_index(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
24
0
{
25
0
    PyObject *return_value = NULL;
26
0
    PyObject *value;
27
0
    Py_ssize_t start = 0;
28
0
    Py_ssize_t stop = PY_SSIZE_T_MAX;
29
30
0
    if (!_PyArg_CheckPositional("index", nargs, 1, 3)) {
31
0
        goto exit;
32
0
    }
33
0
    value = args[0];
34
0
    if (nargs < 2) {
35
0
        goto skip_optional;
36
0
    }
37
0
    if (!_PyEval_SliceIndexNotNone(args[1], &start)) {
38
0
        goto exit;
39
0
    }
40
0
    if (nargs < 3) {
41
0
        goto skip_optional;
42
0
    }
43
0
    if (!_PyEval_SliceIndexNotNone(args[2], &stop)) {
44
0
        goto exit;
45
0
    }
46
0
skip_optional:
47
0
    return_value = tuple_index_impl((PyTupleObject *)self, value, start, stop);
48
49
0
exit:
50
0
    return return_value;
51
0
}
52
53
PyDoc_STRVAR(tuple_count__doc__,
54
"count($self, value, /)\n"
55
"--\n"
56
"\n"
57
"Return number of occurrences of value.");
58
59
#define TUPLE_COUNT_METHODDEF    \
60
    {"count", (PyCFunction)tuple_count, METH_O, tuple_count__doc__},
61
62
static PyObject *
63
tuple_count_impl(PyTupleObject *self, PyObject *value);
64
65
static PyObject *
66
tuple_count(PyObject *self, PyObject *value)
67
0
{
68
0
    PyObject *return_value = NULL;
69
70
0
    return_value = tuple_count_impl((PyTupleObject *)self, value);
71
72
0
    return return_value;
73
0
}
74
75
PyDoc_STRVAR(tuple_new__doc__,
76
"tuple(iterable=(), /)\n"
77
"--\n"
78
"\n"
79
"Built-in immutable sequence.\n"
80
"\n"
81
"If no argument is given, the constructor returns an empty tuple.\n"
82
"If iterable is specified the tuple is initialized from iterable\'s items.\n"
83
"\n"
84
"If the argument is a tuple, the return value is the same object.");
85
86
static PyObject *
87
tuple_new_impl(PyTypeObject *type, PyObject *iterable);
88
89
static PyObject *
90
tuple_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
91
263
{
92
263
    PyObject *return_value = NULL;
93
263
    PyTypeObject *base_tp = &PyTuple_Type;
94
263
    PyObject *iterable = NULL;
95
96
263
    if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
97
263
        !_PyArg_NoKeywords("tuple", kwargs)) {
98
0
        goto exit;
99
0
    }
100
263
    if (!_PyArg_CheckPositional("tuple", PyTuple_GET_SIZE(args), 0, 1)) {
101
0
        goto exit;
102
0
    }
103
263
    if (PyTuple_GET_SIZE(args) < 1) {
104
0
        goto skip_optional;
105
0
    }
106
263
    iterable = PyTuple_GET_ITEM(args, 0);
107
263
skip_optional:
108
263
    return_value = tuple_new_impl(type, iterable);
109
110
263
exit:
111
263
    return return_value;
112
263
}
113
114
PyDoc_STRVAR(tuple___getnewargs____doc__,
115
"__getnewargs__($self, /)\n"
116
"--\n"
117
"\n");
118
119
#define TUPLE___GETNEWARGS___METHODDEF    \
120
    {"__getnewargs__", (PyCFunction)tuple___getnewargs__, METH_NOARGS, tuple___getnewargs____doc__},
121
122
static PyObject *
123
tuple___getnewargs___impl(PyTupleObject *self);
124
125
static PyObject *
126
tuple___getnewargs__(PyObject *self, PyObject *Py_UNUSED(ignored))
127
0
{
128
0
    return tuple___getnewargs___impl((PyTupleObject *)self);
129
0
}
130
/*[clinic end generated code: output=bd11662d62d973c2 input=a9049054013a1b77]*/