Coverage Report

Created: 2026-12-01 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Objects/clinic/frameobject.c.h
Line
Count
Source
1
/*[clinic input]
2
preserve
3
[clinic start generated code]*/
4
5
#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
6
#include "pycore_modsupport.h"    // _PyArg_CheckPositional()
7
8
PyDoc_STRVAR(framelocalsproxy_new__doc__,
9
"FrameLocalsProxy(frame, /)\n"
10
"--\n"
11
"\n"
12
"Create a write-through view of the locals dictionary for a frame.\n"
13
"\n"
14
"  frame\n"
15
"    the frame object to wrap.");
16
17
static PyObject *
18
framelocalsproxy_new_impl(PyTypeObject *type, PyObject *frame);
19
20
static PyObject *
21
framelocalsproxy_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
22
0
{
23
0
    PyObject *return_value = NULL;
24
0
    PyTypeObject *base_tp = &PyFrameLocalsProxy_Type;
25
0
    PyObject *frame;
26
27
0
    if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
28
0
        !_PyArg_NoKeywords("FrameLocalsProxy", kwargs)) {
29
0
        goto exit;
30
0
    }
31
0
    if (!_PyArg_CheckPositional("FrameLocalsProxy", PyTuple_GET_SIZE(args), 1, 1)) {
32
0
        goto exit;
33
0
    }
34
0
    frame = PyTuple_GET_ITEM(args, 0);
35
0
    return_value = framelocalsproxy_new_impl(type, frame);
36
37
0
exit:
38
0
    return return_value;
39
0
}
40
41
static PyObject *
42
framelocalsproxy_vectorcall(PyObject *type, PyObject *const *args,
43
    size_t nargsf, PyObject *kwnames)
