Coverage Report

Created: 2026-09-01 06:32

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