Coverage Report

Created: 2025-11-24 06:11

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Modules/clinic/symtablemodule.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
PyDoc_STRVAR(_symtable_symtable__doc__,
12
"symtable($module, source, filename, startstr, /, *, module=None)\n"
13
"--\n"
14
"\n"
15
"Return symbol and scope dictionaries used internally by compiler.");
16
17
#define _SYMTABLE_SYMTABLE_METHODDEF    \
18
    {"symtable", _PyCFunction_CAST(_symtable_symtable), METH_FASTCALL|METH_KEYWORDS, _symtable_symtable__doc__},
19
20
static PyObject *
21
_symtable_symtable_impl(PyObject *module, PyObject *source,
22
                        PyObject *filename, const char *startstr,
23
                        PyObject *modname);
24
25
static PyObject *
26
_symtable_symtable(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
27
0
{
28
0
    PyObject *return_value = NULL;
29
0
    #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
30
31
0
    #define NUM_KEYWORDS 1
32
0
    static struct {
33
0
        PyGC_Head _this_is_not_used;
34
0
        PyObject_VAR_HEAD
35
0
        Py_hash_t ob_hash;
36
0
        PyObject *ob_item[NUM_KEYWORDS];
37
0
    } _kwtuple = {
38
0
        .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
39
0
        .ob_hash = -1,
40
0
        .ob_item = { &_Py_ID(module), },
41
0
    };
42
0
    #undef NUM_KEYWORDS
43
0
    #define KWTUPLE (&_kwtuple.ob_base.ob_base)
44
45
    #else  // !Py_BUILD_CORE
46
    #  define KWTUPLE NULL
47
    #endif  // !Py_BUILD_CORE
48
49
0
    static const char * const _keywords[] = {"", "", "", "module", NULL};
50
0
    static _PyArg_Parser _parser = {
51
0
        .keywords = _keywords,
52
0
        .fname = "symtable",
53
0
        .kwtuple = KWTUPLE,
54
0
    };
55
0
    #undef KWTUPLE
56
0
    PyObject *argsbuf[4];
57
0
    Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
58
0
    PyObject *source;
59
0
    PyObject *filename = NULL;
60
0
    const char *startstr;
61
0
    PyObject *modname = Py_None;
62
63
0
    args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser,
64
0
            /*minpos*/ 3, /*maxpos*/ 3, /*minkw*/ 0, /*varpos*/ 0, argsbuf);
65
0
    if (!args) {
66
0
        goto exit;
67
0
    }
68
0
    source = args[0];
69
0
    if (!PyUnicode_FSDecoder(args[1], &filename)) {
70
0
        goto exit;
71
0
    }
72
0
    if (!PyUnicode_Check(args[2])) {
73
0
        _PyArg_BadArgument("symtable", "argument 3", "str", args[2]);
74
0
        goto exit;
75
0
    }
76
0
    Py_ssize_t startstr_length;
77
0
    startstr = PyUnicode_AsUTF8AndSize(args[2], &startstr_length);
78
0
    if (startstr == NULL) {
79
0
        goto exit;
80
0
    }
81
0
    if (strlen(startstr) != (size_t)startstr_length) {
82
0
        PyErr_SetString(PyExc_ValueError, "embedded null character");
83
0
        goto exit;
84
0
    }
85
0
    if (!noptargs) {
86
0
        goto skip_optional_kwonly;
87
0
    }
88
0
    modname = args[3];
89
0
skip_optional_kwonly:
90
0
    return_value = _symtable_symtable_impl(module, source, filename, startstr, modname);
91
92
0
exit:
93
    /* Cleanup for filename */
94
0
    Py_XDECREF(filename);
95
96
0
    return return_value;
97
0
}
98
/*[clinic end generated code: output=0137be60c487c841 input=a9049054013a1b77]*/