44
0
{
45
0
    PyObject *return_value = NULL;
46
0
    Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
47
0
    PyObject *frame;
48
49
0
    assert(_PyType_CAST(type)->tp_new == framelocalsproxy_new);
50
    /* Make sure the type object is immutable: the generated
51
     * vectorcall doesn't deal e.g. with users reassigning __init__. */
52
0
    assert(PyType_HasFeature(_PyType_CAST(type), Py_TPFLAGS_IMMUTABLETYPE));
53
0
    if (!_PyArg_NoKwnames("FrameLocalsProxy", kwnames)) {
54
0
        goto exit;
55
0
    }
56
0
    if (!_PyArg_CheckPositional("FrameLocalsProxy", nargs, 1, 1)) {
57
0
        goto exit;
58
0
    }
59
0
    frame = args[0];
60
0
    return_value = framelocalsproxy_new_impl(_PyType_CAST(type), frame);
61
62
0
exit:
63
0
    return return_value;
64
0
}
65
66
PyDoc_STRVAR(frame_locals__doc__,
67
"Return the mapping used by the frame to look up local variables.");
68
69
static PyObject *
70
frame_locals_get_impl(PyFrameObject *self);
71
72
static PyObject *
73
frame_locals_get(PyObject *self, void *Py_UNUSED(context))
74
37
{
75
37
    PyObject *return_value = NULL;
76
77
37
    Py_BEGIN_CRITICAL_SECTION(self);
78
37
    return_value = frame_locals_get_impl((PyFrameObject *)self);
79
37
    Py_END_CRITICAL_SECTION();
80
81
37
    return return_value;
82
37
}
83
84
PyDoc_STRVAR(frame_lineno__doc__,
85
"Return the current line number in the frame.");
86
87
static PyObject *
88
frame_lineno_get_impl(PyFrameObject *self);
89
90
static PyObject *
91
frame_lineno_get(PyObject *self, void *Py_UNUSED(context))
92
21.2k
{
93
21.2k
    PyObject *return_value = NULL;
94
95
21.2k
    Py_BEGIN_CRITICAL_SECTION(self);
96
21.2k
    return_value = frame_lineno_get_impl((PyFrameObject *)self);
97
21.2k
    Py_END_CRITICAL_SECTION();
98
99
21.2k
    return return_value;
100
21.2k
}
101
102
PyDoc_STRVAR(frame_lasti__doc__,
103
"Return the index of the last attempted instruction in the frame.");
104
105
static PyObject *
106
frame_lasti_get_impl(PyFrameObject *self);
107
108
static PyObject *
109
frame_lasti_get(PyObject *self, void *Py_UNUSED(context))
110
0
{
111
0
    PyObject *return_value = NULL;
112
113
0
    Py_BEGIN_CRITICAL_SECTION(self);
114
0
    return_value = frame_lasti_get_impl((PyFrameObject *)self);
115
0
    Py_END_CRITICAL_SECTION();
116
117
0
    return return_value;
118
0
}
119
120
PyDoc_STRVAR(frame_globals__doc__,
121
"Return the global variables in the frame.");
122
123
static PyObject *
124
frame_globals_get_impl(PyFrameObject *self);
125
126
static PyObject *
127
frame_globals_get(PyObject *self, void *Py_UNUSED(context))
128
0
{
129
0
    PyObject *return_value = NULL;
130
131
0
    Py_BEGIN_CRITICAL_SECTION(self);
132
0
    return_value = frame_globals_get_impl((PyFrameObject *)self);
133
0
    Py_END_CRITICAL_SECTION();
134
135
0
    return return_value;
136
0
}
137
138
PyDoc_STRVAR(frame_builtins__doc__,
139
"Return the built-in variables in the frame.");
140
141
static PyObject *
142
frame_builtins_get_impl(PyFrameObject *self);
143
144
static PyObject *
145
frame_builtins_get(PyObject *self, void *Py_UNUSED(context))
146
0
{
147
0
    PyObject *return_value = NULL;
148
149
0
    Py_BEGIN_CRITICAL_SECTION(self);
150
0
    return_value = frame_builtins_get_impl((PyFrameObject *)self);
151
0
    Py_END_CRITICAL_SECTION();
152
153
0
    return return_value;
154
0
}
155
156
PyDoc_STRVAR(frame_code__doc__,
157
"Return the code object being executed in this frame.");
158
159
static PyObject *
160
frame_code_get_impl(PyFrameObject *self);
161
162
static PyObject *
163
frame_code_get(PyObject *self, void *Py_UNUSED(context))
164
63.7k
{
165
63.7k
    return frame_code_get_impl((PyFrameObject *)self);
166
63.7k
}
167
168
static PyObject *
169
frame_back_get_impl(PyFrameObject *self);
170
171
static PyObject *
172
frame_back_get(PyObject *self, void *Py_UNUSED(context))
173
22.5k
{
174
22.5k
    PyObject *return_value = NULL;
175
176
22.5k
    Py_BEGIN_CRITICAL_SECTION(self);
177
22.5k
    return_value = frame_back_get_impl((PyFrameObject *)self);
178
22.5k
    Py_END_CRITICAL_SECTION();
179
180
22.5k
    return return_value;
181
22.5k
}
182
183
PyDoc_STRVAR(frame_trace_opcodes__doc__,
184
"Return True if opcode tracing is enabled, False otherwise.");
185
186
static PyObject *
187
frame_trace_opcodes_get_impl(PyFrameObject *self);
188
189
static PyObject *
190
frame_trace_opcodes_get(PyObject *self, void *Py_UNUSED(context))
191
0
{
192
0
    PyObject *return_value = NULL;
193
194
0
    Py_BEGIN_CRITICAL_SECTION(self);
195
0
    return_value = frame_trace_opcodes_get_impl((PyFrameObject *)self);
196
0
    Py_END_CRITICAL_SECTION();
197
198
0
    return return_value;
199
0
}
200
201
static int
202
frame_trace_opcodes_set_impl(PyFrameObject *self, PyObject *value);
203
204
static int
205
frame_trace_opcodes_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context))
206
0
{
207
0
    int return_value = -1;
208
0
    PyObject *value;
209
210
0
    if (arg == NULL) {
211
0
        PyErr_Format(PyExc_AttributeError,
212
0
                     "attribute 'f_trace_opcodes' of '%.100s' objects cannot be deleted",
213
0
                     Py_TYPE(self)->tp_name);
214
0
        return -1;
215
0
    }
216
0
    value = arg;
217
0
    Py_BEGIN_CRITICAL_SECTION(self);
218
0
    return_value = frame_trace_opcodes_set_impl((PyFrameObject *)self, value);
219
0
    Py_END_CRITICAL_SECTION();
220
221
0
    return return_value;
222
0
}
223
224
static int
225
frame_lineno_set_impl(PyFrameObject *self, PyObject *value);
226
227
static int
228
frame_lineno_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context))
229
0
{
230
0
    int return_value = -1;
231
0
    PyObject *value;
232
233
0
    if (arg == NULL) {
234
0
        PyErr_Format(PyExc_AttributeError,
235
0
                     "attribute 'f_lineno' of '%.100s' objects cannot be deleted",
236
0
                     Py_TYPE(self)->tp_name);
237
0
        return -1;
238
0
    }
239
0
    value = arg;
240
0
    Py_BEGIN_CRITICAL_SECTION(self);
241
0
    return_value = frame_lineno_set_impl((PyFrameObject *)self, value);
242
0
    Py_END_CRITICAL_SECTION();
243
244
0
    return return_value;
245
0
}
246
247
PyDoc_STRVAR(frame_trace__doc__,
248
"Return the trace function for this frame, or None if no trace function is set.");
249
250
static PyObject *
251
frame_trace_get_impl(PyFrameObject *self);
252
253
static PyObject *
254
frame_trace_get(PyObject *self, void *Py_UNUSED(context))
255
0
{
256
0
    PyObject *return_value = NULL;
257
258
0
    Py_BEGIN_CRITICAL_SECTION(self);
259
0
    return_value = frame_trace_get_impl((PyFrameObject *)self);
260
0
    Py_END_CRITICAL_SECTION();
261
262
0
    return return_value;
263
0
}
264
265
static int
266
frame_trace_set_impl(PyFrameObject *self, PyObject *value);
267
268
static int
269
frame_trace_set(PyObject *self, PyObject *arg, void *Py_UNUSED(context))
270
0
{
271
0
    int return_value = -1;
272
0
    PyObject *value = NULL;
273
274
0
    if (arg != NULL) {
275
0
        value = arg;
276
0
    }
277
0
    Py_BEGIN_CRITICAL_SECTION(self);
278
0
    return_value = frame_trace_set_impl((PyFrameObject *)self, value);
279
0
    Py_END_CRITICAL_SECTION();
280
281
0
    return return_value;
282
0
}
283
284
PyDoc_STRVAR(frame_generator__doc__,
285
"Return the generator or coroutine associated with this frame, or None.");
286
287
static PyObject *
288
frame_generator_get_impl(PyFrameObject *self);
289
290
static PyObject *
291
frame_generator_get(PyObject *self, void *Py_UNUSED(context))
292
0
{
293
0
    PyObject *return_value = NULL;
294
295
0
    Py_BEGIN_CRITICAL_SECTION(self);
296
0
    return_value = frame_generator_get_impl((PyFrameObject *)self);
297
0
    Py_END_CRITICAL_SECTION();
298
299
0
    return return_value;
300
0
}
301
302
PyDoc_STRVAR(frame_clear__doc__,
303
"clear($self, /)\n"
304
"--\n"
305
"\n"
306
"Clear all references held by the frame.");
307
308
#define FRAME_CLEAR_METHODDEF    \
309
    {"clear", (PyCFunction)frame_clear, METH_NOARGS, frame_clear__doc__},
