Coverage Report

Created: 2026-12-01 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Objects/clinic/cellobject.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(cell_new__doc__,
8
"cell([contents])\n"
9
"--\n"
10
"\n"
11
"Create a new cell object.\n"
12
"\n"
13
"  contents\n"
14
"    the contents of the cell. If not specified, the cell will be empty,\n"
15
"    and further attempts to access its cell_contents attribute will\n"
16
"    raise a ValueError.");
17
18
static PyObject *
19
cell_new_impl(PyTypeObject *type, PyObject *contents);
20
21
static PyObject *
22
cell_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
23
0
{
24
0
    PyObject *return_value = NULL;
25
0
    PyTypeObject *base_tp = &PyCell_Type;
26
0
    PyObject *contents = NULL;
27
28
0
    if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
29
0
        !_PyArg_NoKeywords("cell", kwargs)) {
30
0
        goto exit;
31
0
    }
32
0
    if (!_PyArg_CheckPositional("cell", PyTuple_GET_SIZE(args), 0, 1)) {
33
0
        goto exit;
34
0
    }
35
0
    if (PyTuple_GET_SIZE(args) < 1) {
36
0
        goto skip_optional;
37
0
    }
38
0
    contents = PyTuple_GET_ITEM(args, 0);
39
0
skip_optional:
40
0
    return_value = cell_new_impl(type, contents);
41
42
0
exit:
43
0
    return return_value;
44
0
}
45
46
static PyObject *
47
cell_vectorcall(PyObject *type, PyObject *const *args,
48
    size_t nargsf, PyObject *kwnames)
49
0
{
50
0
    PyObject *return_value = NULL;
51
0
    Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
52
0
    PyObject *contents = NULL;
53
54
0
    assert(_PyType_CAST(type)->tp_new == cell_new);
55
    /* Make sure the type object is immutable: the generated
56
     * vectorcall doesn't deal e.g. with users reassigning __init__. */
57
0
    assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE));
58
0
    if (!_PyArg_NoKwnames("cell", kwnames)) {
59
0
        goto exit;
60
0
    }
61
0
    if (!_PyArg_CheckPositional("cell", nargs, 0, 1)) {
62
0
        goto exit;
63
0
    }
64
0
    if (nargs < 1) {
65
0
        goto skip_optional;
66
0
    }
67
0
    contents = args[0];
68
0
skip_optional:
69
0
    return_value = cell_new_impl(_PyType_CAST(type), contents);
70
71
0
exit:
72
0
    return return_value;
73
0
}
74
/*[clinic end generated code: output=687470647f1a75f8 input=a9049054013a1b77]*/