Coverage Report

Created: 2026-10-31 06:21

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Objects/clinic/sentinelobject.c.h
Line
Count
Source
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
#include "pycore_modsupport.h"    // _PyArg_UnpackKeywords()
10
11
static PyObject *
12
sentinel_new_impl(PyTypeObject *type, PyObject *name, PyObject *repr);
13
14
static PyObject *
15
sentinel_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
16
124
{
17
124
    PyObject *return_value = NULL;
18
124
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
19
20
124
    #define NUM_KEYWORDS 1
21
124
    static struct {
22
124
        PyGC_Head _this_is_not_used;
23
124
        PyObject_VAR_HEAD
24
124
        Py_hash_t ob_hash;
25
124
        PyObject *ob_item[NUM_KEYWORDS];
26
124
    } _kwtuple = {
27
124
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
28
124
        .ob_hash = -1,
29
124
        .ob_item = { &_Py_ID(repr), },
30
124
    };
31
124
    #undef NUM_KEYWORDS
32
124
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
33
34
    #else  // !Py_BUILD_CORE
35
    #  define KWTUPLE NULL
36
    #endif  // !Py_BUILD_CORE
37
38
124
    static const char * const _keywords[] = {"", "repr", NULL};
39
124
    static _PyArg_Parser _parser = {
40
124
        .keywords = _keywords,
41
124
        .fname = "sentinel",
42
124
        .kwtuple = KWTUPLE,
43
124
    };
44
124
    #undef KWTUPLE
45
124
    PyObject *argsbuf[2];
46
124
    PyObject * const *fastargs;
47
124
    Py_ssize_t nargs = PyTuple_GET_SIZE(args);
48
124
    Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
49
124
    PyObject *name;
50
124
    PyObject *repr = Py_None;
51
52
124
    fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
53
124
            /*minpos*/ 1, /*maxpos*/ 1, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
54
124
    if (!fastargs) {
55
0
        goto exit;
56
0
    }
57
124
    if (!PyUnicode_Check(fastargs[0])) {
58
0
        _PyArg_BadArgument("sentinel", "argument 1", "str", fastargs[0]);
59
0
        goto exit;
60
0
    }
61
124
    name = fastargs[0];
62
124
    if (!noptargs) {
63
120
        goto skip_optional_kwonly;
64
120
    }
65
4
    repr = fastargs[1];
66
124
skip_optional_kwonly:
67
124
    return_value = sentinel_new_impl(type, name, repr);
68
69
124
exit:
70
124
    return return_value;
71
124
}
72
/*[clinic end generated code: output=958842ece254c82f input=a9049054013a1b77]*/