310
311
static PyObject *
312
frame_clear_impl(PyFrameObject *self);
313
314
static PyObject *
315
frame_clear(PyObject *self, PyObject *Py_UNUSED(ignored))
316
0
{
317
0
    PyObject *return_value = NULL;
318
319
0
    Py_BEGIN_CRITICAL_SECTION(self);
320
0
    return_value = frame_clear_impl((PyFrameObject *)self);
321
0
    Py_END_CRITICAL_SECTION();
322
323
0
    return return_value;
324
0
}
325
326
PyDoc_STRVAR(frame___sizeof____doc__,
327
"__sizeof__($self, /)\n"
328
"--\n"
329
"\n"
330
"Return the size of the frame in memory, in bytes.");
331
332
#define FRAME___SIZEOF___METHODDEF    \
333
    {"__sizeof__", (PyCFunction)frame___sizeof__, METH_NOARGS, frame___sizeof____doc__},
334
335
static PyObject *
336
frame___sizeof___impl(PyFrameObject *self);
337
338
static PyObject *
339
frame___sizeof__(PyObject *self, PyObject *Py_UNUSED(ignored))
340
0
{
341
0
    PyObject *return_value = NULL;
342
343
0
    Py_BEGIN_CRITICAL_SECTION(self);
344
0
    return_value = frame___sizeof___impl((PyFrameObject *)self);
345
0
    Py_END_CRITICAL_SECTION();
346
347
0
    return return_value;
348
0
}
349
350
static PyObject *
351
frame_repr_impl(PyFrameObject *self);
352
353
static PyObject *
354
frame_repr(PyObject *self)
355
0
{
356
0
    PyObject *return_value = NULL;
357
358
0
    Py_BEGIN_CRITICAL_SECTION(self);
359
0
    return_value = frame_repr_impl((PyFrameObject *)self);
360
0
    Py_END_CRITICAL_SECTION();
361
362
0
    return return_value;
363
0
}
364
#define FRAME_F_LOCALS_GETSETDEF {"f_locals", (getter)frame_locals_get, (setter)NULL, frame_locals__doc__},
365
366
#define FRAME_F_LINENO_GETSETDEF {"f_lineno", (getter)frame_lineno_get, (setter)frame_lineno_set, frame_lineno__doc__},
367
368
#define FRAME_F_LASTI_GETSETDEF {"f_lasti", (getter)frame_lasti_get, (setter)NULL, frame_lasti__doc__},
369
370
#define FRAME_F_GLOBALS_GETSETDEF {"f_globals", (getter)frame_globals_get, (setter)NULL, frame_globals__doc__},
371
372
#define FRAME_F_BUILTINS_GETSETDEF {"f_builtins", (getter)frame_builtins_get, (setter)NULL, frame_builtins__doc__},
373
374
#define FRAME_F_CODE_GETSETDEF {"f_code", (getter)frame_code_get, (setter)NULL, frame_code__doc__},
375
376
#define FRAME_F_BACK_GETSETDEF {"f_back", (getter)frame_back_get, (setter)NULL, NULL},
377
378
#define FRAME_F_TRACE_OPCODES_GETSETDEF {"f_trace_opcodes", (getter)frame_trace_opcodes_get, (setter)frame_trace_opcodes_set, frame_trace_opcodes__doc__},
379
380
#define FRAME_F_TRACE_GETSETDEF {"f_trace", (getter)frame_trace_get, (setter)frame_trace_set, frame_trace__doc__},
381
382
#define FRAME_F_GENERATOR_GETSETDEF {"f_generator", (getter)frame_generator_get, (setter)NULL, frame_generator__doc__},
383
384
/*[clinic end generated code: output=e6d74bb87e4b1a95 input=a9049054013a1b77]*/