Branch data Line data Source code
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 : :
10 : :
11 : : PyDoc_STRVAR(code_new__doc__,
12 : : "code(argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize,\n"
13 : : " flags, codestring, constants, names, varnames, filename, name,\n"
14 : : " qualname, firstlineno, linetable, exceptiontable, freevars=(),\n"
15 : : " cellvars=(), /)\n"
16 : : "--\n"
17 : : "\n"
18 : : "Create a code object. Not for the faint of heart.");
19 : :
20 : : static PyObject *
21 : : code_new_impl(PyTypeObject *type, int argcount, int posonlyargcount,
22 : : int kwonlyargcount, int nlocals, int stacksize, int flags,
23 : : PyObject *code, PyObject *consts, PyObject *names,
24 : : PyObject *varnames, PyObject *filename, PyObject *name,
25 : : PyObject *qualname, int firstlineno, PyObject *linetable,
26 : : PyObject *exceptiontable, PyObject *freevars,
27 : : PyObject *cellvars);
28 : :
29 : : static PyObject *
30 : 0 : code_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
31 : : {
32 : 0 : PyObject *return_value = NULL;
33 : 0 : PyTypeObject *base_tp = &PyCode_Type;
34 : : int argcount;
35 : : int posonlyargcount;
36 : : int kwonlyargcount;
37 : : int nlocals;
38 : : int stacksize;
39 : : int flags;
40 : : PyObject *code;
41 : : PyObject *consts;
42 : : PyObject *names;
43 : : PyObject *varnames;
44 : : PyObject *filename;
45 : : PyObject *name;
46 : : PyObject *qualname;
47 : : int firstlineno;
48 : : PyObject *linetable;
49 : : PyObject *exceptiontable;
50 : 0 : PyObject *freevars = NULL;
51 : 0 : PyObject *cellvars = NULL;
52 : :
53 [ # # # # : 0 : if ((type == base_tp || type->tp_init == base_tp->tp_init) &&
# # ]
54 [ # # ]: 0 : !_PyArg_NoKeywords("code", kwargs)) {
55 : 0 : goto exit;
56 : : }
57 [ # # # # : 0 : if (!_PyArg_CheckPositional("code", PyTuple_GET_SIZE(args), 16, 18)) {
# # ]
58 : 0 : goto exit;
59 : : }
60 : 0 : argcount = _PyLong_AsInt(PyTuple_GET_ITEM(args, 0));
61 [ # # # # ]: 0 : if (argcount == -1 && PyErr_Occurred()) {
62 : 0 : goto exit;
63 : : }
64 : 0 : posonlyargcount = _PyLong_AsInt(PyTuple_GET_ITEM(args, 1));
65 [ # # # # ]: 0 : if (posonlyargcount == -1 && PyErr_Occurred()) {
66 : 0 : goto exit;
67 : : }
68 : 0 : kwonlyargcount = _PyLong_AsInt(PyTuple_GET_ITEM(args, 2));
69 [ # # # # ]: 0 : if (kwonlyargcount == -1 && PyErr_Occurred()) {
70 : 0 : goto exit;
71 : : }
72 : 0 : nlocals = _PyLong_AsInt(PyTuple_GET_ITEM(args, 3));
73 [ # # # # ]: 0 : if (nlocals == -1 && PyErr_Occurred()) {
74 : 0 : goto exit;
75 : : }
76 : 0 : stacksize = _PyLong_AsInt(PyTuple_GET_ITEM(args, 4));
77 [ # # # # ]: 0 : if (stacksize == -1 && PyErr_Occurred()) {
78 : 0 : goto exit;
79 : : }
80 : 0 : flags = _PyLong_AsInt(PyTuple_GET_ITEM(args, 5));
81 [ # # # # ]: 0 : if (flags == -1 && PyErr_Occurred()) {
82 : 0 : goto exit;
83 : : }
84 [ # # ]: 0 : if (!PyBytes_Check(PyTuple_GET_ITEM(args, 6))) {
85 : 0 : _PyArg_BadArgument("code", "argument 7", "bytes", PyTuple_GET_ITEM(args, 6));
86 : 0 : goto exit;
87 : : }
88 : 0 : code = PyTuple_GET_ITEM(args, 6);
89 [ # # ]: 0 : if (!PyTuple_Check(PyTuple_GET_ITEM(args, 7))) {
90 : 0 : _PyArg_BadArgument("code", "argument 8", "tuple", PyTuple_GET_ITEM(args, 7));
91 : 0 : goto exit;
92 : : }
93 : 0 : consts = PyTuple_GET_ITEM(args, 7);
94 [ # # ]: 0 : if (!PyTuple_Check(PyTuple_GET_ITEM(args, 8))) {
95 : 0 : _PyArg_BadArgument("code", "argument 9", "tuple", PyTuple_GET_ITEM(args, 8));
96 : 0 : goto exit;
97 : : }
98 : 0 : names = PyTuple_GET_ITEM(args, 8);
99 [ # # ]: 0 : if (!PyTuple_Check(PyTuple_GET_ITEM(args, 9))) {
100 : 0 : _PyArg_BadArgument("code", "argument 10", "tuple", PyTuple_GET_ITEM(args, 9));
101 : 0 : goto exit;
102 : : }
103 : 0 : varnames = PyTuple_GET_ITEM(args, 9);
104 [ # # ]: 0 : if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 10))) {
105 : 0 : _PyArg_BadArgument("code", "argument 11", "str", PyTuple_GET_ITEM(args, 10));
106 : 0 : goto exit;
107 : : }
108 [ # # ]: 0 : if (PyUnicode_READY(PyTuple_GET_ITEM(args, 10)) == -1) {
109 : 0 : goto exit;
110 : : }
111 : 0 : filename = PyTuple_GET_ITEM(args, 10);
112 [ # # ]: 0 : if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 11))) {
113 : 0 : _PyArg_BadArgument("code", "argument 12", "str", PyTuple_GET_ITEM(args, 11));
114 : 0 : goto exit;
115 : : }
116 [ # # ]: 0 : if (PyUnicode_READY(PyTuple_GET_ITEM(args, 11)) == -1) {
117 : 0 : goto exit;
118 : : }
119 : 0 : name = PyTuple_GET_ITEM(args, 11);
120 [ # # ]: 0 : if (!PyUnicode_Check(PyTuple_GET_ITEM(args, 12))) {
121 : 0 : _PyArg_BadArgument("code", "argument 13", "str", PyTuple_GET_ITEM(args, 12));
122 : 0 : goto exit;
123 : : }
124 [ # # ]: 0 : if (PyUnicode_READY(PyTuple_GET_ITEM(args, 12)) == -1) {
125 : 0 : goto exit;
126 : : }
127 : 0 : qualname = PyTuple_GET_ITEM(args, 12);
128 : 0 : firstlineno = _PyLong_AsInt(PyTuple_GET_ITEM(args, 13));
129 [ # # # # ]: 0 : if (firstlineno == -1 && PyErr_Occurred()) {
130 : 0 : goto exit;
131 : : }
132 [ # # ]: 0 : if (!PyBytes_Check(PyTuple_GET_ITEM(args, 14))) {
133 : 0 : _PyArg_BadArgument("code", "argument 15", "bytes", PyTuple_GET_ITEM(args, 14));
134 : 0 : goto exit;
135 : : }
136 : 0 : linetable = PyTuple_GET_ITEM(args, 14);
137 [ # # ]: 0 : if (!PyBytes_Check(PyTuple_GET_ITEM(args, 15))) {
138 : 0 : _PyArg_BadArgument("code", "argument 16", "bytes", PyTuple_GET_ITEM(args, 15));
139 : 0 : goto exit;
140 : : }
141 : 0 : exceptiontable = PyTuple_GET_ITEM(args, 15);
142 [ # # ]: 0 : if (PyTuple_GET_SIZE(args) < 17) {
143 : 0 : goto skip_optional;
144 : : }
145 [ # # ]: 0 : if (!PyTuple_Check(PyTuple_GET_ITEM(args, 16))) {
146 : 0 : _PyArg_BadArgument("code", "argument 17", "tuple", PyTuple_GET_ITEM(args, 16));
147 : 0 : goto exit;
148 : : }
149 : 0 : freevars = PyTuple_GET_ITEM(args, 16);
150 [ # # ]: 0 : if (PyTuple_GET_SIZE(args) < 18) {
151 : 0 : goto skip_optional;
152 : : }
153 [ # # ]: 0 : if (!PyTuple_Check(PyTuple_GET_ITEM(args, 17))) {
154 : 0 : _PyArg_BadArgument("code", "argument 18", "tuple", PyTuple_GET_ITEM(args, 17));
155 : 0 : goto exit;
156 : : }
157 : 0 : cellvars = PyTuple_GET_ITEM(args, 17);
158 : 0 : skip_optional:
159 : 0 : return_value = code_new_impl(type, argcount, posonlyargcount, kwonlyargcount, nlocals, stacksize, flags, code, consts, names, varnames, filename, name, qualname, firstlineno, linetable, exceptiontable, freevars, cellvars);
160 : :
161 : 0 : exit:
162 : 0 : return return_value;
163 : : }
164 : :
165 : : PyDoc_STRVAR(code_replace__doc__,
166 : : "replace($self, /, *, co_argcount=-1, co_posonlyargcount=-1,\n"
167 : : " co_kwonlyargcount=-1, co_nlocals=-1, co_stacksize=-1,\n"
168 : : " co_flags=-1, co_firstlineno=-1, co_code=None, co_consts=None,\n"
169 : : " co_names=None, co_varnames=None, co_freevars=None,\n"
170 : : " co_cellvars=None, co_filename=None, co_name=None,\n"
171 : : " co_qualname=None, co_linetable=None, co_exceptiontable=None)\n"
172 : : "--\n"
173 : : "\n"
174 : : "Return a copy of the code object with new values for the specified fields.");
175 : :
176 : : #define CODE_REPLACE_METHODDEF \
177 : : {"replace", _PyCFunction_CAST(code_replace), METH_FASTCALL|METH_KEYWORDS, code_replace__doc__},
178 : :
179 : : static PyObject *
180 : : code_replace_impl(PyCodeObject *self, int co_argcount,
181 : : int co_posonlyargcount, int co_kwonlyargcount,
182 : : int co_nlocals, int co_stacksize, int co_flags,
183 : : int co_firstlineno, PyBytesObject *co_code,
184 : : PyObject *co_consts, PyObject *co_names,
185 : : PyObject *co_varnames, PyObject *co_freevars,
186 : : PyObject *co_cellvars, PyObject *co_filename,
187 : : PyObject *co_name, PyObject *co_qualname,
188 : : PyBytesObject *co_linetable,
189 : : PyBytesObject *co_exceptiontable);
190 : :
191 : : static PyObject *
192 : 1 : code_replace(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
193 : : {
194 : 1 : PyObject *return_value = NULL;
195 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
196 : :
197 : : #define NUM_KEYWORDS 18
198 : : static struct {
199 : : PyGC_Head _this_is_not_used;
200 : : PyObject_VAR_HEAD
201 : : PyObject *ob_item[NUM_KEYWORDS];
202 : : } _kwtuple = {
203 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
204 : : .ob_item = { &_Py_ID(co_argcount), &_Py_ID(co_posonlyargcount), &_Py_ID(co_kwonlyargcount), &_Py_ID(co_nlocals), &_Py_ID(co_stacksize), &_Py_ID(co_flags), &_Py_ID(co_firstlineno), &_Py_ID(co_code), &_Py_ID(co_consts), &_Py_ID(co_names), &_Py_ID(co_varnames), &_Py_ID(co_freevars), &_Py_ID(co_cellvars), &_Py_ID(co_filename), &_Py_ID(co_name), &_Py_ID(co_qualname), &_Py_ID(co_linetable), &_Py_ID(co_exceptiontable), },
205 : : };
206 : : #undef NUM_KEYWORDS
207 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
208 : :
209 : : #else // !Py_BUILD_CORE
210 : : # define KWTUPLE NULL
211 : : #endif // !Py_BUILD_CORE
212 : :
213 : : static const char * const _keywords[] = {"co_argcount", "co_posonlyargcount", "co_kwonlyargcount", "co_nlocals", "co_stacksize", "co_flags", "co_firstlineno", "co_code", "co_consts", "co_names", "co_varnames", "co_freevars", "co_cellvars", "co_filename", "co_name", "co_qualname", "co_linetable", "co_exceptiontable", NULL};
214 : : static _PyArg_Parser _parser = {
215 : : .keywords = _keywords,
216 : : .fname = "replace",
217 : : .kwtuple = KWTUPLE,
218 : : };
219 : : #undef KWTUPLE
220 : : PyObject *argsbuf[18];
221 [ + - ]: 1 : Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
222 : 1 : int co_argcount = self->co_argcount;
223 : 1 : int co_posonlyargcount = self->co_posonlyargcount;
224 : 1 : int co_kwonlyargcount = self->co_kwonlyargcount;
225 : 1 : int co_nlocals = self->co_nlocals;
226 : 1 : int co_stacksize = self->co_stacksize;
227 : 1 : int co_flags = self->co_flags;
228 : 1 : int co_firstlineno = self->co_firstlineno;
229 : 1 : PyBytesObject *co_code = NULL;
230 : 1 : PyObject *co_consts = self->co_consts;
231 : 1 : PyObject *co_names = self->co_names;
232 : 1 : PyObject *co_varnames = NULL;
233 : 1 : PyObject *co_freevars = NULL;
234 : 1 : PyObject *co_cellvars = NULL;
235 : 1 : PyObject *co_filename = self->co_filename;
236 : 1 : PyObject *co_name = self->co_name;
237 : 1 : PyObject *co_qualname = self->co_qualname;
238 : 1 : PyBytesObject *co_linetable = (PyBytesObject *)self->co_linetable;
239 : 1 : PyBytesObject *co_exceptiontable = (PyBytesObject *)self->co_exceptiontable;
240 : :
241 [ - + - - : 1 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
- - - - ]
242 [ - + ]: 1 : if (!args) {
243 : 0 : goto exit;
244 : : }
245 [ - + ]: 1 : if (!noptargs) {
246 : 0 : goto skip_optional_kwonly;
247 : : }
248 [ - + ]: 1 : if (args[0]) {
249 : 0 : co_argcount = _PyLong_AsInt(args[0]);
250 [ # # # # ]: 0 : if (co_argcount == -1 && PyErr_Occurred()) {
251 : 0 : goto exit;
252 : : }
253 [ # # ]: 0 : if (!--noptargs) {
254 : 0 : goto skip_optional_kwonly;
255 : : }
256 : : }
257 [ - + ]: 1 : if (args[1]) {
258 : 0 : co_posonlyargcount = _PyLong_AsInt(args[1]);
259 [ # # # # ]: 0 : if (co_posonlyargcount == -1 && PyErr_Occurred()) {
260 : 0 : goto exit;
261 : : }
262 [ # # ]: 0 : if (!--noptargs) {
263 : 0 : goto skip_optional_kwonly;
264 : : }
265 : : }
266 [ - + ]: 1 : if (args[2]) {
267 : 0 : co_kwonlyargcount = _PyLong_AsInt(args[2]);
268 [ # # # # ]: 0 : if (co_kwonlyargcount == -1 && PyErr_Occurred()) {
269 : 0 : goto exit;
270 : : }
271 [ # # ]: 0 : if (!--noptargs) {
272 : 0 : goto skip_optional_kwonly;
273 : : }
274 : : }
275 [ - + ]: 1 : if (args[3]) {
276 : 0 : co_nlocals = _PyLong_AsInt(args[3]);
277 [ # # # # ]: 0 : if (co_nlocals == -1 && PyErr_Occurred()) {
278 : 0 : goto exit;
279 : : }
280 [ # # ]: 0 : if (!--noptargs) {
281 : 0 : goto skip_optional_kwonly;
282 : : }
283 : : }
284 [ - + ]: 1 : if (args[4]) {
285 : 0 : co_stacksize = _PyLong_AsInt(args[4]);
286 [ # # # # ]: 0 : if (co_stacksize == -1 && PyErr_Occurred()) {
287 : 0 : goto exit;
288 : : }
289 [ # # ]: 0 : if (!--noptargs) {
290 : 0 : goto skip_optional_kwonly;
291 : : }
292 : : }
293 [ + - ]: 1 : if (args[5]) {
294 : 1 : co_flags = _PyLong_AsInt(args[5]);
295 [ - + - - ]: 1 : if (co_flags == -1 && PyErr_Occurred()) {
296 : 0 : goto exit;
297 : : }
298 [ + - ]: 1 : if (!--noptargs) {
299 : 1 : goto skip_optional_kwonly;
300 : : }
301 : : }
302 [ # # ]: 0 : if (args[6]) {
303 : 0 : co_firstlineno = _PyLong_AsInt(args[6]);
304 [ # # # # ]: 0 : if (co_firstlineno == -1 && PyErr_Occurred()) {
305 : 0 : goto exit;
306 : : }
307 [ # # ]: 0 : if (!--noptargs) {
308 : 0 : goto skip_optional_kwonly;
309 : : }
310 : : }
311 [ # # ]: 0 : if (args[7]) {
312 [ # # ]: 0 : if (!PyBytes_Check(args[7])) {
313 : 0 : _PyArg_BadArgument("replace", "argument 'co_code'", "bytes", args[7]);
314 : 0 : goto exit;
315 : : }
316 : 0 : co_code = (PyBytesObject *)args[7];
317 [ # # ]: 0 : if (!--noptargs) {
318 : 0 : goto skip_optional_kwonly;
319 : : }
320 : : }
321 [ # # ]: 0 : if (args[8]) {
322 [ # # ]: 0 : if (!PyTuple_Check(args[8])) {
323 : 0 : _PyArg_BadArgument("replace", "argument 'co_consts'", "tuple", args[8]);
324 : 0 : goto exit;
325 : : }
326 : 0 : co_consts = args[8];
327 [ # # ]: 0 : if (!--noptargs) {
328 : 0 : goto skip_optional_kwonly;
329 : : }
330 : : }
331 [ # # ]: 0 : if (args[9]) {
332 [ # # ]: 0 : if (!PyTuple_Check(args[9])) {
333 : 0 : _PyArg_BadArgument("replace", "argument 'co_names'", "tuple", args[9]);
334 : 0 : goto exit;
335 : : }
336 : 0 : co_names = args[9];
337 [ # # ]: 0 : if (!--noptargs) {
338 : 0 : goto skip_optional_kwonly;
339 : : }
340 : : }
341 [ # # ]: 0 : if (args[10]) {
342 [ # # ]: 0 : if (!PyTuple_Check(args[10])) {
343 : 0 : _PyArg_BadArgument("replace", "argument 'co_varnames'", "tuple", args[10]);
344 : 0 : goto exit;
345 : : }
346 : 0 : co_varnames = args[10];
347 [ # # ]: 0 : if (!--noptargs) {
348 : 0 : goto skip_optional_kwonly;
349 : : }
350 : : }
351 [ # # ]: 0 : if (args[11]) {
352 [ # # ]: 0 : if (!PyTuple_Check(args[11])) {
353 : 0 : _PyArg_BadArgument("replace", "argument 'co_freevars'", "tuple", args[11]);
354 : 0 : goto exit;
355 : : }
356 : 0 : co_freevars = args[11];
357 [ # # ]: 0 : if (!--noptargs) {
358 : 0 : goto skip_optional_kwonly;
359 : : }
360 : : }
361 [ # # ]: 0 : if (args[12]) {
362 [ # # ]: 0 : if (!PyTuple_Check(args[12])) {
363 : 0 : _PyArg_BadArgument("replace", "argument 'co_cellvars'", "tuple", args[12]);
364 : 0 : goto exit;
365 : : }
366 : 0 : co_cellvars = args[12];
367 [ # # ]: 0 : if (!--noptargs) {
368 : 0 : goto skip_optional_kwonly;
369 : : }
370 : : }
371 [ # # ]: 0 : if (args[13]) {
372 [ # # ]: 0 : if (!PyUnicode_Check(args[13])) {
373 : 0 : _PyArg_BadArgument("replace", "argument 'co_filename'", "str", args[13]);
374 : 0 : goto exit;
375 : : }
376 [ # # ]: 0 : if (PyUnicode_READY(args[13]) == -1) {
377 : 0 : goto exit;
378 : : }
379 : 0 : co_filename = args[13];
380 [ # # ]: 0 : if (!--noptargs) {
381 : 0 : goto skip_optional_kwonly;
382 : : }
383 : : }
384 [ # # ]: 0 : if (args[14]) {
385 [ # # ]: 0 : if (!PyUnicode_Check(args[14])) {
386 : 0 : _PyArg_BadArgument("replace", "argument 'co_name'", "str", args[14]);
387 : 0 : goto exit;
388 : : }
389 [ # # ]: 0 : if (PyUnicode_READY(args[14]) == -1) {
390 : 0 : goto exit;
391 : : }
392 : 0 : co_name = args[14];
393 [ # # ]: 0 : if (!--noptargs) {
394 : 0 : goto skip_optional_kwonly;
395 : : }
396 : : }
397 [ # # ]: 0 : if (args[15]) {
398 [ # # ]: 0 : if (!PyUnicode_Check(args[15])) {
399 : 0 : _PyArg_BadArgument("replace", "argument 'co_qualname'", "str", args[15]);
400 : 0 : goto exit;
401 : : }
402 [ # # ]: 0 : if (PyUnicode_READY(args[15]) == -1) {
403 : 0 : goto exit;
404 : : }
405 : 0 : co_qualname = args[15];
406 [ # # ]: 0 : if (!--noptargs) {
407 : 0 : goto skip_optional_kwonly;
408 : : }
409 : : }
410 [ # # ]: 0 : if (args[16]) {
411 [ # # ]: 0 : if (!PyBytes_Check(args[16])) {
412 : 0 : _PyArg_BadArgument("replace", "argument 'co_linetable'", "bytes", args[16]);
413 : 0 : goto exit;
414 : : }
415 : 0 : co_linetable = (PyBytesObject *)args[16];
416 [ # # ]: 0 : if (!--noptargs) {
417 : 0 : goto skip_optional_kwonly;
418 : : }
419 : : }
420 [ # # ]: 0 : if (!PyBytes_Check(args[17])) {
421 : 0 : _PyArg_BadArgument("replace", "argument 'co_exceptiontable'", "bytes", args[17]);
422 : 0 : goto exit;
423 : : }
424 : 0 : co_exceptiontable = (PyBytesObject *)args[17];
425 : 1 : skip_optional_kwonly:
426 : 1 : return_value = code_replace_impl(self, co_argcount, co_posonlyargcount, co_kwonlyargcount, co_nlocals, co_stacksize, co_flags, co_firstlineno, co_code, co_consts, co_names, co_varnames, co_freevars, co_cellvars, co_filename, co_name, co_qualname, co_linetable, co_exceptiontable);
427 : :
428 : 1 : exit:
429 : 1 : return return_value;
430 : : }
431 : :
432 : : PyDoc_STRVAR(code__varname_from_oparg__doc__,
433 : : "_varname_from_oparg($self, /, oparg)\n"
434 : : "--\n"
435 : : "\n"
436 : : "(internal-only) Return the local variable name for the given oparg.\n"
437 : : "\n"
438 : : "WARNING: this method is for internal use only and may change or go away.");
439 : :
440 : : #define CODE__VARNAME_FROM_OPARG_METHODDEF \
441 : : {"_varname_from_oparg", _PyCFunction_CAST(code__varname_from_oparg), METH_FASTCALL|METH_KEYWORDS, code__varname_from_oparg__doc__},
442 : :
443 : : static PyObject *
444 : : code__varname_from_oparg_impl(PyCodeObject *self, int oparg);
445 : :
446 : : static PyObject *
447 : 0 : code__varname_from_oparg(PyCodeObject *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
448 : : {
449 : 0 : PyObject *return_value = NULL;
450 : : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
451 : :
452 : : #define NUM_KEYWORDS 1
453 : : static struct {
454 : : PyGC_Head _this_is_not_used;
455 : : PyObject_VAR_HEAD
456 : : PyObject *ob_item[NUM_KEYWORDS];
457 : : } _kwtuple = {
458 : : .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
459 : : .ob_item = { &_Py_ID(oparg), },
460 : : };
461 : : #undef NUM_KEYWORDS
462 : : #define KWTUPLE (&_kwtuple.ob_base.ob_base)
463 : :
464 : : #else // !Py_BUILD_CORE
465 : : # define KWTUPLE NULL
466 : : #endif // !Py_BUILD_CORE
467 : :
468 : : static const char * const _keywords[] = {"oparg", NULL};
469 : : static _PyArg_Parser _parser = {
470 : : .keywords = _keywords,
471 : : .fname = "_varname_from_oparg",
472 : : .kwtuple = KWTUPLE,
473 : : };
474 : : #undef KWTUPLE
475 : : PyObject *argsbuf[1];
476 : : int oparg;
477 : :
478 [ # # # # : 0 : args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
# # # # ]
479 [ # # ]: 0 : if (!args) {
480 : 0 : goto exit;
481 : : }
482 : 0 : oparg = _PyLong_AsInt(args[0]);
483 [ # # # # ]: 0 : if (oparg == -1 && PyErr_Occurred()) {
484 : 0 : goto exit;
485 : : }
486 : 0 : return_value = code__varname_from_oparg_impl(self, oparg);
487 : :
488 : 0 : exit:
489 : 0 : return return_value;
490 : : }
491 : : /*[clinic end generated code: output=f1fab6e71c785182 input=a9049054013a1b77]*/
|