Coverage Report

Created: 2026-05-30 06:18

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