Coverage Report

Created: 2025-07-04 06:49

/src/cpython/Objects/clinic/interpolationobject.c.h
Line
Count
Source (jump to first uncovered line)
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
interpolation_new_impl(PyTypeObject *type, PyObject *value,
13
                       PyObject *expression, PyObject *conversion,
14
                       PyObject *format_spec);
15
16
static PyObject *
17
interpolation_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
18
0
{
19
0
    PyObject *return_value = NULL;
20
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
21
22
0
    #define NUM_KEYWORDS 4
23
0
    static struct {
24
0
        PyGC_Head _this_is_not_used;
25
0
        PyObject_VAR_HEAD
26
0
        Py_hash_t ob_hash;
27
0
        PyObject *ob_item[NUM_KEYWORDS];
28
0
    } _kwtuple = {
29
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
30
0
        .ob_hash = -1,
31
0
        .ob_item = { &_Py_ID(value), &_Py_ID(expression), &_Py_ID(conversion), &_Py_ID(format_spec), },
32
0
    };
33
0
    #undef NUM_KEYWORDS
34
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
35
36
    #else  // !Py_BUILD_CORE
37
    #  define KWTUPLE NULL
38
    #endif  // !Py_BUILD_CORE
39
40
0
    static const char * const _keywords[] = {"value", "expression", "conversion", "format_spec", NULL};
41
0
    static _PyArg_Parser _parser = {
42
0
        .keywords = _keywords,
43
0
        .fname = "Interpolation",
44
0
        .kwtuple = KWTUPLE,
45
0
    };
46
0
    #undef KWTUPLE
47
0
    PyObject *argsbuf[4];
48
0
    PyObject * const *fastargs;
49
0
    Py_ssize_t nargs = PyTuple_GET_SIZE(args);
50
0
    Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 2;
51
0
    PyObject *value;
52
0
    PyObject *expression;
53
0
    PyObject *conversion = Py_None;
54
0
    PyObject *format_spec = &_Py_STR(empty);
55
56
0
    fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser,
57
0
            /*minpos*/ 2, /*maxpos*/ 4, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
58
0
    if (!fastargs) {
59
0
        goto exit;
60
0
    }
61
0
    value = fastargs[0];
62
0
    if (!PyUnicode_Check(fastargs[1])) {
63
0
        _PyArg_BadArgument("Interpolation", "argument 'expression'", "str", fastargs[1]);
64
0
        goto exit;
65
0
    }
66
0
    expression = fastargs[1];
67
0
    if (!noptargs) {
68
0
        goto skip_optional_pos;
69
0
    }
70
0
    if (fastargs[2]) {
71
0
        if (!_conversion_converter(fastargs[2], &conversion)) {
72
0
            goto exit;
73
0
        }
74
0
        if (!--noptargs) {
75
0
            goto skip_optional_pos;
76
0
        }
77
0
    }
78
0
    if (!PyUnicode_Check(fastargs[3])) {
79
0
        _PyArg_BadArgument("Interpolation", "argument 'format_spec'", "str", fastargs[3]);
80
0
        goto exit;
81
0
    }
82
0
    format_spec = fastargs[3];
83
0
skip_optional_pos:
84
0
    return_value = interpolation_new_impl(type, value, expression, conversion, format_spec);
85
86
0
exit:
87
0
    return return_value;
88
0
}
89
/*[clinic end generated code: output=599742a5ccd6f060 input=a9049054013a1b77]*/