Coverage Report

Created: 2026-12-01 06:09

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/cpython/Python/Python-ast.c
Line
Count
Source
1
// File automatically generated by Parser/asdl_c.py.
2
3
#include "Python.h"
4
#include "pycore_ast.h"
5
#include "pycore_ast_state.h"     // struct ast_state
6
#include "pycore_ceval.h"         // _Py_EnterRecursiveCall()
7
#include "pycore_lock.h"          // _PyOnceFlag
8
#include "pycore_modsupport.h"    // _PyArg_NoPositional()
9
#include "pycore_pystate.h"       // _PyInterpreterState_GET()
10
#include "pycore_runtime.h"       // _Py_ID()
11
#include "pycore_setobject.h"     // _PySet_NextEntry()
12
#include "pycore_unionobject.h"   // _Py_union_type_or
13
14
#include <stddef.h>               // offsetof()
15
16
17
// Forward declaration
18
static int init_types(void *arg);
19
20
static struct ast_state*
21
get_ast_state(void)
22
75.5k
{
23
75.5k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
75.5k
    struct ast_state *state = &interp->ast;
25
75.5k
    assert(!state->finalized);
26
75.5k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
75.5k
    return state;
30
75.5k
}
31
32
void _PyAST_Fini(PyInterpreterState *interp)
33
0
{
34
0
    struct ast_state *state = &interp->ast;
35
36
0
    static const size_t offsets[] = {
37
0
        offsetof(struct ast_state, AST_type),
38
0
        offsetof(struct ast_state, Add_singleton),
39
0
        offsetof(struct ast_state, Add_type),
40
0
        offsetof(struct ast_state, And_singleton),
41
0
        offsetof(struct ast_state, And_type),
42
0
        offsetof(struct ast_state, AnnAssign_type),
43
0
        offsetof(struct ast_state, Assert_type),
44
0
        offsetof(struct ast_state, Assign_type),
45
0
        offsetof(struct ast_state, AsyncFor_type),
46
0
        offsetof(struct ast_state, AsyncFunctionDef_type),
47
0
        offsetof(struct ast_state, AsyncWith_type),
48
0
        offsetof(struct ast_state, Attribute_type),
49
0
        offsetof(struct ast_state, AugAssign_type),
50
0
        offsetof(struct ast_state, Await_type),
51
0
        offsetof(struct ast_state, BinOp_type),
52
0
        offsetof(struct ast_state, BitAnd_singleton),
53
0
        offsetof(struct ast_state, BitAnd_type),
54
0
        offsetof(struct ast_state, BitOr_singleton),
55
0
        offsetof(struct ast_state, BitOr_type),
56
0
        offsetof(struct ast_state, BitXor_singleton),
57
0
        offsetof(struct ast_state, BitXor_type),
58
0
        offsetof(struct ast_state, BoolOp_type),
59
0
        offsetof(struct ast_state, Break_type),
60
0
        offsetof(struct ast_state, Call_type),
61
0
        offsetof(struct ast_state, ClassDef_type),
62
0
        offsetof(struct ast_state, Compare_type),
63
0
        offsetof(struct ast_state, Constant_type),
64
0
        offsetof(struct ast_state, Continue_type),
65
0
        offsetof(struct ast_state, Del_singleton),
66
0
        offsetof(struct ast_state, Del_type),
67
0
        offsetof(struct ast_state, Delete_type),
68
0
        offsetof(struct ast_state, DictComp_type),
69
0
        offsetof(struct ast_state, Dict_type),
70
0
        offsetof(struct ast_state, Div_singleton),
71
0
        offsetof(struct ast_state, Div_type),
72
0
        offsetof(struct ast_state, Eq_singleton),
73
0
        offsetof(struct ast_state, Eq_type),
74
0
        offsetof(struct ast_state, ExceptHandler_type),
75
0
        offsetof(struct ast_state, Expr_type),
76
0
        offsetof(struct ast_state, Expression_type),
77
0
        offsetof(struct ast_state, FloorDiv_singleton),
78
0
        offsetof(struct ast_state, FloorDiv_type),
79
0
        offsetof(struct ast_state, For_type),
80
0
        offsetof(struct ast_state, FormattedValue_type),
81
0
        offsetof(struct ast_state, FunctionDef_type),
82
0
        offsetof(struct ast_state, FunctionType_type),
83
0
        offsetof(struct ast_state, GeneratorExp_type),
84
0
        offsetof(struct ast_state, Global_type),
85
0
        offsetof(struct ast_state, GtE_singleton),
86
0
        offsetof(struct ast_state, GtE_type),
87
0
        offsetof(struct ast_state, Gt_singleton),
88
0
        offsetof(struct ast_state, Gt_type),
89
0
        offsetof(struct ast_state, IfExp_type),
90
0
        offsetof(struct ast_state, If_type),
91
0
        offsetof(struct ast_state, ImportFrom_type),
92
0
        offsetof(struct ast_state, Import_type),
93
0
        offsetof(struct ast_state, In_singleton),
94
0
        offsetof(struct ast_state, In_type),
95
0
        offsetof(struct ast_state, Interactive_type),
96
0
        offsetof(struct ast_state, Interpolation_type),
97
0
        offsetof(struct ast_state, Invert_singleton),
98
0
        offsetof(struct ast_state, Invert_type),
99
0
        offsetof(struct ast_state, IsNot_singleton),
100
0
        offsetof(struct ast_state, IsNot_type),
101
0
        offsetof(struct ast_state, Is_singleton),
102
0
        offsetof(struct ast_state, Is_type),
103
0
        offsetof(struct ast_state, JoinedStr_type),
104
0
        offsetof(struct ast_state, LShift_singleton),
105
0
        offsetof(struct ast_state, LShift_type),
106
0
        offsetof(struct ast_state, Lambda_type),
107
0
        offsetof(struct ast_state, ListComp_type),
108
0
        offsetof(struct ast_state, List_type),
109
0
        offsetof(struct ast_state, Load_singleton),
110
0
        offsetof(struct ast_state, Load_type),
111
0
        offsetof(struct ast_state, LtE_singleton),
112
0
        offsetof(struct ast_state, LtE_type),
113
0
        offsetof(struct ast_state, Lt_singleton),
114
0
        offsetof(struct ast_state, Lt_type),
115
0
        offsetof(struct ast_state, MatMult_singleton),
116
0
        offsetof(struct ast_state, MatMult_type),
117
0
        offsetof(struct ast_state, MatchAs_type),
118
0
        offsetof(struct ast_state, MatchClass_type),
119
0
        offsetof(struct ast_state, MatchMapping_type),
120
0
        offsetof(struct ast_state, MatchOr_type),
121
0
        offsetof(struct ast_state, MatchSequence_type),
122
0
        offsetof(struct ast_state, MatchSingleton_type),
123
0
        offsetof(struct ast_state, MatchStar_type),
124
0
        offsetof(struct ast_state, MatchValue_type),
125
0
        offsetof(struct ast_state, Match_type),
126
0
        offsetof(struct ast_state, Mod_singleton),
127
0
        offsetof(struct ast_state, Mod_type),
128
0
        offsetof(struct ast_state, Module_type),
129
0
        offsetof(struct ast_state, Mult_singleton),
130
0
        offsetof(struct ast_state, Mult_type),
131
0
        offsetof(struct ast_state, Name_type),
132
0
        offsetof(struct ast_state, NamedExpr_type),
133
0
        offsetof(struct ast_state, Nonlocal_type),
134
0
        offsetof(struct ast_state, NotEq_singleton),
135
0
        offsetof(struct ast_state, NotEq_type),
136
0
        offsetof(struct ast_state, NotIn_singleton),
137
0
        offsetof(struct ast_state, NotIn_type),
138
0
        offsetof(struct ast_state, Not_singleton),
139
0
        offsetof(struct ast_state, Not_type),
140
0
        offsetof(struct ast_state, Or_singleton),
141
0
        offsetof(struct ast_state, Or_type),
142
0
        offsetof(struct ast_state, ParamSpec_type),
143
0
        offsetof(struct ast_state, Pass_type),
144
0
        offsetof(struct ast_state, Pow_singleton),
145
0
        offsetof(struct ast_state, Pow_type),
146
0
        offsetof(struct ast_state, RShift_singleton),
147
0
        offsetof(struct ast_state, RShift_type),
148
0
        offsetof(struct ast_state, Raise_type),
149
0
        offsetof(struct ast_state, Return_type),
150
0
        offsetof(struct ast_state, SetComp_type),
151
0
        offsetof(struct ast_state, Set_type),
152
0
        offsetof(struct ast_state, Slice_type),
153
0
        offsetof(struct ast_state, Starred_type),
154
0
        offsetof(struct ast_state, Store_singleton),
155
0
        offsetof(struct ast_state, Store_type),
156
0
        offsetof(struct ast_state, Sub_singleton),
157
0
        offsetof(struct ast_state, Sub_type),
158
0
        offsetof(struct ast_state, Subscript_type),
159
0
        offsetof(struct ast_state, TemplateStr_type),
160
0
        offsetof(struct ast_state, TryStar_type),
161
0
        offsetof(struct ast_state, Try_type),
162
0
        offsetof(struct ast_state, Tuple_type),
163
0
        offsetof(struct ast_state, TypeAlias_type),
164
0
        offsetof(struct ast_state, TypeIgnore_type),
165
0
        offsetof(struct ast_state, TypeVarTuple_type),
166
0
        offsetof(struct ast_state, TypeVar_type),
167
0
        offsetof(struct ast_state, UAdd_singleton),
168
0
        offsetof(struct ast_state, UAdd_type),
169
0
        offsetof(struct ast_state, USub_singleton),
170
0
        offsetof(struct ast_state, USub_type),
171
0
        offsetof(struct ast_state, UnaryOp_type),
172
0
        offsetof(struct ast_state, While_type),
173
0
        offsetof(struct ast_state, With_type),
174
0
        offsetof(struct ast_state, YieldFrom_type),
175
0
        offsetof(struct ast_state, Yield_type),
176
0
        offsetof(struct ast_state, __dict__),
177
0
        offsetof(struct ast_state, __doc__),
178
0
        offsetof(struct ast_state, __match_args__),
179
0
        offsetof(struct ast_state, __module__),
180
0
        offsetof(struct ast_state, _attributes),
181
0
        offsetof(struct ast_state, _fields),
182
0
        offsetof(struct ast_state, abstract_types),
183
0
        offsetof(struct ast_state, alias_type),
184
0
        offsetof(struct ast_state, annotation),
185
0
        offsetof(struct ast_state, arg),
186
0
        offsetof(struct ast_state, arg_type),
187
0
        offsetof(struct ast_state, args),
188
0
        offsetof(struct ast_state, argtypes),
189
0
        offsetof(struct ast_state, arguments_type),
190
0
        offsetof(struct ast_state, asname),
191
0
        offsetof(struct ast_state, ast),
192
0
        offsetof(struct ast_state, attr),
193
0
        offsetof(struct ast_state, bases),
194
0
        offsetof(struct ast_state, body),
195
0
        offsetof(struct ast_state, boolop_type),
196
0
        offsetof(struct ast_state, bound),
197
0
        offsetof(struct ast_state, cases),
198
0
        offsetof(struct ast_state, cause),
199
0
        offsetof(struct ast_state, cls),
200
0
        offsetof(struct ast_state, cmpop_type),
201
0
        offsetof(struct ast_state, col_offset),
202
0
        offsetof(struct ast_state, comparators),
203
0
        offsetof(struct ast_state, comprehension_type),
204
0
        offsetof(struct ast_state, context_expr),
205
0
        offsetof(struct ast_state, conversion),
206
0
        offsetof(struct ast_state, ctx),
207
0
        offsetof(struct ast_state, decorator_list),
208
0
        offsetof(struct ast_state, default_value),
209
0
        offsetof(struct ast_state, defaults),
210
0
        offsetof(struct ast_state, elt),
211
0
        offsetof(struct ast_state, elts),
212
0
        offsetof(struct ast_state, end_col_offset),
213
0
        offsetof(struct ast_state, end_lineno),
214
0
        offsetof(struct ast_state, exc),
215
0
        offsetof(struct ast_state, excepthandler_type),
216
0
        offsetof(struct ast_state, expr_context_type),
217
0
        offsetof(struct ast_state, expr_type),
218
0
        offsetof(struct ast_state, finalbody),
219
0
        offsetof(struct ast_state, format_spec),
220
0
        offsetof(struct ast_state, func),
221
0
        offsetof(struct ast_state, generators),
222
0
        offsetof(struct ast_state, guard),
223
0
        offsetof(struct ast_state, handlers),
224
0
        offsetof(struct ast_state, id),
225
0
        offsetof(struct ast_state, ifs),
226
0
        offsetof(struct ast_state, is_async),
227
0
        offsetof(struct ast_state, is_lazy),
228
0
        offsetof(struct ast_state, items),
229
0
        offsetof(struct ast_state, iter),
230
0
        offsetof(struct ast_state, key),
231
0
        offsetof(struct ast_state, keys),
232
0
        offsetof(struct ast_state, keyword_type),
233
0
        offsetof(struct ast_state, keywords),
234
0
        offsetof(struct ast_state, kind),
235
0
        offsetof(struct ast_state, kw_defaults),
236
0
        offsetof(struct ast_state, kwarg),
237
0
        offsetof(struct ast_state, kwd_attrs),
238
0
        offsetof(struct ast_state, kwd_patterns),
239
0
        offsetof(struct ast_state, kwonlyargs),
240
0
        offsetof(struct ast_state, left),
241
0
        offsetof(struct ast_state, level),
242
0
        offsetof(struct ast_state, lineno),
243
0
        offsetof(struct ast_state, lower),
244
0
        offsetof(struct ast_state, match_case_type),
245
0
        offsetof(struct ast_state, mod_type),
246
0
        offsetof(struct ast_state, module),
247
0
        offsetof(struct ast_state, msg),
248
0
        offsetof(struct ast_state, name),
249
0
        offsetof(struct ast_state, names),
250
0
        offsetof(struct ast_state, op),
251
0
        offsetof(struct ast_state, operand),
252
0
        offsetof(struct ast_state, operator_type),
253
0
        offsetof(struct ast_state, ops),
254
0
        offsetof(struct ast_state, optional_vars),
255
0
        offsetof(struct ast_state, orelse),
256
0
        offsetof(struct ast_state, pattern),
257
0
        offsetof(struct ast_state, pattern_type),
258
0
        offsetof(struct ast_state, patterns),
259
0
        offsetof(struct ast_state, posonlyargs),
260
0
        offsetof(struct ast_state, rest),
261
0
        offsetof(struct ast_state, returns),
262
0
        offsetof(struct ast_state, right),
263
0
        offsetof(struct ast_state, simple),
264
0
        offsetof(struct ast_state, slice),
265
0
        offsetof(struct ast_state, step),
266
0
        offsetof(struct ast_state, stmt_type),
267
0
        offsetof(struct ast_state, str),
268
0
        offsetof(struct ast_state, subject),
269
0
        offsetof(struct ast_state, tag),
270
0
        offsetof(struct ast_state, target),
271
0
        offsetof(struct ast_state, targets),
272
0
        offsetof(struct ast_state, test),
273
0
        offsetof(struct ast_state, type),
274
0
        offsetof(struct ast_state, type_comment),
275
0
        offsetof(struct ast_state, type_ignore_type),
276
0
        offsetof(struct ast_state, type_ignores),
277
0
        offsetof(struct ast_state, type_param_type),
278
0
        offsetof(struct ast_state, type_params),
279
0
        offsetof(struct ast_state, unaryop_type),
280
0
        offsetof(struct ast_state, upper),
281
0
        offsetof(struct ast_state, value),
282
0
        offsetof(struct ast_state, values),
283
0
        offsetof(struct ast_state, vararg),
284
0
        offsetof(struct ast_state, withitem_type),
285
0
    };
286
287
0
    for (size_t i = 0; i < Py_ARRAY_LENGTH(offsets); i++) {
288
0
        PyObject **field = (PyObject **)((char *)state + offsets[i]);
289
0
        Py_CLEAR(*field);
290
0
    }
291
0
    state->finalized = 1;
292
0
    state->once = (_PyOnceFlag){0};
293
0
}
294
295
static int init_identifiers(struct ast_state *state)
296
16
{
297
16
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
298
16
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
299
16
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
300
16
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
301
16
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
302
16
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
303
16
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
304
16
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
305
16
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
306
16
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
307
16
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
308
16
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
309
16
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
310
16
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
311
16
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
312
16
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
313
16
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
314
16
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
315
16
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
316
16
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
317
16
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
318
16
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
319
16
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
320
16
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
321
16
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
322
16
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
323
16
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
324
16
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
325
16
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
326
16
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
327
16
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
328
16
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
329
16
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
330
16
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
331
16
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
332
16
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
333
16
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
334
16
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
335
16
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
336
16
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
337
16
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
338
16
    if ((state->is_lazy = PyUnicode_InternFromString("is_lazy")) == NULL) return -1;
339
16
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
340
16
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
341
16
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
342
16
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
343
16
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
344
16
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
345
16
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
346
16
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
347
16
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
348
16
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
349
16
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
350
16
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
351
16
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
352
16
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
353
16
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
354
16
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
355
16
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
356
16
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
357
16
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
358
16
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
359
16
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
360
16
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
361
16
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
362
16
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
363
16
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
364
16
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
365
16
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
366
16
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
367
16
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
368
16
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
369
16
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
370
16
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
371
16
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
372
16
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
373
16
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
374
16
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
375
16
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
376
16
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
377
16
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
378
16
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
379
16
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
380
16
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
381
16
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
382
16
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
383
16
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
384
16
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
385
16
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
386
16
    return 0;
387
16
};
388
389
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
390
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
391
472k
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
392
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
393
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
394
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
395
570k
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
396
10.7k
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
397
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
398
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
399
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
400
1.61k
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
401
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
402
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
403
404
static PyObject* ast2obj_mod(struct ast_state *state, void*);
405
static const char * const Module_fields[]={
406
    "body",
407
    "type_ignores",
408
};
409
static const char * const Interactive_fields[]={
410
    "body",
411
};
412
static const char * const Expression_fields[]={
413
    "body",
414
};
415
static const char * const FunctionType_fields[]={
416
    "argtypes",
417
    "returns",
418
};
419
static const char * const stmt_attributes[] = {
420
    "lineno",
421
    "col_offset",
422
    "end_lineno",
423
    "end_col_offset",
424
};
425
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
426
static const char * const FunctionDef_fields[]={
427
    "name",
428
    "args",
429
    "body",
430
    "decorator_list",
431
    "returns",
432
    "type_comment",
433
    "type_params",
434
};
435
static const char * const AsyncFunctionDef_fields[]={
436
    "name",
437
    "args",
438
    "body",
439
    "decorator_list",
440
    "returns",
441
    "type_comment",
442
    "type_params",
443
};
444
static const char * const ClassDef_fields[]={
445
    "name",
446
    "bases",
447
    "keywords",
448
    "body",
449
    "decorator_list",
450
    "type_params",
451
};
452
static const char * const Return_fields[]={
453
    "value",
454
};
455
static const char * const Delete_fields[]={
456
    "targets",
457
};
458
static const char * const Assign_fields[]={
459
    "targets",
460
    "value",
461
    "type_comment",
462
};
463
static const char * const TypeAlias_fields[]={
464
    "name",
465
    "type_params",
466
    "value",
467
};
468
static const char * const AugAssign_fields[]={
469
    "target",
470
    "op",
471
    "value",
472
};
473
static const char * const AnnAssign_fields[]={
474
    "target",
475
    "annotation",
476
    "value",
477
    "simple",
478
};
479
static const char * const For_fields[]={
480
    "target",
481
    "iter",
482
    "body",
483
    "orelse",
484
    "type_comment",
485
};
486
static const char * const AsyncFor_fields[]={
487
    "target",
488
    "iter",
489
    "body",
490
    "orelse",
491
    "type_comment",
492
};
493
static const char * const While_fields[]={
494
    "test",
495
    "body",
496
    "orelse",
497
};
498
static const char * const If_fields[]={
499
    "test",
500
    "body",
501
    "orelse",
502
};
503
static const char * const With_fields[]={
504
    "items",
505
    "body",
506
    "type_comment",
507
};
508
static const char * const AsyncWith_fields[]={
509
    "items",
510
    "body",
511
    "type_comment",
512
};
513
static const char * const Match_fields[]={
514
    "subject",
515
    "cases",
516
};
517
static const char * const Raise_fields[]={
518
    "exc",
519
    "cause",
520
};
521
static const char * const Try_fields[]={
522
    "body",
523
    "handlers",
524
    "orelse",
525
    "finalbody",
526
};
527
static const char * const TryStar_fields[]={
528
    "body",
529
    "handlers",
530
    "orelse",
531
    "finalbody",
532
};
533
static const char * const Assert_fields[]={
534
    "test",
535
    "msg",
536
};
537
static const char * const Import_fields[]={
538
    "names",
539
    "is_lazy",
540
};
541
static const char * const ImportFrom_fields[]={
542
    "module",
543
    "names",
544
    "level",
545
    "is_lazy",
546
};
547
static const char * const Global_fields[]={
548
    "names",
549
};
550
static const char * const Nonlocal_fields[]={
551
    "names",
552
};
553
static const char * const Expr_fields[]={
554
    "value",
555
};
556
static const char * const expr_attributes[] = {
557
    "lineno",
558
    "col_offset",
559
    "end_lineno",
560
    "end_col_offset",
561
};
562
static PyObject* ast2obj_expr(struct ast_state *state, void*);
563
static const char * const BoolOp_fields[]={
564
    "op",
565
    "values",
566
};
567
static const char * const NamedExpr_fields[]={
568
    "target",
569
    "value",
570
};
571
static const char * const BinOp_fields[]={
572
    "left",
573
    "op",
574
    "right",
575
};
576
static const char * const UnaryOp_fields[]={
577
    "op",
578
    "operand",
579
};
580
static const char * const Lambda_fields[]={
581
    "args",
582
    "body",
583
};
584
static const char * const IfExp_fields[]={
585
    "test",
586
    "body",
587
    "orelse",
588
};
589
static const char * const Dict_fields[]={
590
    "keys",
591
    "values",
592
};
593
static const char * const Set_fields[]={
594
    "elts",
595
};
596
static const char * const ListComp_fields[]={
597
    "elt",
598
    "generators",
599
};
600
static const char * const SetComp_fields[]={
601
    "elt",
602
    "generators",
603
};
604
static const char * const DictComp_fields[]={
605
    "key",
606
    "value",
607
    "generators",
608
};
609
static const char * const GeneratorExp_fields[]={
610
    "elt",
611
    "generators",
612
};
613
static const char * const Await_fields[]={
614
    "value",
615
};
616
static const char * const Yield_fields[]={
617
    "value",
618
};
619
static const char * const YieldFrom_fields[]={
620
    "value",
621
};
622
static const char * const Compare_fields[]={
623
    "left",
624
    "ops",
625
    "comparators",
626
};
627
static const char * const Call_fields[]={
628
    "func",
629
    "args",
630
    "keywords",
631
};
632
static const char * const FormattedValue_fields[]={
633
    "value",
634
    "conversion",
635
    "format_spec",
636
};
637
static const char * const Interpolation_fields[]={
638
    "value",
639
    "str",
640
    "conversion",
641
    "format_spec",
642
};
643
static const char * const JoinedStr_fields[]={
644
    "values",
645
};
646
static const char * const TemplateStr_fields[]={
647
    "values",
648
};
649
static const char * const Constant_fields[]={
650
    "value",
651
    "kind",
652
};
653
static const char * const Attribute_fields[]={
654
    "value",
655
    "attr",
656
    "ctx",
657
};
658
static const char * const Subscript_fields[]={
659
    "value",
660
    "slice",
661
    "ctx",
662
};
663
static const char * const Starred_fields[]={
664
    "value",
665
    "ctx",
666
};
667
static const char * const Name_fields[]={
668
    "id",
669
    "ctx",
670
};
671
static const char * const List_fields[]={
672
    "elts",
673
    "ctx",
674
};
675
static const char * const Tuple_fields[]={
676
    "elts",
677
    "ctx",
678
};
679
static const char * const Slice_fields[]={
680
    "lower",
681
    "upper",
682
    "step",
683
};
684
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
685
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
686
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
687
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
688
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
689
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
690
static const char * const comprehension_fields[]={
691
    "target",
692
    "iter",
693
    "ifs",
694
    "is_async",
695
};
696
static const char * const excepthandler_attributes[] = {
697
    "lineno",
698
    "col_offset",
699
    "end_lineno",
700
    "end_col_offset",
701
};
702
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
703
static const char * const ExceptHandler_fields[]={
704
    "type",
705
    "name",
706
    "body",
707
};
708
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
709
static const char * const arguments_fields[]={
710
    "posonlyargs",
711
    "args",
712
    "vararg",
713
    "kwonlyargs",
714
    "kw_defaults",
715
    "kwarg",
716
    "defaults",
717
};
718
static PyObject* ast2obj_arg(struct ast_state *state, void*);
719
static const char * const arg_attributes[] = {
720
    "lineno",
721
    "col_offset",
722
    "end_lineno",
723
    "end_col_offset",
724
};
725
static const char * const arg_fields[]={
726
    "arg",
727
    "annotation",
728
    "type_comment",
729
};
730
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
731
static const char * const keyword_attributes[] = {
732
    "lineno",
733
    "col_offset",
734
    "end_lineno",
735
    "end_col_offset",
736
};
737
static const char * const keyword_fields[]={
738
    "arg",
739
    "value",
740
};
741
static PyObject* ast2obj_alias(struct ast_state *state, void*);
742
static const char * const alias_attributes[] = {
743
    "lineno",
744
    "col_offset",
745
    "end_lineno",
746
    "end_col_offset",
747
};
748
static const char * const alias_fields[]={
749
    "name",
750
    "asname",
751
};
752
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
753
static const char * const withitem_fields[]={
754
    "context_expr",
755
    "optional_vars",
756
};
757
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
758
static const char * const match_case_fields[]={
759
    "pattern",
760
    "guard",
761
    "body",
762
};
763
static const char * const pattern_attributes[] = {
764
    "lineno",
765
    "col_offset",
766
    "end_lineno",
767
    "end_col_offset",
768
};
769
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
770
static const char * const MatchValue_fields[]={
771
    "value",
772
};
773
static const char * const MatchSingleton_fields[]={
774
    "value",
775
};
776
static const char * const MatchSequence_fields[]={
777
    "patterns",
778
};
779
static const char * const MatchMapping_fields[]={
780
    "keys",
781
    "patterns",
782
    "rest",
783
};
784
static const char * const MatchClass_fields[]={
785
    "cls",
786
    "patterns",
787
    "kwd_attrs",
788
    "kwd_patterns",
789
};
790
static const char * const MatchStar_fields[]={
791
    "name",
792
};
793
static const char * const MatchAs_fields[]={
794
    "pattern",
795
    "name",
796
};
797
static const char * const MatchOr_fields[]={
798
    "patterns",
799
};
800
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
801
static const char * const TypeIgnore_fields[]={
802
    "lineno",
803
    "tag",
804
};
805
static const char * const type_param_attributes[] = {
806
    "lineno",
807
    "col_offset",
808
    "end_lineno",
809
    "end_col_offset",
810
};
811
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
812
static const char * const TypeVar_fields[]={
813
    "name",
814
    "bound",
815
    "default_value",
816
};
817
static const char * const ParamSpec_fields[]={
818
    "name",
819
    "default_value",
820
};
821
static const char * const TypeVarTuple_fields[]={
822
    "name",
823
    "default_value",
824
};
825
826
827
static int
828
add_ast_annotations(struct ast_state *state)
829
16
{
830
16
    enum {
831
16
        FIELD_OPTIONAL = 1,
832
16
        FIELD_SEQUENCE = 2,
833
16
        FIELD_BUILTIN = 4,
834
16
    };
835
16
    PyTypeObject *const builtin_types[] = {
836
16
        &PyUnicode_Type,
837
16
        &PyLong_Type,
838
16
        &PyBaseObject_Type,
839
16
    };
840
    // Offsets refer to this interpreter's AST state, not global types.
841
16
    static_assert(sizeof(struct ast_state) <= UINT16_MAX,
842
16
                  "ast_state offsets must fit in uint16_t");
843
16
    static const struct {
844
16
        uint16_t name_offset;
845
16
        uint16_t type_offset;  // An index into builtin_types for builtins.
846
16
        uint8_t flags;
847
16
    } fields[] = {
848
16
        {offsetof(struct ast_state, body),
849
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
850
16
        {offsetof(struct ast_state, type_ignores),
851
16
         offsetof(struct ast_state, type_ignore_type), FIELD_SEQUENCE},
852
16
        {offsetof(struct ast_state, body),
853
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
854
16
        {offsetof(struct ast_state, body),
855
16
         offsetof(struct ast_state, expr_type), 0},
856
16
        {offsetof(struct ast_state, argtypes),
857
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
858
16
        {offsetof(struct ast_state, returns),
859
16
         offsetof(struct ast_state, expr_type), 0},
860
16
        {offsetof(struct ast_state, name),
861
16
         0, FIELD_BUILTIN},
862
16
        {offsetof(struct ast_state, args),
863
16
         offsetof(struct ast_state, arguments_type), 0},
864
16
        {offsetof(struct ast_state, body),
865
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
866
16
        {offsetof(struct ast_state, decorator_list),
867
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
868
16
        {offsetof(struct ast_state, returns),
869
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
870
16
        {offsetof(struct ast_state, type_comment),
871
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
872
16
        {offsetof(struct ast_state, type_params),
873
16
         offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE},
874
16
        {offsetof(struct ast_state, name),
875
16
         0, FIELD_BUILTIN},
876
16
        {offsetof(struct ast_state, args),
877
16
         offsetof(struct ast_state, arguments_type), 0},
878
16
        {offsetof(struct ast_state, body),
879
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
880
16
        {offsetof(struct ast_state, decorator_list),
881
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
882
16
        {offsetof(struct ast_state, returns),
883
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
884
16
        {offsetof(struct ast_state, type_comment),
885
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
886
16
        {offsetof(struct ast_state, type_params),
887
16
         offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE},
888
16
        {offsetof(struct ast_state, name),
889
16
         0, FIELD_BUILTIN},
890
16
        {offsetof(struct ast_state, bases),
891
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
892
16
        {offsetof(struct ast_state, keywords),
893
16
         offsetof(struct ast_state, keyword_type), FIELD_SEQUENCE},
894
16
        {offsetof(struct ast_state, body),
895
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
896
16
        {offsetof(struct ast_state, decorator_list),
897
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
898
16
        {offsetof(struct ast_state, type_params),
899
16
         offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE},
900
16
        {offsetof(struct ast_state, value),
901
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
902
16
        {offsetof(struct ast_state, targets),
903
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
904
16
        {offsetof(struct ast_state, targets),
905
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
906
16
        {offsetof(struct ast_state, value),
907
16
         offsetof(struct ast_state, expr_type), 0},
908
16
        {offsetof(struct ast_state, type_comment),
909
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
910
16
        {offsetof(struct ast_state, name),
911
16
         offsetof(struct ast_state, expr_type), 0},
912
16
        {offsetof(struct ast_state, type_params),
913
16
         offsetof(struct ast_state, type_param_type), FIELD_SEQUENCE},
914
16
        {offsetof(struct ast_state, value),
915
16
         offsetof(struct ast_state, expr_type), 0},
916
16
        {offsetof(struct ast_state, target),
917
16
         offsetof(struct ast_state, expr_type), 0},
918
16
        {offsetof(struct ast_state, op),
919
16
         offsetof(struct ast_state, operator_type), 0},
920
16
        {offsetof(struct ast_state, value),
921
16
         offsetof(struct ast_state, expr_type), 0},
922
16
        {offsetof(struct ast_state, target),
923
16
         offsetof(struct ast_state, expr_type), 0},
924
16
        {offsetof(struct ast_state, annotation),
925
16
         offsetof(struct ast_state, expr_type), 0},
926
16
        {offsetof(struct ast_state, value),
927
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
928
16
        {offsetof(struct ast_state, simple),
929
16
         1, FIELD_BUILTIN},
930
16
        {offsetof(struct ast_state, target),
931
16
         offsetof(struct ast_state, expr_type), 0},
932
16
        {offsetof(struct ast_state, iter),
933
16
         offsetof(struct ast_state, expr_type), 0},
934
16
        {offsetof(struct ast_state, body),
935
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
936
16
        {offsetof(struct ast_state, orelse),
937
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
938
16
        {offsetof(struct ast_state, type_comment),
939
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
940
16
        {offsetof(struct ast_state, target),
941
16
         offsetof(struct ast_state, expr_type), 0},
942
16
        {offsetof(struct ast_state, iter),
943
16
         offsetof(struct ast_state, expr_type), 0},
944
16
        {offsetof(struct ast_state, body),
945
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
946
16
        {offsetof(struct ast_state, orelse),
947
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
948
16
        {offsetof(struct ast_state, type_comment),
949
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
950
16
        {offsetof(struct ast_state, test),
951
16
         offsetof(struct ast_state, expr_type), 0},
952
16
        {offsetof(struct ast_state, body),
953
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
954
16
        {offsetof(struct ast_state, orelse),
955
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
956
16
        {offsetof(struct ast_state, test),
957
16
         offsetof(struct ast_state, expr_type), 0},
958
16
        {offsetof(struct ast_state, body),
959
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
960
16
        {offsetof(struct ast_state, orelse),
961
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
962
16
        {offsetof(struct ast_state, items),
963
16
         offsetof(struct ast_state, withitem_type), FIELD_SEQUENCE},
964
16
        {offsetof(struct ast_state, body),
965
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
966
16
        {offsetof(struct ast_state, type_comment),
967
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
968
16
        {offsetof(struct ast_state, items),
969
16
         offsetof(struct ast_state, withitem_type), FIELD_SEQUENCE},
970
16
        {offsetof(struct ast_state, body),
971
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
972
16
        {offsetof(struct ast_state, type_comment),
973
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
974
16
        {offsetof(struct ast_state, subject),
975
16
         offsetof(struct ast_state, expr_type), 0},
976
16
        {offsetof(struct ast_state, cases),
977
16
         offsetof(struct ast_state, match_case_type), FIELD_SEQUENCE},
978
16
        {offsetof(struct ast_state, exc),
979
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
980
16
        {offsetof(struct ast_state, cause),
981
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
982
16
        {offsetof(struct ast_state, body),
983
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
984
16
        {offsetof(struct ast_state, handlers),
985
16
         offsetof(struct ast_state, excepthandler_type), FIELD_SEQUENCE},
986
16
        {offsetof(struct ast_state, orelse),
987
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
988
16
        {offsetof(struct ast_state, finalbody),
989
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
990
16
        {offsetof(struct ast_state, body),
991
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
992
16
        {offsetof(struct ast_state, handlers),
993
16
         offsetof(struct ast_state, excepthandler_type), FIELD_SEQUENCE},
994
16
        {offsetof(struct ast_state, orelse),
995
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
996
16
        {offsetof(struct ast_state, finalbody),
997
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
998
16
        {offsetof(struct ast_state, test),
999
16
         offsetof(struct ast_state, expr_type), 0},
1000
16
        {offsetof(struct ast_state, msg),
1001
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1002
16
        {offsetof(struct ast_state, names),
1003
16
         offsetof(struct ast_state, alias_type), FIELD_SEQUENCE},
1004
16
        {offsetof(struct ast_state, is_lazy),
1005
16
         1, FIELD_OPTIONAL | FIELD_BUILTIN},
1006
16
        {offsetof(struct ast_state, module),
1007
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1008
16
        {offsetof(struct ast_state, names),
1009
16
         offsetof(struct ast_state, alias_type), FIELD_SEQUENCE},
1010
16
        {offsetof(struct ast_state, level),
1011
16
         1, FIELD_OPTIONAL | FIELD_BUILTIN},
1012
16
        {offsetof(struct ast_state, is_lazy),
1013
16
         1, FIELD_OPTIONAL | FIELD_BUILTIN},
1014
16
        {offsetof(struct ast_state, names),
1015
16
         0, FIELD_SEQUENCE | FIELD_BUILTIN},
1016
16
        {offsetof(struct ast_state, names),
1017
16
         0, FIELD_SEQUENCE | FIELD_BUILTIN},
1018
16
        {offsetof(struct ast_state, value),
1019
16
         offsetof(struct ast_state, expr_type), 0},
1020
16
        {offsetof(struct ast_state, op),
1021
16
         offsetof(struct ast_state, boolop_type), 0},
1022
16
        {offsetof(struct ast_state, values),
1023
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1024
16
        {offsetof(struct ast_state, target),
1025
16
         offsetof(struct ast_state, expr_type), 0},
1026
16
        {offsetof(struct ast_state, value),
1027
16
         offsetof(struct ast_state, expr_type), 0},
1028
16
        {offsetof(struct ast_state, left),
1029
16
         offsetof(struct ast_state, expr_type), 0},
1030
16
        {offsetof(struct ast_state, op),
1031
16
         offsetof(struct ast_state, operator_type), 0},
1032
16
        {offsetof(struct ast_state, right),
1033
16
         offsetof(struct ast_state, expr_type), 0},
1034
16
        {offsetof(struct ast_state, op),
1035
16
         offsetof(struct ast_state, unaryop_type), 0},
1036
16
        {offsetof(struct ast_state, operand),
1037
16
         offsetof(struct ast_state, expr_type), 0},
1038
16
        {offsetof(struct ast_state, args),
1039
16
         offsetof(struct ast_state, arguments_type), 0},
1040
16
        {offsetof(struct ast_state, body),
1041
16
         offsetof(struct ast_state, expr_type), 0},
1042
16
        {offsetof(struct ast_state, test),
1043
16
         offsetof(struct ast_state, expr_type), 0},
1044
16
        {offsetof(struct ast_state, body),
1045
16
         offsetof(struct ast_state, expr_type), 0},
1046
16
        {offsetof(struct ast_state, orelse),
1047
16
         offsetof(struct ast_state, expr_type), 0},
1048
16
        {offsetof(struct ast_state, keys),
1049
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1050
16
        {offsetof(struct ast_state, values),
1051
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1052
16
        {offsetof(struct ast_state, elts),
1053
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1054
16
        {offsetof(struct ast_state, elt),
1055
16
         offsetof(struct ast_state, expr_type), 0},
1056
16
        {offsetof(struct ast_state, generators),
1057
16
         offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE},
1058
16
        {offsetof(struct ast_state, elt),
1059
16
         offsetof(struct ast_state, expr_type), 0},
1060
16
        {offsetof(struct ast_state, generators),
1061
16
         offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE},
1062
16
        {offsetof(struct ast_state, key),
1063
16
         offsetof(struct ast_state, expr_type), 0},
1064
16
        {offsetof(struct ast_state, value),
1065
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1066
16
        {offsetof(struct ast_state, generators),
1067
16
         offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE},
1068
16
        {offsetof(struct ast_state, elt),
1069
16
         offsetof(struct ast_state, expr_type), 0},
1070
16
        {offsetof(struct ast_state, generators),
1071
16
         offsetof(struct ast_state, comprehension_type), FIELD_SEQUENCE},
1072
16
        {offsetof(struct ast_state, value),
1073
16
         offsetof(struct ast_state, expr_type), 0},
1074
16
        {offsetof(struct ast_state, value),
1075
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1076
16
        {offsetof(struct ast_state, value),
1077
16
         offsetof(struct ast_state, expr_type), 0},
1078
16
        {offsetof(struct ast_state, left),
1079
16
         offsetof(struct ast_state, expr_type), 0},
1080
16
        {offsetof(struct ast_state, ops),
1081
16
         offsetof(struct ast_state, cmpop_type), FIELD_SEQUENCE},
1082
16
        {offsetof(struct ast_state, comparators),
1083
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1084
16
        {offsetof(struct ast_state, func),
1085
16
         offsetof(struct ast_state, expr_type), 0},
1086
16
        {offsetof(struct ast_state, args),
1087
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1088
16
        {offsetof(struct ast_state, keywords),
1089
16
         offsetof(struct ast_state, keyword_type), FIELD_SEQUENCE},
1090
16
        {offsetof(struct ast_state, value),
1091
16
         offsetof(struct ast_state, expr_type), 0},
1092
16
        {offsetof(struct ast_state, conversion),
1093
16
         1, FIELD_BUILTIN},
1094
16
        {offsetof(struct ast_state, format_spec),
1095
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1096
16
        {offsetof(struct ast_state, value),
1097
16
         offsetof(struct ast_state, expr_type), 0},
1098
16
        {offsetof(struct ast_state, str),
1099
16
         2, FIELD_BUILTIN},
1100
16
        {offsetof(struct ast_state, conversion),
1101
16
         1, FIELD_BUILTIN},
1102
16
        {offsetof(struct ast_state, format_spec),
1103
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1104
16
        {offsetof(struct ast_state, values),
1105
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1106
16
        {offsetof(struct ast_state, values),
1107
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1108
16
        {offsetof(struct ast_state, value),
1109
16
         2, FIELD_BUILTIN},
1110
16
        {offsetof(struct ast_state, kind),
1111
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1112
16
        {offsetof(struct ast_state, value),
1113
16
         offsetof(struct ast_state, expr_type), 0},
1114
16
        {offsetof(struct ast_state, attr),
1115
16
         0, FIELD_BUILTIN},
1116
16
        {offsetof(struct ast_state, ctx),
1117
16
         offsetof(struct ast_state, expr_context_type), 0},
1118
16
        {offsetof(struct ast_state, value),
1119
16
         offsetof(struct ast_state, expr_type), 0},
1120
16
        {offsetof(struct ast_state, slice),
1121
16
         offsetof(struct ast_state, expr_type), 0},
1122
16
        {offsetof(struct ast_state, ctx),
1123
16
         offsetof(struct ast_state, expr_context_type), 0},
1124
16
        {offsetof(struct ast_state, value),
1125
16
         offsetof(struct ast_state, expr_type), 0},
1126
16
        {offsetof(struct ast_state, ctx),
1127
16
         offsetof(struct ast_state, expr_context_type), 0},
1128
16
        {offsetof(struct ast_state, id),
1129
16
         0, FIELD_BUILTIN},
1130
16
        {offsetof(struct ast_state, ctx),
1131
16
         offsetof(struct ast_state, expr_context_type), 0},
1132
16
        {offsetof(struct ast_state, elts),
1133
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1134
16
        {offsetof(struct ast_state, ctx),
1135
16
         offsetof(struct ast_state, expr_context_type), 0},
1136
16
        {offsetof(struct ast_state, elts),
1137
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1138
16
        {offsetof(struct ast_state, ctx),
1139
16
         offsetof(struct ast_state, expr_context_type), 0},
1140
16
        {offsetof(struct ast_state, lower),
1141
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1142
16
        {offsetof(struct ast_state, upper),
1143
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1144
16
        {offsetof(struct ast_state, step),
1145
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1146
16
        {offsetof(struct ast_state, target),
1147
16
         offsetof(struct ast_state, expr_type), 0},
1148
16
        {offsetof(struct ast_state, iter),
1149
16
         offsetof(struct ast_state, expr_type), 0},
1150
16
        {offsetof(struct ast_state, ifs),
1151
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1152
16
        {offsetof(struct ast_state, is_async),
1153
16
         1, FIELD_BUILTIN},
1154
16
        {offsetof(struct ast_state, type),
1155
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1156
16
        {offsetof(struct ast_state, name),
1157
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1158
16
        {offsetof(struct ast_state, body),
1159
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
1160
16
        {offsetof(struct ast_state, posonlyargs),
1161
16
         offsetof(struct ast_state, arg_type), FIELD_SEQUENCE},
1162
16
        {offsetof(struct ast_state, args),
1163
16
         offsetof(struct ast_state, arg_type), FIELD_SEQUENCE},
1164
16
        {offsetof(struct ast_state, vararg),
1165
16
         offsetof(struct ast_state, arg_type), FIELD_OPTIONAL},
1166
16
        {offsetof(struct ast_state, kwonlyargs),
1167
16
         offsetof(struct ast_state, arg_type), FIELD_SEQUENCE},
1168
16
        {offsetof(struct ast_state, kw_defaults),
1169
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1170
16
        {offsetof(struct ast_state, kwarg),
1171
16
         offsetof(struct ast_state, arg_type), FIELD_OPTIONAL},
1172
16
        {offsetof(struct ast_state, defaults),
1173
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1174
16
        {offsetof(struct ast_state, arg),
1175
16
         0, FIELD_BUILTIN},
1176
16
        {offsetof(struct ast_state, annotation),
1177
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1178
16
        {offsetof(struct ast_state, type_comment),
1179
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1180
16
        {offsetof(struct ast_state, arg),
1181
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1182
16
        {offsetof(struct ast_state, value),
1183
16
         offsetof(struct ast_state, expr_type), 0},
1184
16
        {offsetof(struct ast_state, name),
1185
16
         0, FIELD_BUILTIN},
1186
16
        {offsetof(struct ast_state, asname),
1187
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1188
16
        {offsetof(struct ast_state, context_expr),
1189
16
         offsetof(struct ast_state, expr_type), 0},
1190
16
        {offsetof(struct ast_state, optional_vars),
1191
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1192
16
        {offsetof(struct ast_state, pattern),
1193
16
         offsetof(struct ast_state, pattern_type), 0},
1194
16
        {offsetof(struct ast_state, guard),
1195
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1196
16
        {offsetof(struct ast_state, body),
1197
16
         offsetof(struct ast_state, stmt_type), FIELD_SEQUENCE},
1198
16
        {offsetof(struct ast_state, value),
1199
16
         offsetof(struct ast_state, expr_type), 0},
1200
16
        {offsetof(struct ast_state, value),
1201
16
         2, FIELD_BUILTIN},
1202
16
        {offsetof(struct ast_state, patterns),
1203
16
         offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE},
1204
16
        {offsetof(struct ast_state, keys),
1205
16
         offsetof(struct ast_state, expr_type), FIELD_SEQUENCE},
1206
16
        {offsetof(struct ast_state, patterns),
1207
16
         offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE},
1208
16
        {offsetof(struct ast_state, rest),
1209
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1210
16
        {offsetof(struct ast_state, cls),
1211
16
         offsetof(struct ast_state, expr_type), 0},
1212
16
        {offsetof(struct ast_state, patterns),
1213
16
         offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE},
1214
16
        {offsetof(struct ast_state, kwd_attrs),
1215
16
         0, FIELD_SEQUENCE | FIELD_BUILTIN},
1216
16
        {offsetof(struct ast_state, kwd_patterns),
1217
16
         offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE},
1218
16
        {offsetof(struct ast_state, name),
1219
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1220
16
        {offsetof(struct ast_state, pattern),
1221
16
         offsetof(struct ast_state, pattern_type), FIELD_OPTIONAL},
1222
16
        {offsetof(struct ast_state, name),
1223
16
         0, FIELD_OPTIONAL | FIELD_BUILTIN},
1224
16
        {offsetof(struct ast_state, patterns),
1225
16
         offsetof(struct ast_state, pattern_type), FIELD_SEQUENCE},
1226
16
        {offsetof(struct ast_state, lineno),
1227
16
         1, FIELD_BUILTIN},
1228
16
        {offsetof(struct ast_state, tag),
1229
16
         0, FIELD_BUILTIN},
1230
16
        {offsetof(struct ast_state, name),
1231
16
         0, FIELD_BUILTIN},
1232
16
        {offsetof(struct ast_state, bound),
1233
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1234
16
        {offsetof(struct ast_state, default_value),
1235
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1236
16
        {offsetof(struct ast_state, name),
1237
16
         0, FIELD_BUILTIN},
1238
16
        {offsetof(struct ast_state, default_value),
1239
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1240
16
        {offsetof(struct ast_state, name),
1241
16
         0, FIELD_BUILTIN},
1242
16
        {offsetof(struct ast_state, default_value),
1243
16
         offsetof(struct ast_state, expr_type), FIELD_OPTIONAL},
1244
16
    };
1245
16
    static const struct {
1246
16
        uint16_t type_offset;
1247
16
        uint16_t first_field;
1248
16
        uint16_t nfields;
1249
16
    } nodes[] = {
1250
16
        {offsetof(struct ast_state, Module_type), 0, 2},
1251
16
        {offsetof(struct ast_state, Interactive_type), 2, 1},
1252
16
        {offsetof(struct ast_state, Expression_type), 3, 1},
1253
16
        {offsetof(struct ast_state, FunctionType_type), 4, 2},
1254
16
        {offsetof(struct ast_state, FunctionDef_type), 6, 7},
1255
16
        {offsetof(struct ast_state, AsyncFunctionDef_type), 13, 7},
1256
16
        {offsetof(struct ast_state, ClassDef_type), 20, 6},
1257
16
        {offsetof(struct ast_state, Return_type), 26, 1},
1258
16
        {offsetof(struct ast_state, Delete_type), 27, 1},
1259
16
        {offsetof(struct ast_state, Assign_type), 28, 3},
1260
16
        {offsetof(struct ast_state, TypeAlias_type), 31, 3},
1261
16
        {offsetof(struct ast_state, AugAssign_type), 34, 3},
1262
16
        {offsetof(struct ast_state, AnnAssign_type), 37, 4},
1263
16
        {offsetof(struct ast_state, For_type), 41, 5},
1264
16
        {offsetof(struct ast_state, AsyncFor_type), 46, 5},
1265
16
        {offsetof(struct ast_state, While_type), 51, 3},
1266
16
        {offsetof(struct ast_state, If_type), 54, 3},
1267
16
        {offsetof(struct ast_state, With_type), 57, 3},
1268
16
        {offsetof(struct ast_state, AsyncWith_type), 60, 3},
1269
16
        {offsetof(struct ast_state, Match_type), 63, 2},
1270
16
        {offsetof(struct ast_state, Raise_type), 65, 2},
1271
16
        {offsetof(struct ast_state, Try_type), 67, 4},
1272
16
        {offsetof(struct ast_state, TryStar_type), 71, 4},
1273
16
        {offsetof(struct ast_state, Assert_type), 75, 2},
1274
16
        {offsetof(struct ast_state, Import_type), 77, 2},
1275
16
        {offsetof(struct ast_state, ImportFrom_type), 79, 4},
1276
16
        {offsetof(struct ast_state, Global_type), 83, 1},
1277
16
        {offsetof(struct ast_state, Nonlocal_type), 84, 1},
1278
16
        {offsetof(struct ast_state, Expr_type), 85, 1},
1279
16
        {offsetof(struct ast_state, Pass_type), 86, 0},
1280
16
        {offsetof(struct ast_state, Break_type), 86, 0},
1281
16
        {offsetof(struct ast_state, Continue_type), 86, 0},
1282
16
        {offsetof(struct ast_state, BoolOp_type), 86, 2},
1283
16
        {offsetof(struct ast_state, NamedExpr_type), 88, 2},
1284
16
        {offsetof(struct ast_state, BinOp_type), 90, 3},
1285
16
        {offsetof(struct ast_state, UnaryOp_type), 93, 2},
1286
16
        {offsetof(struct ast_state, Lambda_type), 95, 2},
1287
16
        {offsetof(struct ast_state, IfExp_type), 97, 3},
1288
16
        {offsetof(struct ast_state, Dict_type), 100, 2},
1289
16
        {offsetof(struct ast_state, Set_type), 102, 1},
1290
16
        {offsetof(struct ast_state, ListComp_type), 103, 2},
1291
16
        {offsetof(struct ast_state, SetComp_type), 105, 2},
1292
16
        {offsetof(struct ast_state, DictComp_type), 107, 3},
1293
16
        {offsetof(struct ast_state, GeneratorExp_type), 110, 2},
1294
16
        {offsetof(struct ast_state, Await_type), 112, 1},
1295
16
        {offsetof(struct ast_state, Yield_type), 113, 1},
1296
16
        {offsetof(struct ast_state, YieldFrom_type), 114, 1},
1297
16
        {offsetof(struct ast_state, Compare_type), 115, 3},
1298
16
        {offsetof(struct ast_state, Call_type), 118, 3},
1299
16
        {offsetof(struct ast_state, FormattedValue_type), 121, 3},
1300
16
        {offsetof(struct ast_state, Interpolation_type), 124, 4},
1301
16
        {offsetof(struct ast_state, JoinedStr_type), 128, 1},
1302
16
        {offsetof(struct ast_state, TemplateStr_type), 129, 1},
1303
16
        {offsetof(struct ast_state, Constant_type), 130, 2},
1304
16
        {offsetof(struct ast_state, Attribute_type), 132, 3},
1305
16
        {offsetof(struct ast_state, Subscript_type), 135, 3},
1306
16
        {offsetof(struct ast_state, Starred_type), 138, 2},
1307
16
        {offsetof(struct ast_state, Name_type), 140, 2},
1308
16
        {offsetof(struct ast_state, List_type), 142, 2},
1309
16
        {offsetof(struct ast_state, Tuple_type), 144, 2},
1310
16
        {offsetof(struct ast_state, Slice_type), 146, 3},
1311
16
        {offsetof(struct ast_state, Load_type), 149, 0},
1312
16
        {offsetof(struct ast_state, Store_type), 149, 0},
1313
16
        {offsetof(struct ast_state, Del_type), 149, 0},
1314
16
        {offsetof(struct ast_state, And_type), 149, 0},
1315
16
        {offsetof(struct ast_state, Or_type), 149, 0},
1316
16
        {offsetof(struct ast_state, Add_type), 149, 0},
1317
16
        {offsetof(struct ast_state, Sub_type), 149, 0},
1318
16
        {offsetof(struct ast_state, Mult_type), 149, 0},
1319
16
        {offsetof(struct ast_state, MatMult_type), 149, 0},
1320
16
        {offsetof(struct ast_state, Div_type), 149, 0},
1321
16
        {offsetof(struct ast_state, Mod_type), 149, 0},
1322
16
        {offsetof(struct ast_state, Pow_type), 149, 0},
1323
16
        {offsetof(struct ast_state, LShift_type), 149, 0},
1324
16
        {offsetof(struct ast_state, RShift_type), 149, 0},
1325
16
        {offsetof(struct ast_state, BitOr_type), 149, 0},
1326
16
        {offsetof(struct ast_state, BitXor_type), 149, 0},
1327
16
        {offsetof(struct ast_state, BitAnd_type), 149, 0},
1328
16
        {offsetof(struct ast_state, FloorDiv_type), 149, 0},
1329
16
        {offsetof(struct ast_state, Invert_type), 149, 0},
1330
16
        {offsetof(struct ast_state, Not_type), 149, 0},
1331
16
        {offsetof(struct ast_state, UAdd_type), 149, 0},
1332
16
        {offsetof(struct ast_state, USub_type), 149, 0},
1333
16
        {offsetof(struct ast_state, Eq_type), 149, 0},
1334
16
        {offsetof(struct ast_state, NotEq_type), 149, 0},
1335
16
        {offsetof(struct ast_state, Lt_type), 149, 0},
1336
16
        {offsetof(struct ast_state, LtE_type), 149, 0},
1337
16
        {offsetof(struct ast_state, Gt_type), 149, 0},
1338
16
        {offsetof(struct ast_state, GtE_type), 149, 0},
1339
16
        {offsetof(struct ast_state, Is_type), 149, 0},
1340
16
        {offsetof(struct ast_state, IsNot_type), 149, 0},
1341
16
        {offsetof(struct ast_state, In_type), 149, 0},
1342
16
        {offsetof(struct ast_state, NotIn_type), 149, 0},
1343
16
        {offsetof(struct ast_state, comprehension_type), 149, 4},
1344
16
        {offsetof(struct ast_state, ExceptHandler_type), 153, 3},
1345
16
        {offsetof(struct ast_state, arguments_type), 156, 7},
1346
16
        {offsetof(struct ast_state, arg_type), 163, 3},
1347
16
        {offsetof(struct ast_state, keyword_type), 166, 2},
1348
16
        {offsetof(struct ast_state, alias_type), 168, 2},
1349
16
        {offsetof(struct ast_state, withitem_type), 170, 2},
1350
16
        {offsetof(struct ast_state, match_case_type), 172, 3},
1351
16
        {offsetof(struct ast_state, MatchValue_type), 175, 1},
1352
16
        {offsetof(struct ast_state, MatchSingleton_type), 176, 1},
1353
16
        {offsetof(struct ast_state, MatchSequence_type), 177, 1},
1354
16
        {offsetof(struct ast_state, MatchMapping_type), 178, 3},
1355
16
        {offsetof(struct ast_state, MatchClass_type), 181, 4},
1356
16
        {offsetof(struct ast_state, MatchStar_type), 185, 1},
1357
16
        {offsetof(struct ast_state, MatchAs_type), 186, 2},
1358
16
        {offsetof(struct ast_state, MatchOr_type), 188, 1},
1359
16
        {offsetof(struct ast_state, TypeIgnore_type), 189, 2},
1360
16
        {offsetof(struct ast_state, TypeVar_type), 191, 3},
1361
16
        {offsetof(struct ast_state, ParamSpec_type), 194, 2},
1362
16
        {offsetof(struct ast_state, TypeVarTuple_type), 196, 2},
1363
16
    };
1364
16
    char *base = (char *)state;
1365
16
    PyObject *annotations = NULL;
1366
1.82k
    for (size_t i = 0; i < Py_ARRAY_LENGTH(nodes); i++) {
1367
1.80k
        annotations = PyDict_New();
1368
1.80k
        if (annotations == NULL) {
1369
0
            goto error;
1370
0
        }
1371
1.80k
        size_t end = nodes[i].first_field + nodes[i].nfields;
1372
4.97k
        for (size_t j = nodes[i].first_field; j < end; j++) {
1373
3.16k
            PyObject *name = *(PyObject **)(base + fields[j].name_offset);
1374
3.16k
            PyObject *type;
1375
3.16k
            if (fields[j].flags & FIELD_BUILTIN) {
1376
656
                type = (PyObject *)builtin_types[fields[j].type_offset];
1377
656
            }
1378
2.51k
            else {
1379
2.51k
                type = *(PyObject **)(base + fields[j].type_offset);
1380
2.51k
            }
1381
3.16k
            if (fields[j].flags & FIELD_OPTIONAL) {
1382
704
                type = _Py_union_type_or(type, Py_None);
1383
704
            }
1384
2.46k
            else if (fields[j].flags & FIELD_SEQUENCE) {
1385
1.18k
                type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1386
1.18k
            }
1387
1.28k
            else {
1388
1.28k
                Py_INCREF(type);
1389
1.28k
            }
1390
3.16k
            if (type == NULL) {
1391
0
                goto error;
1392
0
            }
1393
3.16k
            int res = PyDict_SetItem(annotations, name, type);
1394
3.16k
            Py_DECREF(type);
1395
3.16k
            if (res < 0) {
1396
0
                goto error;
1397
0
            }
1398
3.16k
        }
1399
1.80k
        PyObject *node = *(PyObject **)(base + nodes[i].type_offset);
1400
1.80k
        if (PyObject_SetAttrString(node, "_field_types", annotations) < 0 ||
1401
1.80k
            PyObject_SetAttrString(node, "__annotations__", annotations) < 0)
1402
0
        {
1403
0
            goto error;
1404
0
        }
1405
1.80k
        Py_CLEAR(annotations);
1406
1.80k
    }
1407
16
    return 1;
1408
0
error:
1409
0
    Py_XDECREF(annotations);
1410
0
    return 0;
1411
16
}
1412
1413
1414
1415
typedef struct {
1416
    PyObject_HEAD
1417
} AST_object;
1418
1419
static void
1420
ast_dealloc(PyObject *op)
1421
448k
{
1422
448k
    AST_object *self = (AST_object*)op;
1423
    /* bpo-31095: UnTrack is needed before calling any callbacks */
1424
448k
    PyTypeObject *tp = Py_TYPE(self);
1425
448k
    PyObject_GC_UnTrack(self);
1426
448k
    PyObject_ClearManagedDict(op);
1427
448k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
1428
448k
    assert(free_func != NULL);
1429
448k
    free_func(self);
1430
448k
    Py_DECREF(tp);
1431
448k
}
1432
1433
static int
1434
ast_traverse(PyObject *op, visitproc visit, void *arg)
1435
308k
{
1436
308k
    AST_object *self = (AST_object*)op;
1437
308k
    Py_VISIT(Py_TYPE(self));
1438
308k
    return PyObject_VisitManagedDict(op, visit, arg);
1439
308k
}
1440
1441
static int
1442
ast_clear(PyObject *op)
1443
0
{
1444
0
    PyObject_ClearManagedDict(op);
1445
0
    return 0;
1446
0
}
1447
1448
/*
1449
 * Format the names in the set 'missing' into a natural language list,
1450
 * sorted in the order in which they appear in 'fields'.
1451
 *
1452
 * Similar to format_missing() from 'Python/ceval.c'.
1453
 *
1454
 * Parameters
1455
 *
1456
 *      missing     Set of missing field names to render.
1457
 *      fields      Sequence of AST node field names (self._fields).
1458
 */
1459
static PyObject *
1460
format_missing(PyObject *missing, PyObject *fields)
1461
0
{
1462
0
    Py_ssize_t num_fields, num_total, num_left;
1463
0
    num_fields = PySequence_Size(fields);
1464
0
    if (num_fields == -1) {
1465
0
        return NULL;
1466
0
    }
1467
0
    num_total = num_left = PySet_GET_SIZE(missing);
1468
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
1469
0
    if (writer == NULL) {
1470
0
        goto error;
1471
0
    }
1472
    // Iterate all AST node fields in order so that the missing positional
1473
    // arguments are rendered in the order in which __init__ expects them.
1474
0
    for (Py_ssize_t i = 0; i < num_fields; i++) {
1475
0
        PyObject *name = PySequence_GetItem(fields, i);
1476
0
        if (name == NULL) {
1477
0
            goto error;
1478
0
        }
1479
0
        int contains = PySet_Contains(missing, name);
1480
0
        if (contains == -1) {
1481
0
            Py_DECREF(name);
1482
0
            goto error;
1483
0
        }
1484
0
        else if (contains == 1) {
1485
0
            const char* fmt = NULL;
1486
0
            if (num_left == 1) {
1487
0
                fmt = "'%U'";
1488
0
            }
1489
0
            else if (num_total == 2) {
1490
0
                fmt = "'%U' and ";
1491
0
            }
1492
0
            else if (num_left == 2) {
1493
0
                fmt = "'%U', and ";
1494
0
            }
1495
0
            else {
1496
0
                fmt = "'%U', ";
1497
0
            }
1498
0
            num_left--;
1499
0
            if (PyUnicodeWriter_Format(writer, fmt, name) < 0) {
1500
0
                Py_DECREF(name);
1501
0
                goto error;
1502
0
            }
1503
0
        }
1504
0
        Py_DECREF(name);
1505
0
    }
1506
0
    return PyUnicodeWriter_Finish(writer);
1507
0
error:
1508
0
    PyUnicodeWriter_Discard(writer);
1509
0
    return NULL;
1510
0
}
1511
1512
static int
1513
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
1514
245
{
1515
245
    struct ast_state *state = get_ast_state();
1516
245
    if (state == NULL) {
1517
0
        return -1;
1518
0
    }
1519
1520
245
    int contains = PySet_Contains(state->abstract_types, (PyObject *)Py_TYPE(self));
1521
245
    if (contains == -1) {
1522
0
        return -1;
1523
0
    }
1524
245
    else if (contains == 1) {
1525
0
        if (PyErr_WarnFormat(
1526
0
                PyExc_DeprecationWarning, 1,
1527
0
                "Instantiating abstract AST node class %T is deprecated. "
1528
0
                "This will become an error in Python 3.20", self) < 0) {
1529
0
            return -1;
1530
0
        }
1531
0
    }
1532
1533
245
    Py_ssize_t i, numfields = 0;
1534
245
    int res = -1;
1535
245
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
1536
1537
245
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
1538
245
    if (fields == NULL) {
1539
0
        goto cleanup;
1540
0
    }
1541
1542
245
    numfields = PySequence_Size(fields);
1543
245
    if (numfields == -1) {
1544
0
        goto cleanup;
1545
0
    }
1546
245
    remaining_fields = PySet_New(fields);
1547
245
    if (remaining_fields == NULL) {
1548
0
        goto cleanup;
1549
0
    }
1550
1551
245
    res = 0; /* if no error occurs, this stays 0 to the end */
1552
245
    if (numfields < PyTuple_GET_SIZE(args)) {
1553
0
        PyErr_Format(PyExc_TypeError, "%T constructor takes at most "
1554
0
                     "%zd positional argument%s",
1555
0
                     self, numfields, numfields == 1 ? "" : "s");
1556
0
        res = -1;
1557
0
        goto cleanup;
1558
0
    }
1559
245
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
1560
        /* cannot be reached when fields is NULL */
1561
0
        PyObject *name = PySequence_GetItem(fields, i);
1562
0
        if (!name) {
1563
0
            res = -1;
1564
0
            goto cleanup;
1565
0
        }
1566
0
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
1567
0
        if (PySet_Discard(remaining_fields, name) < 0) {
1568
0
            res = -1;
1569
0
            Py_DECREF(name);
1570
0
            goto cleanup;
1571
0
        }
1572
0
        Py_DECREF(name);
1573
0
        if (res < 0) {
1574
0
            goto cleanup;
1575
0
        }
1576
0
    }
1577
245
    if (kw) {
1578
0
        i = 0;  /* needed by PyDict_Next */
1579
0
        while (PyDict_Next(kw, &i, &key, &value)) {
1580
0
            int contains = PySequence_Contains(fields, key);
1581
0
            if (contains == -1) {
1582
0
                res = -1;
1583
0
                goto cleanup;
1584
0
            }
1585
0
            else if (contains == 1) {
1586
0
                int p = PySet_Discard(remaining_fields, key);
1587
0
                if (p == -1) {
1588
0
                    res = -1;
1589
0
                    goto cleanup;
1590
0
                }
1591
0
                if (p == 0) {
1592
0
                    PyErr_Format(PyExc_TypeError,
1593
0
                        "%T got multiple values for argument %R",
1594
0
                        self, key);
1595
0
                    res = -1;
1596
0
                    goto cleanup;
1597
0
                }
1598
0
            }
1599
0
            else {
1600
                // Lazily initialize "attributes"
1601
0
                if (attributes == NULL) {
1602
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
1603
0
                    if (attributes == NULL) {
1604
0
                        res = -1;
1605
0
                        goto cleanup;
1606
0
                    }
1607
0
                }
1608
0
                int contains = PySequence_Contains(attributes, key);
1609
0
                if (contains == -1) {
1610
0
                    res = -1;
1611
0
                    goto cleanup;
1612
0
                }
1613
0
                else if (contains == 0) {
1614
0
                    PyErr_Format(PyExc_TypeError,
1615
0
                        "%T.__init__ got an unexpected keyword argument %R",
1616
0
                        self, key);
1617
0
                    res = -1;
1618
0
                    goto cleanup;
1619
0
                }
1620
0
            }
1621
0
            res = PyObject_SetAttr(self, key, value);
1622
0
            if (res < 0) {
1623
0
                goto cleanup;
1624
0
            }
1625
0
        }
1626
0
    }
1627
245
    Py_ssize_t size = PySet_Size(remaining_fields);
1628
245
    PyObject *field_types = NULL, *remaining_list = NULL, *missing_names = NULL;
1629
245
    if (size > 0) {
1630
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
1631
0
                                     &field_types) < 0) {
1632
0
            res = -1;
1633
0
            goto cleanup;
1634
0
        }
1635
0
        if (field_types == NULL) {
1636
            // Probably a user-defined subclass of AST that lacks _field_types.
1637
            // This will continue to work as it did before 3.13; i.e., attributes
1638
            // that are not passed in simply do not exist on the instance.
1639
0
            goto cleanup;
1640
0
        }
1641
0
        remaining_list = PySequence_List(remaining_fields);
1642
0
        if (!remaining_list) {
1643
0
            goto set_remaining_cleanup;
1644
0
        }
1645
0
        missing_names = PySet_New(NULL);
1646
0
        if (!missing_names) {
1647
0
            goto set_remaining_cleanup;
1648
0
        }
1649
0
        for (Py_ssize_t i = 0; i < size; i++) {
1650
0
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
1651
0
            PyObject *type = PyDict_GetItemWithError(field_types, name);
1652
0
            if (!type) {
1653
0
                if (PyErr_Occurred()) {
1654
0
                    goto set_remaining_cleanup;
1655
0
                }
1656
0
                else {
1657
0
                    PyErr_Format(PyExc_TypeError,
1658
0
                        "Field %R is missing from %T._field_types",
1659
0
                        name, self);
1660
0
                    goto set_remaining_cleanup;
1661
0
                }
1662
0
            }
1663
0
            else if (_PyUnion_Check(type)) {
1664
                // optional field
1665
                // do nothing, we'll have set a None default on the class
1666
0
            }
1667
0
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
1668
                // list field
1669
0
                PyObject *empty = PyList_New(0);
1670
0
                if (!empty) {
1671
0
                    goto set_remaining_cleanup;
1672
0
                }
1673
0
                res = PyObject_SetAttr(self, name, empty);
1674
0
                Py_DECREF(empty);
1675
0
                if (res < 0) {
1676
0
                    goto set_remaining_cleanup;
1677
0
                }
1678
0
            }
1679
0
            else if (type == state->expr_context_type) {
1680
                // special case for expr_context: default to Load()
1681
0
                res = PyObject_SetAttr(self, name, state->Load_singleton);
1682
0
                if (res < 0) {
1683
0
                    goto set_remaining_cleanup;
1684
0
                }
1685
0
            }
1686
0
            else {
1687
                // simple field (e.g., identifier)
1688
0
                res = PySet_Add(missing_names, name);
1689
0
                if (res < 0) {
1690
0
                    goto set_remaining_cleanup;
1691
0
                }
1692
0
            }
1693
0
        }
1694
0
        Py_ssize_t num_missing = PySet_GET_SIZE(missing_names);
1695
0
        if (num_missing > 0) {
1696
0
            PyObject *name_str = format_missing(missing_names, fields);
1697
0
            if (!name_str) {
1698
0
                goto set_remaining_cleanup;
1699
0
            }
1700
0
            PyErr_Format(PyExc_TypeError,
1701
0
                "%T.__init__ missing %d required positional argument%s: %U",
1702
0
                self, num_missing, num_missing == 1 ? "" : "s", name_str);
1703
0
            Py_DECREF(name_str);
1704
0
            goto set_remaining_cleanup;
1705
0
        }
1706
0
        Py_DECREF(missing_names);
1707
0
        Py_DECREF(remaining_list);
1708
0
        Py_DECREF(field_types);
1709
0
    }
1710
245
  cleanup:
1711
245
    Py_XDECREF(attributes);
1712
245
    Py_XDECREF(fields);
1713
245
    Py_XDECREF(remaining_fields);
1714
245
    return res;
1715
0
  set_remaining_cleanup:
1716
0
    Py_XDECREF(missing_names);
1717
0
    Py_XDECREF(remaining_list);
1718
0
    Py_XDECREF(field_types);
1719
0
    res = -1;
1720
0
    goto cleanup;
1721
245
}
1722
1723
/* Pickling support */
1724
static PyObject *
1725
ast_type_reduce(PyObject *self, PyObject *unused)
1726
0
{
1727
0
    struct ast_state *state = get_ast_state();
1728
0
    if (state == NULL) {
1729
0
        return NULL;
1730
0
    }
1731
1732
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
1733
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
1734
0
        return NULL;
1735
0
    }
1736
0
    PyObject *result = NULL;
1737
0
    if (dict) {
1738
        // Unpickling (or copying) works as follows:
1739
        // - Construct the object with only positional arguments
1740
        // - Set the fields from the dict
1741
        // We have two constraints:
1742
        // - We must set all the required fields in the initial constructor call,
1743
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
1744
        // - We must not include child nodes in the positional args, because
1745
        //   that may trigger runaway recursion during copying (gh-120108).
1746
        // To satisfy both constraints, we set all the fields to None in the
1747
        // initial list of positional args, and then set the fields from the dict.
1748
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
1749
0
            goto cleanup;
1750
0
        }
1751
0
        if (fields) {
1752
0
            Py_ssize_t numfields = PySequence_Size(fields);
1753
0
            if (numfields == -1) {
1754
0
                Py_DECREF(dict);
1755
0
                goto cleanup;
1756
0
            }
1757
0
            positional_args = PyList_New(0);
1758
0
            if (!positional_args) {
1759
0
                goto cleanup;
1760
0
            }
1761
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
1762
0
                PyObject *name = PySequence_GetItem(fields, i);
1763
0
                if (!name) {
1764
0
                    goto cleanup;
1765
0
                }
1766
0
                PyObject *value;
1767
0
                int rc = PyDict_GetItemRef(dict, name, &value);
1768
0
                Py_DECREF(name);
1769
0
                if (rc < 0) {
1770
0
                    goto cleanup;
1771
0
                }
1772
0
                if (!value) {
1773
0
                    break;
1774
0
                }
1775
0
                rc = PyList_Append(positional_args, Py_None);
1776
0
                Py_DECREF(value);
1777
0
                if (rc < 0) {
1778
0
                    goto cleanup;
1779
0
                }
1780
0
            }
1781
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
1782
0
            if (!args_tuple) {
1783
0
                goto cleanup;
1784
0
            }
1785
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
1786
0
        }
1787
0
        else {
1788
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
1789
0
        }
1790
0
    }
1791
0
    else {
1792
0
        result = Py_BuildValue("O()", Py_TYPE(self));
1793
0
    }
1794
0
cleanup:
1795
0
    Py_XDECREF(fields);
1796
0
    Py_XDECREF(positional_args);
1797
0
    return result;
1798
0
}
1799
1800
/*
1801
 * Python equivalent:
1802
 *
1803
 *   for key in keys:
1804
 *       if hasattr(self, key):
1805
 *           payload[key] = getattr(self, key)
1806
 *
1807
 * The 'keys' argument is a sequence corresponding to
1808
 * the '_fields' or the '_attributes' of an AST node.
1809
 *
1810
 * This returns -1 if an error occurs and 0 otherwise.
1811
 *
1812
 * Parameters
1813
 *
1814
 *      payload   A dictionary to fill.
1815
 *      keys      A sequence of keys or NULL for an empty sequence.
1816
 *      dict      The AST node instance dictionary (must not be NULL).
1817
 */
1818
static inline int
1819
ast_type_replace_update_payload(PyObject *payload,
1820
                                PyObject *keys,
1821
                                PyObject *dict)
1822
0
{
1823
0
    assert(dict != NULL);
1824
0
    if (keys == NULL) {
1825
0
        return 0;
1826
0
    }
1827
0
    Py_ssize_t n = PySequence_Size(keys);
1828
0
    if (n == -1) {
1829
0
        return -1;
1830
0
    }
1831
0
    for (Py_ssize_t i = 0; i < n; i++) {
1832
0
        PyObject *key = PySequence_GetItem(keys, i);
1833
0
        if (key == NULL) {
1834
0
            return -1;
1835
0
        }
1836
0
        PyObject *value;
1837
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
1838
0
            Py_DECREF(key);
1839
0
            return -1;
1840
0
        }
1841
0
        if (value == NULL) {
1842
0
            Py_DECREF(key);
1843
            // If a field or attribute is not present at runtime, it should
1844
            // be explicitly given in 'kwargs'. If not, the constructor will
1845
            // issue a warning (which becomes an error in 3.15).
1846
0
            continue;
1847
0
        }
1848
0
        int rc = PyDict_SetItem(payload, key, value);
1849
0
        Py_DECREF(key);
1850
0
        Py_DECREF(value);
1851
0
        if (rc < 0) {
1852
0
            return -1;
1853
0
        }
1854
0
    }
1855
0
    return 0;
1856
0
}
1857
1858
/* copy.replace() support (shallow copy) */
1859
static PyObject *
1860
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
1861
0
{
1862
0
    if (!_PyArg_NoPositional("__replace__", args)) {
1863
0
        return NULL;
1864
0
    }
1865
1866
0
    struct ast_state *state = get_ast_state();
1867
0
    if (state == NULL) {
1868
0
        return NULL;
1869
0
    }
1870
1871
0
    PyObject *result = NULL;
1872
    // known AST class fields and attributes
1873
0
    PyObject *fields = NULL, *attributes = NULL;
1874
    // current instance dictionary
1875
0
    PyObject *dict = NULL;
1876
    // constructor positional and keyword arguments
1877
0
    PyObject *empty_tuple = NULL, *payload = NULL;
1878
1879
0
    PyObject *type = (PyObject *)Py_TYPE(self);
1880
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
1881
0
        goto cleanup;
1882
0
    }
1883
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
1884
0
        goto cleanup;
1885
0
    }
1886
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
1887
0
        goto cleanup;
1888
0
    }
1889
0
    empty_tuple = PyTuple_New(0);
1890
0
    if (empty_tuple == NULL) {
1891
0
        goto cleanup;
1892
0
    }
1893
0
    payload = PyDict_New();
1894
0
    if (payload == NULL) {
1895
0
        goto cleanup;
1896
0
    }
1897
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
1898
        // copy the instance's fields (possibly NULL)
1899
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
1900
0
            goto cleanup;
1901
0
        }
1902
        // copy the instance's attributes (possibly NULL)
1903
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
1904
0
            goto cleanup;
1905
0
        }
1906
0
    }
1907
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
1908
0
        goto cleanup;
1909
0
    }
1910
0
    result = PyObject_Call(type, empty_tuple, payload);
1911
0
cleanup:
1912
0
    Py_XDECREF(payload);
1913
0
    Py_XDECREF(empty_tuple);
1914
0
    Py_XDECREF(dict);
1915
0
    Py_XDECREF(attributes);
1916
0
    Py_XDECREF(fields);
1917
0
    return result;
1918
0
}
1919
1920
static PyMethodDef ast_type_methods[] = {
1921
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
1922
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
1923
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
1924
               "Return a copy of the AST node with new values "
1925
               "for the specified fields.")},
1926
    {NULL}
1927
};
1928
1929
static PyGetSetDef ast_type_getsets[] = {
1930
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
1931
    {NULL}
1932
};
1933
1934
static PyObject *
1935
ast_repr_max_depth(AST_object *self, int depth);
1936
1937
/* Format list and tuple properties of AST nodes.
1938
   Note that, only the first and last elements are shown.
1939
   Anything in between is represented with an ellipsis ('...').
1940
   For example, the list [1, 2, 3] is formatted as
1941
   'List(elts=[Constant(1), ..., Constant(3)])'. */
1942
static PyObject *
1943
ast_repr_list(PyObject *list, int depth)
1944
0
{
1945
0
    assert(PyList_Check(list) || PyTuple_Check(list));
1946
1947
0
    struct ast_state *state = get_ast_state();
1948
0
    if (state == NULL) {
1949
0
        return NULL;
1950
0
    }
1951
1952
0
    Py_ssize_t length = PySequence_Size(list);
1953
0
    if (length < 0) {
1954
0
        return NULL;
1955
0
    }
1956
0
    else if (length == 0) {
1957
0
        return PyObject_Repr(list);
1958
0
    }
1959
1960
0
    PyObject *items[2] = {NULL, NULL};
1961
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
1962
0
    if (writer == NULL) {
1963
0
        goto error;
1964
0
    }
1965
1966
0
    items[0] = PySequence_GetItem(list, 0);
1967
0
    if (!items[0]) {
1968
0
        goto error;
1969
0
    }
1970
0
    if (length > 1) {
1971
0
        items[1] = PySequence_GetItem(list, length - 1);
1972
0
        if (!items[1]) {
1973
0
            goto error;
1974
0
        }
1975
0
    }
1976
1977
0
    bool is_list = PyList_Check(list);
1978
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
1979
0
        goto error;
1980
0
    }
1981
1982
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
1983
0
        if (i > 0) {
1984
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
1985
0
                goto error;
1986
0
            }
1987
0
        }
1988
1989
0
        PyObject *item = items[i];
1990
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
1991
0
            PyObject *item_repr;
1992
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
1993
0
            if (!item_repr) {
1994
0
                goto error;
1995
0
            }
1996
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
1997
0
                Py_DECREF(item_repr);
1998
0
                goto error;
1999
0
            }
2000
0
            Py_DECREF(item_repr);
2001
0
        } else {
2002
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
2003
0
                goto error;
2004
0
            }
2005
0
        }
2006
2007
0
        if (i == 0 && length > 2) {
2008
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
2009
0
                goto error;
2010
0
            }
2011
0
        }
2012
0
    }
2013
2014
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
2015
0
        goto error;
2016
0
    }
2017
2018
0
    Py_XDECREF(items[0]);
2019
0
    Py_XDECREF(items[1]);
2020
0
    return PyUnicodeWriter_Finish(writer);
2021
2022
0
error:
2023
0
    Py_XDECREF(items[0]);
2024
0
    Py_XDECREF(items[1]);
2025
0
    PyUnicodeWriter_Discard(writer);
2026
0
    return NULL;
2027
0
}
2028
2029
static PyObject *
2030
ast_repr_max_depth(AST_object *self, int depth)
2031
0
{
2032
0
    struct ast_state *state = get_ast_state();
2033
0
    if (state == NULL) {
2034
0
        return NULL;
2035
0
    }
2036
2037
0
    PyObject *fields = PyObject_GetAttr((PyObject *)Py_TYPE(self), state->_fields);
2038
0
    if (!fields) {
2039
0
        return NULL;
2040
0
    }
2041
2042
0
    Py_ssize_t numfields = PySequence_Size(fields);
2043
0
    if (numfields < 0) {
2044
0
        Py_DECREF(fields);
2045
0
        return NULL;
2046
0
    }
2047
2048
0
    if (numfields == 0) {
2049
0
        Py_DECREF(fields);
2050
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
2051
0
    }
2052
2053
0
    if (depth <= 0) {
2054
0
        Py_DECREF(fields);
2055
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
2056
0
    }
2057
2058
0
    int status = Py_ReprEnter((PyObject *)self);
2059
0
    if (status != 0) {
2060
0
        Py_DECREF(fields);
2061
0
        if (status < 0) {
2062
0
            return NULL;
2063
0
        }
2064
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
2065
0
    }
2066
2067
0
    const char* tp_name = Py_TYPE(self)->tp_name;
2068
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
2069
0
    if (writer == NULL) {
2070
0
        goto error;
2071
0
    }
2072
2073
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
2074
0
        goto error;
2075
0
    }
2076
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
2077
0
        goto error;
2078
0
    }
2079
2080
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
2081
0
        PyObject *name = PySequence_GetItem(fields, i);
2082
0
        if (!name) {
2083
0
            goto error;
2084
0
        }
2085
2086
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
2087
0
        if (!value) {
2088
0
            Py_DECREF(name);
2089
0
            goto error;
2090
0
        }
2091
2092
0
        PyObject *value_repr;
2093
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
2094
0
            value_repr = ast_repr_list(value, depth);
2095
0
        }
2096
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
2097
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
2098
0
        }
2099
0
        else {
2100
0
            value_repr = PyObject_Repr(value);
2101
0
        }
2102
2103
0
        Py_DECREF(value);
2104
2105
0
        if (!value_repr) {
2106
0
            Py_DECREF(name);
2107
0
            goto error;
2108
0
        }
2109
2110
0
        if (i > 0) {
2111
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
2112
0
                Py_DECREF(name);
2113
0
                Py_DECREF(value_repr);
2114
0
                goto error;
2115
0
            }
2116
0
        }
2117
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
2118
0
            Py_DECREF(name);
2119
0
            Py_DECREF(value_repr);
2120
0
            goto error;
2121
0
        }
2122
2123
0
        Py_DECREF(name);
2124
2125
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
2126
0
            Py_DECREF(value_repr);
2127
0
            goto error;
2128
0
        }
2129
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
2130
0
            Py_DECREF(value_repr);
2131
0
            goto error;
2132
0
        }
2133
2134
0
        Py_DECREF(value_repr);
2135
0
    }
2136
2137
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
2138
0
        goto error;
2139
0
    }
2140
0
    Py_ReprLeave((PyObject *)self);
2141
0
    Py_DECREF(fields);
2142
0
    return PyUnicodeWriter_Finish(writer);
2143
2144
0
error:
2145
0
    Py_ReprLeave((PyObject *)self);
2146
0
    Py_DECREF(fields);
2147
0
    PyUnicodeWriter_Discard(writer);
2148
0
    return NULL;
2149
0
}
2150
2151
static PyObject *
2152
ast_repr(PyObject *self)
2153
0
{
2154
0
    return ast_repr_max_depth((AST_object*)self, 3);
2155
0
}
2156
2157
static PyType_Slot AST_type_slots[] = {
2158
    {Py_tp_dealloc, ast_dealloc},
2159
    {Py_tp_repr, ast_repr},
2160
    {Py_tp_getattro, PyObject_GenericGetAttr},
2161
    {Py_tp_setattro, PyObject_GenericSetAttr},
2162
    {Py_tp_traverse, ast_traverse},
2163
    {Py_tp_clear, ast_clear},
2164
    {Py_tp_methods, ast_type_methods},
2165
    {Py_tp_getset, ast_type_getsets},
2166
    {Py_tp_init, ast_type_init},
2167
    {Py_tp_alloc, PyType_GenericAlloc},
2168
    {Py_tp_new, PyType_GenericNew},
2169
    {Py_tp_free, PyObject_GC_Del},
2170
    {0, 0},
2171
};
2172
2173
static PyType_Spec AST_type_spec = {
2174
    "ast.AST",
2175
    sizeof(AST_object),
2176
    0,
2177
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
2178
    Py_TPFLAGS_MANAGED_DICT,
2179
    AST_type_slots
2180
};
2181
2182
static PyObject *
2183
make_type(struct ast_state *state, const char *type, PyObject* base,
2184
          const char* const* fields, int num_fields, const char *doc)
2185
2.00k
{
2186
2.00k
    PyObject *fnames, *result;
2187
2.00k
    int i;
2188
2.00k
    fnames = PyTuple_New(num_fields);
2189
2.00k
    if (!fnames) return NULL;
2190
5.16k
    for (i = 0; i < num_fields; i++) {
2191
3.16k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
2192
3.16k
        if (!field) {
2193
0
            Py_DECREF(fnames);
2194
0
            return NULL;
2195
0
        }
2196
3.16k
        PyTuple_SET_ITEM(fnames, i, field);
2197
3.16k
    }
2198
2.00k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
2199
2.00k
                    type, base,
2200
2.00k
                    state->_fields, fnames,
2201
2.00k
                    state->__match_args__, fnames,
2202
2.00k
                    state->__module__,
2203
2.00k
                    state->ast,
2204
2.00k
                    state->__doc__, doc);
2205
2.00k
    Py_DECREF(fnames);
2206
2.00k
    return result;
2207
2.00k
}
2208
2209
static int
2210
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
2211
304
{
2212
304
    int i, result;
2213
304
    PyObject *s, *l = PyTuple_New(num_fields);
2214
304
    if (!l)
2215
0
        return -1;
2216
816
    for (i = 0; i < num_fields; i++) {
2217
512
        s = PyUnicode_InternFromString(attrs[i]);
2218
512
        if (!s) {
2219
0
            Py_DECREF(l);
2220
0
            return -1;
2221
0
        }
2222
512
        PyTuple_SET_ITEM(l, i, s);
2223
512
    }
2224
304
    result = PyObject_SetAttr(type, state->_attributes, l);
2225
304
    Py_DECREF(l);
2226
304
    return result;
2227
304
}
2228
2229
/* Conversion AST -> Python */
2230
2231
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
2232
                              PyObject* (*func)(struct ast_state *state, void*))
2233
117k
{
2234
117k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
2235
117k
    PyObject *result = PyList_New(n);
2236
117k
    PyObject *value;
2237
117k
    if (!result)
2238
0
        return NULL;
2239
292k
    for (i = 0; i < n; i++) {
2240
174k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
2241
174k
        if (!value) {
2242
0
            Py_DECREF(result);
2243
0
            return NULL;
2244
0
        }
2245
174k
        PyList_SET_ITEM(result, i, value);
2246
174k
    }
2247
117k
    return result;
2248
117k
}
2249
2250
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
2251
277k
{
2252
277k
    PyObject *op = (PyObject*)o;
2253
277k
    if (!op) {
2254
87.4k
        op = Py_None;
2255
87.4k
    }
2256
277k
    return Py_NewRef(op);
2257
277k
}
2258
63.5k
#define ast2obj_constant ast2obj_object
2259
136k
#define ast2obj_identifier ast2obj_object
2260
76.4k
#define ast2obj_string ast2obj_object
2261
2262
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
2263
1.74M
{
2264
1.74M
    return PyLong_FromLong(b);
2265
1.74M
}
2266
2267
/* Conversion Python -> AST */
2268
2269
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj,
2270
                          PyObject** out,
2271
                          const char* Py_UNUSED(field), PyArena* arena)
2272
0
{
2273
0
    if (obj == Py_None)
2274
0
        obj = NULL;
2275
0
    if (obj) {
2276
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
2277
0
            *out = NULL;
2278
0
            return -1;
2279
0
        }
2280
0
        *out = Py_NewRef(obj);
2281
0
    }
2282
0
    else {
2283
0
        *out = NULL;
2284
0
    }
2285
0
    return 0;
2286
0
}
2287
2288
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj,
2289
                            PyObject** out,
2290
                            const char* Py_UNUSED(field), PyArena* arena)
2291
0
{
2292
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
2293
0
        *out = NULL;
2294
0
        return -1;
2295
0
    }
2296
0
    *out = Py_NewRef(obj);
2297
0
    return 0;
2298
0
}
2299
2300
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, const char* field, PyArena* arena)
2301
0
{
2302
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
2303
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting a string object, got %T", field, obj);
2304
0
        return -1;
2305
0
    }
2306
0
    return obj2ast_object(state, obj, out, field, arena);
2307
0
}
2308
2309
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, const char* field, PyArena* arena)
2310
0
{
2311
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
2312
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting a string or bytes object, got %T", field, obj);
2313
0
        return -1;
2314
0
    }
2315
0
    return obj2ast_object(state, obj, out, field, arena);
2316
0
}
2317
2318
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, const char* field, PyArena* arena)
2319
0
{
2320
0
    int i;
2321
0
    if (!PyLong_Check(obj)) {
2322
0
        PyErr_Format(PyExc_ValueError, "field \"%s\" got an invalid integer value: %R", field, obj);
2323
0
        return -1;
2324
0
    }
2325
2326
0
    i = PyLong_AsInt(obj);
2327
0
    if (i == -1 && PyErr_Occurred())
2328
0
        return -1;
2329
0
    *out = i;
2330
0
    return 0;
2331
0
}
2332
2333
static int add_ast_fields(struct ast_state *state)
2334
16
{
2335
16
    PyObject *empty_tuple;
2336
16
    empty_tuple = PyTuple_New(0);
2337
16
    if (!empty_tuple ||
2338
16
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
2339
16
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
2340
16
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
2341
0
        Py_XDECREF(empty_tuple);
2342
0
        return -1;
2343
0
    }
2344
16
    Py_DECREF(empty_tuple);
2345
16
    return 0;
2346
16
}
2347
2348
2349
2350
static int
2351
init_types(void *arg)
2352
16
{
2353
16
    struct ast_state *state = arg;
2354
16
    if (init_identifiers(state) < 0) {
2355
0
        return -1;
2356
0
    }
2357
16
    state->AST_type = PyType_FromSpec(&AST_type_spec);
2358
16
    if (!state->AST_type) {
2359
0
        return -1;
2360
0
    }
2361
16
    state->abstract_types = PySet_New(NULL);
2362
16
    if (!state->abstract_types) {
2363
0
        return -1;
2364
0
    }
2365
16
    if (PySet_Add(state->abstract_types, state->AST_type) < 0) {
2366
0
        return -1;
2367
0
    }
2368
16
    if (add_ast_fields(state) < 0) {
2369
0
        return -1;
2370
0
    }
2371
16
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
2372
16
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
2373
16
        "    | Interactive(stmt* body)\n"
2374
16
        "    | Expression(expr body)\n"
2375
16
        "    | FunctionType(expr* argtypes, expr returns)");
2376
16
    if (!state->mod_type) return -1;
2377
16
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
2378
16
    if (PySet_Add(state->abstract_types, state->mod_type) < 0) return -1;
2379
16
    state->Module_type = make_type(state, "Module", state->mod_type,
2380
16
                                   Module_fields, 2,
2381
16
        "Module(stmt* body, type_ignore* type_ignores)");
2382
16
    if (!state->Module_type) return -1;
2383
16
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
2384
16
                                        Interactive_fields, 1,
2385
16
        "Interactive(stmt* body)");
2386
16
    if (!state->Interactive_type) return -1;
2387
16
    state->Expression_type = make_type(state, "Expression", state->mod_type,
2388
16
                                       Expression_fields, 1,
2389
16
        "Expression(expr body)");
2390
16
    if (!state->Expression_type) return -1;
2391
16
    state->FunctionType_type = make_type(state, "FunctionType",
2392
16
                                         state->mod_type, FunctionType_fields,
2393
16
                                         2,
2394
16
        "FunctionType(expr* argtypes, expr returns)");
2395
16
    if (!state->FunctionType_type) return -1;
2396
16
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
2397
16
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
2398
16
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
2399
16
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
2400
16
        "     | Return(expr? value)\n"
2401
16
        "     | Delete(expr* targets)\n"
2402
16
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
2403
16
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
2404
16
        "     | AugAssign(expr target, operator op, expr value)\n"
2405
16
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
2406
16
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
2407
16
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
2408
16
        "     | While(expr test, stmt* body, stmt* orelse)\n"
2409
16
        "     | If(expr test, stmt* body, stmt* orelse)\n"
2410
16
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
2411
16
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
2412
16
        "     | Match(expr subject, match_case* cases)\n"
2413
16
        "     | Raise(expr? exc, expr? cause)\n"
2414
16
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
2415
16
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
2416
16
        "     | Assert(expr test, expr? msg)\n"
2417
16
        "     | Import(alias* names, int? is_lazy)\n"
2418
16
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
2419
16
        "     | Global(identifier* names)\n"
2420
16
        "     | Nonlocal(identifier* names)\n"
2421
16
        "     | Expr(expr value)\n"
2422
16
        "     | Pass\n"
2423
16
        "     | Break\n"
2424
16
        "     | Continue");
2425
16
    if (!state->stmt_type) return -1;
2426
16
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
2427
0
        -1;
2428
16
    if (PySet_Add(state->abstract_types, state->stmt_type) < 0) return -1;
2429
16
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
2430
0
        return -1;
2431
16
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
2432
16
        -1)
2433
0
        return -1;
2434
16
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
2435
16
                                        FunctionDef_fields, 7,
2436
16
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
2437
16
    if (!state->FunctionDef_type) return -1;
2438
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
2439
16
        -1)
2440
0
        return -1;
2441
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
2442
16
        == -1)
2443
0
        return -1;
2444
16
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
2445
16
                                             state->stmt_type,
2446
16
                                             AsyncFunctionDef_fields, 7,
2447
16
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
2448
16
    if (!state->AsyncFunctionDef_type) return -1;
2449
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
2450
16
        == -1)
2451
0
        return -1;
2452
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
2453
16
        Py_None) == -1)
2454
0
        return -1;
2455
16
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
2456
16
                                     ClassDef_fields, 6,
2457
16
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
2458
16
    if (!state->ClassDef_type) return -1;
2459
16
    state->Return_type = make_type(state, "Return", state->stmt_type,
2460
16
                                   Return_fields, 1,
2461
16
        "Return(expr? value)");
2462
16
    if (!state->Return_type) return -1;
2463
16
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
2464
0
        return -1;
2465
16
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
2466
16
                                   Delete_fields, 1,
2467
16
        "Delete(expr* targets)");
2468
16
    if (!state->Delete_type) return -1;
2469
16
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
2470
16
                                   Assign_fields, 3,
2471
16
        "Assign(expr* targets, expr value, string? type_comment)");
2472
16
    if (!state->Assign_type) return -1;
2473
16
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
2474
16
        -1)
2475
0
        return -1;
2476
16
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
2477
16
                                      TypeAlias_fields, 3,
2478
16
        "TypeAlias(expr name, type_param* type_params, expr value)");
2479
16
    if (!state->TypeAlias_type) return -1;
2480
16
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
2481
16
                                      AugAssign_fields, 3,
2482
16
        "AugAssign(expr target, operator op, expr value)");
2483
16
    if (!state->AugAssign_type) return -1;
2484
16
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
2485
16
                                      AnnAssign_fields, 4,
2486
16
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
2487
16
    if (!state->AnnAssign_type) return -1;
2488
16
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
2489
0
        return -1;
2490
16
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
2491
16
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
2492
16
    if (!state->For_type) return -1;
2493
16
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
2494
0
        return -1;
2495
16
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
2496
16
                                     AsyncFor_fields, 5,
2497
16
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
2498
16
    if (!state->AsyncFor_type) return -1;
2499
16
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
2500
16
        -1)
2501
0
        return -1;
2502
16
    state->While_type = make_type(state, "While", state->stmt_type,
2503
16
                                  While_fields, 3,
2504
16
        "While(expr test, stmt* body, stmt* orelse)");
2505
16
    if (!state->While_type) return -1;
2506
16
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
2507
16
        "If(expr test, stmt* body, stmt* orelse)");
2508
16
    if (!state->If_type) return -1;
2509
16
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
2510
16
                                 3,
2511
16
        "With(withitem* items, stmt* body, string? type_comment)");
2512
16
    if (!state->With_type) return -1;
2513
16
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
2514
0
        return -1;
2515
16
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
2516
16
                                      AsyncWith_fields, 3,
2517
16
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
2518
16
    if (!state->AsyncWith_type) return -1;
2519
16
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
2520
16
        == -1)
2521
0
        return -1;
2522
16
    state->Match_type = make_type(state, "Match", state->stmt_type,
2523
16
                                  Match_fields, 2,
2524
16
        "Match(expr subject, match_case* cases)");
2525
16
    if (!state->Match_type) return -1;
2526
16
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
2527
16
                                  Raise_fields, 2,
2528
16
        "Raise(expr? exc, expr? cause)");
2529
16
    if (!state->Raise_type) return -1;
2530
16
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
2531
0
        return -1;
2532
16
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
2533
0
        return -1;
2534
16
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
2535
16
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
2536
16
    if (!state->Try_type) return -1;
2537
16
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
2538
16
                                    TryStar_fields, 4,
2539
16
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
2540
16
    if (!state->TryStar_type) return -1;
2541
16
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
2542
16
                                   Assert_fields, 2,
2543
16
        "Assert(expr test, expr? msg)");
2544
16
    if (!state->Assert_type) return -1;
2545
16
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
2546
0
        return -1;
2547
16
    state->Import_type = make_type(state, "Import", state->stmt_type,
2548
16
                                   Import_fields, 2,
2549
16
        "Import(alias* names, int? is_lazy)");
2550
16
    if (!state->Import_type) return -1;
2551
16
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
2552
0
        return -1;
2553
16
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
2554
16
                                       ImportFrom_fields, 4,
2555
16
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
2556
16
    if (!state->ImportFrom_type) return -1;
2557
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
2558
0
        return -1;
2559
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
2560
0
        return -1;
2561
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
2562
0
        return -1;
2563
16
    state->Global_type = make_type(state, "Global", state->stmt_type,
2564
16
                                   Global_fields, 1,
2565
16
        "Global(identifier* names)");
2566
16
    if (!state->Global_type) return -1;
2567
16
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
2568
16
                                     Nonlocal_fields, 1,
2569
16
        "Nonlocal(identifier* names)");
2570
16
    if (!state->Nonlocal_type) return -1;
2571
16
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
2572
16
                                 1,
2573
16
        "Expr(expr value)");
2574
16
    if (!state->Expr_type) return -1;
2575
16
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
2576
16
        "Pass");
2577
16
    if (!state->Pass_type) return -1;
2578
16
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
2579
16
        "Break");
2580
16
    if (!state->Break_type) return -1;
2581
16
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
2582
16
                                     0,
2583
16
        "Continue");
2584
16
    if (!state->Continue_type) return -1;
2585
16
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
2586
16
        "expr = BoolOp(boolop op, expr* values)\n"
2587
16
        "     | NamedExpr(expr target, expr value)\n"
2588
16
        "     | BinOp(expr left, operator op, expr right)\n"
2589
16
        "     | UnaryOp(unaryop op, expr operand)\n"
2590
16
        "     | Lambda(arguments args, expr body)\n"
2591
16
        "     | IfExp(expr test, expr body, expr orelse)\n"
2592
16
        "     | Dict(expr?* keys, expr* values)\n"
2593
16
        "     | Set(expr* elts)\n"
2594
16
        "     | ListComp(expr elt, comprehension* generators)\n"
2595
16
        "     | SetComp(expr elt, comprehension* generators)\n"
2596
16
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
2597
16
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
2598
16
        "     | Await(expr value)\n"
2599
16
        "     | Yield(expr? value)\n"
2600
16
        "     | YieldFrom(expr value)\n"
2601
16
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
2602
16
        "     | Call(expr func, expr* args, keyword* keywords)\n"
2603
16
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
2604
16
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
2605
16
        "     | JoinedStr(expr* values)\n"
2606
16
        "     | TemplateStr(expr* values)\n"
2607
16
        "     | Constant(constant value, string? kind)\n"
2608
16
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
2609
16
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
2610
16
        "     | Starred(expr value, expr_context ctx)\n"
2611
16
        "     | Name(identifier id, expr_context ctx)\n"
2612
16
        "     | List(expr* elts, expr_context ctx)\n"
2613
16
        "     | Tuple(expr* elts, expr_context ctx)\n"
2614
16
        "     | Slice(expr? lower, expr? upper, expr? step)");
2615
16
    if (!state->expr_type) return -1;
2616
16
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
2617
0
        -1;
2618
16
    if (PySet_Add(state->abstract_types, state->expr_type) < 0) return -1;
2619
16
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
2620
0
        return -1;
2621
16
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
2622
16
        -1)
2623
0
        return -1;
2624
16
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
2625
16
                                   BoolOp_fields, 2,
2626
16
        "BoolOp(boolop op, expr* values)");
2627
16
    if (!state->BoolOp_type) return -1;
2628
16
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
2629
16
                                      NamedExpr_fields, 2,
2630
16
        "NamedExpr(expr target, expr value)");
2631
16
    if (!state->NamedExpr_type) return -1;
2632
16
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
2633
16
                                  BinOp_fields, 3,
2634
16
        "BinOp(expr left, operator op, expr right)");
2635
16
    if (!state->BinOp_type) return -1;
2636
16
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
2637
16
                                    UnaryOp_fields, 2,
2638
16
        "UnaryOp(unaryop op, expr operand)");
2639
16
    if (!state->UnaryOp_type) return -1;
2640
16
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
2641
16
                                   Lambda_fields, 2,
2642
16
        "Lambda(arguments args, expr body)");
2643
16
    if (!state->Lambda_type) return -1;
2644
16
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
2645
16
                                  IfExp_fields, 3,
2646
16
        "IfExp(expr test, expr body, expr orelse)");
2647
16
    if (!state->IfExp_type) return -1;
2648
16
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
2649
16
                                 2,
2650
16
        "Dict(expr?* keys, expr* values)");
2651
16
    if (!state->Dict_type) return -1;
2652
16
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
2653
16
        "Set(expr* elts)");
2654
16
    if (!state->Set_type) return -1;
2655
16
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
2656
16
                                     ListComp_fields, 2,
2657
16
        "ListComp(expr elt, comprehension* generators)");
2658
16
    if (!state->ListComp_type) return -1;
2659
16
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
2660
16
                                    SetComp_fields, 2,
2661
16
        "SetComp(expr elt, comprehension* generators)");
2662
16
    if (!state->SetComp_type) return -1;
2663
16
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
2664
16
                                     DictComp_fields, 3,
2665
16
        "DictComp(expr key, expr? value, comprehension* generators)");
2666
16
    if (!state->DictComp_type) return -1;
2667
16
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
2668
0
        return -1;
2669
16
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
2670
16
                                         state->expr_type, GeneratorExp_fields,
2671
16
                                         2,
2672
16
        "GeneratorExp(expr elt, comprehension* generators)");
2673
16
    if (!state->GeneratorExp_type) return -1;
2674
16
    state->Await_type = make_type(state, "Await", state->expr_type,
2675
16
                                  Await_fields, 1,
2676
16
        "Await(expr value)");
2677
16
    if (!state->Await_type) return -1;
2678
16
    state->Yield_type = make_type(state, "Yield", state->expr_type,
2679
16
                                  Yield_fields, 1,
2680
16
        "Yield(expr? value)");
2681
16
    if (!state->Yield_type) return -1;
2682
16
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
2683
0
        return -1;
2684
16
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
2685
16
                                      YieldFrom_fields, 1,
2686
16
        "YieldFrom(expr value)");
2687
16
    if (!state->YieldFrom_type) return -1;
2688
16
    state->Compare_type = make_type(state, "Compare", state->expr_type,
2689
16
                                    Compare_fields, 3,
2690
16
        "Compare(expr left, cmpop* ops, expr* comparators)");
2691
16
    if (!state->Compare_type) return -1;
2692
16
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
2693
16
                                 3,
2694
16
        "Call(expr func, expr* args, keyword* keywords)");
2695
16
    if (!state->Call_type) return -1;
2696
16
    state->FormattedValue_type = make_type(state, "FormattedValue",
2697
16
                                           state->expr_type,
2698
16
                                           FormattedValue_fields, 3,
2699
16
        "FormattedValue(expr value, int conversion, expr? format_spec)");
2700
16
    if (!state->FormattedValue_type) return -1;
2701
16
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
2702
16
        Py_None) == -1)
2703
0
        return -1;
2704
16
    state->Interpolation_type = make_type(state, "Interpolation",
2705
16
                                          state->expr_type,
2706
16
                                          Interpolation_fields, 4,
2707
16
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
2708
16
    if (!state->Interpolation_type) return -1;
2709
16
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
2710
16
        Py_None) == -1)
2711
0
        return -1;
2712
16
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
2713
16
                                      JoinedStr_fields, 1,
2714
16
        "JoinedStr(expr* values)");
2715
16
    if (!state->JoinedStr_type) return -1;
2716
16
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
2717
16
                                        TemplateStr_fields, 1,
2718
16
        "TemplateStr(expr* values)");
2719
16
    if (!state->TemplateStr_type) return -1;
2720
16
    state->Constant_type = make_type(state, "Constant", state->expr_type,
2721
16
                                     Constant_fields, 2,
2722
16
        "Constant(constant value, string? kind)");
2723
16
    if (!state->Constant_type) return -1;
2724
16
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
2725
0
        return -1;
2726
16
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
2727
16
                                      Attribute_fields, 3,
2728
16
        "Attribute(expr value, identifier attr, expr_context ctx)");
2729
16
    if (!state->Attribute_type) return -1;
2730
16
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
2731
16
                                      Subscript_fields, 3,
2732
16
        "Subscript(expr value, expr slice, expr_context ctx)");
2733
16
    if (!state->Subscript_type) return -1;
2734
16
    state->Starred_type = make_type(state, "Starred", state->expr_type,
2735
16
                                    Starred_fields, 2,
2736
16
        "Starred(expr value, expr_context ctx)");
2737
16
    if (!state->Starred_type) return -1;
2738
16
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
2739
16
                                 2,
2740
16
        "Name(identifier id, expr_context ctx)");
2741
16
    if (!state->Name_type) return -1;
2742
16
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
2743
16
                                 2,
2744
16
        "List(expr* elts, expr_context ctx)");
2745
16
    if (!state->List_type) return -1;
2746
16
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
2747
16
                                  Tuple_fields, 2,
2748
16
        "Tuple(expr* elts, expr_context ctx)");
2749
16
    if (!state->Tuple_type) return -1;
2750
16
    state->Slice_type = make_type(state, "Slice", state->expr_type,
2751
16
                                  Slice_fields, 3,
2752
16
        "Slice(expr? lower, expr? upper, expr? step)");
2753
16
    if (!state->Slice_type) return -1;
2754
16
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
2755
0
        return -1;
2756
16
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
2757
0
        return -1;
2758
16
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
2759
0
        return -1;
2760
16
    state->expr_context_type = make_type(state, "expr_context",
2761
16
                                         state->AST_type, NULL, 0,
2762
16
        "expr_context = Load | Store | Del");
2763
16
    if (!state->expr_context_type) return -1;
2764
16
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
2765
16
    if (PySet_Add(state->abstract_types, state->expr_context_type) < 0) return
2766
0
        -1;
2767
16
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
2768
16
                                 0,
2769
16
        "Load");
2770
16
    if (!state->Load_type) return -1;
2771
16
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
2772
16
                                              NULL, NULL);
2773
16
    if (!state->Load_singleton) return -1;
2774
16
    state->Store_type = make_type(state, "Store", state->expr_context_type,
2775
16
                                  NULL, 0,
2776
16
        "Store");
2777
16
    if (!state->Store_type) return -1;
2778
16
    state->Store_singleton = PyType_GenericNew((PyTypeObject
2779
16
                                               *)state->Store_type, NULL, NULL);
2780
16
    if (!state->Store_singleton) return -1;
2781
16
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
2782
16
        "Del");
2783
16
    if (!state->Del_type) return -1;
2784
16
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
2785
16
                                             NULL, NULL);
2786
16
    if (!state->Del_singleton) return -1;
2787
16
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
2788
16
        "boolop = And | Or");
2789
16
    if (!state->boolop_type) return -1;
2790
16
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
2791
16
    if (PySet_Add(state->abstract_types, state->boolop_type) < 0) return -1;
2792
16
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
2793
16
        "And");
2794
16
    if (!state->And_type) return -1;
2795
16
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
2796
16
                                             NULL, NULL);
2797
16
    if (!state->And_singleton) return -1;
2798
16
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
2799
16
        "Or");
2800
16
    if (!state->Or_type) return -1;
2801
16
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
2802
16
                                            NULL, NULL);
2803
16
    if (!state->Or_singleton) return -1;
2804
16
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
2805
16
                                     0,
2806
16
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
2807
16
    if (!state->operator_type) return -1;
2808
16
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
2809
16
    if (PySet_Add(state->abstract_types, state->operator_type) < 0) return -1;
2810
16
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
2811
16
        "Add");
2812
16
    if (!state->Add_type) return -1;
2813
16
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
2814
16
                                             NULL, NULL);
2815
16
    if (!state->Add_singleton) return -1;
2816
16
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
2817
16
        "Sub");
2818
16
    if (!state->Sub_type) return -1;
2819
16
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
2820
16
                                             NULL, NULL);
2821
16
    if (!state->Sub_singleton) return -1;
2822
16
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
2823
16
        "Mult");
2824
16
    if (!state->Mult_type) return -1;
2825
16
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
2826
16
                                              NULL, NULL);
2827
16
    if (!state->Mult_singleton) return -1;
2828
16
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
2829
16
                                    NULL, 0,
2830
16
        "MatMult");
2831
16
    if (!state->MatMult_type) return -1;
2832
16
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
2833
16
                                                 *)state->MatMult_type, NULL,
2834
16
                                                 NULL);
2835
16
    if (!state->MatMult_singleton) return -1;
2836
16
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
2837
16
        "Div");
2838
16
    if (!state->Div_type) return -1;
2839
16
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
2840
16
                                             NULL, NULL);
2841
16
    if (!state->Div_singleton) return -1;
2842
16
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
2843
16
        "Mod");
2844
16
    if (!state->Mod_type) return -1;
2845
16
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
2846
16
                                             NULL, NULL);
2847
16
    if (!state->Mod_singleton) return -1;
2848
16
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
2849
16
        "Pow");
2850
16
    if (!state->Pow_type) return -1;
2851
16
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
2852
16
                                             NULL, NULL);
2853
16
    if (!state->Pow_singleton) return -1;
2854
16
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
2855
16
                                   0,
2856
16
        "LShift");
2857
16
    if (!state->LShift_type) return -1;
2858
16
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
2859
16
                                                *)state->LShift_type, NULL,
2860
16
                                                NULL);
2861
16
    if (!state->LShift_singleton) return -1;
2862
16
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
2863
16
                                   0,
2864
16
        "RShift");
2865
16
    if (!state->RShift_type) return -1;
2866
16
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
2867
16
                                                *)state->RShift_type, NULL,
2868
16
                                                NULL);
2869
16
    if (!state->RShift_singleton) return -1;
2870
16
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
2871
16
        "BitOr");
2872
16
    if (!state->BitOr_type) return -1;
2873
16
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
2874
16
                                               *)state->BitOr_type, NULL, NULL);
2875
16
    if (!state->BitOr_singleton) return -1;
2876
16
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
2877
16
                                   0,
2878
16
        "BitXor");
2879
16
    if (!state->BitXor_type) return -1;
2880
16
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
2881
16
                                                *)state->BitXor_type, NULL,
2882
16
                                                NULL);
2883
16
    if (!state->BitXor_singleton) return -1;
2884
16
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
2885
16
                                   0,
2886
16
        "BitAnd");
2887
16
    if (!state->BitAnd_type) return -1;
2888
16
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
2889
16
                                                *)state->BitAnd_type, NULL,
2890
16
                                                NULL);
2891
16
    if (!state->BitAnd_singleton) return -1;
2892
16
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
2893
16
                                     NULL, 0,
2894
16
        "FloorDiv");
2895
16
    if (!state->FloorDiv_type) return -1;
2896
16
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
2897
16
                                                  *)state->FloorDiv_type, NULL,
2898
16
                                                  NULL);
2899
16
    if (!state->FloorDiv_singleton) return -1;
2900
16
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
2901
16
        "unaryop = Invert | Not | UAdd | USub");
2902
16
    if (!state->unaryop_type) return -1;
2903
16
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
2904
16
    if (PySet_Add(state->abstract_types, state->unaryop_type) < 0) return -1;
2905
16
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
2906
16
                                   0,
2907
16
        "Invert");
2908
16
    if (!state->Invert_type) return -1;
2909
16
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
2910
16
                                                *)state->Invert_type, NULL,
2911
16
                                                NULL);
2912
16
    if (!state->Invert_singleton) return -1;
2913
16
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
2914
16
        "Not");
2915
16
    if (!state->Not_type) return -1;
2916
16
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
2917
16
                                             NULL, NULL);
2918
16
    if (!state->Not_singleton) return -1;
2919
16
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
2920
16
        "UAdd");
2921
16
    if (!state->UAdd_type) return -1;
2922
16
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
2923
16
                                              NULL, NULL);
2924
16
    if (!state->UAdd_singleton) return -1;
2925
16
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
2926
16
        "USub");
2927
16
    if (!state->USub_type) return -1;
2928
16
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
2929
16
                                              NULL, NULL);
2930
16
    if (!state->USub_singleton) return -1;
2931
16
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
2932
16
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
2933
16
    if (!state->cmpop_type) return -1;
2934
16
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
2935
16
    if (PySet_Add(state->abstract_types, state->cmpop_type) < 0) return -1;
2936
16
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
2937
16
        "Eq");
2938
16
    if (!state->Eq_type) return -1;
2939
16
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
2940
16
                                            NULL, NULL);
2941
16
    if (!state->Eq_singleton) return -1;
2942
16
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
2943
16
        "NotEq");
2944
16
    if (!state->NotEq_type) return -1;
2945
16
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
2946
16
                                               *)state->NotEq_type, NULL, NULL);
2947
16
    if (!state->NotEq_singleton) return -1;
2948
16
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
2949
16
        "Lt");
2950
16
    if (!state->Lt_type) return -1;
2951
16
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
2952
16
                                            NULL, NULL);
2953
16
    if (!state->Lt_singleton) return -1;
2954
16
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
2955
16
        "LtE");
2956
16
    if (!state->LtE_type) return -1;
2957
16
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
2958
16
                                             NULL, NULL);
2959
16
    if (!state->LtE_singleton) return -1;
2960
16
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
2961
16
        "Gt");
2962
16
    if (!state->Gt_type) return -1;
2963
16
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
2964
16
                                            NULL, NULL);
2965
16
    if (!state->Gt_singleton) return -1;
2966
16
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
2967
16
        "GtE");
2968
16
    if (!state->GtE_type) return -1;
2969
16
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
2970
16
                                             NULL, NULL);
2971
16
    if (!state->GtE_singleton) return -1;
2972
16
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
2973
16
        "Is");
2974
16
    if (!state->Is_type) return -1;
2975
16
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
2976
16
                                            NULL, NULL);
2977
16
    if (!state->Is_singleton) return -1;
2978
16
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
2979
16
        "IsNot");
2980
16
    if (!state->IsNot_type) return -1;
2981
16
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
2982
16
                                               *)state->IsNot_type, NULL, NULL);
2983
16
    if (!state->IsNot_singleton) return -1;
2984
16
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
2985
16
        "In");
2986
16
    if (!state->In_type) return -1;
2987
16
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
2988
16
                                            NULL, NULL);
2989
16
    if (!state->In_singleton) return -1;
2990
16
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
2991
16
        "NotIn");
2992
16
    if (!state->NotIn_type) return -1;
2993
16
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
2994
16
                                               *)state->NotIn_type, NULL, NULL);
2995
16
    if (!state->NotIn_singleton) return -1;
2996
16
    state->comprehension_type = make_type(state, "comprehension",
2997
16
                                          state->AST_type,
2998
16
                                          comprehension_fields, 4,
2999
16
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
3000
16
    if (!state->comprehension_type) return -1;
3001
16
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
3002
0
        -1;
3003
16
    state->excepthandler_type = make_type(state, "excepthandler",
3004
16
                                          state->AST_type, NULL, 0,
3005
16
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
3006
16
    if (!state->excepthandler_type) return -1;
3007
16
    if (add_attributes(state, state->excepthandler_type,
3008
16
        excepthandler_attributes, 4) < 0) return -1;
3009
16
    if (PySet_Add(state->abstract_types, state->excepthandler_type) < 0) return
3010
0
        -1;
3011
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
3012
16
        == -1)
3013
0
        return -1;
3014
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
3015
16
        Py_None) == -1)
3016
0
        return -1;
3017
16
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
3018
16
                                          state->excepthandler_type,
3019
16
                                          ExceptHandler_fields, 3,
3020
16
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
3021
16
    if (!state->ExceptHandler_type) return -1;
3022
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
3023
0
        return -1;
3024
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
3025
0
        return -1;
3026
16
    state->arguments_type = make_type(state, "arguments", state->AST_type,
3027
16
                                      arguments_fields, 7,
3028
16
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
3029
16
    if (!state->arguments_type) return -1;
3030
16
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
3031
16
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
3032
0
        return -1;
3033
16
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
3034
0
        return -1;
3035
16
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
3036
16
        "arg(identifier arg, expr? annotation, string? type_comment)");
3037
16
    if (!state->arg_type) return -1;
3038
16
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
3039
0
        -1;
3040
16
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
3041
0
        return -1;
3042
16
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
3043
0
        return -1;
3044
16
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
3045
0
        return -1;
3046
16
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
3047
0
        return -1;
3048
16
    state->keyword_type = make_type(state, "keyword", state->AST_type,
3049
16
                                    keyword_fields, 2,
3050
16
        "keyword(identifier? arg, expr value)");
3051
16
    if (!state->keyword_type) return -1;
3052
16
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
3053
0
        return -1;
3054
16
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
3055
0
        return -1;
3056
16
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
3057
0
        return -1;
3058
16
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
3059
16
        == -1)
3060
0
        return -1;
3061
16
    state->alias_type = make_type(state, "alias", state->AST_type,
3062
16
                                  alias_fields, 2,
3063
16
        "alias(identifier name, identifier? asname)");
3064
16
    if (!state->alias_type) return -1;
3065
16
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
3066
0
        return -1;
3067
16
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
3068
0
        return -1;
3069
16
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
3070
0
        return -1;
3071
16
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
3072
16
        -1)
3073
0
        return -1;
3074
16
    state->withitem_type = make_type(state, "withitem", state->AST_type,
3075
16
                                     withitem_fields, 2,
3076
16
        "withitem(expr context_expr, expr? optional_vars)");
3077
16
    if (!state->withitem_type) return -1;
3078
16
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
3079
16
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
3080
16
        == -1)
3081
0
        return -1;
3082
16
    state->match_case_type = make_type(state, "match_case", state->AST_type,
3083
16
                                       match_case_fields, 3,
3084
16
        "match_case(pattern pattern, expr? guard, stmt* body)");
3085
16
    if (!state->match_case_type) return -1;
3086
16
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
3087
16
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
3088
0
        return -1;
3089
16
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
3090
16
        "pattern = MatchValue(expr value)\n"
3091
16
        "        | MatchSingleton(constant value)\n"
3092
16
        "        | MatchSequence(pattern* patterns)\n"
3093
16
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
3094
16
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
3095
16
        "        | MatchStar(identifier? name)\n"
3096
16
        "        | MatchAs(pattern? pattern, identifier? name)\n"
3097
16
        "        | MatchOr(pattern* patterns)");
3098
16
    if (!state->pattern_type) return -1;
3099
16
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
3100
0
        return -1;
3101
16
    if (PySet_Add(state->abstract_types, state->pattern_type) < 0) return -1;
3102
16
    state->MatchValue_type = make_type(state, "MatchValue",
3103
16
                                       state->pattern_type, MatchValue_fields,
3104
16
                                       1,
3105
16
        "MatchValue(expr value)");
3106
16
    if (!state->MatchValue_type) return -1;
3107
16
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
3108
16
                                           state->pattern_type,
3109
16
                                           MatchSingleton_fields, 1,
3110
16
        "MatchSingleton(constant value)");
3111
16
    if (!state->MatchSingleton_type) return -1;
3112
16
    state->MatchSequence_type = make_type(state, "MatchSequence",
3113
16
                                          state->pattern_type,
3114
16
                                          MatchSequence_fields, 1,
3115
16
        "MatchSequence(pattern* patterns)");
3116
16
    if (!state->MatchSequence_type) return -1;
3117
16
    state->MatchMapping_type = make_type(state, "MatchMapping",
3118
16
                                         state->pattern_type,
3119
16
                                         MatchMapping_fields, 3,
3120
16
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
3121
16
    if (!state->MatchMapping_type) return -1;
3122
16
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
3123
0
        return -1;
3124
16
    state->MatchClass_type = make_type(state, "MatchClass",
3125
16
                                       state->pattern_type, MatchClass_fields,
3126
16
                                       4,
3127
16
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
3128
16
    if (!state->MatchClass_type) return -1;
3129
16
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
3130
16
                                      MatchStar_fields, 1,
3131
16
        "MatchStar(identifier? name)");
3132
16
    if (!state->MatchStar_type) return -1;
3133
16
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
3134
0
        return -1;
3135
16
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
3136
16
                                    MatchAs_fields, 2,
3137
16
        "MatchAs(pattern? pattern, identifier? name)");
3138
16
    if (!state->MatchAs_type) return -1;
3139
16
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
3140
0
        return -1;
3141
16
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
3142
0
        return -1;
3143
16
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
3144
16
                                    MatchOr_fields, 1,
3145
16
        "MatchOr(pattern* patterns)");
3146
16
    if (!state->MatchOr_type) return -1;
3147
16
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
3148
16
                                        NULL, 0,
3149
16
        "type_ignore = TypeIgnore(int lineno, string tag)");
3150
16
    if (!state->type_ignore_type) return -1;
3151
16
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
3152
16
    if (PySet_Add(state->abstract_types, state->type_ignore_type) < 0) return
3153
0
        -1;
3154
16
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
3155
16
                                       state->type_ignore_type,
3156
16
                                       TypeIgnore_fields, 2,
3157
16
        "TypeIgnore(int lineno, string tag)");
3158
16
    if (!state->TypeIgnore_type) return -1;
3159
16
    state->type_param_type = make_type(state, "type_param", state->AST_type,
3160
16
                                       NULL, 0,
3161
16
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
3162
16
        "           | ParamSpec(identifier name, expr? default_value)\n"
3163
16
        "           | TypeVarTuple(identifier name, expr? default_value)");
3164
16
    if (!state->type_param_type) return -1;
3165
16
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
3166
16
        < 0) return -1;
3167
16
    if (PySet_Add(state->abstract_types, state->type_param_type) < 0) return -1;
3168
16
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
3169
16
                                    TypeVar_fields, 3,
3170
16
        "TypeVar(identifier name, expr? bound, expr? default_value)");
3171
16
    if (!state->TypeVar_type) return -1;
3172
16
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
3173
0
        return -1;
3174
16
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
3175
16
        -1)
3176
0
        return -1;
3177
16
    state->ParamSpec_type = make_type(state, "ParamSpec",
3178
16
                                      state->type_param_type, ParamSpec_fields,
3179
16
                                      2,
3180
16
        "ParamSpec(identifier name, expr? default_value)");
3181
16
    if (!state->ParamSpec_type) return -1;
3182
16
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
3183
16
        == -1)
3184
0
        return -1;
3185
16
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
3186
16
                                         state->type_param_type,
3187
16
                                         TypeVarTuple_fields, 2,
3188
16
        "TypeVarTuple(identifier name, expr? default_value)");
3189
16
    if (!state->TypeVarTuple_type) return -1;
3190
16
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
3191
16
        Py_None) == -1)
3192
0
        return -1;
3193
3194
16
    if (!add_ast_annotations(state)) {
3195
0
        return -1;
3196
0
    }
3197
16
    return 0;
3198
16
}
3199
3200
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
3201
                       const char* field, PyArena* arena);
3202
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
3203
                        const char* field, PyArena* arena);
3204
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
3205
                        const char* field, PyArena* arena);
3206
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
3207
                                expr_context_ty* out, const char* field,
3208
                                PyArena* arena);
3209
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
3210
                          out, const char* field, PyArena* arena);
3211
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
3212
                            operator_ty* out, const char* field, PyArena*
3213
                            arena);
3214
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
3215
                           out, const char* field, PyArena* arena);
3216
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
3217
                         const char* field, PyArena* arena);
3218
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
3219
                                 comprehension_ty* out, const char* field,
3220
                                 PyArena* arena);
3221
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
3222
                                 excepthandler_ty* out, const char* field,
3223
                                 PyArena* arena);
3224
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
3225
                             arguments_ty* out, const char* field, PyArena*
3226
                             arena);
3227
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
3228
                       const char* field, PyArena* arena);
3229
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
3230
                           out, const char* field, PyArena* arena);
3231
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
3232
                         const char* field, PyArena* arena);
3233
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
3234
                            withitem_ty* out, const char* field, PyArena*
3235
                            arena);
3236
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
3237
                              match_case_ty* out, const char* field, PyArena*
3238
                              arena);
3239
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
3240
                           out, const char* field, PyArena* arena);
3241
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
3242
                               type_ignore_ty* out, const char* field, PyArena*
3243
                               arena);
3244
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
3245
                              type_param_ty* out, const char* field, PyArena*
3246
                              arena);
3247
3248
mod_ty
3249
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
3250
              PyArena *arena)
3251
8.87k
{
3252
8.87k
    mod_ty p;
3253
8.87k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
3254
8.87k
    if (!p)
3255
0
        return NULL;
3256
8.87k
    p->kind = Module_kind;
3257
8.87k
    p->v.Module.body = body;
3258
8.87k
    p->v.Module.type_ignores = type_ignores;
3259
8.87k
    return p;
3260
8.87k
}
3261
3262
mod_ty
3263
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
3264
0
{
3265
0
    mod_ty p;
3266
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
3267
0
    if (!p)
3268
0
        return NULL;
3269
0
    p->kind = Interactive_kind;
3270
0
    p->v.Interactive.body = body;
3271
0
    return p;
3272
0
}
3273
3274
mod_ty
3275
_PyAST_Expression(expr_ty body, PyArena *arena)
3276
172
{
3277
172
    mod_ty p;
3278
172
    if (!body) {
3279
0
        PyErr_SetString(PyExc_ValueError,
3280
0
                        "field 'body' is required for Expression");
3281
0
        return NULL;
3282
0
    }
3283
172
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
3284
172
    if (!p)
3285
0
        return NULL;
3286
172
    p->kind = Expression_kind;
3287
172
    p->v.Expression.body = body;
3288
172
    return p;
3289
172
}
3290
3291
mod_ty
3292
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
3293
0
{
3294
0
    mod_ty p;
3295
0
    if (!returns) {
3296
0
        PyErr_SetString(PyExc_ValueError,
3297
0
                        "field 'returns' is required for FunctionType");
3298
0
        return NULL;
3299
0
    }
3300
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
3301
0
    if (!p)
3302
0
        return NULL;
3303
0
    p->kind = FunctionType_kind;
3304
0
    p->v.FunctionType.argtypes = argtypes;
3305
0
    p->v.FunctionType.returns = returns;
3306
0
    return p;
3307
0
}
3308
3309
stmt_ty
3310
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
3311
                   asdl_expr_seq * decorator_list, expr_ty returns, string
3312
                   type_comment, asdl_type_param_seq * type_params, int lineno,
3313
                   int col_offset, int end_lineno, int end_col_offset, PyArena
3314
                   *arena)
3315
6.58k
{
3316
6.58k
    stmt_ty p;
3317
6.58k
    if (!name) {
3318
0
        PyErr_SetString(PyExc_ValueError,
3319
0
                        "field 'name' is required for FunctionDef");
3320
0
        return NULL;
3321
0
    }
3322
6.58k
    if (!args) {
3323
0
        PyErr_SetString(PyExc_ValueError,
3324
0
                        "field 'args' is required for FunctionDef");
3325
0
        return NULL;
3326
0
    }
3327
6.58k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3328
6.58k
    if (!p)
3329
0
        return NULL;
3330
6.58k
    p->kind = FunctionDef_kind;
3331
6.58k
    p->v.FunctionDef.name = name;
3332
6.58k
    p->v.FunctionDef.args = args;
3333
6.58k
    p->v.FunctionDef.body = body;
3334
6.58k
    p->v.FunctionDef.decorator_list = decorator_list;
3335
6.58k
    p->v.FunctionDef.returns = returns;
3336
6.58k
    p->v.FunctionDef.type_comment = type_comment;
3337
6.58k
    p->v.FunctionDef.type_params = type_params;
3338
6.58k
    p->lineno = lineno;
3339
6.58k
    p->col_offset = col_offset;
3340
6.58k
    p->end_lineno = end_lineno;
3341
6.58k
    p->end_col_offset = end_col_offset;
3342
6.58k
    return p;
3343
6.58k
}
3344
3345
stmt_ty
3346
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
3347
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
3348
                        string type_comment, asdl_type_param_seq * type_params,
3349
                        int lineno, int col_offset, int end_lineno, int
3350
                        end_col_offset, PyArena *arena)
3351
1.36k
{
3352
1.36k
    stmt_ty p;
3353
1.36k
    if (!name) {
3354
0
        PyErr_SetString(PyExc_ValueError,
3355
0
                        "field 'name' is required for AsyncFunctionDef");
3356
0
        return NULL;
3357
0
    }
3358
1.36k
    if (!args) {
3359
0
        PyErr_SetString(PyExc_ValueError,
3360
0
                        "field 'args' is required for AsyncFunctionDef");
3361
0
        return NULL;
3362
0
    }
3363
1.36k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3364
1.36k
    if (!p)
3365
0
        return NULL;
3366
1.36k
    p->kind = AsyncFunctionDef_kind;
3367
1.36k
    p->v.AsyncFunctionDef.name = name;
3368
1.36k
    p->v.AsyncFunctionDef.args = args;
3369
1.36k
    p->v.AsyncFunctionDef.body = body;
3370
1.36k
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
3371
1.36k
    p->v.AsyncFunctionDef.returns = returns;
3372
1.36k
    p->v.AsyncFunctionDef.type_comment = type_comment;
3373
1.36k
    p->v.AsyncFunctionDef.type_params = type_params;
3374
1.36k
    p->lineno = lineno;
3375
1.36k
    p->col_offset = col_offset;
3376
1.36k
    p->end_lineno = end_lineno;
3377
1.36k
    p->end_col_offset = end_col_offset;
3378
1.36k
    return p;
3379
1.36k
}
3380
3381
stmt_ty
3382
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
3383
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
3384
                asdl_type_param_seq * type_params, int lineno, int col_offset,
3385
                int end_lineno, int end_col_offset, PyArena *arena)
3386
3.13k
{
3387
3.13k
    stmt_ty p;
3388
3.13k
    if (!name) {
3389
0
        PyErr_SetString(PyExc_ValueError,
3390
0
                        "field 'name' is required for ClassDef");
3391
0
        return NULL;
3392
0
    }
3393
3.13k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3394
3.13k
    if (!p)
3395
0
        return NULL;
3396
3.13k
    p->kind = ClassDef_kind;
3397
3.13k
    p->v.ClassDef.name = name;
3398
3.13k
    p->v.ClassDef.bases = bases;
3399
3.13k
    p->v.ClassDef.keywords = keywords;
3400
3.13k
    p->v.ClassDef.body = body;
3401
3.13k
    p->v.ClassDef.decorator_list = decorator_list;
3402
3.13k
    p->v.ClassDef.type_params = type_params;
3403
3.13k
    p->lineno = lineno;
3404
3.13k
    p->col_offset = col_offset;
3405
3.13k
    p->end_lineno = end_lineno;
3406
3.13k
    p->end_col_offset = end_col_offset;
3407
3.13k
    return p;
3408
3.13k
}
3409
3410
stmt_ty
3411
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
3412
              end_col_offset, PyArena *arena)
3413
2.53k
{
3414
2.53k
    stmt_ty p;
3415
2.53k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3416
2.53k
    if (!p)
3417
0
        return NULL;
3418
2.53k
    p->kind = Return_kind;
3419
2.53k
    p->v.Return.value = value;
3420
2.53k
    p->lineno = lineno;
3421
2.53k
    p->col_offset = col_offset;
3422
2.53k
    p->end_lineno = end_lineno;
3423
2.53k
    p->end_col_offset = end_col_offset;
3424
2.53k
    return p;
3425
2.53k
}
3426
3427
stmt_ty
3428
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
3429
              end_lineno, int end_col_offset, PyArena *arena)
3430
1.16k
{
3431
1.16k
    stmt_ty p;
3432
1.16k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3433
1.16k
    if (!p)
3434
0
        return NULL;
3435
1.16k
    p->kind = Delete_kind;
3436
1.16k
    p->v.Delete.targets = targets;
3437
1.16k
    p->lineno = lineno;
3438
1.16k
    p->col_offset = col_offset;
3439
1.16k
    p->end_lineno = end_lineno;
3440
1.16k
    p->end_col_offset = end_col_offset;
3441
1.16k
    return p;
3442
1.16k
}
3443
3444
stmt_ty
3445
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
3446
              lineno, int col_offset, int end_lineno, int end_col_offset,
3447
              PyArena *arena)
3448
3.43k
{
3449
3.43k
    stmt_ty p;
3450
3.43k
    if (!value) {
3451
0
        PyErr_SetString(PyExc_ValueError,
3452
0
                        "field 'value' is required for Assign");
3453
0
        return NULL;
3454
0
    }
3455
3.43k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3456
3.43k
    if (!p)
3457
0
        return NULL;
3458
3.43k
    p->kind = Assign_kind;
3459
3.43k
    p->v.Assign.targets = targets;
3460
3.43k
    p->v.Assign.value = value;
3461
3.43k
    p->v.Assign.type_comment = type_comment;
3462
3.43k
    p->lineno = lineno;
3463
3.43k
    p->col_offset = col_offset;
3464
3.43k
    p->end_lineno = end_lineno;
3465
3.43k
    p->end_col_offset = end_col_offset;
3466
3.43k
    return p;
3467
3.43k
}
3468
3469
stmt_ty
3470
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
3471
                 value, int lineno, int col_offset, int end_lineno, int
3472
                 end_col_offset, PyArena *arena)
3473
405
{
3474
405
    stmt_ty p;
3475
405
    if (!name) {
3476
0
        PyErr_SetString(PyExc_ValueError,
3477
0
                        "field 'name' is required for TypeAlias");
3478
0
        return NULL;
3479
0
    }
3480
405
    if (!value) {
3481
0
        PyErr_SetString(PyExc_ValueError,
3482
0
                        "field 'value' is required for TypeAlias");
3483
0
        return NULL;
3484
0
    }
3485
405
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3486
405
    if (!p)
3487
0
        return NULL;
3488
405
    p->kind = TypeAlias_kind;
3489
405
    p->v.TypeAlias.name = name;
3490
405
    p->v.TypeAlias.type_params = type_params;
3491
405
    p->v.TypeAlias.value = value;
3492
405
    p->lineno = lineno;
3493
405
    p->col_offset = col_offset;
3494
405
    p->end_lineno = end_lineno;
3495
405
    p->end_col_offset = end_col_offset;
3496
405
    return p;
3497
405
}
3498
3499
stmt_ty
3500
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
3501
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3502
2.93k
{
3503
2.93k
    stmt_ty p;
3504
2.93k
    if (!target) {
3505
0
        PyErr_SetString(PyExc_ValueError,
3506
0
                        "field 'target' is required for AugAssign");
3507
0
        return NULL;
3508
0
    }
3509
2.93k
    if (!op) {
3510
0
        PyErr_SetString(PyExc_ValueError,
3511
0
                        "field 'op' is required for AugAssign");
3512
0
        return NULL;
3513
0
    }
3514
2.93k
    if (!value) {
3515
0
        PyErr_SetString(PyExc_ValueError,
3516
0
                        "field 'value' is required for AugAssign");
3517
0
        return NULL;
3518
0
    }
3519
2.93k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3520
2.93k
    if (!p)
3521
0
        return NULL;
3522
2.93k
    p->kind = AugAssign_kind;
3523
2.93k
    p->v.AugAssign.target = target;
3524
2.93k
    p->v.AugAssign.op = op;
3525
2.93k
    p->v.AugAssign.value = value;
3526
2.93k
    p->lineno = lineno;
3527
2.93k
    p->col_offset = col_offset;
3528
2.93k
    p->end_lineno = end_lineno;
3529
2.93k
    p->end_col_offset = end_col_offset;
3530
2.93k
    return p;
3531
2.93k
}
3532
3533
stmt_ty
3534
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
3535
                 int lineno, int col_offset, int end_lineno, int
3536
                 end_col_offset, PyArena *arena)
3537
3.41k
{
3538
3.41k
    stmt_ty p;
3539
3.41k
    if (!target) {
3540
0
        PyErr_SetString(PyExc_ValueError,
3541
0
                        "field 'target' is required for AnnAssign");
3542
0
        return NULL;
3543
0
    }
3544
3.41k
    if (!annotation) {
3545
0
        PyErr_SetString(PyExc_ValueError,
3546
0
                        "field 'annotation' is required for AnnAssign");
3547
0
        return NULL;
3548
0
    }
3549
3.41k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3550
3.41k
    if (!p)
3551
0
        return NULL;
3552
3.41k
    p->kind = AnnAssign_kind;
3553
3.41k
    p->v.AnnAssign.target = target;
3554
3.41k
    p->v.AnnAssign.annotation = annotation;
3555
3.41k
    p->v.AnnAssign.value = value;
3556
3.41k
    p->v.AnnAssign.simple = simple;
3557
3.41k
    p->lineno = lineno;
3558
3.41k
    p->col_offset = col_offset;
3559
3.41k
    p->end_lineno = end_lineno;
3560
3.41k
    p->end_col_offset = end_col_offset;
3561
3.41k
    return p;
3562
3.41k
}
3563
3564
stmt_ty
3565
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
3566
           orelse, string type_comment, int lineno, int col_offset, int
3567
           end_lineno, int end_col_offset, PyArena *arena)
3568
1.23k
{
3569
1.23k
    stmt_ty p;
3570
1.23k
    if (!target) {
3571
0
        PyErr_SetString(PyExc_ValueError,
3572
0
                        "field 'target' is required for For");
3573
0
        return NULL;
3574
0
    }
3575
1.23k
    if (!iter) {
3576
0
        PyErr_SetString(PyExc_ValueError,
3577
0
                        "field 'iter' is required for For");
3578
0
        return NULL;
3579
0
    }
3580
1.23k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3581
1.23k
    if (!p)
3582
0
        return NULL;
3583
1.23k
    p->kind = For_kind;
3584
1.23k
    p->v.For.target = target;
3585
1.23k
    p->v.For.iter = iter;
3586
1.23k
    p->v.For.body = body;
3587
1.23k
    p->v.For.orelse = orelse;
3588
1.23k
    p->v.For.type_comment = type_comment;
3589
1.23k
    p->lineno = lineno;
3590
1.23k
    p->col_offset = col_offset;
3591
1.23k
    p->end_lineno = end_lineno;
3592
1.23k
    p->end_col_offset = end_col_offset;
3593
1.23k
    return p;
3594
1.23k
}
3595
3596
stmt_ty
3597
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
3598
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
3599
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3600
230
{
3601
230
    stmt_ty p;
3602
230
    if (!target) {
3603
0
        PyErr_SetString(PyExc_ValueError,
3604
0
                        "field 'target' is required for AsyncFor");
3605
0
        return NULL;
3606
0
    }
3607
230
    if (!iter) {
3608
0
        PyErr_SetString(PyExc_ValueError,
3609
0
                        "field 'iter' is required for AsyncFor");
3610
0
        return NULL;
3611
0
    }
3612
230
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3613
230
    if (!p)
3614
0
        return NULL;
3615
230
    p->kind = AsyncFor_kind;
3616
230
    p->v.AsyncFor.target = target;
3617
230
    p->v.AsyncFor.iter = iter;
3618
230
    p->v.AsyncFor.body = body;
3619
230
    p->v.AsyncFor.orelse = orelse;
3620
230
    p->v.AsyncFor.type_comment = type_comment;
3621
230
    p->lineno = lineno;
3622
230
    p->col_offset = col_offset;
3623
230
    p->end_lineno = end_lineno;
3624
230
    p->end_col_offset = end_col_offset;
3625
230
    return p;
3626
230
}
3627
3628
stmt_ty
3629
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
3630
             lineno, int col_offset, int end_lineno, int end_col_offset,
3631
             PyArena *arena)
3632
1.32k
{
3633
1.32k
    stmt_ty p;
3634
1.32k
    if (!test) {
3635
0
        PyErr_SetString(PyExc_ValueError,
3636
0
                        "field 'test' is required for While");
3637
0
        return NULL;
3638
0
    }
3639
1.32k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3640
1.32k
    if (!p)
3641
0
        return NULL;
3642
1.32k
    p->kind = While_kind;
3643
1.32k
    p->v.While.test = test;
3644
1.32k
    p->v.While.body = body;
3645
1.32k
    p->v.While.orelse = orelse;
3646
1.32k
    p->lineno = lineno;
3647
1.32k
    p->col_offset = col_offset;
3648
1.32k
    p->end_lineno = end_lineno;
3649
1.32k
    p->end_col_offset = end_col_offset;
3650
1.32k
    return p;
3651
1.32k
}
3652
3653
stmt_ty
3654
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
3655
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
3656
          *arena)
3657
4.19k
{
3658
4.19k
    stmt_ty p;
3659
4.19k
    if (!test) {
3660
0
        PyErr_SetString(PyExc_ValueError,
3661
0
                        "field 'test' is required for If");
3662
0
        return NULL;
3663
0
    }
3664
4.19k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3665
4.19k
    if (!p)
3666
0
        return NULL;
3667
4.19k
    p->kind = If_kind;
3668
4.19k
    p->v.If.test = test;
3669
4.19k
    p->v.If.body = body;
3670
4.19k
    p->v.If.orelse = orelse;
3671
4.19k
    p->lineno = lineno;
3672
4.19k
    p->col_offset = col_offset;
3673
4.19k
    p->end_lineno = end_lineno;
3674
4.19k
    p->end_col_offset = end_col_offset;
3675
4.19k
    return p;
3676
4.19k
}
3677
3678
stmt_ty
3679
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
3680
            type_comment, int lineno, int col_offset, int end_lineno, int
3681
            end_col_offset, PyArena *arena)
3682
4.12k
{
3683
4.12k
    stmt_ty p;
3684
4.12k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3685
4.12k
    if (!p)
3686
0
        return NULL;
3687
4.12k
    p->kind = With_kind;
3688
4.12k
    p->v.With.items = items;
3689
4.12k
    p->v.With.body = body;
3690
4.12k
    p->v.With.type_comment = type_comment;
3691
4.12k
    p->lineno = lineno;
3692
4.12k
    p->col_offset = col_offset;
3693
4.12k
    p->end_lineno = end_lineno;
3694
4.12k
    p->end_col_offset = end_col_offset;
3695
4.12k
    return p;
3696
4.12k
}
3697
3698
stmt_ty
3699
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
3700
                 type_comment, int lineno, int col_offset, int end_lineno, int
3701
                 end_col_offset, PyArena *arena)
3702
808
{
3703
808
    stmt_ty p;
3704
808
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3705
808
    if (!p)
3706
0
        return NULL;
3707
808
    p->kind = AsyncWith_kind;
3708
808
    p->v.AsyncWith.items = items;
3709
808
    p->v.AsyncWith.body = body;
3710
808
    p->v.AsyncWith.type_comment = type_comment;
3711
808
    p->lineno = lineno;
3712
808
    p->col_offset = col_offset;
3713
808
    p->end_lineno = end_lineno;
3714
808
    p->end_col_offset = end_col_offset;
3715
808
    return p;
3716
808
}
3717
3718
stmt_ty
3719
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
3720
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3721
931
{
3722
931
    stmt_ty p;
3723
931
    if (!subject) {
3724
0
        PyErr_SetString(PyExc_ValueError,
3725
0
                        "field 'subject' is required for Match");
3726
0
        return NULL;
3727
0
    }
3728
931
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3729
931
    if (!p)
3730
0
        return NULL;
3731
931
    p->kind = Match_kind;
3732
931
    p->v.Match.subject = subject;
3733
931
    p->v.Match.cases = cases;
3734
931
    p->lineno = lineno;
3735
931
    p->col_offset = col_offset;
3736
931
    p->end_lineno = end_lineno;
3737
931
    p->end_col_offset = end_col_offset;
3738
931
    return p;
3739
931
}
3740
3741
stmt_ty
3742
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
3743
             end_lineno, int end_col_offset, PyArena *arena)
3744
2.16k
{
3745
2.16k
    stmt_ty p;
3746
2.16k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3747
2.16k
    if (!p)
3748
0
        return NULL;
3749
2.16k
    p->kind = Raise_kind;
3750
2.16k
    p->v.Raise.exc = exc;
3751
2.16k
    p->v.Raise.cause = cause;
3752
2.16k
    p->lineno = lineno;
3753
2.16k
    p->col_offset = col_offset;
3754
2.16k
    p->end_lineno = end_lineno;
3755
2.16k
    p->end_col_offset = end_col_offset;
3756
2.16k
    return p;
3757
2.16k
}
3758
3759
stmt_ty
3760
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
3761
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
3762
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
3763
3.28k
{
3764
3.28k
    stmt_ty p;
3765
3.28k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3766
3.28k
    if (!p)
3767
0
        return NULL;
3768
3.28k
    p->kind = Try_kind;
3769
3.28k
    p->v.Try.body = body;
3770
3.28k
    p->v.Try.handlers = handlers;
3771
3.28k
    p->v.Try.orelse = orelse;
3772
3.28k
    p->v.Try.finalbody = finalbody;
3773
3.28k
    p->lineno = lineno;
3774
3.28k
    p->col_offset = col_offset;
3775
3.28k
    p->end_lineno = end_lineno;
3776
3.28k
    p->end_col_offset = end_col_offset;
3777
3.28k
    return p;
3778
3.28k
}
3779
3780
stmt_ty
3781
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
3782
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
3783
               int col_offset, int end_lineno, int end_col_offset, PyArena
3784
               *arena)
3785
1.31k
{
3786
1.31k
    stmt_ty p;
3787
1.31k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3788
1.31k
    if (!p)
3789
0
        return NULL;
3790
1.31k
    p->kind = TryStar_kind;
3791
1.31k
    p->v.TryStar.body = body;
3792
1.31k
    p->v.TryStar.handlers = handlers;
3793
1.31k
    p->v.TryStar.orelse = orelse;
3794
1.31k
    p->v.TryStar.finalbody = finalbody;
3795
1.31k
    p->lineno = lineno;
3796
1.31k
    p->col_offset = col_offset;
3797
1.31k
    p->end_lineno = end_lineno;
3798
1.31k
    p->end_col_offset = end_col_offset;
3799
1.31k
    return p;
3800
1.31k
}
3801
3802
stmt_ty
3803
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
3804
              end_lineno, int end_col_offset, PyArena *arena)
3805
1.26k
{
3806
1.26k
    stmt_ty p;
3807
1.26k
    if (!test) {
3808
0
        PyErr_SetString(PyExc_ValueError,
3809
0
                        "field 'test' is required for Assert");
3810
0
        return NULL;
3811
0
    }
3812
1.26k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3813
1.26k
    if (!p)
3814
0
        return NULL;
3815
1.26k
    p->kind = Assert_kind;
3816
1.26k
    p->v.Assert.test = test;
3817
1.26k
    p->v.Assert.msg = msg;
3818
1.26k
    p->lineno = lineno;
3819
1.26k
    p->col_offset = col_offset;
3820
1.26k
    p->end_lineno = end_lineno;
3821
1.26k
    p->end_col_offset = end_col_offset;
3822
1.26k
    return p;
3823
1.26k
}
3824
3825
stmt_ty
3826
_PyAST_Import(asdl_alias_seq * names, int is_lazy, int lineno, int col_offset,
3827
              int end_lineno, int end_col_offset, PyArena *arena)
3828
2.52k
{
3829
2.52k
    stmt_ty p;
3830
2.52k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3831
2.52k
    if (!p)
3832
0
        return NULL;
3833
2.52k
    p->kind = Import_kind;
3834
2.52k
    p->v.Import.names = names;
3835
2.52k
    p->v.Import.is_lazy = is_lazy;
3836
2.52k
    p->lineno = lineno;
3837
2.52k
    p->col_offset = col_offset;
3838
2.52k
    p->end_lineno = end_lineno;
3839
2.52k
    p->end_col_offset = end_col_offset;
3840
2.52k
    return p;
3841
2.52k
}
3842
3843
stmt_ty
3844
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
3845
                  is_lazy, int lineno, int col_offset, int end_lineno, int
3846
                  end_col_offset, PyArena *arena)
3847
6.27k
{
3848
6.27k
    stmt_ty p;
3849
6.27k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3850
6.27k
    if (!p)
3851
0
        return NULL;
3852
6.27k
    p->kind = ImportFrom_kind;
3853
6.27k
    p->v.ImportFrom.module = module;
3854
6.27k
    p->v.ImportFrom.names = names;
3855
6.27k
    p->v.ImportFrom.level = level;
3856
6.27k
    p->v.ImportFrom.is_lazy = is_lazy;
3857
6.27k
    p->lineno = lineno;
3858
6.27k
    p->col_offset = col_offset;
3859
6.27k
    p->end_lineno = end_lineno;
3860
6.27k
    p->end_col_offset = end_col_offset;
3861
6.27k
    return p;
3862
6.27k
}
3863
3864
stmt_ty
3865
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
3866
              end_lineno, int end_col_offset, PyArena *arena)
3867
856
{
3868
856
    stmt_ty p;
3869
856
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3870
856
    if (!p)
3871
0
        return NULL;
3872
856
    p->kind = Global_kind;
3873
856
    p->v.Global.names = names;
3874
856
    p->lineno = lineno;
3875
856
    p->col_offset = col_offset;
3876
856
    p->end_lineno = end_lineno;
3877
856
    p->end_col_offset = end_col_offset;
3878
856
    return p;
3879
856
}
3880
3881
stmt_ty
3882
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
3883
                end_lineno, int end_col_offset, PyArena *arena)
3884
379
{
3885
379
    stmt_ty p;
3886
379
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3887
379
    if (!p)
3888
0
        return NULL;
3889
379
    p->kind = Nonlocal_kind;
3890
379
    p->v.Nonlocal.names = names;
3891
379
    p->lineno = lineno;
3892
379
    p->col_offset = col_offset;
3893
379
    p->end_lineno = end_lineno;
3894
379
    p->end_col_offset = end_col_offset;
3895
379
    return p;
3896
379
}
3897
3898
stmt_ty
3899
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
3900
            end_col_offset, PyArena *arena)
3901
114k
{
3902
114k
    stmt_ty p;
3903
114k
    if (!value) {
3904
0
        PyErr_SetString(PyExc_ValueError,
3905
0
                        "field 'value' is required for Expr");
3906
0
        return NULL;
3907
0
    }
3908
114k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3909
114k
    if (!p)
3910
0
        return NULL;
3911
114k
    p->kind = Expr_kind;
3912
114k
    p->v.Expr.value = value;
3913
114k
    p->lineno = lineno;
3914
114k
    p->col_offset = col_offset;
3915
114k
    p->end_lineno = end_lineno;
3916
114k
    p->end_col_offset = end_col_offset;
3917
114k
    return p;
3918
114k
}
3919
3920
stmt_ty
3921
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
3922
            PyArena *arena)
3923
1.49k
{
3924
1.49k
    stmt_ty p;
3925
1.49k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3926
1.49k
    if (!p)
3927
0
        return NULL;
3928
1.49k
    p->kind = Pass_kind;
3929
1.49k
    p->lineno = lineno;
3930
1.49k
    p->col_offset = col_offset;
3931
1.49k
    p->end_lineno = end_lineno;
3932
1.49k
    p->end_col_offset = end_col_offset;
3933
1.49k
    return p;
3934
1.49k
}
3935
3936
stmt_ty
3937
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
3938
             PyArena *arena)
3939
1.47k
{
3940
1.47k
    stmt_ty p;
3941
1.47k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3942
1.47k
    if (!p)
3943
0
        return NULL;
3944
1.47k
    p->kind = Break_kind;
3945
1.47k
    p->lineno = lineno;
3946
1.47k
    p->col_offset = col_offset;
3947
1.47k
    p->end_lineno = end_lineno;
3948
1.47k
    p->end_col_offset = end_col_offset;
3949
1.47k
    return p;
3950
1.47k
}
3951
3952
stmt_ty
3953
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
3954
                PyArena *arena)
3955
3.76k
{
3956
3.76k
    stmt_ty p;
3957
3.76k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
3958
3.76k
    if (!p)
3959
0
        return NULL;
3960
3.76k
    p->kind = Continue_kind;
3961
3.76k
    p->lineno = lineno;
3962
3.76k
    p->col_offset = col_offset;
3963
3.76k
    p->end_lineno = end_lineno;
3964
3.76k
    p->end_col_offset = end_col_offset;
3965
3.76k
    return p;
3966
3.76k
}
3967
3968
expr_ty
3969
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
3970
              int end_lineno, int end_col_offset, PyArena *arena)
3971
2.05k
{
3972
2.05k
    expr_ty p;
3973
2.05k
    if (!op) {
3974
0
        PyErr_SetString(PyExc_ValueError,
3975
0
                        "field 'op' is required for BoolOp");
3976
0
        return NULL;
3977
0
    }
3978
2.05k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
3979
2.05k
    if (!p)
3980
0
        return NULL;
3981
2.05k
    p->kind = BoolOp_kind;
3982
2.05k
    p->v.BoolOp.op = op;
3983
2.05k
    p->v.BoolOp.values = values;
3984
2.05k
    p->lineno = lineno;
3985
2.05k
    p->col_offset = col_offset;
3986
2.05k
    p->end_lineno = end_lineno;
3987
2.05k
    p->end_col_offset = end_col_offset;
3988
2.05k
    return p;
3989
2.05k
}
3990
3991
expr_ty
3992
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
3993
                 end_lineno, int end_col_offset, PyArena *arena)
3994
3.28k
{
3995
3.28k
    expr_ty p;
3996
3.28k
    if (!target) {
3997
0
        PyErr_SetString(PyExc_ValueError,
3998
0
                        "field 'target' is required for NamedExpr");
3999
0
        return NULL;
4000
0
    }
4001
3.28k
    if (!value) {
4002
0
        PyErr_SetString(PyExc_ValueError,
4003
0
                        "field 'value' is required for NamedExpr");
4004
0
        return NULL;
4005
0
    }
4006
3.28k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4007
3.28k
    if (!p)
4008
0
        return NULL;
4009
3.28k
    p->kind = NamedExpr_kind;
4010
3.28k
    p->v.NamedExpr.target = target;
4011
3.28k
    p->v.NamedExpr.value = value;
4012
3.28k
    p->lineno = lineno;
4013
3.28k
    p->col_offset = col_offset;
4014
3.28k
    p->end_lineno = end_lineno;
4015
3.28k
    p->end_col_offset = end_col_offset;
4016
3.28k
    return p;
4017
3.28k
}
4018
4019
expr_ty
4020
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
4021
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4022
60.0k
{
4023
60.0k
    expr_ty p;
4024
60.0k
    if (!left) {
4025
0
        PyErr_SetString(PyExc_ValueError,
4026
0
                        "field 'left' is required for BinOp");
4027
0
        return NULL;
4028
0
    }
4029
60.0k
    if (!op) {
4030
0
        PyErr_SetString(PyExc_ValueError,
4031
0
                        "field 'op' is required for BinOp");
4032
0
        return NULL;
4033
0
    }
4034
60.0k
    if (!right) {
4035
0
        PyErr_SetString(PyExc_ValueError,
4036
0
                        "field 'right' is required for BinOp");
4037
0
        return NULL;
4038
0
    }
4039
60.0k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4040
60.0k
    if (!p)
4041
0
        return NULL;
4042
60.0k
    p->kind = BinOp_kind;
4043
60.0k
    p->v.BinOp.left = left;
4044
60.0k
    p->v.BinOp.op = op;
4045
60.0k
    p->v.BinOp.right = right;
4046
60.0k
    p->lineno = lineno;
4047
60.0k
    p->col_offset = col_offset;
4048
60.0k
    p->end_lineno = end_lineno;
4049
60.0k
    p->end_col_offset = end_col_offset;
4050
60.0k
    return p;
4051
60.0k
}
4052
4053
expr_ty
4054
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
4055
               end_lineno, int end_col_offset, PyArena *arena)
4056
125k
{
4057
125k
    expr_ty p;
4058
125k
    if (!op) {
4059
0
        PyErr_SetString(PyExc_ValueError,
4060
0
                        "field 'op' is required for UnaryOp");
4061
0
        return NULL;
4062
0
    }
4063
125k
    if (!operand) {
4064
0
        PyErr_SetString(PyExc_ValueError,
4065
0
                        "field 'operand' is required for UnaryOp");
4066
0
        return NULL;
4067
0
    }
4068
125k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4069
125k
    if (!p)
4070
0
        return NULL;
4071
125k
    p->kind = UnaryOp_kind;
4072
125k
    p->v.UnaryOp.op = op;
4073
125k
    p->v.UnaryOp.operand = operand;
4074
125k
    p->lineno = lineno;
4075
125k
    p->col_offset = col_offset;
4076
125k
    p->end_lineno = end_lineno;
4077
125k
    p->end_col_offset = end_col_offset;
4078
125k
    return p;
4079
125k
}
4080
4081
expr_ty
4082
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
4083
              end_lineno, int end_col_offset, PyArena *arena)
4084
3.74k
{
4085
3.74k
    expr_ty p;
4086
3.74k
    if (!args) {
4087
0
        PyErr_SetString(PyExc_ValueError,
4088
0
                        "field 'args' is required for Lambda");
4089
0
        return NULL;
4090
0
    }
4091
3.74k
    if (!body) {
4092
0
        PyErr_SetString(PyExc_ValueError,
4093
0
                        "field 'body' is required for Lambda");
4094
0
        return NULL;
4095
0
    }
4096
3.74k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4097
3.74k
    if (!p)
4098
0
        return NULL;
4099
3.74k
    p->kind = Lambda_kind;
4100
3.74k
    p->v.Lambda.args = args;
4101
3.74k
    p->v.Lambda.body = body;
4102
3.74k
    p->lineno = lineno;
4103
3.74k
    p->col_offset = col_offset;
4104
3.74k
    p->end_lineno = end_lineno;
4105
3.74k
    p->end_col_offset = end_col_offset;
4106
3.74k
    return p;
4107
3.74k
}
4108
4109
expr_ty
4110
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
4111
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4112
1.19k
{
4113
1.19k
    expr_ty p;
4114
1.19k
    if (!test) {
4115
0
        PyErr_SetString(PyExc_ValueError,
4116
0
                        "field 'test' is required for IfExp");
4117
0
        return NULL;
4118
0
    }
4119
1.19k
    if (!body) {
4120
0
        PyErr_SetString(PyExc_ValueError,
4121
0
                        "field 'body' is required for IfExp");
4122
0
        return NULL;
4123
0
    }
4124
1.19k
    if (!orelse) {
4125
0
        PyErr_SetString(PyExc_ValueError,
4126
0
                        "field 'orelse' is required for IfExp");
4127
0
        return NULL;
4128
0
    }
4129
1.19k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4130
1.19k
    if (!p)
4131
0
        return NULL;
4132
1.19k
    p->kind = IfExp_kind;
4133
1.19k
    p->v.IfExp.test = test;
4134
1.19k
    p->v.IfExp.body = body;
4135
1.19k
    p->v.IfExp.orelse = orelse;
4136
1.19k
    p->lineno = lineno;
4137
1.19k
    p->col_offset = col_offset;
4138
1.19k
    p->end_lineno = end_lineno;
4139
1.19k
    p->end_col_offset = end_col_offset;
4140
1.19k
    return p;
4141
1.19k
}
4142
4143
expr_ty
4144
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
4145
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4146
4.18k
{
4147
4.18k
    expr_ty p;
4148
4.18k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4149
4.18k
    if (!p)
4150
0
        return NULL;
4151
4.18k
    p->kind = Dict_kind;
4152
4.18k
    p->v.Dict.keys = keys;
4153
4.18k
    p->v.Dict.values = values;
4154
4.18k
    p->lineno = lineno;
4155
4.18k
    p->col_offset = col_offset;
4156
4.18k
    p->end_lineno = end_lineno;
4157
4.18k
    p->end_col_offset = end_col_offset;
4158
4.18k
    return p;
4159
4.18k
}
4160
4161
expr_ty
4162
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
4163
           int end_col_offset, PyArena *arena)
4164
2.08k
{
4165
2.08k
    expr_ty p;
4166
2.08k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4167
2.08k
    if (!p)
4168
0
        return NULL;
4169
2.08k
    p->kind = Set_kind;
4170
2.08k
    p->v.Set.elts = elts;
4171
2.08k
    p->lineno = lineno;
4172
2.08k
    p->col_offset = col_offset;
4173
2.08k
    p->end_lineno = end_lineno;
4174
2.08k
    p->end_col_offset = end_col_offset;
4175
2.08k
    return p;
4176
2.08k
}
4177
4178
expr_ty
4179
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
4180
                int col_offset, int end_lineno, int end_col_offset, PyArena
4181
                *arena)
4182
852
{
4183
852
    expr_ty p;
4184
852
    if (!elt) {
4185
0
        PyErr_SetString(PyExc_ValueError,
4186
0
                        "field 'elt' is required for ListComp");
4187
0
        return NULL;
4188
0
    }
4189
852
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4190
852
    if (!p)
4191
0
        return NULL;
4192
852
    p->kind = ListComp_kind;
4193
852
    p->v.ListComp.elt = elt;
4194
852
    p->v.ListComp.generators = generators;
4195
852
    p->lineno = lineno;
4196
852
    p->col_offset = col_offset;
4197
852
    p->end_lineno = end_lineno;
4198
852
    p->end_col_offset = end_col_offset;
4199
852
    return p;
4200
852
}
4201
4202
expr_ty
4203
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
4204
               int col_offset, int end_lineno, int end_col_offset, PyArena
4205
               *arena)
4206
795
{
4207
795
    expr_ty p;
4208
795
    if (!elt) {
4209
0
        PyErr_SetString(PyExc_ValueError,
4210
0
                        "field 'elt' is required for SetComp");
4211
0
        return NULL;
4212
0
    }
4213
795
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4214
795
    if (!p)
4215
0
        return NULL;
4216
795
    p->kind = SetComp_kind;
4217
795
    p->v.SetComp.elt = elt;
4218
795
    p->v.SetComp.generators = generators;
4219
795
    p->lineno = lineno;
4220
795
    p->col_offset = col_offset;
4221
795
    p->end_lineno = end_lineno;
4222
795
    p->end_col_offset = end_col_offset;
4223
795
    return p;
4224
795
}
4225
4226
expr_ty
4227
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
4228
                generators, int lineno, int col_offset, int end_lineno, int
4229
                end_col_offset, PyArena *arena)
4230
1.22k
{
4231
1.22k
    expr_ty p;
4232
1.22k
    if (!key) {
4233
0
        PyErr_SetString(PyExc_ValueError,
4234
0
                        "field 'key' is required for DictComp");
4235
0
        return NULL;
4236
0
    }
4237
1.22k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4238
1.22k
    if (!p)
4239
0
        return NULL;
4240
1.22k
    p->kind = DictComp_kind;
4241
1.22k
    p->v.DictComp.key = key;
4242
1.22k
    p->v.DictComp.value = value;
4243
1.22k
    p->v.DictComp.generators = generators;
4244
1.22k
    p->lineno = lineno;
4245
1.22k
    p->col_offset = col_offset;
4246
1.22k
    p->end_lineno = end_lineno;
4247
1.22k
    p->end_col_offset = end_col_offset;
4248
1.22k
    return p;
4249
1.22k
}
4250
4251
expr_ty
4252
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
4253
                    lineno, int col_offset, int end_lineno, int end_col_offset,
4254
                    PyArena *arena)
4255
2.38k
{
4256
2.38k
    expr_ty p;
4257
2.38k
    if (!elt) {
4258
0
        PyErr_SetString(PyExc_ValueError,
4259
0
                        "field 'elt' is required for GeneratorExp");
4260
0
        return NULL;
4261
0
    }
4262
2.38k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4263
2.38k
    if (!p)
4264
0
        return NULL;
4265
2.38k
    p->kind = GeneratorExp_kind;
4266
2.38k
    p->v.GeneratorExp.elt = elt;
4267
2.38k
    p->v.GeneratorExp.generators = generators;
4268
2.38k
    p->lineno = lineno;
4269
2.38k
    p->col_offset = col_offset;
4270
2.38k
    p->end_lineno = end_lineno;
4271
2.38k
    p->end_col_offset = end_col_offset;
4272
2.38k
    return p;
4273
2.38k
}
4274
4275
expr_ty
4276
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
4277
             end_col_offset, PyArena *arena)
4278
396
{
4279
396
    expr_ty p;
4280
396
    if (!value) {
4281
0
        PyErr_SetString(PyExc_ValueError,
4282
0
                        "field 'value' is required for Await");
4283
0
        return NULL;
4284
0
    }
4285
396
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4286
396
    if (!p)
4287
0
        return NULL;
4288
396
    p->kind = Await_kind;
4289
396
    p->v.Await.value = value;
4290
396
    p->lineno = lineno;
4291
396
    p->col_offset = col_offset;
4292
396
    p->end_lineno = end_lineno;
4293
396
    p->end_col_offset = end_col_offset;
4294
396
    return p;
4295
396
}
4296
4297
expr_ty
4298
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
4299
             end_col_offset, PyArena *arena)
4300
1.86k
{
4301
1.86k
    expr_ty p;
4302
1.86k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4303
1.86k
    if (!p)
4304
0
        return NULL;
4305
1.86k
    p->kind = Yield_kind;
4306
1.86k
    p->v.Yield.value = value;
4307
1.86k
    p->lineno = lineno;
4308
1.86k
    p->col_offset = col_offset;
4309
1.86k
    p->end_lineno = end_lineno;
4310
1.86k
    p->end_col_offset = end_col_offset;
4311
1.86k
    return p;
4312
1.86k
}
4313
4314
expr_ty
4315
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
4316
                 end_col_offset, PyArena *arena)
4317
404
{
4318
404
    expr_ty p;
4319
404
    if (!value) {
4320
0
        PyErr_SetString(PyExc_ValueError,
4321
0
                        "field 'value' is required for YieldFrom");
4322
0
        return NULL;
4323
0
    }
4324
404
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4325
404
    if (!p)
4326
0
        return NULL;
4327
404
    p->kind = YieldFrom_kind;
4328
404
    p->v.YieldFrom.value = value;
4329
404
    p->lineno = lineno;
4330
404
    p->col_offset = col_offset;
4331
404
    p->end_lineno = end_lineno;
4332
404
    p->end_col_offset = end_col_offset;
4333
404
    return p;
4334
404
}
4335
4336
expr_ty
4337
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
4338
               int lineno, int col_offset, int end_lineno, int end_col_offset,
4339
               PyArena *arena)
4340
8.41k
{
4341
8.41k
    expr_ty p;
4342
8.41k
    if (!left) {
4343
0
        PyErr_SetString(PyExc_ValueError,
4344
0
                        "field 'left' is required for Compare");
4345
0
        return NULL;
4346
0
    }
4347
8.41k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4348
8.41k
    if (!p)
4349
0
        return NULL;
4350
8.41k
    p->kind = Compare_kind;
4351
8.41k
    p->v.Compare.left = left;
4352
8.41k
    p->v.Compare.ops = ops;
4353
8.41k
    p->v.Compare.comparators = comparators;
4354
8.41k
    p->lineno = lineno;
4355
8.41k
    p->col_offset = col_offset;
4356
8.41k
    p->end_lineno = end_lineno;
4357
8.41k
    p->end_col_offset = end_col_offset;
4358
8.41k
    return p;
4359
8.41k
}
4360
4361
expr_ty
4362
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
4363
            int lineno, int col_offset, int end_lineno, int end_col_offset,
4364
            PyArena *arena)
4365
59.4k
{
4366
59.4k
    expr_ty p;
4367
59.4k
    if (!func) {
4368
0
        PyErr_SetString(PyExc_ValueError,
4369
0
                        "field 'func' is required for Call");
4370
0
        return NULL;
4371
0
    }
4372
59.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4373
59.4k
    if (!p)
4374
0
        return NULL;
4375
59.4k
    p->kind = Call_kind;
4376
59.4k
    p->v.Call.func = func;
4377
59.4k
    p->v.Call.args = args;
4378
59.4k
    p->v.Call.keywords = keywords;
4379
59.4k
    p->lineno = lineno;
4380
59.4k
    p->col_offset = col_offset;
4381
59.4k
    p->end_lineno = end_lineno;
4382
59.4k
    p->end_col_offset = end_col_offset;
4383
59.4k
    return p;
4384
59.4k
}
4385
4386
expr_ty
4387
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
4388
                      lineno, int col_offset, int end_lineno, int
4389
                      end_col_offset, PyArena *arena)
4390
24.7k
{
4391
24.7k
    expr_ty p;
4392
24.7k
    if (!value) {
4393
0
        PyErr_SetString(PyExc_ValueError,
4394
0
                        "field 'value' is required for FormattedValue");
4395
0
        return NULL;
4396
0
    }
4397
24.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4398
24.7k
    if (!p)
4399
0
        return NULL;
4400
24.7k
    p->kind = FormattedValue_kind;
4401
24.7k
    p->v.FormattedValue.value = value;
4402
24.7k
    p->v.FormattedValue.conversion = conversion;
4403
24.7k
    p->v.FormattedValue.format_spec = format_spec;
4404
24.7k
    p->lineno = lineno;
4405
24.7k
    p->col_offset = col_offset;
4406
24.7k
    p->end_lineno = end_lineno;
4407
24.7k
    p->end_col_offset = end_col_offset;
4408
24.7k
    return p;
4409
24.7k
}
4410
4411
expr_ty
4412
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
4413
                     format_spec, int lineno, int col_offset, int end_lineno,
4414
                     int end_col_offset, PyArena *arena)
4415
6.40k
{
4416
6.40k
    expr_ty p;
4417
6.40k
    if (!value) {
4418
0
        PyErr_SetString(PyExc_ValueError,
4419
0
                        "field 'value' is required for Interpolation");
4420
0
        return NULL;
4421
0
    }
4422
6.40k
    if (!str) {
4423
0
        PyErr_SetString(PyExc_ValueError,
4424
0
                        "field 'str' is required for Interpolation");
4425
0
        return NULL;
4426
0
    }
4427
6.40k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4428
6.40k
    if (!p)
4429
0
        return NULL;
4430
6.40k
    p->kind = Interpolation_kind;
4431
6.40k
    p->v.Interpolation.value = value;
4432
6.40k
    p->v.Interpolation.str = str;
4433
6.40k
    p->v.Interpolation.conversion = conversion;
4434
6.40k
    p->v.Interpolation.format_spec = format_spec;
4435
6.40k
    p->lineno = lineno;
4436
6.40k
    p->col_offset = col_offset;
4437
6.40k
    p->end_lineno = end_lineno;
4438
6.40k
    p->end_col_offset = end_col_offset;
4439
6.40k
    return p;
4440
6.40k
}
4441
4442
expr_ty
4443
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
4444
                 end_lineno, int end_col_offset, PyArena *arena)
4445
48.3k
{
4446
48.3k
    expr_ty p;
4447
48.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4448
48.3k
    if (!p)
4449
0
        return NULL;
4450
48.3k
    p->kind = JoinedStr_kind;
4451
48.3k
    p->v.JoinedStr.values = values;
4452
48.3k
    p->lineno = lineno;
4453
48.3k
    p->col_offset = col_offset;
4454
48.3k
    p->end_lineno = end_lineno;
4455
48.3k
    p->end_col_offset = end_col_offset;
4456
48.3k
    return p;
4457
48.3k
}
4458
4459
expr_ty
4460
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
4461
                   end_lineno, int end_col_offset, PyArena *arena)
4462
5.82k
{
4463
5.82k
    expr_ty p;
4464
5.82k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4465
5.82k
    if (!p)
4466
0
        return NULL;
4467
5.82k
    p->kind = TemplateStr_kind;
4468
5.82k
    p->v.TemplateStr.values = values;
4469
5.82k
    p->lineno = lineno;
4470
5.82k
    p->col_offset = col_offset;
4471
5.82k
    p->end_lineno = end_lineno;
4472
5.82k
    p->end_col_offset = end_col_offset;
4473
5.82k
    return p;
4474
5.82k
}
4475
4476
expr_ty
4477
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
4478
                end_lineno, int end_col_offset, PyArena *arena)
4479
284k
{
4480
284k
    expr_ty p;
4481
284k
    if (!value) {
4482
0
        PyErr_SetString(PyExc_ValueError,
4483
0
                        "field 'value' is required for Constant");
4484
0
        return NULL;
4485
0
    }
4486
284k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4487
284k
    if (!p)
4488
0
        return NULL;
4489
284k
    p->kind = Constant_kind;
4490
284k
    p->v.Constant.value = value;
4491
284k
    p->v.Constant.kind = kind;
4492
284k
    p->lineno = lineno;
4493
284k
    p->col_offset = col_offset;
4494
284k
    p->end_lineno = end_lineno;
4495
284k
    p->end_col_offset = end_col_offset;
4496
284k
    return p;
4497
284k
}
4498
4499
expr_ty
4500
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
4501
                 lineno, int col_offset, int end_lineno, int end_col_offset,
4502
                 PyArena *arena)
4503
28.9k
{
4504
28.9k
    expr_ty p;
4505
28.9k
    if (!value) {
4506
0
        PyErr_SetString(PyExc_ValueError,
4507
0
                        "field 'value' is required for Attribute");
4508
0
        return NULL;
4509
0
    }
4510
28.9k
    if (!attr) {
4511
0
        PyErr_SetString(PyExc_ValueError,
4512
0
                        "field 'attr' is required for Attribute");
4513
0
        return NULL;
4514
0
    }
4515
28.9k
    if (!ctx) {
4516
0
        PyErr_SetString(PyExc_ValueError,
4517
0
                        "field 'ctx' is required for Attribute");
4518
0
        return NULL;
4519
0
    }
4520
28.9k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4521
28.9k
    if (!p)
4522
0
        return NULL;
4523
28.9k
    p->kind = Attribute_kind;
4524
28.9k
    p->v.Attribute.value = value;
4525
28.9k
    p->v.Attribute.attr = attr;
4526
28.9k
    p->v.Attribute.ctx = ctx;
4527
28.9k
    p->lineno = lineno;
4528
28.9k
    p->col_offset = col_offset;
4529
28.9k
    p->end_lineno = end_lineno;
4530
28.9k
    p->end_col_offset = end_col_offset;
4531
28.9k
    return p;
4532
28.9k
}
4533
4534
expr_ty
4535
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
4536
                 int col_offset, int end_lineno, int end_col_offset, PyArena
4537
                 *arena)
4538
4.84k
{
4539
4.84k
    expr_ty p;
4540
4.84k
    if (!value) {
4541
0
        PyErr_SetString(PyExc_ValueError,
4542
0
                        "field 'value' is required for Subscript");
4543
0
        return NULL;
4544
0
    }
4545
4.84k
    if (!slice) {
4546
0
        PyErr_SetString(PyExc_ValueError,
4547
0
                        "field 'slice' is required for Subscript");
4548
0
        return NULL;
4549
0
    }
4550
4.84k
    if (!ctx) {
4551
0
        PyErr_SetString(PyExc_ValueError,
4552
0
                        "field 'ctx' is required for Subscript");
4553
0
        return NULL;
4554
0
    }
4555
4.84k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4556
4.84k
    if (!p)
4557
0
        return NULL;
4558
4.84k
    p->kind = Subscript_kind;
4559
4.84k
    p->v.Subscript.value = value;
4560
4.84k
    p->v.Subscript.slice = slice;
4561
4.84k
    p->v.Subscript.ctx = ctx;
4562
4.84k
    p->lineno = lineno;
4563
4.84k
    p->col_offset = col_offset;
4564
4.84k
    p->end_lineno = end_lineno;
4565
4.84k
    p->end_col_offset = end_col_offset;
4566
4.84k
    return p;
4567
4.84k
}
4568
4569
expr_ty
4570
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
4571
               int end_lineno, int end_col_offset, PyArena *arena)
4572
22.6k
{
4573
22.6k
    expr_ty p;
4574
22.6k
    if (!value) {
4575
0
        PyErr_SetString(PyExc_ValueError,
4576
0
                        "field 'value' is required for Starred");
4577
0
        return NULL;
4578
0
    }
4579
22.6k
    if (!ctx) {
4580
0
        PyErr_SetString(PyExc_ValueError,
4581
0
                        "field 'ctx' is required for Starred");
4582
0
        return NULL;
4583
0
    }
4584
22.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4585
22.6k
    if (!p)
4586
0
        return NULL;
4587
22.6k
    p->kind = Starred_kind;
4588
22.6k
    p->v.Starred.value = value;
4589
22.6k
    p->v.Starred.ctx = ctx;
4590
22.6k
    p->lineno = lineno;
4591
22.6k
    p->col_offset = col_offset;
4592
22.6k
    p->end_lineno = end_lineno;
4593
22.6k
    p->end_col_offset = end_col_offset;
4594
22.6k
    return p;
4595
22.6k
}
4596
4597
expr_ty
4598
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
4599
            end_lineno, int end_col_offset, PyArena *arena)
4600
781k
{
4601
781k
    expr_ty p;
4602
781k
    if (!id) {
4603
0
        PyErr_SetString(PyExc_ValueError,
4604
0
                        "field 'id' is required for Name");
4605
0
        return NULL;
4606
0
    }
4607
781k
    if (!ctx) {
4608
0
        PyErr_SetString(PyExc_ValueError,
4609
0
                        "field 'ctx' is required for Name");
4610
0
        return NULL;
4611
0
    }
4612
781k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4613
781k
    if (!p)
4614
0
        return NULL;
4615
781k
    p->kind = Name_kind;
4616
781k
    p->v.Name.id = id;
4617
781k
    p->v.Name.ctx = ctx;
4618
781k
    p->lineno = lineno;
4619
781k
    p->col_offset = col_offset;
4620
781k
    p->end_lineno = end_lineno;
4621
781k
    p->end_col_offset = end_col_offset;
4622
781k
    return p;
4623
781k
}
4624
4625
expr_ty
4626
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
4627
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4628
9.90k
{
4629
9.90k
    expr_ty p;
4630
9.90k
    if (!ctx) {
4631
0
        PyErr_SetString(PyExc_ValueError,
4632
0
                        "field 'ctx' is required for List");
4633
0
        return NULL;
4634
0
    }
4635
9.90k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4636
9.90k
    if (!p)
4637
0
        return NULL;
4638
9.90k
    p->kind = List_kind;
4639
9.90k
    p->v.List.elts = elts;
4640
9.90k
    p->v.List.ctx = ctx;
4641
9.90k
    p->lineno = lineno;
4642
9.90k
    p->col_offset = col_offset;
4643
9.90k
    p->end_lineno = end_lineno;
4644
9.90k
    p->end_col_offset = end_col_offset;
4645
9.90k
    return p;
4646
9.90k
}
4647
4648
expr_ty
4649
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
4650
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4651
68.5k
{
4652
68.5k
    expr_ty p;
4653
68.5k
    if (!ctx) {
4654
0
        PyErr_SetString(PyExc_ValueError,
4655
0
                        "field 'ctx' is required for Tuple");
4656
0
        return NULL;
4657
0
    }
4658
68.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4659
68.5k
    if (!p)
4660
0
        return NULL;
4661
68.5k
    p->kind = Tuple_kind;
4662
68.5k
    p->v.Tuple.elts = elts;
4663
68.5k
    p->v.Tuple.ctx = ctx;
4664
68.5k
    p->lineno = lineno;
4665
68.5k
    p->col_offset = col_offset;
4666
68.5k
    p->end_lineno = end_lineno;
4667
68.5k
    p->end_col_offset = end_col_offset;
4668
68.5k
    return p;
4669
68.5k
}
4670
4671
expr_ty
4672
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
4673
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4674
5.38k
{
4675
5.38k
    expr_ty p;
4676
5.38k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
4677
5.38k
    if (!p)
4678
0
        return NULL;
4679
5.38k
    p->kind = Slice_kind;
4680
5.38k
    p->v.Slice.lower = lower;
4681
5.38k
    p->v.Slice.upper = upper;
4682
5.38k
    p->v.Slice.step = step;
4683
5.38k
    p->lineno = lineno;
4684
5.38k
    p->col_offset = col_offset;
4685
5.38k
    p->end_lineno = end_lineno;
4686
5.38k
    p->end_col_offset = end_col_offset;
4687
5.38k
    return p;
4688
5.38k
}
4689
4690
comprehension_ty
4691
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
4692
                     is_async, PyArena *arena)
4693
8.59k
{
4694
8.59k
    comprehension_ty p;
4695
8.59k
    if (!target) {
4696
0
        PyErr_SetString(PyExc_ValueError,
4697
0
                        "field 'target' is required for comprehension");
4698
0
        return NULL;
4699
0
    }
4700
8.59k
    if (!iter) {
4701
0
        PyErr_SetString(PyExc_ValueError,
4702
0
                        "field 'iter' is required for comprehension");
4703
0
        return NULL;
4704
0
    }
4705
8.59k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
4706
8.59k
    if (!p)
4707
0
        return NULL;
4708
8.59k
    p->target = target;
4709
8.59k
    p->iter = iter;
4710
8.59k
    p->ifs = ifs;
4711
8.59k
    p->is_async = is_async;
4712
8.59k
    return p;
4713
8.59k
}
4714
4715
excepthandler_ty
4716
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
4717
                     lineno, int col_offset, int end_lineno, int
4718
                     end_col_offset, PyArena *arena)
4719
11.8k
{
4720
11.8k
    excepthandler_ty p;
4721
11.8k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
4722
11.8k
    if (!p)
4723
0
        return NULL;
4724
11.8k
    p->kind = ExceptHandler_kind;
4725
11.8k
    p->v.ExceptHandler.type = type;
4726
11.8k
    p->v.ExceptHandler.name = name;
4727
11.8k
    p->v.ExceptHandler.body = body;
4728
11.8k
    p->lineno = lineno;
4729
11.8k
    p->col_offset = col_offset;
4730
11.8k
    p->end_lineno = end_lineno;
4731
11.8k
    p->end_col_offset = end_col_offset;
4732
11.8k
    return p;
4733
11.8k
}
4734
4735
arguments_ty
4736
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
4737
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
4738
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
4739
                 *arena)
4740
190k
{
4741
190k
    arguments_ty p;
4742
190k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
4743
190k
    if (!p)
4744
0
        return NULL;
4745
190k
    p->posonlyargs = posonlyargs;
4746
190k
    p->args = args;
4747
190k
    p->vararg = vararg;
4748
190k
    p->kwonlyargs = kwonlyargs;
4749
190k
    p->kw_defaults = kw_defaults;
4750
190k
    p->kwarg = kwarg;
4751
190k
    p->defaults = defaults;
4752
190k
    return p;
4753
190k
}
4754
4755
arg_ty
4756
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
4757
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
4758
5.82M
{
4759
5.82M
    arg_ty p;
4760
5.82M
    if (!arg) {
4761
0
        PyErr_SetString(PyExc_ValueError,
4762
0
                        "field 'arg' is required for arg");
4763
0
        return NULL;
4764
0
    }
4765
5.82M
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
4766
5.82M
    if (!p)
4767
0
        return NULL;
4768
5.82M
    p->arg = arg;
4769
5.82M
    p->annotation = annotation;
4770
5.82M
    p->type_comment = type_comment;
4771
5.82M
    p->lineno = lineno;
4772
5.82M
    p->col_offset = col_offset;
4773
5.82M
    p->end_lineno = end_lineno;
4774
5.82M
    p->end_col_offset = end_col_offset;
4775
5.82M
    return p;
4776
5.82M
}
4777
4778
keyword_ty
4779
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
4780
               end_lineno, int end_col_offset, PyArena *arena)
4781
25.4k
{
4782
25.4k
    keyword_ty p;
4783
25.4k
    if (!value) {
4784
0
        PyErr_SetString(PyExc_ValueError,
4785
0
                        "field 'value' is required for keyword");
4786
0
        return NULL;
4787
0
    }
4788
25.4k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
4789
25.4k
    if (!p)
4790
0
        return NULL;
4791
25.4k
    p->arg = arg;
4792
25.4k
    p->value = value;
4793
25.4k
    p->lineno = lineno;
4794
25.4k
    p->col_offset = col_offset;
4795
25.4k
    p->end_lineno = end_lineno;
4796
25.4k
    p->end_col_offset = end_col_offset;
4797
25.4k
    return p;
4798
25.4k
}
4799
4800
alias_ty
4801
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
4802
             int end_lineno, int end_col_offset, PyArena *arena)
4803
16.4k
{
4804
16.4k
    alias_ty p;
4805
16.4k
    if (!name) {
4806
0
        PyErr_SetString(PyExc_ValueError,
4807
0
                        "field 'name' is required for alias");
4808
0
        return NULL;
4809
0
    }
4810
16.4k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
4811
16.4k
    if (!p)
4812
0
        return NULL;
4813
16.4k
    p->name = name;
4814
16.4k
    p->asname = asname;
4815
16.4k
    p->lineno = lineno;
4816
16.4k
    p->col_offset = col_offset;
4817
16.4k
    p->end_lineno = end_lineno;
4818
16.4k
    p->end_col_offset = end_col_offset;
4819
16.4k
    return p;
4820
16.4k
}
4821
4822
withitem_ty
4823
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
4824
11.3k
{
4825
11.3k
    withitem_ty p;
4826
11.3k
    if (!context_expr) {
4827
0
        PyErr_SetString(PyExc_ValueError,
4828
0
                        "field 'context_expr' is required for withitem");
4829
0
        return NULL;
4830
0
    }
4831
11.3k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
4832
11.3k
    if (!p)
4833
0
        return NULL;
4834
11.3k
    p->context_expr = context_expr;
4835
11.3k
    p->optional_vars = optional_vars;
4836
11.3k
    return p;
4837
11.3k
}
4838
4839
match_case_ty
4840
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
4841
                  PyArena *arena)
4842
3.34k
{
4843
3.34k
    match_case_ty p;
4844
3.34k
    if (!pattern) {
4845
0
        PyErr_SetString(PyExc_ValueError,
4846
0
                        "field 'pattern' is required for match_case");
4847
0
        return NULL;
4848
0
    }
4849
3.34k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
4850
3.34k
    if (!p)
4851
0
        return NULL;
4852
3.34k
    p->pattern = pattern;
4853
3.34k
    p->guard = guard;
4854
3.34k
    p->body = body;
4855
3.34k
    return p;
4856
3.34k
}
4857
4858
pattern_ty
4859
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
4860
                  int end_col_offset, PyArena *arena)
4861
6.86k
{
4862
6.86k
    pattern_ty p;
4863
6.86k
    if (!value) {
4864
0
        PyErr_SetString(PyExc_ValueError,
4865
0
                        "field 'value' is required for MatchValue");
4866
0
        return NULL;
4867
0
    }
4868
6.86k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4869
6.86k
    if (!p)
4870
0
        return NULL;
4871
6.86k
    p->kind = MatchValue_kind;
4872
6.86k
    p->v.MatchValue.value = value;
4873
6.86k
    p->lineno = lineno;
4874
6.86k
    p->col_offset = col_offset;
4875
6.86k
    p->end_lineno = end_lineno;
4876
6.86k
    p->end_col_offset = end_col_offset;
4877
6.86k
    return p;
4878
6.86k
}
4879
4880
pattern_ty
4881
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
4882
                      end_lineno, int end_col_offset, PyArena *arena)
4883
937
{
4884
937
    pattern_ty p;
4885
937
    if (!value) {
4886
0
        PyErr_SetString(PyExc_ValueError,
4887
0
                        "field 'value' is required for MatchSingleton");
4888
0
        return NULL;
4889
0
    }
4890
937
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4891
937
    if (!p)
4892
0
        return NULL;
4893
937
    p->kind = MatchSingleton_kind;
4894
937
    p->v.MatchSingleton.value = value;
4895
937
    p->lineno = lineno;
4896
937
    p->col_offset = col_offset;
4897
937
    p->end_lineno = end_lineno;
4898
937
    p->end_col_offset = end_col_offset;
4899
937
    return p;
4900
937
}
4901
4902
pattern_ty
4903
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
4904
                     int end_lineno, int end_col_offset, PyArena *arena)
4905
4.19k
{
4906
4.19k
    pattern_ty p;
4907
4.19k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4908
4.19k
    if (!p)
4909
0
        return NULL;
4910
4.19k
    p->kind = MatchSequence_kind;
4911
4.19k
    p->v.MatchSequence.patterns = patterns;
4912
4.19k
    p->lineno = lineno;
4913
4.19k
    p->col_offset = col_offset;
4914
4.19k
    p->end_lineno = end_lineno;
4915
4.19k
    p->end_col_offset = end_col_offset;
4916
4.19k
    return p;
4917
4.19k
}
4918
4919
pattern_ty
4920
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
4921
                    identifier rest, int lineno, int col_offset, int
4922
                    end_lineno, int end_col_offset, PyArena *arena)
4923
1.49k
{
4924
1.49k
    pattern_ty p;
4925
1.49k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4926
1.49k
    if (!p)
4927
0
        return NULL;
4928
1.49k
    p->kind = MatchMapping_kind;
4929
1.49k
    p->v.MatchMapping.keys = keys;
4930
1.49k
    p->v.MatchMapping.patterns = patterns;
4931
1.49k
    p->v.MatchMapping.rest = rest;
4932
1.49k
    p->lineno = lineno;
4933
1.49k
    p->col_offset = col_offset;
4934
1.49k
    p->end_lineno = end_lineno;
4935
1.49k
    p->end_col_offset = end_col_offset;
4936
1.49k
    return p;
4937
1.49k
}
4938
4939
pattern_ty
4940
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
4941
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
4942
                  col_offset, int end_lineno, int end_col_offset, PyArena
4943
                  *arena)
4944
2.30k
{
4945
2.30k
    pattern_ty p;
4946
2.30k
    if (!cls) {
4947
0
        PyErr_SetString(PyExc_ValueError,
4948
0
                        "field 'cls' is required for MatchClass");
4949
0
        return NULL;
4950
0
    }
4951
2.30k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4952
2.30k
    if (!p)
4953
0
        return NULL;
4954
2.30k
    p->kind = MatchClass_kind;
4955
2.30k
    p->v.MatchClass.cls = cls;
4956
2.30k
    p->v.MatchClass.patterns = patterns;
4957
2.30k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
4958
2.30k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
4959
2.30k
    p->lineno = lineno;
4960
2.30k
    p->col_offset = col_offset;
4961
2.30k
    p->end_lineno = end_lineno;
4962
2.30k
    p->end_col_offset = end_col_offset;
4963
2.30k
    return p;
4964
2.30k
}
4965
4966
pattern_ty
4967
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
4968
                 int end_col_offset, PyArena *arena)
4969
1.98k
{
4970
1.98k
    pattern_ty p;
4971
1.98k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4972
1.98k
    if (!p)
4973
0
        return NULL;
4974
1.98k
    p->kind = MatchStar_kind;
4975
1.98k
    p->v.MatchStar.name = name;
4976
1.98k
    p->lineno = lineno;
4977
1.98k
    p->col_offset = col_offset;
4978
1.98k
    p->end_lineno = end_lineno;
4979
1.98k
    p->end_col_offset = end_col_offset;
4980
1.98k
    return p;
4981
1.98k
}
4982
4983
pattern_ty
4984
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
4985
               int end_lineno, int end_col_offset, PyArena *arena)
4986
21.1k
{
4987
21.1k
    pattern_ty p;
4988
21.1k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
4989
21.1k
    if (!p)
4990
0
        return NULL;
4991
21.1k
    p->kind = MatchAs_kind;
4992
21.1k
    p->v.MatchAs.pattern = pattern;
4993
21.1k
    p->v.MatchAs.name = name;
4994
21.1k
    p->lineno = lineno;
4995
21.1k
    p->col_offset = col_offset;
4996
21.1k
    p->end_lineno = end_lineno;
4997
21.1k
    p->end_col_offset = end_col_offset;
4998
21.1k
    return p;
4999
21.1k
}
5000
5001
pattern_ty
5002
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
5003
               end_lineno, int end_col_offset, PyArena *arena)
5004
8.12k
{
5005
8.12k
    pattern_ty p;
5006
8.12k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
5007
8.12k
    if (!p)
5008
0
        return NULL;
5009
8.12k
    p->kind = MatchOr_kind;
5010
8.12k
    p->v.MatchOr.patterns = patterns;
5011
8.12k
    p->lineno = lineno;
5012
8.12k
    p->col_offset = col_offset;
5013
8.12k
    p->end_lineno = end_lineno;
5014
8.12k
    p->end_col_offset = end_col_offset;
5015
8.12k
    return p;
5016
8.12k
}
5017
5018
type_ignore_ty
5019
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
5020
0
{
5021
0
    type_ignore_ty p;
5022
0
    if (!tag) {
5023
0
        PyErr_SetString(PyExc_ValueError,
5024
0
                        "field 'tag' is required for TypeIgnore");
5025
0
        return NULL;
5026
0
    }
5027
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
5028
0
    if (!p)
5029
0
        return NULL;
5030
0
    p->kind = TypeIgnore_kind;
5031
0
    p->v.TypeIgnore.lineno = lineno;
5032
0
    p->v.TypeIgnore.tag = tag;
5033
0
    return p;
5034
0
}
5035
5036
type_param_ty
5037
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
5038
               lineno, int col_offset, int end_lineno, int end_col_offset,
5039
               PyArena *arena)
5040
7.90k
{
5041
7.90k
    type_param_ty p;
5042
7.90k
    if (!name) {
5043
0
        PyErr_SetString(PyExc_ValueError,
5044
0
                        "field 'name' is required for TypeVar");
5045
0
        return NULL;
5046
0
    }
5047
7.90k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
5048
7.90k
    if (!p)
5049
0
        return NULL;
5050
7.90k
    p->kind = TypeVar_kind;
5051
7.90k
    p->v.TypeVar.name = name;
5052
7.90k
    p->v.TypeVar.bound = bound;
5053
7.90k
    p->v.TypeVar.default_value = default_value;
5054
7.90k
    p->lineno = lineno;
5055
7.90k
    p->col_offset = col_offset;
5056
7.90k
    p->end_lineno = end_lineno;
5057
7.90k
    p->end_col_offset = end_col_offset;
5058
7.90k
    return p;
5059
7.90k
}
5060
5061
type_param_ty
5062
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
5063
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
5064
1.78k
{
5065
1.78k
    type_param_ty p;
5066
1.78k
    if (!name) {
5067
0
        PyErr_SetString(PyExc_ValueError,
5068
0
                        "field 'name' is required for ParamSpec");
5069
0
        return NULL;
5070
0
    }
5071
1.78k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
5072
1.78k
    if (!p)
5073
0
        return NULL;
5074
1.78k
    p->kind = ParamSpec_kind;
5075
1.78k
    p->v.ParamSpec.name = name;
5076
1.78k
    p->v.ParamSpec.default_value = default_value;
5077
1.78k
    p->lineno = lineno;
5078
1.78k
    p->col_offset = col_offset;
5079
1.78k
    p->end_lineno = end_lineno;
5080
1.78k
    p->end_col_offset = end_col_offset;
5081
1.78k
    return p;
5082
1.78k
}
5083
5084
type_param_ty
5085
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
5086
                    col_offset, int end_lineno, int end_col_offset, PyArena
5087
                    *arena)
5088
1.73k
{
5089
1.73k
    type_param_ty p;
5090
1.73k
    if (!name) {
5091
0
        PyErr_SetString(PyExc_ValueError,
5092
0
                        "field 'name' is required for TypeVarTuple");
5093
0
        return NULL;
5094
0
    }
5095
1.73k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
5096
1.73k
    if (!p)
5097
0
        return NULL;
5098
1.73k
    p->kind = TypeVarTuple_kind;
5099
1.73k
    p->v.TypeVarTuple.name = name;
5100
1.73k
    p->v.TypeVarTuple.default_value = default_value;
5101
1.73k
    p->lineno = lineno;
5102
1.73k
    p->col_offset = col_offset;
5103
1.73k
    p->end_lineno = end_lineno;
5104
1.73k
    p->end_col_offset = end_col_offset;
5105
1.73k
    return p;
5106
1.73k
}
5107
5108
5109
PyObject*
5110
ast2obj_mod(struct ast_state *state, void* _o)
5111
8.22k
{
5112
8.22k
    mod_ty o = (mod_ty)_o;
5113
8.22k
    PyObject *result = NULL, *value = NULL;
5114
8.22k
    PyTypeObject *tp;
5115
8.22k
    if (!o) {
5116
0
        Py_RETURN_NONE;
5117
0
    }
5118
8.22k
    if (Py_EnterRecursiveCall("during  ast construction")) {
5119
0
        return NULL;
5120
0
    }
5121
8.22k
    switch (o->kind) {
5122
8.22k
    case Module_kind:
5123
8.22k
        tp = (PyTypeObject *)state->Module_type;
5124
8.22k
        result = PyType_GenericNew(tp, NULL, NULL);
5125
8.22k
        if (!result) goto failed;
5126
8.22k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
5127
8.22k
        if (!value) goto failed;
5128
8.22k
        if (PyObject_SetAttr(result, state->body, value) == -1)
5129
0
            goto failed;
5130
8.22k
        Py_DECREF(value);
5131
8.22k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
5132
8.22k
                             ast2obj_type_ignore);
5133
8.22k
        if (!value) goto failed;
5134
8.22k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
5135
0
            goto failed;
5136
8.22k
        Py_DECREF(value);
5137
8.22k
        break;
5138
0
    case Interactive_kind:
5139
0
        tp = (PyTypeObject *)state->Interactive_type;
5140
0
        result = PyType_GenericNew(tp, NULL, NULL);
5141
0
        if (!result) goto failed;
5142
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
5143
0
                             ast2obj_stmt);
5144
0
        if (!value) goto failed;
5145
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
5146
0
            goto failed;
5147
0
        Py_DECREF(value);
5148
0
        break;
5149
0
    case Expression_kind:
5150
0
        tp = (PyTypeObject *)state->Expression_type;
5151
0
        result = PyType_GenericNew(tp, NULL, NULL);
5152
0
        if (!result) goto failed;
5153
0
        value = ast2obj_expr(state, o->v.Expression.body);
5154
0
        if (!value) goto failed;
5155
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
5156
0
            goto failed;
5157
0
        Py_DECREF(value);
5158
0
        break;
5159
0
    case FunctionType_kind:
5160
0
        tp = (PyTypeObject *)state->FunctionType_type;
5161
0
        result = PyType_GenericNew(tp, NULL, NULL);
5162
0
        if (!result) goto failed;
5163
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
5164
0
                             ast2obj_expr);
5165
0
        if (!value) goto failed;
5166
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
5167
0
            goto failed;
5168
0
        Py_DECREF(value);
5169
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
5170
0
        if (!value) goto failed;
5171
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
5172
0
            goto failed;
5173
0
        Py_DECREF(value);
5174
0
        break;
5175
8.22k
    }
5176
8.22k
    Py_LeaveRecursiveCall();
5177
8.22k
    return result;
5178
0
failed:
5179
0
    Py_LeaveRecursiveCall();
5180
0
    Py_XDECREF(value);
5181
0
    Py_XDECREF(result);
5182
0
    return NULL;
5183
8.22k
}
5184
5185
PyObject*
5186
ast2obj_stmt(struct ast_state *state, void* _o)
5187
54.6k
{
5188
54.6k
    stmt_ty o = (stmt_ty)_o;
5189
54.6k
    PyObject *result = NULL, *value = NULL;
5190
54.6k
    PyTypeObject *tp;
5191
54.6k
    if (!o) {
5192
0
        Py_RETURN_NONE;
5193
0
    }
5194
54.6k
    if (Py_EnterRecursiveCall("during  ast construction")) {
5195
0
        return NULL;
5196
0
    }
5197
54.6k
    switch (o->kind) {
5198
2.16k
    case FunctionDef_kind:
5199
2.16k
        tp = (PyTypeObject *)state->FunctionDef_type;
5200
2.16k
        result = PyType_GenericNew(tp, NULL, NULL);
5201
2.16k
        if (!result) goto failed;
5202
2.16k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
5203
2.16k
        if (!value) goto failed;
5204
2.16k
        if (PyObject_SetAttr(result, state->name, value) == -1)
5205
0
            goto failed;
5206
2.16k
        Py_DECREF(value);
5207
2.16k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
5208
2.16k
        if (!value) goto failed;
5209
2.16k
        if (PyObject_SetAttr(result, state->args, value) == -1)
5210
0
            goto failed;
5211
2.16k
        Py_DECREF(value);
5212
2.16k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
5213
2.16k
                             ast2obj_stmt);
5214
2.16k
        if (!value) goto failed;
5215
2.16k
        if (PyObject_SetAttr(result, state->body, value) == -1)
5216
0
            goto failed;
5217
2.16k
        Py_DECREF(value);
5218
2.16k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
5219
2.16k
                             ast2obj_expr);
5220
2.16k
        if (!value) goto failed;
5221
2.16k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
5222
0
            goto failed;
5223
2.16k
        Py_DECREF(value);
5224
2.16k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
5225
2.16k
        if (!value) goto failed;
5226
2.16k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
5227
0
            goto failed;
5228
2.16k
        Py_DECREF(value);
5229
2.16k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
5230
2.16k
        if (!value) goto failed;
5231
2.16k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5232
0
            goto failed;
5233
2.16k
        Py_DECREF(value);
5234
2.16k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
5235
2.16k
                             ast2obj_type_param);
5236
2.16k
        if (!value) goto failed;
5237
2.16k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
5238
0
            goto failed;
5239
2.16k
        Py_DECREF(value);
5240
2.16k
        break;
5241
698
    case AsyncFunctionDef_kind:
5242
698
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
5243
698
        result = PyType_GenericNew(tp, NULL, NULL);
5244
698
        if (!result) goto failed;
5245
698
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
5246
698
        if (!value) goto failed;
5247
698
        if (PyObject_SetAttr(result, state->name, value) == -1)
5248
0
            goto failed;
5249
698
        Py_DECREF(value);
5250
698
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
5251
698
        if (!value) goto failed;
5252
698
        if (PyObject_SetAttr(result, state->args, value) == -1)
5253
0
            goto failed;
5254
698
        Py_DECREF(value);
5255
698
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
5256
698
                             ast2obj_stmt);
5257
698
        if (!value) goto failed;
5258
698
        if (PyObject_SetAttr(result, state->body, value) == -1)
5259
0
            goto failed;
5260
698
        Py_DECREF(value);
5261
698
        value = ast2obj_list(state,
5262
698
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
5263
698
                             ast2obj_expr);
5264
698
        if (!value) goto failed;
5265
698
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
5266
0
            goto failed;
5267
698
        Py_DECREF(value);
5268
698
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
5269
698
        if (!value) goto failed;
5270
698
        if (PyObject_SetAttr(result, state->returns, value) == -1)
5271
0
            goto failed;
5272
698
        Py_DECREF(value);
5273
698
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
5274
698
        if (!value) goto failed;
5275
698
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5276
0
            goto failed;
5277
698
        Py_DECREF(value);
5278
698
        value = ast2obj_list(state,
5279
698
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
5280
698
                             ast2obj_type_param);
5281
698
        if (!value) goto failed;
5282
698
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
5283
0
            goto failed;
5284
698
        Py_DECREF(value);
5285
698
        break;
5286
336
    case ClassDef_kind:
5287
336
        tp = (PyTypeObject *)state->ClassDef_type;
5288
336
        result = PyType_GenericNew(tp, NULL, NULL);
5289
336
        if (!result) goto failed;
5290
336
        value = ast2obj_identifier(state, o->v.ClassDef.name);
5291
336
        if (!value) goto failed;
5292
336
        if (PyObject_SetAttr(result, state->name, value) == -1)
5293
0
            goto failed;
5294
336
        Py_DECREF(value);
5295
336
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
5296
336
                             ast2obj_expr);
5297
336
        if (!value) goto failed;
5298
336
        if (PyObject_SetAttr(result, state->bases, value) == -1)
5299
0
            goto failed;
5300
336
        Py_DECREF(value);
5301
336
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
5302
336
                             ast2obj_keyword);
5303
336
        if (!value) goto failed;
5304
336
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
5305
0
            goto failed;
5306
336
        Py_DECREF(value);
5307
336
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
5308
336
                             ast2obj_stmt);
5309
336
        if (!value) goto failed;
5310
336
        if (PyObject_SetAttr(result, state->body, value) == -1)
5311
0
            goto failed;
5312
336
        Py_DECREF(value);
5313
336
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
5314
336
                             ast2obj_expr);
5315
336
        if (!value) goto failed;
5316
336
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
5317
0
            goto failed;
5318
336
        Py_DECREF(value);
5319
336
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
5320
336
                             ast2obj_type_param);
5321
336
        if (!value) goto failed;
5322
336
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
5323
0
            goto failed;
5324
336
        Py_DECREF(value);
5325
336
        break;
5326
464
    case Return_kind:
5327
464
        tp = (PyTypeObject *)state->Return_type;
5328
464
        result = PyType_GenericNew(tp, NULL, NULL);
5329
464
        if (!result) goto failed;
5330
464
        value = ast2obj_expr(state, o->v.Return.value);
5331
464
        if (!value) goto failed;
5332
464
        if (PyObject_SetAttr(result, state->value, value) == -1)
5333
0
            goto failed;
5334
464
        Py_DECREF(value);
5335
464
        break;
5336
369
    case Delete_kind:
5337
369
        tp = (PyTypeObject *)state->Delete_type;
5338
369
        result = PyType_GenericNew(tp, NULL, NULL);
5339
369
        if (!result) goto failed;
5340
369
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
5341
369
                             ast2obj_expr);
5342
369
        if (!value) goto failed;
5343
369
        if (PyObject_SetAttr(result, state->targets, value) == -1)
5344
0
            goto failed;
5345
369
        Py_DECREF(value);
5346
369
        break;
5347
667
    case Assign_kind:
5348
667
        tp = (PyTypeObject *)state->Assign_type;
5349
667
        result = PyType_GenericNew(tp, NULL, NULL);
5350
667
        if (!result) goto failed;
5351
667
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
5352
667
                             ast2obj_expr);
5353
667
        if (!value) goto failed;
5354
667
        if (PyObject_SetAttr(result, state->targets, value) == -1)
5355
0
            goto failed;
5356
667
        Py_DECREF(value);
5357
667
        value = ast2obj_expr(state, o->v.Assign.value);
5358
667
        if (!value) goto failed;
5359
667
        if (PyObject_SetAttr(result, state->value, value) == -1)
5360
0
            goto failed;
5361
667
        Py_DECREF(value);
5362
667
        value = ast2obj_string(state, o->v.Assign.type_comment);
5363
667
        if (!value) goto failed;
5364
667
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5365
0
            goto failed;
5366
667
        Py_DECREF(value);
5367
667
        break;
5368
215
    case TypeAlias_kind:
5369
215
        tp = (PyTypeObject *)state->TypeAlias_type;
5370
215
        result = PyType_GenericNew(tp, NULL, NULL);
5371
215
        if (!result) goto failed;
5372
215
        value = ast2obj_expr(state, o->v.TypeAlias.name);
5373
215
        if (!value) goto failed;
5374
215
        if (PyObject_SetAttr(result, state->name, value) == -1)
5375
0
            goto failed;
5376
215
        Py_DECREF(value);
5377
215
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
5378
215
                             ast2obj_type_param);
5379
215
        if (!value) goto failed;
5380
215
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
5381
0
            goto failed;
5382
215
        Py_DECREF(value);
5383
215
        value = ast2obj_expr(state, o->v.TypeAlias.value);
5384
215
        if (!value) goto failed;
5385
215
        if (PyObject_SetAttr(result, state->value, value) == -1)
5386
0
            goto failed;
5387
215
        Py_DECREF(value);
5388
215
        break;
5389
519
    case AugAssign_kind:
5390
519
        tp = (PyTypeObject *)state->AugAssign_type;
5391
519
        result = PyType_GenericNew(tp, NULL, NULL);
5392
519
        if (!result) goto failed;
5393
519
        value = ast2obj_expr(state, o->v.AugAssign.target);
5394
519
        if (!value) goto failed;
5395
519
        if (PyObject_SetAttr(result, state->target, value) == -1)
5396
0
            goto failed;
5397
519
        Py_DECREF(value);
5398
519
        value = ast2obj_operator(state, o->v.AugAssign.op);
5399
519
        if (!value) goto failed;
5400
519
        if (PyObject_SetAttr(result, state->op, value) == -1)
5401
0
            goto failed;
5402
519
        Py_DECREF(value);
5403
519
        value = ast2obj_expr(state, o->v.AugAssign.value);
5404
519
        if (!value) goto failed;
5405
519
        if (PyObject_SetAttr(result, state->value, value) == -1)
5406
0
            goto failed;
5407
519
        Py_DECREF(value);
5408
519
        break;
5409
1.24k
    case AnnAssign_kind:
5410
1.24k
        tp = (PyTypeObject *)state->AnnAssign_type;
5411
1.24k
        result = PyType_GenericNew(tp, NULL, NULL);
5412
1.24k
        if (!result) goto failed;
5413
1.24k
        value = ast2obj_expr(state, o->v.AnnAssign.target);
5414
1.24k
        if (!value) goto failed;
5415
1.24k
        if (PyObject_SetAttr(result, state->target, value) == -1)
5416
0
            goto failed;
5417
1.24k
        Py_DECREF(value);
5418
1.24k
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
5419
1.24k
        if (!value) goto failed;
5420
1.24k
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
5421
0
            goto failed;
5422
1.24k
        Py_DECREF(value);
5423
1.24k
        value = ast2obj_expr(state, o->v.AnnAssign.value);
5424
1.24k
        if (!value) goto failed;
5425
1.24k
        if (PyObject_SetAttr(result, state->value, value) == -1)
5426
0
            goto failed;
5427
1.24k
        Py_DECREF(value);
5428
1.24k
        value = ast2obj_int(state, o->v.AnnAssign.simple);
5429
1.24k
        if (!value) goto failed;
5430
1.24k
        if (PyObject_SetAttr(result, state->simple, value) == -1)
5431
0
            goto failed;
5432
1.24k
        Py_DECREF(value);
5433
1.24k
        break;
5434
229
    case For_kind:
5435
229
        tp = (PyTypeObject *)state->For_type;
5436
229
        result = PyType_GenericNew(tp, NULL, NULL);
5437
229
        if (!result) goto failed;
5438
229
        value = ast2obj_expr(state, o->v.For.target);
5439
229
        if (!value) goto failed;
5440
229
        if (PyObject_SetAttr(result, state->target, value) == -1)
5441
0
            goto failed;
5442
229
        Py_DECREF(value);
5443
229
        value = ast2obj_expr(state, o->v.For.iter);
5444
229
        if (!value) goto failed;
5445
229
        if (PyObject_SetAttr(result, state->iter, value) == -1)
5446
0
            goto failed;
5447
229
        Py_DECREF(value);
5448
229
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
5449
229
        if (!value) goto failed;
5450
229
        if (PyObject_SetAttr(result, state->body, value) == -1)
5451
0
            goto failed;
5452
229
        Py_DECREF(value);
5453
229
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
5454
229
        if (!value) goto failed;
5455
229
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5456
0
            goto failed;
5457
229
        Py_DECREF(value);
5458
229
        value = ast2obj_string(state, o->v.For.type_comment);
5459
229
        if (!value) goto failed;
5460
229
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5461
0
            goto failed;
5462
229
        Py_DECREF(value);
5463
229
        break;
5464
84
    case AsyncFor_kind:
5465
84
        tp = (PyTypeObject *)state->AsyncFor_type;
5466
84
        result = PyType_GenericNew(tp, NULL, NULL);
5467
84
        if (!result) goto failed;
5468
84
        value = ast2obj_expr(state, o->v.AsyncFor.target);
5469
84
        if (!value) goto failed;
5470
84
        if (PyObject_SetAttr(result, state->target, value) == -1)
5471
0
            goto failed;
5472
84
        Py_DECREF(value);
5473
84
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
5474
84
        if (!value) goto failed;
5475
84
        if (PyObject_SetAttr(result, state->iter, value) == -1)
5476
0
            goto failed;
5477
84
        Py_DECREF(value);
5478
84
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
5479
84
                             ast2obj_stmt);
5480
84
        if (!value) goto failed;
5481
84
        if (PyObject_SetAttr(result, state->body, value) == -1)
5482
0
            goto failed;
5483
84
        Py_DECREF(value);
5484
84
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
5485
84
                             ast2obj_stmt);
5486
84
        if (!value) goto failed;
5487
84
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5488
0
            goto failed;
5489
84
        Py_DECREF(value);
5490
84
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
5491
84
        if (!value) goto failed;
5492
84
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5493
0
            goto failed;
5494
84
        Py_DECREF(value);
5495
84
        break;
5496
276
    case While_kind:
5497
276
        tp = (PyTypeObject *)state->While_type;
5498
276
        result = PyType_GenericNew(tp, NULL, NULL);
5499
276
        if (!result) goto failed;
5500
276
        value = ast2obj_expr(state, o->v.While.test);
5501
276
        if (!value) goto failed;
5502
276
        if (PyObject_SetAttr(result, state->test, value) == -1)
5503
0
            goto failed;
5504
276
        Py_DECREF(value);
5505
276
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
5506
276
        if (!value) goto failed;
5507
276
        if (PyObject_SetAttr(result, state->body, value) == -1)
5508
0
            goto failed;
5509
276
        Py_DECREF(value);
5510
276
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
5511
276
        if (!value) goto failed;
5512
276
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5513
0
            goto failed;
5514
276
        Py_DECREF(value);
5515
276
        break;
5516
462
    case If_kind:
5517
462
        tp = (PyTypeObject *)state->If_type;
5518
462
        result = PyType_GenericNew(tp, NULL, NULL);
5519
462
        if (!result) goto failed;
5520
462
        value = ast2obj_expr(state, o->v.If.test);
5521
462
        if (!value) goto failed;
5522
462
        if (PyObject_SetAttr(result, state->test, value) == -1)
5523
0
            goto failed;
5524
462
        Py_DECREF(value);
5525
462
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
5526
462
        if (!value) goto failed;
5527
462
        if (PyObject_SetAttr(result, state->body, value) == -1)
5528
0
            goto failed;
5529
462
        Py_DECREF(value);
5530
462
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
5531
462
        if (!value) goto failed;
5532
462
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5533
0
            goto failed;
5534
462
        Py_DECREF(value);
5535
462
        break;
5536
580
    case With_kind:
5537
580
        tp = (PyTypeObject *)state->With_type;
5538
580
        result = PyType_GenericNew(tp, NULL, NULL);
5539
580
        if (!result) goto failed;
5540
580
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
5541
580
                             ast2obj_withitem);
5542
580
        if (!value) goto failed;
5543
580
        if (PyObject_SetAttr(result, state->items, value) == -1)
5544
0
            goto failed;
5545
580
        Py_DECREF(value);
5546
580
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
5547
580
        if (!value) goto failed;
5548
580
        if (PyObject_SetAttr(result, state->body, value) == -1)
5549
0
            goto failed;
5550
580
        Py_DECREF(value);
5551
580
        value = ast2obj_string(state, o->v.With.type_comment);
5552
580
        if (!value) goto failed;
5553
580
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5554
0
            goto failed;
5555
580
        Py_DECREF(value);
5556
580
        break;
5557
236
    case AsyncWith_kind:
5558
236
        tp = (PyTypeObject *)state->AsyncWith_type;
5559
236
        result = PyType_GenericNew(tp, NULL, NULL);
5560
236
        if (!result) goto failed;
5561
236
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
5562
236
                             ast2obj_withitem);
5563
236
        if (!value) goto failed;
5564
236
        if (PyObject_SetAttr(result, state->items, value) == -1)
5565
0
            goto failed;
5566
236
        Py_DECREF(value);
5567
236
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
5568
236
                             ast2obj_stmt);
5569
236
        if (!value) goto failed;
5570
236
        if (PyObject_SetAttr(result, state->body, value) == -1)
5571
0
            goto failed;
5572
236
        Py_DECREF(value);
5573
236
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
5574
236
        if (!value) goto failed;
5575
236
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
5576
0
            goto failed;
5577
236
        Py_DECREF(value);
5578
236
        break;
5579
295
    case Match_kind:
5580
295
        tp = (PyTypeObject *)state->Match_type;
5581
295
        result = PyType_GenericNew(tp, NULL, NULL);
5582
295
        if (!result) goto failed;
5583
295
        value = ast2obj_expr(state, o->v.Match.subject);
5584
295
        if (!value) goto failed;
5585
295
        if (PyObject_SetAttr(result, state->subject, value) == -1)
5586
0
            goto failed;
5587
295
        Py_DECREF(value);
5588
295
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
5589
295
                             ast2obj_match_case);
5590
295
        if (!value) goto failed;
5591
295
        if (PyObject_SetAttr(result, state->cases, value) == -1)
5592
0
            goto failed;
5593
295
        Py_DECREF(value);
5594
295
        break;
5595
639
    case Raise_kind:
5596
639
        tp = (PyTypeObject *)state->Raise_type;
5597
639
        result = PyType_GenericNew(tp, NULL, NULL);
5598
639
        if (!result) goto failed;
5599
639
        value = ast2obj_expr(state, o->v.Raise.exc);
5600
639
        if (!value) goto failed;
5601
639
        if (PyObject_SetAttr(result, state->exc, value) == -1)
5602
0
            goto failed;
5603
639
        Py_DECREF(value);
5604
639
        value = ast2obj_expr(state, o->v.Raise.cause);
5605
639
        if (!value) goto failed;
5606
639
        if (PyObject_SetAttr(result, state->cause, value) == -1)
5607
0
            goto failed;
5608
639
        Py_DECREF(value);
5609
639
        break;
5610
601
    case Try_kind:
5611
601
        tp = (PyTypeObject *)state->Try_type;
5612
601
        result = PyType_GenericNew(tp, NULL, NULL);
5613
601
        if (!result) goto failed;
5614
601
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
5615
601
        if (!value) goto failed;
5616
601
        if (PyObject_SetAttr(result, state->body, value) == -1)
5617
0
            goto failed;
5618
601
        Py_DECREF(value);
5619
601
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
5620
601
                             ast2obj_excepthandler);
5621
601
        if (!value) goto failed;
5622
601
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
5623
0
            goto failed;
5624
601
        Py_DECREF(value);
5625
601
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
5626
601
        if (!value) goto failed;
5627
601
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5628
0
            goto failed;
5629
601
        Py_DECREF(value);
5630
601
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
5631
601
                             ast2obj_stmt);
5632
601
        if (!value) goto failed;
5633
601
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
5634
0
            goto failed;
5635
601
        Py_DECREF(value);
5636
601
        break;
5637
373
    case TryStar_kind:
5638
373
        tp = (PyTypeObject *)state->TryStar_type;
5639
373
        result = PyType_GenericNew(tp, NULL, NULL);
5640
373
        if (!result) goto failed;
5641
373
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
5642
373
        if (!value) goto failed;
5643
373
        if (PyObject_SetAttr(result, state->body, value) == -1)
5644
0
            goto failed;
5645
373
        Py_DECREF(value);
5646
373
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
5647
373
                             ast2obj_excepthandler);
5648
373
        if (!value) goto failed;
5649
373
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
5650
0
            goto failed;
5651
373
        Py_DECREF(value);
5652
373
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
5653
373
                             ast2obj_stmt);
5654
373
        if (!value) goto failed;
5655
373
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5656
0
            goto failed;
5657
373
        Py_DECREF(value);
5658
373
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
5659
373
                             ast2obj_stmt);
5660
373
        if (!value) goto failed;
5661
373
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
5662
0
            goto failed;
5663
373
        Py_DECREF(value);
5664
373
        break;
5665
289
    case Assert_kind:
5666
289
        tp = (PyTypeObject *)state->Assert_type;
5667
289
        result = PyType_GenericNew(tp, NULL, NULL);
5668
289
        if (!result) goto failed;
5669
289
        value = ast2obj_expr(state, o->v.Assert.test);
5670
289
        if (!value) goto failed;
5671
289
        if (PyObject_SetAttr(result, state->test, value) == -1)
5672
0
            goto failed;
5673
289
        Py_DECREF(value);
5674
289
        value = ast2obj_expr(state, o->v.Assert.msg);
5675
289
        if (!value) goto failed;
5676
289
        if (PyObject_SetAttr(result, state->msg, value) == -1)
5677
0
            goto failed;
5678
289
        Py_DECREF(value);
5679
289
        break;
5680
649
    case Import_kind:
5681
649
        tp = (PyTypeObject *)state->Import_type;
5682
649
        result = PyType_GenericNew(tp, NULL, NULL);
5683
649
        if (!result) goto failed;
5684
649
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
5685
649
                             ast2obj_alias);
5686
649
        if (!value) goto failed;
5687
649
        if (PyObject_SetAttr(result, state->names, value) == -1)
5688
0
            goto failed;
5689
649
        Py_DECREF(value);
5690
649
        value = ast2obj_int(state, o->v.Import.is_lazy);
5691
649
        if (!value) goto failed;
5692
649
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
5693
0
            goto failed;
5694
649
        Py_DECREF(value);
5695
649
        break;
5696
1.11k
    case ImportFrom_kind:
5697
1.11k
        tp = (PyTypeObject *)state->ImportFrom_type;
5698
1.11k
        result = PyType_GenericNew(tp, NULL, NULL);
5699
1.11k
        if (!result) goto failed;
5700
1.11k
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
5701
1.11k
        if (!value) goto failed;
5702
1.11k
        if (PyObject_SetAttr(result, state->module, value) == -1)
5703
0
            goto failed;
5704
1.11k
        Py_DECREF(value);
5705
1.11k
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
5706
1.11k
                             ast2obj_alias);
5707
1.11k
        if (!value) goto failed;
5708
1.11k
        if (PyObject_SetAttr(result, state->names, value) == -1)
5709
0
            goto failed;
5710
1.11k
        Py_DECREF(value);
5711
1.11k
        value = ast2obj_int(state, o->v.ImportFrom.level);
5712
1.11k
        if (!value) goto failed;
5713
1.11k
        if (PyObject_SetAttr(result, state->level, value) == -1)
5714
0
            goto failed;
5715
1.11k
        Py_DECREF(value);
5716
1.11k
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
5717
1.11k
        if (!value) goto failed;
5718
1.11k
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
5719
0
            goto failed;
5720
1.11k
        Py_DECREF(value);
5721
1.11k
        break;
5722
333
    case Global_kind:
5723
333
        tp = (PyTypeObject *)state->Global_type;
5724
333
        result = PyType_GenericNew(tp, NULL, NULL);
5725
333
        if (!result) goto failed;
5726
333
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
5727
333
                             ast2obj_identifier);
5728
333
        if (!value) goto failed;
5729
333
        if (PyObject_SetAttr(result, state->names, value) == -1)
5730
0
            goto failed;
5731
333
        Py_DECREF(value);
5732
333
        break;
5733
194
    case Nonlocal_kind:
5734
194
        tp = (PyTypeObject *)state->Nonlocal_type;
5735
194
        result = PyType_GenericNew(tp, NULL, NULL);
5736
194
        if (!result) goto failed;
5737
194
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
5738
194
                             ast2obj_identifier);
5739
194
        if (!value) goto failed;
5740
194
        if (PyObject_SetAttr(result, state->names, value) == -1)
5741
0
            goto failed;
5742
194
        Py_DECREF(value);
5743
194
        break;
5744
40.8k
    case Expr_kind:
5745
40.8k
        tp = (PyTypeObject *)state->Expr_type;
5746
40.8k
        result = PyType_GenericNew(tp, NULL, NULL);
5747
40.8k
        if (!result) goto failed;
5748
40.8k
        value = ast2obj_expr(state, o->v.Expr.value);
5749
40.8k
        if (!value) goto failed;
5750
40.8k
        if (PyObject_SetAttr(result, state->value, value) == -1)
5751
0
            goto failed;
5752
40.8k
        Py_DECREF(value);
5753
40.8k
        break;
5754
228
    case Pass_kind:
5755
228
        tp = (PyTypeObject *)state->Pass_type;
5756
228
        result = PyType_GenericNew(tp, NULL, NULL);
5757
228
        if (!result) goto failed;
5758
228
        break;
5759
303
    case Break_kind:
5760
303
        tp = (PyTypeObject *)state->Break_type;
5761
303
        result = PyType_GenericNew(tp, NULL, NULL);
5762
303
        if (!result) goto failed;
5763
303
        break;
5764
303
    case Continue_kind:
5765
214
        tp = (PyTypeObject *)state->Continue_type;
5766
214
        result = PyType_GenericNew(tp, NULL, NULL);
5767
214
        if (!result) goto failed;
5768
214
        break;
5769
54.6k
    }
5770
54.6k
    value = ast2obj_int(state, o->lineno);
5771
54.6k
    if (!value) goto failed;
5772
54.6k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
5773
0
        goto failed;
5774
54.6k
    Py_DECREF(value);
5775
54.6k
    value = ast2obj_int(state, o->col_offset);
5776
54.6k
    if (!value) goto failed;
5777
54.6k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
5778
0
        goto failed;
5779
54.6k
    Py_DECREF(value);
5780
54.6k
    value = ast2obj_int(state, o->end_lineno);
5781
54.6k
    if (!value) goto failed;
5782
54.6k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
5783
0
        goto failed;
5784
54.6k
    Py_DECREF(value);
5785
54.6k
    value = ast2obj_int(state, o->end_col_offset);
5786
54.6k
    if (!value) goto failed;
5787
54.6k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
5788
0
        goto failed;
5789
54.6k
    Py_DECREF(value);
5790
54.6k
    Py_LeaveRecursiveCall();
5791
54.6k
    return result;
5792
0
failed:
5793
0
    Py_LeaveRecursiveCall();
5794
0
    Py_XDECREF(value);
5795
0
    Py_XDECREF(result);
5796
0
    return NULL;
5797
54.6k
}
5798
5799
PyObject*
5800
ast2obj_expr(struct ast_state *state, void* _o)
5801
385k
{
5802
385k
    expr_ty o = (expr_ty)_o;
5803
385k
    PyObject *result = NULL, *value = NULL;
5804
385k
    PyTypeObject *tp;
5805
385k
    if (!o) {
5806
50.1k
        Py_RETURN_NONE;
5807
50.1k
    }
5808
335k
    if (Py_EnterRecursiveCall("during  ast construction")) {
5809
0
        return NULL;
5810
0
    }
5811
335k
    switch (o->kind) {
5812
918
    case BoolOp_kind:
5813
918
        tp = (PyTypeObject *)state->BoolOp_type;
5814
918
        result = PyType_GenericNew(tp, NULL, NULL);
5815
918
        if (!result) goto failed;
5816
918
        value = ast2obj_boolop(state, o->v.BoolOp.op);
5817
918
        if (!value) goto failed;
5818
918
        if (PyObject_SetAttr(result, state->op, value) == -1)
5819
0
            goto failed;
5820
918
        Py_DECREF(value);
5821
918
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
5822
918
                             ast2obj_expr);
5823
918
        if (!value) goto failed;
5824
918
        if (PyObject_SetAttr(result, state->values, value) == -1)
5825
0
            goto failed;
5826
918
        Py_DECREF(value);
5827
918
        break;
5828
68
    case NamedExpr_kind:
5829
68
        tp = (PyTypeObject *)state->NamedExpr_type;
5830
68
        result = PyType_GenericNew(tp, NULL, NULL);
5831
68
        if (!result) goto failed;
5832
68
        value = ast2obj_expr(state, o->v.NamedExpr.target);
5833
68
        if (!value) goto failed;
5834
68
        if (PyObject_SetAttr(result, state->target, value) == -1)
5835
0
            goto failed;
5836
68
        Py_DECREF(value);
5837
68
        value = ast2obj_expr(state, o->v.NamedExpr.value);
5838
68
        if (!value) goto failed;
5839
68
        if (PyObject_SetAttr(result, state->value, value) == -1)
5840
0
            goto failed;
5841
68
        Py_DECREF(value);
5842
68
        break;
5843
24.4k
    case BinOp_kind:
5844
24.4k
        tp = (PyTypeObject *)state->BinOp_type;
5845
24.4k
        result = PyType_GenericNew(tp, NULL, NULL);
5846
24.4k
        if (!result) goto failed;
5847
24.4k
        value = ast2obj_expr(state, o->v.BinOp.left);
5848
24.4k
        if (!value) goto failed;
5849
24.4k
        if (PyObject_SetAttr(result, state->left, value) == -1)
5850
0
            goto failed;
5851
24.4k
        Py_DECREF(value);
5852
24.4k
        value = ast2obj_operator(state, o->v.BinOp.op);
5853
24.4k
        if (!value) goto failed;
5854
24.4k
        if (PyObject_SetAttr(result, state->op, value) == -1)
5855
0
            goto failed;
5856
24.4k
        Py_DECREF(value);
5857
24.4k
        value = ast2obj_expr(state, o->v.BinOp.right);
5858
24.4k
        if (!value) goto failed;
5859
24.4k
        if (PyObject_SetAttr(result, state->right, value) == -1)
5860
0
            goto failed;
5861
24.4k
        Py_DECREF(value);
5862
24.4k
        break;
5863
98.1k
    case UnaryOp_kind:
5864
98.1k
        tp = (PyTypeObject *)state->UnaryOp_type;
5865
98.1k
        result = PyType_GenericNew(tp, NULL, NULL);
5866
98.1k
        if (!result) goto failed;
5867
98.1k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
5868
98.1k
        if (!value) goto failed;
5869
98.1k
        if (PyObject_SetAttr(result, state->op, value) == -1)
5870
0
            goto failed;
5871
98.1k
        Py_DECREF(value);
5872
98.1k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
5873
98.1k
        if (!value) goto failed;
5874
98.1k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
5875
0
            goto failed;
5876
98.1k
        Py_DECREF(value);
5877
98.1k
        break;
5878
1.67k
    case Lambda_kind:
5879
1.67k
        tp = (PyTypeObject *)state->Lambda_type;
5880
1.67k
        result = PyType_GenericNew(tp, NULL, NULL);
5881
1.67k
        if (!result) goto failed;
5882
1.67k
        value = ast2obj_arguments(state, o->v.Lambda.args);
5883
1.67k
        if (!value) goto failed;
5884
1.67k
        if (PyObject_SetAttr(result, state->args, value) == -1)
5885
0
            goto failed;
5886
1.67k
        Py_DECREF(value);
5887
1.67k
        value = ast2obj_expr(state, o->v.Lambda.body);
5888
1.67k
        if (!value) goto failed;
5889
1.67k
        if (PyObject_SetAttr(result, state->body, value) == -1)
5890
0
            goto failed;
5891
1.67k
        Py_DECREF(value);
5892
1.67k
        break;
5893
196
    case IfExp_kind:
5894
196
        tp = (PyTypeObject *)state->IfExp_type;
5895
196
        result = PyType_GenericNew(tp, NULL, NULL);
5896
196
        if (!result) goto failed;
5897
196
        value = ast2obj_expr(state, o->v.IfExp.test);
5898
196
        if (!value) goto failed;
5899
196
        if (PyObject_SetAttr(result, state->test, value) == -1)
5900
0
            goto failed;
5901
196
        Py_DECREF(value);
5902
196
        value = ast2obj_expr(state, o->v.IfExp.body);
5903
196
        if (!value) goto failed;
5904
196
        if (PyObject_SetAttr(result, state->body, value) == -1)
5905
0
            goto failed;
5906
196
        Py_DECREF(value);
5907
196
        value = ast2obj_expr(state, o->v.IfExp.orelse);
5908
196
        if (!value) goto failed;
5909
196
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
5910
0
            goto failed;
5911
196
        Py_DECREF(value);
5912
196
        break;
5913
1.16k
    case Dict_kind:
5914
1.16k
        tp = (PyTypeObject *)state->Dict_type;
5915
1.16k
        result = PyType_GenericNew(tp, NULL, NULL);
5916
1.16k
        if (!result) goto failed;
5917
1.16k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
5918
1.16k
        if (!value) goto failed;
5919
1.16k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
5920
0
            goto failed;
5921
1.16k
        Py_DECREF(value);
5922
1.16k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
5923
1.16k
        if (!value) goto failed;
5924
1.16k
        if (PyObject_SetAttr(result, state->values, value) == -1)
5925
0
            goto failed;
5926
1.16k
        Py_DECREF(value);
5927
1.16k
        break;
5928
479
    case Set_kind:
5929
479
        tp = (PyTypeObject *)state->Set_type;
5930
479
        result = PyType_GenericNew(tp, NULL, NULL);
5931
479
        if (!result) goto failed;
5932
479
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
5933
479
        if (!value) goto failed;
5934
479
        if (PyObject_SetAttr(result, state->elts, value) == -1)
5935
0
            goto failed;
5936
479
        Py_DECREF(value);
5937
479
        break;
5938
241
    case ListComp_kind:
5939
241
        tp = (PyTypeObject *)state->ListComp_type;
5940
241
        result = PyType_GenericNew(tp, NULL, NULL);
5941
241
        if (!result) goto failed;
5942
241
        value = ast2obj_expr(state, o->v.ListComp.elt);
5943
241
        if (!value) goto failed;
5944
241
        if (PyObject_SetAttr(result, state->elt, value) == -1)
5945
0
            goto failed;
5946
241
        Py_DECREF(value);
5947
241
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
5948
241
                             ast2obj_comprehension);
5949
241
        if (!value) goto failed;
5950
241
        if (PyObject_SetAttr(result, state->generators, value) == -1)
5951
0
            goto failed;
5952
241
        Py_DECREF(value);
5953
241
        break;
5954
280
    case SetComp_kind:
5955
280
        tp = (PyTypeObject *)state->SetComp_type;
5956
280
        result = PyType_GenericNew(tp, NULL, NULL);
5957
280
        if (!result) goto failed;
5958
280
        value = ast2obj_expr(state, o->v.SetComp.elt);
5959
280
        if (!value) goto failed;
5960
280
        if (PyObject_SetAttr(result, state->elt, value) == -1)
5961
0
            goto failed;
5962
280
        Py_DECREF(value);
5963
280
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
5964
280
                             ast2obj_comprehension);
5965
280
        if (!value) goto failed;
5966
280
        if (PyObject_SetAttr(result, state->generators, value) == -1)
5967
0
            goto failed;
5968
280
        Py_DECREF(value);
5969
280
        break;
5970
414
    case DictComp_kind:
5971
414
        tp = (PyTypeObject *)state->DictComp_type;
5972
414
        result = PyType_GenericNew(tp, NULL, NULL);
5973
414
        if (!result) goto failed;
5974
414
        value = ast2obj_expr(state, o->v.DictComp.key);
5975
414
        if (!value) goto failed;
5976
414
        if (PyObject_SetAttr(result, state->key, value) == -1)
5977
0
            goto failed;
5978
414
        Py_DECREF(value);
5979
414
        value = ast2obj_expr(state, o->v.DictComp.value);
5980
414
        if (!value) goto failed;
5981
414
        if (PyObject_SetAttr(result, state->value, value) == -1)
5982
0
            goto failed;
5983
414
        Py_DECREF(value);
5984
414
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
5985
414
                             ast2obj_comprehension);
5986
414
        if (!value) goto failed;
5987
414
        if (PyObject_SetAttr(result, state->generators, value) == -1)
5988
0
            goto failed;
5989
414
        Py_DECREF(value);
5990
414
        break;
5991
560
    case GeneratorExp_kind:
5992
560
        tp = (PyTypeObject *)state->GeneratorExp_type;
5993
560
        result = PyType_GenericNew(tp, NULL, NULL);
5994
560
        if (!result) goto failed;
5995
560
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
5996
560
        if (!value) goto failed;
5997
560
        if (PyObject_SetAttr(result, state->elt, value) == -1)
5998
0
            goto failed;
5999
560
        Py_DECREF(value);
6000
560
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
6001
560
                             ast2obj_comprehension);
6002
560
        if (!value) goto failed;
6003
560
        if (PyObject_SetAttr(result, state->generators, value) == -1)
6004
0
            goto failed;
6005
560
        Py_DECREF(value);
6006
560
        break;
6007
207
    case Await_kind:
6008
207
        tp = (PyTypeObject *)state->Await_type;
6009
207
        result = PyType_GenericNew(tp, NULL, NULL);
6010
207
        if (!result) goto failed;
6011
207
        value = ast2obj_expr(state, o->v.Await.value);
6012
207
        if (!value) goto failed;
6013
207
        if (PyObject_SetAttr(result, state->value, value) == -1)
6014
0
            goto failed;
6015
207
        Py_DECREF(value);
6016
207
        break;
6017
298
    case Yield_kind:
6018
298
        tp = (PyTypeObject *)state->Yield_type;
6019
298
        result = PyType_GenericNew(tp, NULL, NULL);
6020
298
        if (!result) goto failed;
6021
298
        value = ast2obj_expr(state, o->v.Yield.value);
6022
298
        if (!value) goto failed;
6023
298
        if (PyObject_SetAttr(result, state->value, value) == -1)
6024
0
            goto failed;
6025
298
        Py_DECREF(value);
6026
298
        break;
6027
198
    case YieldFrom_kind:
6028
198
        tp = (PyTypeObject *)state->YieldFrom_type;
6029
198
        result = PyType_GenericNew(tp, NULL, NULL);
6030
198
        if (!result) goto failed;
6031
198
        value = ast2obj_expr(state, o->v.YieldFrom.value);
6032
198
        if (!value) goto failed;
6033
198
        if (PyObject_SetAttr(result, state->value, value) == -1)
6034
0
            goto failed;
6035
198
        Py_DECREF(value);
6036
198
        break;
6037
4.49k
    case Compare_kind:
6038
4.49k
        tp = (PyTypeObject *)state->Compare_type;
6039
4.49k
        result = PyType_GenericNew(tp, NULL, NULL);
6040
4.49k
        if (!result) goto failed;
6041
4.49k
        value = ast2obj_expr(state, o->v.Compare.left);
6042
4.49k
        if (!value) goto failed;
6043
4.49k
        if (PyObject_SetAttr(result, state->left, value) == -1)
6044
0
            goto failed;
6045
4.49k
        Py_DECREF(value);
6046
4.49k
        {
6047
4.49k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
6048
4.49k
            value = PyList_New(n);
6049
4.49k
            if (!value) goto failed;
6050
17.7k
            for(i = 0; i < n; i++)
6051
13.2k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
6052
4.49k
        }
6053
4.49k
        if (!value) goto failed;
6054
4.49k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
6055
0
            goto failed;
6056
4.49k
        Py_DECREF(value);
6057
4.49k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
6058
4.49k
                             ast2obj_expr);
6059
4.49k
        if (!value) goto failed;
6060
4.49k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
6061
0
            goto failed;
6062
4.49k
        Py_DECREF(value);
6063
4.49k
        break;
6064
9.14k
    case Call_kind:
6065
9.14k
        tp = (PyTypeObject *)state->Call_type;
6066
9.14k
        result = PyType_GenericNew(tp, NULL, NULL);
6067
9.14k
        if (!result) goto failed;
6068
9.14k
        value = ast2obj_expr(state, o->v.Call.func);
6069
9.14k
        if (!value) goto failed;
6070
9.14k
        if (PyObject_SetAttr(result, state->func, value) == -1)
6071
0
            goto failed;
6072
9.14k
        Py_DECREF(value);
6073
9.14k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
6074
9.14k
        if (!value) goto failed;
6075
9.14k
        if (PyObject_SetAttr(result, state->args, value) == -1)
6076
0
            goto failed;
6077
9.14k
        Py_DECREF(value);
6078
9.14k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
6079
9.14k
                             ast2obj_keyword);
6080
9.14k
        if (!value) goto failed;
6081
9.14k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
6082
0
            goto failed;
6083
9.14k
        Py_DECREF(value);
6084
9.14k
        break;
6085
14.2k
    case FormattedValue_kind:
6086
14.2k
        tp = (PyTypeObject *)state->FormattedValue_type;
6087
14.2k
        result = PyType_GenericNew(tp, NULL, NULL);
6088
14.2k
        if (!result) goto failed;
6089
14.2k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
6090
14.2k
        if (!value) goto failed;
6091
14.2k
        if (PyObject_SetAttr(result, state->value, value) == -1)
6092
0
            goto failed;
6093
14.2k
        Py_DECREF(value);
6094
14.2k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
6095
14.2k
        if (!value) goto failed;
6096
14.2k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
6097
0
            goto failed;
6098
14.2k
        Py_DECREF(value);
6099
14.2k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
6100
14.2k
        if (!value) goto failed;
6101
14.2k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
6102
0
            goto failed;
6103
14.2k
        Py_DECREF(value);
6104
14.2k
        break;
6105
2.48k
    case Interpolation_kind:
6106
2.48k
        tp = (PyTypeObject *)state->Interpolation_type;
6107
2.48k
        result = PyType_GenericNew(tp, NULL, NULL);
6108
2.48k
        if (!result) goto failed;
6109
2.48k
        value = ast2obj_expr(state, o->v.Interpolation.value);
6110
2.48k
        if (!value) goto failed;
6111
2.48k
        if (PyObject_SetAttr(result, state->value, value) == -1)
6112
0
            goto failed;
6113
2.48k
        Py_DECREF(value);
6114
2.48k
        value = ast2obj_constant(state, o->v.Interpolation.str);
6115
2.48k
        if (!value) goto failed;
6116
2.48k
        if (PyObject_SetAttr(result, state->str, value) == -1)
6117
0
            goto failed;
6118
2.48k
        Py_DECREF(value);
6119
2.48k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
6120
2.48k
        if (!value) goto failed;
6121
2.48k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
6122
0
            goto failed;
6123
2.48k
        Py_DECREF(value);
6124
2.48k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
6125
2.48k
        if (!value) goto failed;
6126
2.48k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
6127
0
            goto failed;
6128
2.48k
        Py_DECREF(value);
6129
2.48k
        break;
6130
8.59k
    case JoinedStr_kind:
6131
8.59k
        tp = (PyTypeObject *)state->JoinedStr_type;
6132
8.59k
        result = PyType_GenericNew(tp, NULL, NULL);
6133
8.59k
        if (!result) goto failed;
6134
8.59k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
6135
8.59k
                             ast2obj_expr);
6136
8.59k
        if (!value) goto failed;
6137
8.59k
        if (PyObject_SetAttr(result, state->values, value) == -1)
6138
0
            goto failed;
6139
8.59k
        Py_DECREF(value);
6140
8.59k
        break;
6141
438
    case TemplateStr_kind:
6142
438
        tp = (PyTypeObject *)state->TemplateStr_type;
6143
438
        result = PyType_GenericNew(tp, NULL, NULL);
6144
438
        if (!result) goto failed;
6145
438
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
6146
438
                             ast2obj_expr);
6147
438
        if (!value) goto failed;
6148
438
        if (PyObject_SetAttr(result, state->values, value) == -1)
6149
0
            goto failed;
6150
438
        Py_DECREF(value);
6151
438
        break;
6152
60.6k
    case Constant_kind:
6153
60.6k
        tp = (PyTypeObject *)state->Constant_type;
6154
60.6k
        result = PyType_GenericNew(tp, NULL, NULL);
6155
60.6k
        if (!result) goto failed;
6156
60.6k
        value = ast2obj_constant(state, o->v.Constant.value);
6157
60.6k
        if (!value) goto failed;
6158
60.6k
        if (PyObject_SetAttr(result, state->value, value) == -1)
6159
0
            goto failed;
6160
60.6k
        Py_DECREF(value);
6161
60.6k
        value = ast2obj_string(state, o->v.Constant.kind);
6162
60.6k
        if (!value) goto failed;
6163
60.6k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
6164
0
            goto failed;
6165
60.6k
        Py_DECREF(value);
6166
60.6k
        break;
6167
8.93k
    case Attribute_kind:
6168
8.93k
        tp = (PyTypeObject *)state->Attribute_type;
6169
8.93k
        result = PyType_GenericNew(tp, NULL, NULL);
6170
8.93k
        if (!result) goto failed;
6171
8.93k
        value = ast2obj_expr(state, o->v.Attribute.value);
6172
8.93k
        if (!value) goto failed;
6173
8.93k
        if (PyObject_SetAttr(result, state->value, value) == -1)
6174
0
            goto failed;
6175
8.93k
        Py_DECREF(value);
6176
8.93k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
6177
8.93k
        if (!value) goto failed;
6178
8.93k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
6179
0
            goto failed;
6180
8.93k
        Py_DECREF(value);
6181
8.93k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
6182
8.93k
        if (!value) goto failed;
6183
8.93k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
6184
0
            goto failed;
6185
8.93k
        Py_DECREF(value);
6186
8.93k
        break;
6187
1.05k
    case Subscript_kind:
6188
1.05k
        tp = (PyTypeObject *)state->Subscript_type;
6189
1.05k
        result = PyType_GenericNew(tp, NULL, NULL);
6190
1.05k
        if (!result) goto failed;
6191
1.05k
        value = ast2obj_expr(state, o->v.Subscript.value);
6192
1.05k
        if (!value) goto failed;
6193
1.05k
        if (PyObject_SetAttr(result, state->value, value) == -1)
6194
0
            goto failed;
6195
1.05k
        Py_DECREF(value);
6196
1.05k
        value = ast2obj_expr(state, o->v.Subscript.slice);
6197
1.05k
        if (!value) goto failed;
6198
1.05k
        if (PyObject_SetAttr(result, state->slice, value) == -1)
6199
0
            goto failed;
6200
1.05k
        Py_DECREF(value);
6201
1.05k
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
6202
1.05k
        if (!value) goto failed;
6203
1.05k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
6204
0
            goto failed;
6205
1.05k
        Py_DECREF(value);
6206
1.05k
        break;
6207
1.27k
    case Starred_kind:
6208
1.27k
        tp = (PyTypeObject *)state->Starred_type;
6209
1.27k
        result = PyType_GenericNew(tp, NULL, NULL);
6210
1.27k
        if (!result) goto failed;
6211
1.27k
        value = ast2obj_expr(state, o->v.Starred.value);
6212
1.27k
        if (!value) goto failed;
6213
1.27k
        if (PyObject_SetAttr(result, state->value, value) == -1)
6214
0
            goto failed;
6215
1.27k
        Py_DECREF(value);
6216
1.27k
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
6217
1.27k
        if (!value) goto failed;
6218
1.27k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
6219
0
            goto failed;
6220
1.27k
        Py_DECREF(value);
6221
1.27k
        break;
6222
83.2k
    case Name_kind:
6223
83.2k
        tp = (PyTypeObject *)state->Name_type;
6224
83.2k
        result = PyType_GenericNew(tp, NULL, NULL);
6225
83.2k
        if (!result) goto failed;
6226
83.2k
        value = ast2obj_identifier(state, o->v.Name.id);
6227
83.2k
        if (!value) goto failed;
6228
83.2k
        if (PyObject_SetAttr(result, state->id, value) == -1)
6229
0
            goto failed;
6230
83.2k
        Py_DECREF(value);
6231
83.2k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
6232
83.2k
        if (!value) goto failed;
6233
83.2k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
6234
0
            goto failed;
6235
83.2k
        Py_DECREF(value);
6236
83.2k
        break;
6237
1.45k
    case List_kind:
6238
1.45k
        tp = (PyTypeObject *)state->List_type;
6239
1.45k
        result = PyType_GenericNew(tp, NULL, NULL);
6240
1.45k
        if (!result) goto failed;
6241
1.45k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
6242
1.45k
        if (!value) goto failed;
6243
1.45k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
6244
0
            goto failed;
6245
1.45k
        Py_DECREF(value);
6246
1.45k
        value = ast2obj_expr_context(state, o->v.List.ctx);
6247
1.45k
        if (!value) goto failed;
6248
1.45k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
6249
0
            goto failed;
6250
1.45k
        Py_DECREF(value);
6251
1.45k
        break;
6252
6.83k
    case Tuple_kind:
6253
6.83k
        tp = (PyTypeObject *)state->Tuple_type;
6254
6.83k
        result = PyType_GenericNew(tp, NULL, NULL);
6255
6.83k
        if (!result) goto failed;
6256
6.83k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
6257
6.83k
        if (!value) goto failed;
6258
6.83k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
6259
0
            goto failed;
6260
6.83k
        Py_DECREF(value);
6261
6.83k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
6262
6.83k
        if (!value) goto failed;
6263
6.83k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
6264
0
            goto failed;
6265
6.83k
        Py_DECREF(value);
6266
6.83k
        break;
6267
3.18k
    case Slice_kind:
6268
3.18k
        tp = (PyTypeObject *)state->Slice_type;
6269
3.18k
        result = PyType_GenericNew(tp, NULL, NULL);
6270
3.18k
        if (!result) goto failed;
6271
3.18k
        value = ast2obj_expr(state, o->v.Slice.lower);
6272
3.18k
        if (!value) goto failed;
6273
3.18k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
6274
0
            goto failed;
6275
3.18k
        Py_DECREF(value);
6276
3.18k
        value = ast2obj_expr(state, o->v.Slice.upper);
6277
3.18k
        if (!value) goto failed;
6278
3.18k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
6279
0
            goto failed;
6280
3.18k
        Py_DECREF(value);
6281
3.18k
        value = ast2obj_expr(state, o->v.Slice.step);
6282
3.18k
        if (!value) goto failed;
6283
3.18k
        if (PyObject_SetAttr(result, state->step, value) == -1)
6284
0
            goto failed;
6285
3.18k
        Py_DECREF(value);
6286
3.18k
        break;
6287
335k
    }
6288
335k
    value = ast2obj_int(state, o->lineno);
6289
335k
    if (!value) goto failed;
6290
335k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
6291
0
        goto failed;
6292
335k
    Py_DECREF(value);
6293
335k
    value = ast2obj_int(state, o->col_offset);
6294
335k
    if (!value) goto failed;
6295
335k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
6296
0
        goto failed;
6297
335k
    Py_DECREF(value);
6298
335k
    value = ast2obj_int(state, o->end_lineno);
6299
335k
    if (!value) goto failed;
6300
335k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
6301
0
        goto failed;
6302
335k
    Py_DECREF(value);
6303
335k
    value = ast2obj_int(state, o->end_col_offset);
6304
335k
    if (!value) goto failed;
6305
335k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
6306
0
        goto failed;
6307
335k
    Py_DECREF(value);
6308
335k
    Py_LeaveRecursiveCall();
6309
335k
    return result;
6310
0
failed:
6311
0
    Py_LeaveRecursiveCall();
6312
0
    Py_XDECREF(value);
6313
0
    Py_XDECREF(result);
6314
0
    return NULL;
6315
335k
}
6316
6317
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
6318
102k
{
6319
102k
    switch(o) {
6320
96.7k
        case Load:
6321
96.7k
            return Py_NewRef(state->Load_singleton);
6322
5.45k
        case Store:
6323
5.45k
            return Py_NewRef(state->Store_singleton);
6324
670
        case Del:
6325
670
            return Py_NewRef(state->Del_singleton);
6326
102k
    }
6327
102k
    Py_UNREACHABLE();
6328
102k
}
6329
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
6330
918
{
6331
918
    switch(o) {
6332
231
        case And:
6333
231
            return Py_NewRef(state->And_singleton);
6334
687
        case Or:
6335
687
            return Py_NewRef(state->Or_singleton);
6336
918
    }
6337
918
    Py_UNREACHABLE();
6338
918
}
6339
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
6340
24.9k
{
6341
24.9k
    switch(o) {
6342
4.50k
        case Add:
6343
4.50k
            return Py_NewRef(state->Add_singleton);
6344
7.66k
        case Sub:
6345
7.66k
            return Py_NewRef(state->Sub_singleton);
6346
4.48k
        case Mult:
6347
4.48k
            return Py_NewRef(state->Mult_singleton);
6348
995
        case MatMult:
6349
995
            return Py_NewRef(state->MatMult_singleton);
6350
860
        case Div:
6351
860
            return Py_NewRef(state->Div_singleton);
6352
1.27k
        case Mod:
6353
1.27k
            return Py_NewRef(state->Mod_singleton);
6354
666
        case Pow:
6355
666
            return Py_NewRef(state->Pow_singleton);
6356
427
        case LShift:
6357
427
            return Py_NewRef(state->LShift_singleton);
6358
326
        case RShift:
6359
326
            return Py_NewRef(state->RShift_singleton);
6360
959
        case BitOr:
6361
959
            return Py_NewRef(state->BitOr_singleton);
6362
1.83k
        case BitXor:
6363
1.83k
            return Py_NewRef(state->BitXor_singleton);
6364
762
        case BitAnd:
6365
762
            return Py_NewRef(state->BitAnd_singleton);
6366
208
        case FloorDiv:
6367
208
            return Py_NewRef(state->FloorDiv_singleton);
6368
24.9k
    }
6369
24.9k
    Py_UNREACHABLE();
6370
24.9k
}
6371
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
6372
98.1k
{
6373
98.1k
    switch(o) {
6374
35.2k
        case Invert:
6375
35.2k
            return Py_NewRef(state->Invert_singleton);
6376
87
        case Not:
6377
87
            return Py_NewRef(state->Not_singleton);
6378
21.4k
        case UAdd:
6379
21.4k
            return Py_NewRef(state->UAdd_singleton);
6380
41.3k
        case USub:
6381
41.3k
            return Py_NewRef(state->USub_singleton);
6382
98.1k
    }
6383
98.1k
    Py_UNREACHABLE();
6384
98.1k
}
6385
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
6386
13.2k
{
6387
13.2k
    switch(o) {
6388
434
        case Eq:
6389
434
            return Py_NewRef(state->Eq_singleton);
6390
217
        case NotEq:
6391
217
            return Py_NewRef(state->NotEq_singleton);
6392
5.32k
        case Lt:
6393
5.32k
            return Py_NewRef(state->Lt_singleton);
6394
238
        case LtE:
6395
238
            return Py_NewRef(state->LtE_singleton);
6396
5.94k
        case Gt:
6397
5.94k
            return Py_NewRef(state->Gt_singleton);
6398
241
        case GtE:
6399
241
            return Py_NewRef(state->GtE_singleton);
6400
279
        case Is:
6401
279
            return Py_NewRef(state->Is_singleton);
6402
76
        case IsNot:
6403
76
            return Py_NewRef(state->IsNot_singleton);
6404
257
        case In:
6405
257
            return Py_NewRef(state->In_singleton);
6406
194
        case NotIn:
6407
194
            return Py_NewRef(state->NotIn_singleton);
6408
13.2k
    }
6409
13.2k
    Py_UNREACHABLE();
6410
13.2k
}
6411
PyObject*
6412
ast2obj_comprehension(struct ast_state *state, void* _o)
6413
1.60k
{
6414
1.60k
    comprehension_ty o = (comprehension_ty)_o;
6415
1.60k
    PyObject *result = NULL, *value = NULL;
6416
1.60k
    PyTypeObject *tp;
6417
1.60k
    if (!o) {
6418
0
        Py_RETURN_NONE;
6419
0
    }
6420
1.60k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6421
0
        return NULL;
6422
0
    }
6423
1.60k
    tp = (PyTypeObject *)state->comprehension_type;
6424
1.60k
    result = PyType_GenericNew(tp, NULL, NULL);
6425
1.60k
    if (!result) return NULL;
6426
1.60k
    value = ast2obj_expr(state, o->target);
6427
1.60k
    if (!value) goto failed;
6428
1.60k
    if (PyObject_SetAttr(result, state->target, value) == -1)
6429
0
        goto failed;
6430
1.60k
    Py_DECREF(value);
6431
1.60k
    value = ast2obj_expr(state, o->iter);
6432
1.60k
    if (!value) goto failed;
6433
1.60k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
6434
0
        goto failed;
6435
1.60k
    Py_DECREF(value);
6436
1.60k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
6437
1.60k
    if (!value) goto failed;
6438
1.60k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
6439
0
        goto failed;
6440
1.60k
    Py_DECREF(value);
6441
1.60k
    value = ast2obj_int(state, o->is_async);
6442
1.60k
    if (!value) goto failed;
6443
1.60k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
6444
0
        goto failed;
6445
1.60k
    Py_DECREF(value);
6446
1.60k
    Py_LeaveRecursiveCall();
6447
1.60k
    return result;
6448
0
failed:
6449
0
    Py_LeaveRecursiveCall();
6450
0
    Py_XDECREF(value);
6451
0
    Py_XDECREF(result);
6452
0
    return NULL;
6453
1.60k
}
6454
6455
PyObject*
6456
ast2obj_excepthandler(struct ast_state *state, void* _o)
6457
1.30k
{
6458
1.30k
    excepthandler_ty o = (excepthandler_ty)_o;
6459
1.30k
    PyObject *result = NULL, *value = NULL;
6460
1.30k
    PyTypeObject *tp;
6461
1.30k
    if (!o) {
6462
0
        Py_RETURN_NONE;
6463
0
    }
6464
1.30k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6465
0
        return NULL;
6466
0
    }
6467
1.30k
    switch (o->kind) {
6468
1.30k
    case ExceptHandler_kind:
6469
1.30k
        tp = (PyTypeObject *)state->ExceptHandler_type;
6470
1.30k
        result = PyType_GenericNew(tp, NULL, NULL);
6471
1.30k
        if (!result) goto failed;
6472
1.30k
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
6473
1.30k
        if (!value) goto failed;
6474
1.30k
        if (PyObject_SetAttr(result, state->type, value) == -1)
6475
0
            goto failed;
6476
1.30k
        Py_DECREF(value);
6477
1.30k
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
6478
1.30k
        if (!value) goto failed;
6479
1.30k
        if (PyObject_SetAttr(result, state->name, value) == -1)
6480
0
            goto failed;
6481
1.30k
        Py_DECREF(value);
6482
1.30k
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
6483
1.30k
                             ast2obj_stmt);
6484
1.30k
        if (!value) goto failed;
6485
1.30k
        if (PyObject_SetAttr(result, state->body, value) == -1)
6486
0
            goto failed;
6487
1.30k
        Py_DECREF(value);
6488
1.30k
        break;
6489
1.30k
    }
6490
1.30k
    value = ast2obj_int(state, o->lineno);
6491
1.30k
    if (!value) goto failed;
6492
1.30k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
6493
0
        goto failed;
6494
1.30k
    Py_DECREF(value);
6495
1.30k
    value = ast2obj_int(state, o->col_offset);
6496
1.30k
    if (!value) goto failed;
6497
1.30k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
6498
0
        goto failed;
6499
1.30k
    Py_DECREF(value);
6500
1.30k
    value = ast2obj_int(state, o->end_lineno);
6501
1.30k
    if (!value) goto failed;
6502
1.30k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
6503
0
        goto failed;
6504
1.30k
    Py_DECREF(value);
6505
1.30k
    value = ast2obj_int(state, o->end_col_offset);
6506
1.30k
    if (!value) goto failed;
6507
1.30k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
6508
0
        goto failed;
6509
1.30k
    Py_DECREF(value);
6510
1.30k
    Py_LeaveRecursiveCall();
6511
1.30k
    return result;
6512
0
failed:
6513
0
    Py_LeaveRecursiveCall();
6514
0
    Py_XDECREF(value);
6515
0
    Py_XDECREF(result);
6516
0
    return NULL;
6517
1.30k
}
6518
6519
PyObject*
6520
ast2obj_arguments(struct ast_state *state, void* _o)
6521
4.53k
{
6522
4.53k
    arguments_ty o = (arguments_ty)_o;
6523
4.53k
    PyObject *result = NULL, *value = NULL;
6524
4.53k
    PyTypeObject *tp;
6525
4.53k
    if (!o) {
6526
0
        Py_RETURN_NONE;
6527
0
    }
6528
4.53k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6529
0
        return NULL;
6530
0
    }
6531
4.53k
    tp = (PyTypeObject *)state->arguments_type;
6532
4.53k
    result = PyType_GenericNew(tp, NULL, NULL);
6533
4.53k
    if (!result) return NULL;
6534
4.53k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
6535
4.53k
    if (!value) goto failed;
6536
4.53k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
6537
0
        goto failed;
6538
4.53k
    Py_DECREF(value);
6539
4.53k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
6540
4.53k
    if (!value) goto failed;
6541
4.53k
    if (PyObject_SetAttr(result, state->args, value) == -1)
6542
0
        goto failed;
6543
4.53k
    Py_DECREF(value);
6544
4.53k
    value = ast2obj_arg(state, o->vararg);
6545
4.53k
    if (!value) goto failed;
6546
4.53k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
6547
0
        goto failed;
6548
4.53k
    Py_DECREF(value);
6549
4.53k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
6550
4.53k
    if (!value) goto failed;
6551
4.53k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
6552
0
        goto failed;
6553
4.53k
    Py_DECREF(value);
6554
4.53k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
6555
4.53k
    if (!value) goto failed;
6556
4.53k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
6557
0
        goto failed;
6558
4.53k
    Py_DECREF(value);
6559
4.53k
    value = ast2obj_arg(state, o->kwarg);
6560
4.53k
    if (!value) goto failed;
6561
4.53k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
6562
0
        goto failed;
6563
4.53k
    Py_DECREF(value);
6564
4.53k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
6565
4.53k
    if (!value) goto failed;
6566
4.53k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
6567
0
        goto failed;
6568
4.53k
    Py_DECREF(value);
6569
4.53k
    Py_LeaveRecursiveCall();
6570
4.53k
    return result;
6571
0
failed:
6572
0
    Py_LeaveRecursiveCall();
6573
0
    Py_XDECREF(value);
6574
0
    Py_XDECREF(result);
6575
0
    return NULL;
6576
4.53k
}
6577
6578
PyObject*
6579
ast2obj_arg(struct ast_state *state, void* _o)
6580
18.4k
{
6581
18.4k
    arg_ty o = (arg_ty)_o;
6582
18.4k
    PyObject *result = NULL, *value = NULL;
6583
18.4k
    PyTypeObject *tp;
6584
18.4k
    if (!o) {
6585
7.34k
        Py_RETURN_NONE;
6586
7.34k
    }
6587
11.1k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6588
0
        return NULL;
6589
0
    }
6590
11.1k
    tp = (PyTypeObject *)state->arg_type;
6591
11.1k
    result = PyType_GenericNew(tp, NULL, NULL);
6592
11.1k
    if (!result) return NULL;
6593
11.1k
    value = ast2obj_identifier(state, o->arg);
6594
11.1k
    if (!value) goto failed;
6595
11.1k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
6596
0
        goto failed;
6597
11.1k
    Py_DECREF(value);
6598
11.1k
    value = ast2obj_expr(state, o->annotation);
6599
11.1k
    if (!value) goto failed;
6600
11.1k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
6601
0
        goto failed;
6602
11.1k
    Py_DECREF(value);
6603
11.1k
    value = ast2obj_string(state, o->type_comment);
6604
11.1k
    if (!value) goto failed;
6605
11.1k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
6606
0
        goto failed;
6607
11.1k
    Py_DECREF(value);
6608
11.1k
    value = ast2obj_int(state, o->lineno);
6609
11.1k
    if (!value) goto failed;
6610
11.1k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
6611
0
        goto failed;
6612
11.1k
    Py_DECREF(value);
6613
11.1k
    value = ast2obj_int(state, o->col_offset);
6614
11.1k
    if (!value) goto failed;
6615
11.1k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
6616
0
        goto failed;
6617
11.1k
    Py_DECREF(value);
6618
11.1k
    value = ast2obj_int(state, o->end_lineno);
6619
11.1k
    if (!value) goto failed;
6620
11.1k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
6621
0
        goto failed;
6622
11.1k
    Py_DECREF(value);
6623
11.1k
    value = ast2obj_int(state, o->end_col_offset);
6624
11.1k
    if (!value) goto failed;
6625
11.1k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
6626
0
        goto failed;
6627
11.1k
    Py_DECREF(value);
6628
11.1k
    Py_LeaveRecursiveCall();
6629
11.1k
    return result;
6630
0
failed:
6631
0
    Py_LeaveRecursiveCall();
6632
0
    Py_XDECREF(value);
6633
0
    Py_XDECREF(result);
6634
0
    return NULL;
6635
11.1k
}
6636
6637
PyObject*
6638
ast2obj_keyword(struct ast_state *state, void* _o)
6639
1.79k
{
6640
1.79k
    keyword_ty o = (keyword_ty)_o;
6641
1.79k
    PyObject *result = NULL, *value = NULL;
6642
1.79k
    PyTypeObject *tp;
6643
1.79k
    if (!o) {
6644
0
        Py_RETURN_NONE;
6645
0
    }
6646
1.79k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6647
0
        return NULL;
6648
0
    }
6649
1.79k
    tp = (PyTypeObject *)state->keyword_type;
6650
1.79k
    result = PyType_GenericNew(tp, NULL, NULL);
6651
1.79k
    if (!result) return NULL;
6652
1.79k
    value = ast2obj_identifier(state, o->arg);
6653
1.79k
    if (!value) goto failed;
6654
1.79k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
6655
0
        goto failed;
6656
1.79k
    Py_DECREF(value);
6657
1.79k
    value = ast2obj_expr(state, o->value);
6658
1.79k
    if (!value) goto failed;
6659
1.79k
    if (PyObject_SetAttr(result, state->value, value) == -1)
6660
0
        goto failed;
6661
1.79k
    Py_DECREF(value);
6662
1.79k
    value = ast2obj_int(state, o->lineno);
6663
1.79k
    if (!value) goto failed;
6664
1.79k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
6665
0
        goto failed;
6666
1.79k
    Py_DECREF(value);
6667
1.79k
    value = ast2obj_int(state, o->col_offset);
6668
1.79k
    if (!value) goto failed;
6669
1.79k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
6670
0
        goto failed;
6671
1.79k
    Py_DECREF(value);
6672
1.79k
    value = ast2obj_int(state, o->end_lineno);
6673
1.79k
    if (!value) goto failed;
6674
1.79k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
6675
0
        goto failed;
6676
1.79k
    Py_DECREF(value);
6677
1.79k
    value = ast2obj_int(state, o->end_col_offset);
6678
1.79k
    if (!value) goto failed;
6679
1.79k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
6680
0
        goto failed;
6681
1.79k
    Py_DECREF(value);
6682
1.79k
    Py_LeaveRecursiveCall();
6683
1.79k
    return result;
6684
0
failed:
6685
0
    Py_LeaveRecursiveCall();
6686
0
    Py_XDECREF(value);
6687
0
    Py_XDECREF(result);
6688
0
    return NULL;
6689
1.79k
}
6690
6691
PyObject*
6692
ast2obj_alias(struct ast_state *state, void* _o)
6693
3.30k
{
6694
3.30k
    alias_ty o = (alias_ty)_o;
6695
3.30k
    PyObject *result = NULL, *value = NULL;
6696
3.30k
    PyTypeObject *tp;
6697
3.30k
    if (!o) {
6698
0
        Py_RETURN_NONE;
6699
0
    }
6700
3.30k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6701
0
        return NULL;
6702
0
    }
6703
3.30k
    tp = (PyTypeObject *)state->alias_type;
6704
3.30k
    result = PyType_GenericNew(tp, NULL, NULL);
6705
3.30k
    if (!result) return NULL;
6706
3.30k
    value = ast2obj_identifier(state, o->name);
6707
3.30k
    if (!value) goto failed;
6708
3.30k
    if (PyObject_SetAttr(result, state->name, value) == -1)
6709
0
        goto failed;
6710
3.30k
    Py_DECREF(value);
6711
3.30k
    value = ast2obj_identifier(state, o->asname);
6712
3.30k
    if (!value) goto failed;
6713
3.30k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
6714
0
        goto failed;
6715
3.30k
    Py_DECREF(value);
6716
3.30k
    value = ast2obj_int(state, o->lineno);
6717
3.30k
    if (!value) goto failed;
6718
3.30k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
6719
0
        goto failed;
6720
3.30k
    Py_DECREF(value);
6721
3.30k
    value = ast2obj_int(state, o->col_offset);
6722
3.30k
    if (!value) goto failed;
6723
3.30k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
6724
0
        goto failed;
6725
3.30k
    Py_DECREF(value);
6726
3.30k
    value = ast2obj_int(state, o->end_lineno);
6727
3.30k
    if (!value) goto failed;
6728
3.30k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
6729
0
        goto failed;
6730
3.30k
    Py_DECREF(value);
6731
3.30k
    value = ast2obj_int(state, o->end_col_offset);
6732
3.30k
    if (!value) goto failed;
6733
3.30k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
6734
0
        goto failed;
6735
3.30k
    Py_DECREF(value);
6736
3.30k
    Py_LeaveRecursiveCall();
6737
3.30k
    return result;
6738
0
failed:
6739
0
    Py_LeaveRecursiveCall();
6740
0
    Py_XDECREF(value);
6741
0
    Py_XDECREF(result);
6742
0
    return NULL;
6743
3.30k
}
6744
6745
PyObject*
6746
ast2obj_withitem(struct ast_state *state, void* _o)
6747
1.96k
{
6748
1.96k
    withitem_ty o = (withitem_ty)_o;
6749
1.96k
    PyObject *result = NULL, *value = NULL;
6750
1.96k
    PyTypeObject *tp;
6751
1.96k
    if (!o) {
6752
0
        Py_RETURN_NONE;
6753
0
    }
6754
1.96k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6755
0
        return NULL;
6756
0
    }
6757
1.96k
    tp = (PyTypeObject *)state->withitem_type;
6758
1.96k
    result = PyType_GenericNew(tp, NULL, NULL);
6759
1.96k
    if (!result) return NULL;
6760
1.96k
    value = ast2obj_expr(state, o->context_expr);
6761
1.96k
    if (!value) goto failed;
6762
1.96k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
6763
0
        goto failed;
6764
1.96k
    Py_DECREF(value);
6765
1.96k
    value = ast2obj_expr(state, o->optional_vars);
6766
1.96k
    if (!value) goto failed;
6767
1.96k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
6768
0
        goto failed;
6769
1.96k
    Py_DECREF(value);
6770
1.96k
    Py_LeaveRecursiveCall();
6771
1.96k
    return result;
6772
0
failed:
6773
0
    Py_LeaveRecursiveCall();
6774
0
    Py_XDECREF(value);
6775
0
    Py_XDECREF(result);
6776
0
    return NULL;
6777
1.96k
}
6778
6779
PyObject*
6780
ast2obj_match_case(struct ast_state *state, void* _o)
6781
838
{
6782
838
    match_case_ty o = (match_case_ty)_o;
6783
838
    PyObject *result = NULL, *value = NULL;
6784
838
    PyTypeObject *tp;
6785
838
    if (!o) {
6786
0
        Py_RETURN_NONE;
6787
0
    }
6788
838
    if (Py_EnterRecursiveCall("during  ast construction")) {
6789
0
        return NULL;
6790
0
    }
6791
838
    tp = (PyTypeObject *)state->match_case_type;
6792
838
    result = PyType_GenericNew(tp, NULL, NULL);
6793
838
    if (!result) return NULL;
6794
838
    value = ast2obj_pattern(state, o->pattern);
6795
838
    if (!value) goto failed;
6796
838
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
6797
0
        goto failed;
6798
838
    Py_DECREF(value);
6799
838
    value = ast2obj_expr(state, o->guard);
6800
838
    if (!value) goto failed;
6801
838
    if (PyObject_SetAttr(result, state->guard, value) == -1)
6802
0
        goto failed;
6803
838
    Py_DECREF(value);
6804
838
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
6805
838
    if (!value) goto failed;
6806
838
    if (PyObject_SetAttr(result, state->body, value) == -1)
6807
0
        goto failed;
6808
838
    Py_DECREF(value);
6809
838
    Py_LeaveRecursiveCall();
6810
838
    return result;
6811
0
failed:
6812
0
    Py_LeaveRecursiveCall();
6813
0
    Py_XDECREF(value);
6814
0
    Py_XDECREF(result);
6815
0
    return NULL;
6816
838
}
6817
6818
PyObject*
6819
ast2obj_pattern(struct ast_state *state, void* _o)
6820
26.5k
{
6821
26.5k
    pattern_ty o = (pattern_ty)_o;
6822
26.5k
    PyObject *result = NULL, *value = NULL;
6823
26.5k
    PyTypeObject *tp;
6824
26.5k
    if (!o) {
6825
9.72k
        Py_RETURN_NONE;
6826
9.72k
    }
6827
16.8k
    if (Py_EnterRecursiveCall("during  ast construction")) {
6828
0
        return NULL;
6829
0
    }
6830
16.8k
    switch (o->kind) {
6831
803
    case MatchValue_kind:
6832
803
        tp = (PyTypeObject *)state->MatchValue_type;
6833
803
        result = PyType_GenericNew(tp, NULL, NULL);
6834
803
        if (!result) goto failed;
6835
803
        value = ast2obj_expr(state, o->v.MatchValue.value);
6836
803
        if (!value) goto failed;
6837
803
        if (PyObject_SetAttr(result, state->value, value) == -1)
6838
0
            goto failed;
6839
803
        Py_DECREF(value);
6840
803
        break;
6841
410
    case MatchSingleton_kind:
6842
410
        tp = (PyTypeObject *)state->MatchSingleton_type;
6843
410
        result = PyType_GenericNew(tp, NULL, NULL);
6844
410
        if (!result) goto failed;
6845
410
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
6846
410
        if (!value) goto failed;
6847
410
        if (PyObject_SetAttr(result, state->value, value) == -1)
6848
0
            goto failed;
6849
410
        Py_DECREF(value);
6850
410
        break;
6851
516
    case MatchSequence_kind:
6852
516
        tp = (PyTypeObject *)state->MatchSequence_type;
6853
516
        result = PyType_GenericNew(tp, NULL, NULL);
6854
516
        if (!result) goto failed;
6855
516
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
6856
516
                             ast2obj_pattern);
6857
516
        if (!value) goto failed;
6858
516
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
6859
0
            goto failed;
6860
516
        Py_DECREF(value);
6861
516
        break;
6862
364
    case MatchMapping_kind:
6863
364
        tp = (PyTypeObject *)state->MatchMapping_type;
6864
364
        result = PyType_GenericNew(tp, NULL, NULL);
6865
364
        if (!result) goto failed;
6866
364
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
6867
364
                             ast2obj_expr);
6868
364
        if (!value) goto failed;
6869
364
        if (PyObject_SetAttr(result, state->keys, value) == -1)
6870
0
            goto failed;
6871
364
        Py_DECREF(value);
6872
364
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
6873
364
                             ast2obj_pattern);
6874
364
        if (!value) goto failed;
6875
364
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
6876
0
            goto failed;
6877
364
        Py_DECREF(value);
6878
364
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
6879
364
        if (!value) goto failed;
6880
364
        if (PyObject_SetAttr(result, state->rest, value) == -1)
6881
0
            goto failed;
6882
364
        Py_DECREF(value);
6883
364
        break;
6884
1.13k
    case MatchClass_kind:
6885
1.13k
        tp = (PyTypeObject *)state->MatchClass_type;
6886
1.13k
        result = PyType_GenericNew(tp, NULL, NULL);
6887
1.13k
        if (!result) goto failed;
6888
1.13k
        value = ast2obj_expr(state, o->v.MatchClass.cls);
6889
1.13k
        if (!value) goto failed;
6890
1.13k
        if (PyObject_SetAttr(result, state->cls, value) == -1)
6891
0
            goto failed;
6892
1.13k
        Py_DECREF(value);
6893
1.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
6894
1.13k
                             ast2obj_pattern);
6895
1.13k
        if (!value) goto failed;
6896
1.13k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
6897
0
            goto failed;
6898
1.13k
        Py_DECREF(value);
6899
1.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
6900
1.13k
                             ast2obj_identifier);
6901
1.13k
        if (!value) goto failed;
6902
1.13k
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
6903
0
            goto failed;
6904
1.13k
        Py_DECREF(value);
6905
1.13k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
6906
1.13k
                             ast2obj_pattern);
6907
1.13k
        if (!value) goto failed;
6908
1.13k
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
6909
0
            goto failed;
6910
1.13k
        Py_DECREF(value);
6911
1.13k
        break;
6912
510
    case MatchStar_kind:
6913
510
        tp = (PyTypeObject *)state->MatchStar_type;
6914
510
        result = PyType_GenericNew(tp, NULL, NULL);
6915
510
        if (!result) goto failed;
6916
510
        value = ast2obj_identifier(state, o->v.MatchStar.name);
6917
510
        if (!value) goto failed;
6918
510
        if (PyObject_SetAttr(result, state->name, value) == -1)
6919
0
            goto failed;
6920
510
        Py_DECREF(value);
6921
510
        break;
6922
9.78k
    case MatchAs_kind:
6923
9.78k
        tp = (PyTypeObject *)state->MatchAs_type;
6924
9.78k
        result = PyType_GenericNew(tp, NULL, NULL);
6925
9.78k
        if (!result) goto failed;
6926
9.78k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
6927
9.78k
        if (!value) goto failed;
6928
9.78k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
6929
0
            goto failed;
6930
9.78k
        Py_DECREF(value);
6931
9.78k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
6932
9.78k
        if (!value) goto failed;
6933
9.78k
        if (PyObject_SetAttr(result, state->name, value) == -1)
6934
0
            goto failed;
6935
9.78k
        Py_DECREF(value);
6936
9.78k
        break;
6937
3.30k
    case MatchOr_kind:
6938
3.30k
        tp = (PyTypeObject *)state->MatchOr_type;
6939
3.30k
        result = PyType_GenericNew(tp, NULL, NULL);
6940
3.30k
        if (!result) goto failed;
6941
3.30k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
6942
3.30k
                             ast2obj_pattern);
6943
3.30k
        if (!value) goto failed;
6944
3.30k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
6945
0
            goto failed;
6946
3.30k
        Py_DECREF(value);
6947
3.30k
        break;
6948
16.8k
    }
6949
16.8k
    value = ast2obj_int(state, o->lineno);
6950
16.8k
    if (!value) goto failed;
6951
16.8k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
6952
0
        goto failed;
6953
16.8k
    Py_DECREF(value);
6954
16.8k
    value = ast2obj_int(state, o->col_offset);
6955
16.8k
    if (!value) goto failed;
6956
16.8k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
6957
0
        goto failed;
6958
16.8k
    Py_DECREF(value);
6959
16.8k
    value = ast2obj_int(state, o->end_lineno);
6960
16.8k
    if (!value) goto failed;
6961
16.8k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
6962
0
        goto failed;
6963
16.8k
    Py_DECREF(value);
6964
16.8k
    value = ast2obj_int(state, o->end_col_offset);
6965
16.8k
    if (!value) goto failed;
6966
16.8k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
6967
0
        goto failed;
6968
16.8k
    Py_DECREF(value);
6969
16.8k
    Py_LeaveRecursiveCall();
6970
16.8k
    return result;
6971
0
failed:
6972
0
    Py_LeaveRecursiveCall();
6973
0
    Py_XDECREF(value);
6974
0
    Py_XDECREF(result);
6975
0
    return NULL;
6976
16.8k
}
6977
6978
PyObject*
6979
ast2obj_type_ignore(struct ast_state *state, void* _o)
6980
0
{
6981
0
    type_ignore_ty o = (type_ignore_ty)_o;
6982
0
    PyObject *result = NULL, *value = NULL;
6983
0
    PyTypeObject *tp;
6984
0
    if (!o) {
6985
0
        Py_RETURN_NONE;
6986
0
    }
6987
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
6988
0
        return NULL;
6989
0
    }
6990
0
    switch (o->kind) {
6991
0
    case TypeIgnore_kind:
6992
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
6993
0
        result = PyType_GenericNew(tp, NULL, NULL);
6994
0
        if (!result) goto failed;
6995
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
6996
0
        if (!value) goto failed;
6997
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
6998
0
            goto failed;
6999
0
        Py_DECREF(value);
7000
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
7001
0
        if (!value) goto failed;
7002
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
7003
0
            goto failed;
7004
0
        Py_DECREF(value);
7005
0
        break;
7006
0
    }
7007
0
    Py_LeaveRecursiveCall();
7008
0
    return result;
7009
0
failed:
7010
0
    Py_LeaveRecursiveCall();
7011
0
    Py_XDECREF(value);
7012
0
    Py_XDECREF(result);
7013
0
    return NULL;
7014
0
}
7015
7016
PyObject*
7017
ast2obj_type_param(struct ast_state *state, void* _o)
7018
7.22k
{
7019
7.22k
    type_param_ty o = (type_param_ty)_o;
7020
7.22k
    PyObject *result = NULL, *value = NULL;
7021
7.22k
    PyTypeObject *tp;
7022
7.22k
    if (!o) {
7023
0
        Py_RETURN_NONE;
7024
0
    }
7025
7.22k
    if (Py_EnterRecursiveCall("during  ast construction")) {
7026
0
        return NULL;
7027
0
    }
7028
7.22k
    switch (o->kind) {
7029
5.41k
    case TypeVar_kind:
7030
5.41k
        tp = (PyTypeObject *)state->TypeVar_type;
7031
5.41k
        result = PyType_GenericNew(tp, NULL, NULL);
7032
5.41k
        if (!result) goto failed;
7033
5.41k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
7034
5.41k
        if (!value) goto failed;
7035
5.41k
        if (PyObject_SetAttr(result, state->name, value) == -1)
7036
0
            goto failed;
7037
5.41k
        Py_DECREF(value);
7038
5.41k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
7039
5.41k
        if (!value) goto failed;
7040
5.41k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
7041
0
            goto failed;
7042
5.41k
        Py_DECREF(value);
7043
5.41k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
7044
5.41k
        if (!value) goto failed;
7045
5.41k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
7046
0
            goto failed;
7047
5.41k
        Py_DECREF(value);
7048
5.41k
        break;
7049
1.02k
    case ParamSpec_kind:
7050
1.02k
        tp = (PyTypeObject *)state->ParamSpec_type;
7051
1.02k
        result = PyType_GenericNew(tp, NULL, NULL);
7052
1.02k
        if (!result) goto failed;
7053
1.02k
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
7054
1.02k
        if (!value) goto failed;
7055
1.02k
        if (PyObject_SetAttr(result, state->name, value) == -1)
7056
0
            goto failed;
7057
1.02k
        Py_DECREF(value);
7058
1.02k
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
7059
1.02k
        if (!value) goto failed;
7060
1.02k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
7061
0
            goto failed;
7062
1.02k
        Py_DECREF(value);
7063
1.02k
        break;
7064
782
    case TypeVarTuple_kind:
7065
782
        tp = (PyTypeObject *)state->TypeVarTuple_type;
7066
782
        result = PyType_GenericNew(tp, NULL, NULL);
7067
782
        if (!result) goto failed;
7068
782
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
7069
782
        if (!value) goto failed;
7070
782
        if (PyObject_SetAttr(result, state->name, value) == -1)
7071
0
            goto failed;
7072
782
        Py_DECREF(value);
7073
782
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
7074
782
        if (!value) goto failed;
7075
782
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
7076
0
            goto failed;
7077
782
        Py_DECREF(value);
7078
782
        break;
7079
7.22k
    }
7080
7.22k
    value = ast2obj_int(state, o->lineno);
7081
7.22k
    if (!value) goto failed;
7082
7.22k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
7083
0
        goto failed;
7084
7.22k
    Py_DECREF(value);
7085
7.22k
    value = ast2obj_int(state, o->col_offset);
7086
7.22k
    if (!value) goto failed;
7087
7.22k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
7088
0
        goto failed;
7089
7.22k
    Py_DECREF(value);
7090
7.22k
    value = ast2obj_int(state, o->end_lineno);
7091
7.22k
    if (!value) goto failed;
7092
7.22k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
7093
0
        goto failed;
7094
7.22k
    Py_DECREF(value);
7095
7.22k
    value = ast2obj_int(state, o->end_col_offset);
7096
7.22k
    if (!value) goto failed;
7097
7.22k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
7098
0
        goto failed;
7099
7.22k
    Py_DECREF(value);
7100
7.22k
    Py_LeaveRecursiveCall();
7101
7.22k
    return result;
7102
0
failed:
7103
0
    Py_LeaveRecursiveCall();
7104
0
    Py_XDECREF(value);
7105
0
    Py_XDECREF(result);
7106
0
    return NULL;
7107
7.22k
}
7108
7109
7110
int
7111
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, const char*
7112
            field, PyArena* arena)
7113
0
{
7114
0
    int isinstance;
7115
7116
0
    PyObject *tmp = NULL;
7117
0
    PyObject *tp;
7118
7119
0
    if (obj == Py_None) {
7120
0
        *out = NULL;
7121
0
        return 0;
7122
0
    }
7123
0
    tp = state->mod_type;
7124
0
    isinstance = PyObject_IsInstance(obj, tp);
7125
0
    if (isinstance == -1) {
7126
0
        return 1;
7127
0
    }
7128
0
    if (!isinstance && field != NULL) {
7129
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'mod', got '%T'", field, obj);
7130
0
        return 1;
7131
0
    }
7132
0
    tp = state->Module_type;
7133
0
    isinstance = PyObject_IsInstance(obj, tp);
7134
0
    if (isinstance == -1) {
7135
0
        return -1;
7136
0
    }
7137
0
    if (isinstance) {
7138
0
        asdl_stmt_seq* body;
7139
0
        asdl_type_ignore_seq* type_ignores;
7140
7141
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
7142
0
            return -1;
7143
0
        }
7144
0
        if (tmp == NULL) {
7145
0
            tmp = PyList_New(0);
7146
0
            if (tmp == NULL) {
7147
0
                return -1;
7148
0
            }
7149
0
        }
7150
0
        {
7151
0
            int res;
7152
0
            Py_ssize_t len;
7153
0
            Py_ssize_t i;
7154
0
            if (!PyList_Check(tmp)) {
7155
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %T", tmp);
7156
0
                goto failed;
7157
0
            }
7158
0
            len = PyList_GET_SIZE(tmp);
7159
0
            body = _Py_asdl_stmt_seq_new(len, arena);
7160
0
            if (body == NULL) goto failed;
7161
0
            for (i = 0; i < len; i++) {
7162
0
                stmt_ty val;
7163
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7164
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
7165
0
                    goto failed;
7166
0
                }
7167
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
7168
0
                _Py_LeaveRecursiveCall();
7169
0
                Py_DECREF(tmp2);
7170
0
                if (res != 0) goto failed;
7171
0
                if (len != PyList_GET_SIZE(tmp)) {
7172
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
7173
0
                    goto failed;
7174
0
                }
7175
0
                asdl_seq_SET(body, i, val);
7176
0
            }
7177
0
            Py_CLEAR(tmp);
7178
0
        }
7179
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
7180
0
            return -1;
7181
0
        }
7182
0
        if (tmp == NULL) {
7183
0
            tmp = PyList_New(0);
7184
0
            if (tmp == NULL) {
7185
0
                return -1;
7186
0
            }
7187
0
        }
7188
0
        {
7189
0
            int res;
7190
0
            Py_ssize_t len;
7191
0
            Py_ssize_t i;
7192
0
            if (!PyList_Check(tmp)) {
7193
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %T", tmp);
7194
0
                goto failed;
7195
0
            }
7196
0
            len = PyList_GET_SIZE(tmp);
7197
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
7198
0
            if (type_ignores == NULL) goto failed;
7199
0
            for (i = 0; i < len; i++) {
7200
0
                type_ignore_ty val;
7201
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7202
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
7203
0
                    goto failed;
7204
0
                }
7205
0
                res = obj2ast_type_ignore(state, tmp2, &val, "type_ignores", arena);
7206
0
                _Py_LeaveRecursiveCall();
7207
0
                Py_DECREF(tmp2);
7208
0
                if (res != 0) goto failed;
7209
0
                if (len != PyList_GET_SIZE(tmp)) {
7210
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
7211
0
                    goto failed;
7212
0
                }
7213
0
                asdl_seq_SET(type_ignores, i, val);
7214
0
            }
7215
0
            Py_CLEAR(tmp);
7216
0
        }
7217
0
        *out = _PyAST_Module(body, type_ignores, arena);
7218
0
        if (*out == NULL) goto failed;
7219
0
        return 0;
7220
0
    }
7221
0
    tp = state->Interactive_type;
7222
0
    isinstance = PyObject_IsInstance(obj, tp);
7223
0
    if (isinstance == -1) {
7224
0
        return -1;
7225
0
    }
7226
0
    if (isinstance) {
7227
0
        asdl_stmt_seq* body;
7228
7229
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
7230
0
            return -1;
7231
0
        }
7232
0
        if (tmp == NULL) {
7233
0
            tmp = PyList_New(0);
7234
0
            if (tmp == NULL) {
7235
0
                return -1;
7236
0
            }
7237
0
        }
7238
0
        {
7239
0
            int res;
7240
0
            Py_ssize_t len;
7241
0
            Py_ssize_t i;
7242
0
            if (!PyList_Check(tmp)) {
7243
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %T", tmp);
7244
0
                goto failed;
7245
0
            }
7246
0
            len = PyList_GET_SIZE(tmp);
7247
0
            body = _Py_asdl_stmt_seq_new(len, arena);
7248
0
            if (body == NULL) goto failed;
7249
0
            for (i = 0; i < len; i++) {
7250
0
                stmt_ty val;
7251
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7252
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
7253
0
                    goto failed;
7254
0
                }
7255
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
7256
0
                _Py_LeaveRecursiveCall();
7257
0
                Py_DECREF(tmp2);
7258
0
                if (res != 0) goto failed;
7259
0
                if (len != PyList_GET_SIZE(tmp)) {
7260
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
7261
0
                    goto failed;
7262
0
                }
7263
0
                asdl_seq_SET(body, i, val);
7264
0
            }
7265
0
            Py_CLEAR(tmp);
7266
0
        }
7267
0
        *out = _PyAST_Interactive(body, arena);
7268
0
        if (*out == NULL) goto failed;
7269
0
        return 0;
7270
0
    }
7271
0
    tp = state->Expression_type;
7272
0
    isinstance = PyObject_IsInstance(obj, tp);
7273
0
    if (isinstance == -1) {
7274
0
        return -1;
7275
0
    }
7276
0
    if (isinstance) {
7277
0
        expr_ty body;
7278
7279
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
7280
0
            return -1;
7281
0
        }
7282
0
        if (tmp == NULL) {
7283
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
7284
0
            return -1;
7285
0
        }
7286
0
        else {
7287
0
            int res;
7288
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
7289
0
                goto failed;
7290
0
            }
7291
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
7292
0
            _Py_LeaveRecursiveCall();
7293
0
            if (res != 0) goto failed;
7294
0
            Py_CLEAR(tmp);
7295
0
        }
7296
0
        *out = _PyAST_Expression(body, arena);
7297
0
        if (*out == NULL) goto failed;
7298
0
        return 0;
7299
0
    }
7300
0
    tp = state->FunctionType_type;
7301
0
    isinstance = PyObject_IsInstance(obj, tp);
7302
0
    if (isinstance == -1) {
7303
0
        return -1;
7304
0
    }
7305
0
    if (isinstance) {
7306
0
        asdl_expr_seq* argtypes;
7307
0
        expr_ty returns;
7308
7309
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
7310
0
            return -1;
7311
0
        }
7312
0
        if (tmp == NULL) {
7313
0
            tmp = PyList_New(0);
7314
0
            if (tmp == NULL) {
7315
0
                return -1;
7316
0
            }
7317
0
        }
7318
0
        {
7319
0
            int res;
7320
0
            Py_ssize_t len;
7321
0
            Py_ssize_t i;
7322
0
            if (!PyList_Check(tmp)) {
7323
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %T", tmp);
7324
0
                goto failed;
7325
0
            }
7326
0
            len = PyList_GET_SIZE(tmp);
7327
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
7328
0
            if (argtypes == NULL) goto failed;
7329
0
            for (i = 0; i < len; i++) {
7330
0
                expr_ty val;
7331
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7332
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
7333
0
                    goto failed;
7334
0
                }
7335
0
                res = obj2ast_expr(state, tmp2, &val, "argtypes", arena);
7336
0
                _Py_LeaveRecursiveCall();
7337
0
                Py_DECREF(tmp2);
7338
0
                if (res != 0) goto failed;
7339
0
                if (len != PyList_GET_SIZE(tmp)) {
7340
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
7341
0
                    goto failed;
7342
0
                }
7343
0
                asdl_seq_SET(argtypes, i, val);
7344
0
            }
7345
0
            Py_CLEAR(tmp);
7346
0
        }
7347
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
7348
0
            return -1;
7349
0
        }
7350
0
        if (tmp == NULL) {
7351
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
7352
0
            return -1;
7353
0
        }
7354
0
        else {
7355
0
            int res;
7356
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
7357
0
                goto failed;
7358
0
            }
7359
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
7360
0
            _Py_LeaveRecursiveCall();
7361
0
            if (res != 0) goto failed;
7362
0
            Py_CLEAR(tmp);
7363
0
        }
7364
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
7365
0
        if (*out == NULL) goto failed;
7366
0
        return 0;
7367
0
    }
7368
7369
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
7370
0
    failed:
7371
0
    Py_XDECREF(tmp);
7372
0
    return -1;
7373
0
}
7374
7375
int
7376
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, const char*
7377
             field, PyArena* arena)
7378
0
{
7379
0
    int isinstance;
7380
7381
0
    PyObject *tmp = NULL;
7382
0
    PyObject *tp;
7383
0
    int lineno;
7384
0
    int col_offset;
7385
0
    int end_lineno;
7386
0
    int end_col_offset;
7387
7388
0
    if (obj == Py_None) {
7389
0
        *out = NULL;
7390
0
        return 0;
7391
0
    }
7392
0
    tp = state->stmt_type;
7393
0
    isinstance = PyObject_IsInstance(obj, tp);
7394
0
    if (isinstance == -1) {
7395
0
        return 1;
7396
0
    }
7397
0
    if (!isinstance && field != NULL) {
7398
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'stmt', got '%T'", field, obj);
7399
0
        return 1;
7400
0
    }
7401
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
7402
0
        return -1;
7403
0
    }
7404
0
    if (tmp == NULL) {
7405
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
7406
0
        return -1;
7407
0
    }
7408
0
    else {
7409
0
        int res;
7410
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
7411
0
            goto failed;
7412
0
        }
7413
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
7414
0
        _Py_LeaveRecursiveCall();
7415
0
        if (res != 0) goto failed;
7416
0
        Py_CLEAR(tmp);
7417
0
    }
7418
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
7419
0
        return -1;
7420
0
    }
7421
0
    if (tmp == NULL) {
7422
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
7423
0
        return -1;
7424
0
    }
7425
0
    else {
7426
0
        int res;
7427
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
7428
0
            goto failed;
7429
0
        }
7430
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
7431
0
        _Py_LeaveRecursiveCall();
7432
0
        if (res != 0) goto failed;
7433
0
        Py_CLEAR(tmp);
7434
0
    }
7435
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
7436
0
        return -1;
7437
0
    }
7438
0
    if (tmp == NULL || tmp == Py_None) {
7439
0
        Py_CLEAR(tmp);
7440
0
        end_lineno = lineno;
7441
0
    }
7442
0
    else {
7443
0
        int res;
7444
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
7445
0
            goto failed;
7446
0
        }
7447
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
7448
0
        _Py_LeaveRecursiveCall();
7449
0
        if (res != 0) goto failed;
7450
0
        Py_CLEAR(tmp);
7451
0
    }
7452
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
7453
0
        return -1;
7454
0
    }
7455
0
    if (tmp == NULL || tmp == Py_None) {
7456
0
        Py_CLEAR(tmp);
7457
0
        end_col_offset = col_offset;
7458
0
    }
7459
0
    else {
7460
0
        int res;
7461
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
7462
0
            goto failed;
7463
0
        }
7464
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
7465
0
        _Py_LeaveRecursiveCall();
7466
0
        if (res != 0) goto failed;
7467
0
        Py_CLEAR(tmp);
7468
0
    }
7469
0
    tp = state->FunctionDef_type;
7470
0
    isinstance = PyObject_IsInstance(obj, tp);
7471
0
    if (isinstance == -1) {
7472
0
        return -1;
7473
0
    }
7474
0
    if (isinstance) {
7475
0
        identifier name;
7476
0
        arguments_ty args;
7477
0
        asdl_stmt_seq* body;
7478
0
        asdl_expr_seq* decorator_list;
7479
0
        expr_ty returns;
7480
0
        string type_comment;
7481
0
        asdl_type_param_seq* type_params;
7482
7483
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
7484
0
            return -1;
7485
0
        }
7486
0
        if (tmp == NULL) {
7487
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
7488
0
            return -1;
7489
0
        }
7490
0
        else {
7491
0
            int res;
7492
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7493
0
                goto failed;
7494
0
            }
7495
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
7496
0
            _Py_LeaveRecursiveCall();
7497
0
            if (res != 0) goto failed;
7498
0
            Py_CLEAR(tmp);
7499
0
        }
7500
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
7501
0
            return -1;
7502
0
        }
7503
0
        if (tmp == NULL) {
7504
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
7505
0
            return -1;
7506
0
        }
7507
0
        else {
7508
0
            int res;
7509
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7510
0
                goto failed;
7511
0
            }
7512
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
7513
0
            _Py_LeaveRecursiveCall();
7514
0
            if (res != 0) goto failed;
7515
0
            Py_CLEAR(tmp);
7516
0
        }
7517
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
7518
0
            return -1;
7519
0
        }
7520
0
        if (tmp == NULL) {
7521
0
            tmp = PyList_New(0);
7522
0
            if (tmp == NULL) {
7523
0
                return -1;
7524
0
            }
7525
0
        }
7526
0
        {
7527
0
            int res;
7528
0
            Py_ssize_t len;
7529
0
            Py_ssize_t i;
7530
0
            if (!PyList_Check(tmp)) {
7531
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %T", tmp);
7532
0
                goto failed;
7533
0
            }
7534
0
            len = PyList_GET_SIZE(tmp);
7535
0
            body = _Py_asdl_stmt_seq_new(len, arena);
7536
0
            if (body == NULL) goto failed;
7537
0
            for (i = 0; i < len; i++) {
7538
0
                stmt_ty val;
7539
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7540
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7541
0
                    goto failed;
7542
0
                }
7543
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
7544
0
                _Py_LeaveRecursiveCall();
7545
0
                Py_DECREF(tmp2);
7546
0
                if (res != 0) goto failed;
7547
0
                if (len != PyList_GET_SIZE(tmp)) {
7548
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
7549
0
                    goto failed;
7550
0
                }
7551
0
                asdl_seq_SET(body, i, val);
7552
0
            }
7553
0
            Py_CLEAR(tmp);
7554
0
        }
7555
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
7556
0
            return -1;
7557
0
        }
7558
0
        if (tmp == NULL) {
7559
0
            tmp = PyList_New(0);
7560
0
            if (tmp == NULL) {
7561
0
                return -1;
7562
0
            }
7563
0
        }
7564
0
        {
7565
0
            int res;
7566
0
            Py_ssize_t len;
7567
0
            Py_ssize_t i;
7568
0
            if (!PyList_Check(tmp)) {
7569
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %T", tmp);
7570
0
                goto failed;
7571
0
            }
7572
0
            len = PyList_GET_SIZE(tmp);
7573
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
7574
0
            if (decorator_list == NULL) goto failed;
7575
0
            for (i = 0; i < len; i++) {
7576
0
                expr_ty val;
7577
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7578
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7579
0
                    goto failed;
7580
0
                }
7581
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
7582
0
                _Py_LeaveRecursiveCall();
7583
0
                Py_DECREF(tmp2);
7584
0
                if (res != 0) goto failed;
7585
0
                if (len != PyList_GET_SIZE(tmp)) {
7586
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
7587
0
                    goto failed;
7588
0
                }
7589
0
                asdl_seq_SET(decorator_list, i, val);
7590
0
            }
7591
0
            Py_CLEAR(tmp);
7592
0
        }
7593
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
7594
0
            return -1;
7595
0
        }
7596
0
        if (tmp == NULL || tmp == Py_None) {
7597
0
            Py_CLEAR(tmp);
7598
0
            returns = NULL;
7599
0
        }
7600
0
        else {
7601
0
            int res;
7602
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7603
0
                goto failed;
7604
0
            }
7605
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
7606
0
            _Py_LeaveRecursiveCall();
7607
0
            if (res != 0) goto failed;
7608
0
            Py_CLEAR(tmp);
7609
0
        }
7610
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
7611
0
            return -1;
7612
0
        }
7613
0
        if (tmp == NULL || tmp == Py_None) {
7614
0
            Py_CLEAR(tmp);
7615
0
            type_comment = NULL;
7616
0
        }
7617
0
        else {
7618
0
            int res;
7619
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7620
0
                goto failed;
7621
0
            }
7622
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
7623
0
                                 arena);
7624
0
            _Py_LeaveRecursiveCall();
7625
0
            if (res != 0) goto failed;
7626
0
            Py_CLEAR(tmp);
7627
0
        }
7628
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
7629
0
            return -1;
7630
0
        }
7631
0
        if (tmp == NULL) {
7632
0
            tmp = PyList_New(0);
7633
0
            if (tmp == NULL) {
7634
0
                return -1;
7635
0
            }
7636
0
        }
7637
0
        {
7638
0
            int res;
7639
0
            Py_ssize_t len;
7640
0
            Py_ssize_t i;
7641
0
            if (!PyList_Check(tmp)) {
7642
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %T", tmp);
7643
0
                goto failed;
7644
0
            }
7645
0
            len = PyList_GET_SIZE(tmp);
7646
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
7647
0
            if (type_params == NULL) goto failed;
7648
0
            for (i = 0; i < len; i++) {
7649
0
                type_param_ty val;
7650
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7651
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
7652
0
                    goto failed;
7653
0
                }
7654
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
7655
0
                _Py_LeaveRecursiveCall();
7656
0
                Py_DECREF(tmp2);
7657
0
                if (res != 0) goto failed;
7658
0
                if (len != PyList_GET_SIZE(tmp)) {
7659
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
7660
0
                    goto failed;
7661
0
                }
7662
0
                asdl_seq_SET(type_params, i, val);
7663
0
            }
7664
0
            Py_CLEAR(tmp);
7665
0
        }
7666
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
7667
0
                                  type_comment, type_params, lineno,
7668
0
                                  col_offset, end_lineno, end_col_offset,
7669
0
                                  arena);
7670
0
        if (*out == NULL) goto failed;
7671
0
        return 0;
7672
0
    }
7673
0
    tp = state->AsyncFunctionDef_type;
7674
0
    isinstance = PyObject_IsInstance(obj, tp);
7675
0
    if (isinstance == -1) {
7676
0
        return -1;
7677
0
    }
7678
0
    if (isinstance) {
7679
0
        identifier name;
7680
0
        arguments_ty args;
7681
0
        asdl_stmt_seq* body;
7682
0
        asdl_expr_seq* decorator_list;
7683
0
        expr_ty returns;
7684
0
        string type_comment;
7685
0
        asdl_type_param_seq* type_params;
7686
7687
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
7688
0
            return -1;
7689
0
        }
7690
0
        if (tmp == NULL) {
7691
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
7692
0
            return -1;
7693
0
        }
7694
0
        else {
7695
0
            int res;
7696
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7697
0
                goto failed;
7698
0
            }
7699
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
7700
0
            _Py_LeaveRecursiveCall();
7701
0
            if (res != 0) goto failed;
7702
0
            Py_CLEAR(tmp);
7703
0
        }
7704
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
7705
0
            return -1;
7706
0
        }
7707
0
        if (tmp == NULL) {
7708
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
7709
0
            return -1;
7710
0
        }
7711
0
        else {
7712
0
            int res;
7713
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7714
0
                goto failed;
7715
0
            }
7716
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
7717
0
            _Py_LeaveRecursiveCall();
7718
0
            if (res != 0) goto failed;
7719
0
            Py_CLEAR(tmp);
7720
0
        }
7721
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
7722
0
            return -1;
7723
0
        }
7724
0
        if (tmp == NULL) {
7725
0
            tmp = PyList_New(0);
7726
0
            if (tmp == NULL) {
7727
0
                return -1;
7728
0
            }
7729
0
        }
7730
0
        {
7731
0
            int res;
7732
0
            Py_ssize_t len;
7733
0
            Py_ssize_t i;
7734
0
            if (!PyList_Check(tmp)) {
7735
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %T", tmp);
7736
0
                goto failed;
7737
0
            }
7738
0
            len = PyList_GET_SIZE(tmp);
7739
0
            body = _Py_asdl_stmt_seq_new(len, arena);
7740
0
            if (body == NULL) goto failed;
7741
0
            for (i = 0; i < len; i++) {
7742
0
                stmt_ty val;
7743
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7744
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7745
0
                    goto failed;
7746
0
                }
7747
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
7748
0
                _Py_LeaveRecursiveCall();
7749
0
                Py_DECREF(tmp2);
7750
0
                if (res != 0) goto failed;
7751
0
                if (len != PyList_GET_SIZE(tmp)) {
7752
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
7753
0
                    goto failed;
7754
0
                }
7755
0
                asdl_seq_SET(body, i, val);
7756
0
            }
7757
0
            Py_CLEAR(tmp);
7758
0
        }
7759
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
7760
0
            return -1;
7761
0
        }
7762
0
        if (tmp == NULL) {
7763
0
            tmp = PyList_New(0);
7764
0
            if (tmp == NULL) {
7765
0
                return -1;
7766
0
            }
7767
0
        }
7768
0
        {
7769
0
            int res;
7770
0
            Py_ssize_t len;
7771
0
            Py_ssize_t i;
7772
0
            if (!PyList_Check(tmp)) {
7773
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %T", tmp);
7774
0
                goto failed;
7775
0
            }
7776
0
            len = PyList_GET_SIZE(tmp);
7777
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
7778
0
            if (decorator_list == NULL) goto failed;
7779
0
            for (i = 0; i < len; i++) {
7780
0
                expr_ty val;
7781
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7782
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7783
0
                    goto failed;
7784
0
                }
7785
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
7786
0
                _Py_LeaveRecursiveCall();
7787
0
                Py_DECREF(tmp2);
7788
0
                if (res != 0) goto failed;
7789
0
                if (len != PyList_GET_SIZE(tmp)) {
7790
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
7791
0
                    goto failed;
7792
0
                }
7793
0
                asdl_seq_SET(decorator_list, i, val);
7794
0
            }
7795
0
            Py_CLEAR(tmp);
7796
0
        }
7797
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
7798
0
            return -1;
7799
0
        }
7800
0
        if (tmp == NULL || tmp == Py_None) {
7801
0
            Py_CLEAR(tmp);
7802
0
            returns = NULL;
7803
0
        }
7804
0
        else {
7805
0
            int res;
7806
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7807
0
                goto failed;
7808
0
            }
7809
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
7810
0
            _Py_LeaveRecursiveCall();
7811
0
            if (res != 0) goto failed;
7812
0
            Py_CLEAR(tmp);
7813
0
        }
7814
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
7815
0
            return -1;
7816
0
        }
7817
0
        if (tmp == NULL || tmp == Py_None) {
7818
0
            Py_CLEAR(tmp);
7819
0
            type_comment = NULL;
7820
0
        }
7821
0
        else {
7822
0
            int res;
7823
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7824
0
                goto failed;
7825
0
            }
7826
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
7827
0
                                 arena);
7828
0
            _Py_LeaveRecursiveCall();
7829
0
            if (res != 0) goto failed;
7830
0
            Py_CLEAR(tmp);
7831
0
        }
7832
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
7833
0
            return -1;
7834
0
        }
7835
0
        if (tmp == NULL) {
7836
0
            tmp = PyList_New(0);
7837
0
            if (tmp == NULL) {
7838
0
                return -1;
7839
0
            }
7840
0
        }
7841
0
        {
7842
0
            int res;
7843
0
            Py_ssize_t len;
7844
0
            Py_ssize_t i;
7845
0
            if (!PyList_Check(tmp)) {
7846
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %T", tmp);
7847
0
                goto failed;
7848
0
            }
7849
0
            len = PyList_GET_SIZE(tmp);
7850
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
7851
0
            if (type_params == NULL) goto failed;
7852
0
            for (i = 0; i < len; i++) {
7853
0
                type_param_ty val;
7854
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7855
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
7856
0
                    goto failed;
7857
0
                }
7858
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
7859
0
                _Py_LeaveRecursiveCall();
7860
0
                Py_DECREF(tmp2);
7861
0
                if (res != 0) goto failed;
7862
0
                if (len != PyList_GET_SIZE(tmp)) {
7863
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
7864
0
                    goto failed;
7865
0
                }
7866
0
                asdl_seq_SET(type_params, i, val);
7867
0
            }
7868
0
            Py_CLEAR(tmp);
7869
0
        }
7870
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
7871
0
                                       returns, type_comment, type_params,
7872
0
                                       lineno, col_offset, end_lineno,
7873
0
                                       end_col_offset, arena);
7874
0
        if (*out == NULL) goto failed;
7875
0
        return 0;
7876
0
    }
7877
0
    tp = state->ClassDef_type;
7878
0
    isinstance = PyObject_IsInstance(obj, tp);
7879
0
    if (isinstance == -1) {
7880
0
        return -1;
7881
0
    }
7882
0
    if (isinstance) {
7883
0
        identifier name;
7884
0
        asdl_expr_seq* bases;
7885
0
        asdl_keyword_seq* keywords;
7886
0
        asdl_stmt_seq* body;
7887
0
        asdl_expr_seq* decorator_list;
7888
0
        asdl_type_param_seq* type_params;
7889
7890
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
7891
0
            return -1;
7892
0
        }
7893
0
        if (tmp == NULL) {
7894
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
7895
0
            return -1;
7896
0
        }
7897
0
        else {
7898
0
            int res;
7899
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
7900
0
                goto failed;
7901
0
            }
7902
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
7903
0
            _Py_LeaveRecursiveCall();
7904
0
            if (res != 0) goto failed;
7905
0
            Py_CLEAR(tmp);
7906
0
        }
7907
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
7908
0
            return -1;
7909
0
        }
7910
0
        if (tmp == NULL) {
7911
0
            tmp = PyList_New(0);
7912
0
            if (tmp == NULL) {
7913
0
                return -1;
7914
0
            }
7915
0
        }
7916
0
        {
7917
0
            int res;
7918
0
            Py_ssize_t len;
7919
0
            Py_ssize_t i;
7920
0
            if (!PyList_Check(tmp)) {
7921
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %T", tmp);
7922
0
                goto failed;
7923
0
            }
7924
0
            len = PyList_GET_SIZE(tmp);
7925
0
            bases = _Py_asdl_expr_seq_new(len, arena);
7926
0
            if (bases == NULL) goto failed;
7927
0
            for (i = 0; i < len; i++) {
7928
0
                expr_ty val;
7929
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7930
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
7931
0
                    goto failed;
7932
0
                }
7933
0
                res = obj2ast_expr(state, tmp2, &val, "bases", arena);
7934
0
                _Py_LeaveRecursiveCall();
7935
0
                Py_DECREF(tmp2);
7936
0
                if (res != 0) goto failed;
7937
0
                if (len != PyList_GET_SIZE(tmp)) {
7938
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
7939
0
                    goto failed;
7940
0
                }
7941
0
                asdl_seq_SET(bases, i, val);
7942
0
            }
7943
0
            Py_CLEAR(tmp);
7944
0
        }
7945
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
7946
0
            return -1;
7947
0
        }
7948
0
        if (tmp == NULL) {
7949
0
            tmp = PyList_New(0);
7950
0
            if (tmp == NULL) {
7951
0
                return -1;
7952
0
            }
7953
0
        }
7954
0
        {
7955
0
            int res;
7956
0
            Py_ssize_t len;
7957
0
            Py_ssize_t i;
7958
0
            if (!PyList_Check(tmp)) {
7959
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %T", tmp);
7960
0
                goto failed;
7961
0
            }
7962
0
            len = PyList_GET_SIZE(tmp);
7963
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
7964
0
            if (keywords == NULL) goto failed;
7965
0
            for (i = 0; i < len; i++) {
7966
0
                keyword_ty val;
7967
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
7968
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
7969
0
                    goto failed;
7970
0
                }
7971
0
                res = obj2ast_keyword(state, tmp2, &val, "keywords", arena);
7972
0
                _Py_LeaveRecursiveCall();
7973
0
                Py_DECREF(tmp2);
7974
0
                if (res != 0) goto failed;
7975
0
                if (len != PyList_GET_SIZE(tmp)) {
7976
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
7977
0
                    goto failed;
7978
0
                }
7979
0
                asdl_seq_SET(keywords, i, val);
7980
0
            }
7981
0
            Py_CLEAR(tmp);
7982
0
        }
7983
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
7984
0
            return -1;
7985
0
        }
7986
0
        if (tmp == NULL) {
7987
0
            tmp = PyList_New(0);
7988
0
            if (tmp == NULL) {
7989
0
                return -1;
7990
0
            }
7991
0
        }
7992
0
        {
7993
0
            int res;
7994
0
            Py_ssize_t len;
7995
0
            Py_ssize_t i;
7996
0
            if (!PyList_Check(tmp)) {
7997
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %T", tmp);
7998
0
                goto failed;
7999
0
            }
8000
0
            len = PyList_GET_SIZE(tmp);
8001
0
            body = _Py_asdl_stmt_seq_new(len, arena);
8002
0
            if (body == NULL) goto failed;
8003
0
            for (i = 0; i < len; i++) {
8004
0
                stmt_ty val;
8005
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8006
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
8007
0
                    goto failed;
8008
0
                }
8009
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
8010
0
                _Py_LeaveRecursiveCall();
8011
0
                Py_DECREF(tmp2);
8012
0
                if (res != 0) goto failed;
8013
0
                if (len != PyList_GET_SIZE(tmp)) {
8014
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
8015
0
                    goto failed;
8016
0
                }
8017
0
                asdl_seq_SET(body, i, val);
8018
0
            }
8019
0
            Py_CLEAR(tmp);
8020
0
        }
8021
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
8022
0
            return -1;
8023
0
        }
8024
0
        if (tmp == NULL) {
8025
0
            tmp = PyList_New(0);
8026
0
            if (tmp == NULL) {
8027
0
                return -1;
8028
0
            }
8029
0
        }
8030
0
        {
8031
0
            int res;
8032
0
            Py_ssize_t len;
8033
0
            Py_ssize_t i;
8034
0
            if (!PyList_Check(tmp)) {
8035
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %T", tmp);
8036
0
                goto failed;
8037
0
            }
8038
0
            len = PyList_GET_SIZE(tmp);
8039
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
8040
0
            if (decorator_list == NULL) goto failed;
8041
0
            for (i = 0; i < len; i++) {
8042
0
                expr_ty val;
8043
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8044
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
8045
0
                    goto failed;
8046
0
                }
8047
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
8048
0
                _Py_LeaveRecursiveCall();
8049
0
                Py_DECREF(tmp2);
8050
0
                if (res != 0) goto failed;
8051
0
                if (len != PyList_GET_SIZE(tmp)) {
8052
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
8053
0
                    goto failed;
8054
0
                }
8055
0
                asdl_seq_SET(decorator_list, i, val);
8056
0
            }
8057
0
            Py_CLEAR(tmp);
8058
0
        }
8059
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
8060
0
            return -1;
8061
0
        }
8062
0
        if (tmp == NULL) {
8063
0
            tmp = PyList_New(0);
8064
0
            if (tmp == NULL) {
8065
0
                return -1;
8066
0
            }
8067
0
        }
8068
0
        {
8069
0
            int res;
8070
0
            Py_ssize_t len;
8071
0
            Py_ssize_t i;
8072
0
            if (!PyList_Check(tmp)) {
8073
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %T", tmp);
8074
0
                goto failed;
8075
0
            }
8076
0
            len = PyList_GET_SIZE(tmp);
8077
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
8078
0
            if (type_params == NULL) goto failed;
8079
0
            for (i = 0; i < len; i++) {
8080
0
                type_param_ty val;
8081
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8082
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
8083
0
                    goto failed;
8084
0
                }
8085
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
8086
0
                _Py_LeaveRecursiveCall();
8087
0
                Py_DECREF(tmp2);
8088
0
                if (res != 0) goto failed;
8089
0
                if (len != PyList_GET_SIZE(tmp)) {
8090
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
8091
0
                    goto failed;
8092
0
                }
8093
0
                asdl_seq_SET(type_params, i, val);
8094
0
            }
8095
0
            Py_CLEAR(tmp);
8096
0
        }
8097
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
8098
0
                               type_params, lineno, col_offset, end_lineno,
8099
0
                               end_col_offset, arena);
8100
0
        if (*out == NULL) goto failed;
8101
0
        return 0;
8102
0
    }
8103
0
    tp = state->Return_type;
8104
0
    isinstance = PyObject_IsInstance(obj, tp);
8105
0
    if (isinstance == -1) {
8106
0
        return -1;
8107
0
    }
8108
0
    if (isinstance) {
8109
0
        expr_ty value;
8110
8111
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
8112
0
            return -1;
8113
0
        }
8114
0
        if (tmp == NULL || tmp == Py_None) {
8115
0
            Py_CLEAR(tmp);
8116
0
            value = NULL;
8117
0
        }
8118
0
        else {
8119
0
            int res;
8120
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
8121
0
                goto failed;
8122
0
            }
8123
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
8124
0
            _Py_LeaveRecursiveCall();
8125
0
            if (res != 0) goto failed;
8126
0
            Py_CLEAR(tmp);
8127
0
        }
8128
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
8129
0
                             end_col_offset, arena);
8130
0
        if (*out == NULL) goto failed;
8131
0
        return 0;
8132
0
    }
8133
0
    tp = state->Delete_type;
8134
0
    isinstance = PyObject_IsInstance(obj, tp);
8135
0
    if (isinstance == -1) {
8136
0
        return -1;
8137
0
    }
8138
0
    if (isinstance) {
8139
0
        asdl_expr_seq* targets;
8140
8141
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
8142
0
            return -1;
8143
0
        }
8144
0
        if (tmp == NULL) {
8145
0
            tmp = PyList_New(0);
8146
0
            if (tmp == NULL) {
8147
0
                return -1;
8148
0
            }
8149
0
        }
8150
0
        {
8151
0
            int res;
8152
0
            Py_ssize_t len;
8153
0
            Py_ssize_t i;
8154
0
            if (!PyList_Check(tmp)) {
8155
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %T", tmp);
8156
0
                goto failed;
8157
0
            }
8158
0
            len = PyList_GET_SIZE(tmp);
8159
0
            targets = _Py_asdl_expr_seq_new(len, arena);
8160
0
            if (targets == NULL) goto failed;
8161
0
            for (i = 0; i < len; i++) {
8162
0
                expr_ty val;
8163
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8164
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
8165
0
                    goto failed;
8166
0
                }
8167
0
                res = obj2ast_expr(state, tmp2, &val, "targets", arena);
8168
0
                _Py_LeaveRecursiveCall();
8169
0
                Py_DECREF(tmp2);
8170
0
                if (res != 0) goto failed;
8171
0
                if (len != PyList_GET_SIZE(tmp)) {
8172
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
8173
0
                    goto failed;
8174
0
                }
8175
0
                asdl_seq_SET(targets, i, val);
8176
0
            }
8177
0
            Py_CLEAR(tmp);
8178
0
        }
8179
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
8180
0
                             end_col_offset, arena);
8181
0
        if (*out == NULL) goto failed;
8182
0
        return 0;
8183
0
    }
8184
0
    tp = state->Assign_type;
8185
0
    isinstance = PyObject_IsInstance(obj, tp);
8186
0
    if (isinstance == -1) {
8187
0
        return -1;
8188
0
    }
8189
0
    if (isinstance) {
8190
0
        asdl_expr_seq* targets;
8191
0
        expr_ty value;
8192
0
        string type_comment;
8193
8194
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
8195
0
            return -1;
8196
0
        }
8197
0
        if (tmp == NULL) {
8198
0
            tmp = PyList_New(0);
8199
0
            if (tmp == NULL) {
8200
0
                return -1;
8201
0
            }
8202
0
        }
8203
0
        {
8204
0
            int res;
8205
0
            Py_ssize_t len;
8206
0
            Py_ssize_t i;
8207
0
            if (!PyList_Check(tmp)) {
8208
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %T", tmp);
8209
0
                goto failed;
8210
0
            }
8211
0
            len = PyList_GET_SIZE(tmp);
8212
0
            targets = _Py_asdl_expr_seq_new(len, arena);
8213
0
            if (targets == NULL) goto failed;
8214
0
            for (i = 0; i < len; i++) {
8215
0
                expr_ty val;
8216
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8217
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
8218
0
                    goto failed;
8219
0
                }
8220
0
                res = obj2ast_expr(state, tmp2, &val, "targets", arena);
8221
0
                _Py_LeaveRecursiveCall();
8222
0
                Py_DECREF(tmp2);
8223
0
                if (res != 0) goto failed;
8224
0
                if (len != PyList_GET_SIZE(tmp)) {
8225
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
8226
0
                    goto failed;
8227
0
                }
8228
0
                asdl_seq_SET(targets, i, val);
8229
0
            }
8230
0
            Py_CLEAR(tmp);
8231
0
        }
8232
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
8233
0
            return -1;
8234
0
        }
8235
0
        if (tmp == NULL) {
8236
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
8237
0
            return -1;
8238
0
        }
8239
0
        else {
8240
0
            int res;
8241
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
8242
0
                goto failed;
8243
0
            }
8244
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
8245
0
            _Py_LeaveRecursiveCall();
8246
0
            if (res != 0) goto failed;
8247
0
            Py_CLEAR(tmp);
8248
0
        }
8249
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
8250
0
            return -1;
8251
0
        }
8252
0
        if (tmp == NULL || tmp == Py_None) {
8253
0
            Py_CLEAR(tmp);
8254
0
            type_comment = NULL;
8255
0
        }
8256
0
        else {
8257
0
            int res;
8258
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
8259
0
                goto failed;
8260
0
            }
8261
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
8262
0
                                 arena);
8263
0
            _Py_LeaveRecursiveCall();
8264
0
            if (res != 0) goto failed;
8265
0
            Py_CLEAR(tmp);
8266
0
        }
8267
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
8268
0
                             end_lineno, end_col_offset, arena);
8269
0
        if (*out == NULL) goto failed;
8270
0
        return 0;
8271
0
    }
8272
0
    tp = state->TypeAlias_type;
8273
0
    isinstance = PyObject_IsInstance(obj, tp);
8274
0
    if (isinstance == -1) {
8275
0
        return -1;
8276
0
    }
8277
0
    if (isinstance) {
8278
0
        expr_ty name;
8279
0
        asdl_type_param_seq* type_params;
8280
0
        expr_ty value;
8281
8282
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
8283
0
            return -1;
8284
0
        }
8285
0
        if (tmp == NULL) {
8286
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
8287
0
            return -1;
8288
0
        }
8289
0
        else {
8290
0
            int res;
8291
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
8292
0
                goto failed;
8293
0
            }
8294
0
            res = obj2ast_expr(state, tmp, &name, "name", arena);
8295
0
            _Py_LeaveRecursiveCall();
8296
0
            if (res != 0) goto failed;
8297
0
            Py_CLEAR(tmp);
8298
0
        }
8299
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
8300
0
            return -1;
8301
0
        }
8302
0
        if (tmp == NULL) {
8303
0
            tmp = PyList_New(0);
8304
0
            if (tmp == NULL) {
8305
0
                return -1;
8306
0
            }
8307
0
        }
8308
0
        {
8309
0
            int res;
8310
0
            Py_ssize_t len;
8311
0
            Py_ssize_t i;
8312
0
            if (!PyList_Check(tmp)) {
8313
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %T", tmp);
8314
0
                goto failed;
8315
0
            }
8316
0
            len = PyList_GET_SIZE(tmp);
8317
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
8318
0
            if (type_params == NULL) goto failed;
8319
0
            for (i = 0; i < len; i++) {
8320
0
                type_param_ty val;
8321
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8322
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
8323
0
                    goto failed;
8324
0
                }
8325
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
8326
0
                _Py_LeaveRecursiveCall();
8327
0
                Py_DECREF(tmp2);
8328
0
                if (res != 0) goto failed;
8329
0
                if (len != PyList_GET_SIZE(tmp)) {
8330
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
8331
0
                    goto failed;
8332
0
                }
8333
0
                asdl_seq_SET(type_params, i, val);
8334
0
            }
8335
0
            Py_CLEAR(tmp);
8336
0
        }
8337
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
8338
0
            return -1;
8339
0
        }
8340
0
        if (tmp == NULL) {
8341
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
8342
0
            return -1;
8343
0
        }
8344
0
        else {
8345
0
            int res;
8346
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
8347
0
                goto failed;
8348
0
            }
8349
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
8350
0
            _Py_LeaveRecursiveCall();
8351
0
            if (res != 0) goto failed;
8352
0
            Py_CLEAR(tmp);
8353
0
        }
8354
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
8355
0
                                end_lineno, end_col_offset, arena);
8356
0
        if (*out == NULL) goto failed;
8357
0
        return 0;
8358
0
    }
8359
0
    tp = state->AugAssign_type;
8360
0
    isinstance = PyObject_IsInstance(obj, tp);
8361
0
    if (isinstance == -1) {
8362
0
        return -1;
8363
0
    }
8364
0
    if (isinstance) {
8365
0
        expr_ty target;
8366
0
        operator_ty op;
8367
0
        expr_ty value;
8368
8369
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
8370
0
            return -1;
8371
0
        }
8372
0
        if (tmp == NULL) {
8373
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
8374
0
            return -1;
8375
0
        }
8376
0
        else {
8377
0
            int res;
8378
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
8379
0
                goto failed;
8380
0
            }
8381
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
8382
0
            _Py_LeaveRecursiveCall();
8383
0
            if (res != 0) goto failed;
8384
0
            Py_CLEAR(tmp);
8385
0
        }
8386
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
8387
0
            return -1;
8388
0
        }
8389
0
        if (tmp == NULL) {
8390
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
8391
0
            return -1;
8392
0
        }
8393
0
        else {
8394
0
            int res;
8395
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
8396
0
                goto failed;
8397
0
            }
8398
0
            res = obj2ast_operator(state, tmp, &op, "op", arena);
8399
0
            _Py_LeaveRecursiveCall();
8400
0
            if (res != 0) goto failed;
8401
0
            Py_CLEAR(tmp);
8402
0
        }
8403
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
8404
0
            return -1;
8405
0
        }
8406
0
        if (tmp == NULL) {
8407
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
8408
0
            return -1;
8409
0
        }
8410
0
        else {
8411
0
            int res;
8412
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
8413
0
                goto failed;
8414
0
            }
8415
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
8416
0
            _Py_LeaveRecursiveCall();
8417
0
            if (res != 0) goto failed;
8418
0
            Py_CLEAR(tmp);
8419
0
        }
8420
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
8421
0
                                end_lineno, end_col_offset, arena);
8422
0
        if (*out == NULL) goto failed;
8423
0
        return 0;
8424
0
    }
8425
0
    tp = state->AnnAssign_type;
8426
0
    isinstance = PyObject_IsInstance(obj, tp);
8427
0
    if (isinstance == -1) {
8428
0
        return -1;
8429
0
    }
8430
0
    if (isinstance) {
8431
0
        expr_ty target;
8432
0
        expr_ty annotation;
8433
0
        expr_ty value;
8434
0
        int simple;
8435
8436
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
8437
0
            return -1;
8438
0
        }
8439
0
        if (tmp == NULL) {
8440
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
8441
0
            return -1;
8442
0
        }
8443
0
        else {
8444
0
            int res;
8445
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
8446
0
                goto failed;
8447
0
            }
8448
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
8449
0
            _Py_LeaveRecursiveCall();
8450
0
            if (res != 0) goto failed;
8451
0
            Py_CLEAR(tmp);
8452
0
        }
8453
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
8454
0
            return -1;
8455
0
        }
8456
0
        if (tmp == NULL) {
8457
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
8458
0
            return -1;
8459
0
        }
8460
0
        else {
8461
0
            int res;
8462
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
8463
0
                goto failed;
8464
0
            }
8465
0
            res = obj2ast_expr(state, tmp, &annotation, "annotation", arena);
8466
0
            _Py_LeaveRecursiveCall();
8467
0
            if (res != 0) goto failed;
8468
0
            Py_CLEAR(tmp);
8469
0
        }
8470
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
8471
0
            return -1;
8472
0
        }
8473
0
        if (tmp == NULL || tmp == Py_None) {
8474
0
            Py_CLEAR(tmp);
8475
0
            value = NULL;
8476
0
        }
8477
0
        else {
8478
0
            int res;
8479
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
8480
0
                goto failed;
8481
0
            }
8482
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
8483
0
            _Py_LeaveRecursiveCall();
8484
0
            if (res != 0) goto failed;
8485
0
            Py_CLEAR(tmp);
8486
0
        }
8487
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
8488
0
            return -1;
8489
0
        }
8490
0
        if (tmp == NULL) {
8491
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
8492
0
            return -1;
8493
0
        }
8494
0
        else {
8495
0
            int res;
8496
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
8497
0
                goto failed;
8498
0
            }
8499
0
            res = obj2ast_int(state, tmp, &simple, "simple", arena);
8500
0
            _Py_LeaveRecursiveCall();
8501
0
            if (res != 0) goto failed;
8502
0
            Py_CLEAR(tmp);
8503
0
        }
8504
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
8505
0
                                col_offset, end_lineno, end_col_offset, arena);
8506
0
        if (*out == NULL) goto failed;
8507
0
        return 0;
8508
0
    }
8509
0
    tp = state->For_type;
8510
0
    isinstance = PyObject_IsInstance(obj, tp);
8511
0
    if (isinstance == -1) {
8512
0
        return -1;
8513
0
    }
8514
0
    if (isinstance) {
8515
0
        expr_ty target;
8516
0
        expr_ty iter;
8517
0
        asdl_stmt_seq* body;
8518
0
        asdl_stmt_seq* orelse;
8519
0
        string type_comment;
8520
8521
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
8522
0
            return -1;
8523
0
        }
8524
0
        if (tmp == NULL) {
8525
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
8526
0
            return -1;
8527
0
        }
8528
0
        else {
8529
0
            int res;
8530
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
8531
0
                goto failed;
8532
0
            }
8533
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
8534
0
            _Py_LeaveRecursiveCall();
8535
0
            if (res != 0) goto failed;
8536
0
            Py_CLEAR(tmp);
8537
0
        }
8538
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
8539
0
            return -1;
8540
0
        }
8541
0
        if (tmp == NULL) {
8542
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
8543
0
            return -1;
8544
0
        }
8545
0
        else {
8546
0
            int res;
8547
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
8548
0
                goto failed;
8549
0
            }
8550
0
            res = obj2ast_expr(state, tmp, &iter, "iter", arena);
8551
0
            _Py_LeaveRecursiveCall();
8552
0
            if (res != 0) goto failed;
8553
0
            Py_CLEAR(tmp);
8554
0
        }
8555
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
8556
0
            return -1;
8557
0
        }
8558
0
        if (tmp == NULL) {
8559
0
            tmp = PyList_New(0);
8560
0
            if (tmp == NULL) {
8561
0
                return -1;
8562
0
            }
8563
0
        }
8564
0
        {
8565
0
            int res;
8566
0
            Py_ssize_t len;
8567
0
            Py_ssize_t i;
8568
0
            if (!PyList_Check(tmp)) {
8569
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %T", tmp);
8570
0
                goto failed;
8571
0
            }
8572
0
            len = PyList_GET_SIZE(tmp);
8573
0
            body = _Py_asdl_stmt_seq_new(len, arena);
8574
0
            if (body == NULL) goto failed;
8575
0
            for (i = 0; i < len; i++) {
8576
0
                stmt_ty val;
8577
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8578
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
8579
0
                    goto failed;
8580
0
                }
8581
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
8582
0
                _Py_LeaveRecursiveCall();
8583
0
                Py_DECREF(tmp2);
8584
0
                if (res != 0) goto failed;
8585
0
                if (len != PyList_GET_SIZE(tmp)) {
8586
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
8587
0
                    goto failed;
8588
0
                }
8589
0
                asdl_seq_SET(body, i, val);
8590
0
            }
8591
0
            Py_CLEAR(tmp);
8592
0
        }
8593
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
8594
0
            return -1;
8595
0
        }
8596
0
        if (tmp == NULL) {
8597
0
            tmp = PyList_New(0);
8598
0
            if (tmp == NULL) {
8599
0
                return -1;
8600
0
            }
8601
0
        }
8602
0
        {
8603
0
            int res;
8604
0
            Py_ssize_t len;
8605
0
            Py_ssize_t i;
8606
0
            if (!PyList_Check(tmp)) {
8607
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %T", tmp);
8608
0
                goto failed;
8609
0
            }
8610
0
            len = PyList_GET_SIZE(tmp);
8611
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
8612
0
            if (orelse == NULL) goto failed;
8613
0
            for (i = 0; i < len; i++) {
8614
0
                stmt_ty val;
8615
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8616
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
8617
0
                    goto failed;
8618
0
                }
8619
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
8620
0
                _Py_LeaveRecursiveCall();
8621
0
                Py_DECREF(tmp2);
8622
0
                if (res != 0) goto failed;
8623
0
                if (len != PyList_GET_SIZE(tmp)) {
8624
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
8625
0
                    goto failed;
8626
0
                }
8627
0
                asdl_seq_SET(orelse, i, val);
8628
0
            }
8629
0
            Py_CLEAR(tmp);
8630
0
        }
8631
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
8632
0
            return -1;
8633
0
        }
8634
0
        if (tmp == NULL || tmp == Py_None) {
8635
0
            Py_CLEAR(tmp);
8636
0
            type_comment = NULL;
8637
0
        }
8638
0
        else {
8639
0
            int res;
8640
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
8641
0
                goto failed;
8642
0
            }
8643
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
8644
0
                                 arena);
8645
0
            _Py_LeaveRecursiveCall();
8646
0
            if (res != 0) goto failed;
8647
0
            Py_CLEAR(tmp);
8648
0
        }
8649
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
8650
0
                          col_offset, end_lineno, end_col_offset, arena);
8651
0
        if (*out == NULL) goto failed;
8652
0
        return 0;
8653
0
    }
8654
0
    tp = state->AsyncFor_type;
8655
0
    isinstance = PyObject_IsInstance(obj, tp);
8656
0
    if (isinstance == -1) {
8657
0
        return -1;
8658
0
    }
8659
0
    if (isinstance) {
8660
0
        expr_ty target;
8661
0
        expr_ty iter;
8662
0
        asdl_stmt_seq* body;
8663
0
        asdl_stmt_seq* orelse;
8664
0
        string type_comment;
8665
8666
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
8667
0
            return -1;
8668
0
        }
8669
0
        if (tmp == NULL) {
8670
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
8671
0
            return -1;
8672
0
        }
8673
0
        else {
8674
0
            int res;
8675
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
8676
0
                goto failed;
8677
0
            }
8678
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
8679
0
            _Py_LeaveRecursiveCall();
8680
0
            if (res != 0) goto failed;
8681
0
            Py_CLEAR(tmp);
8682
0
        }
8683
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
8684
0
            return -1;
8685
0
        }
8686
0
        if (tmp == NULL) {
8687
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
8688
0
            return -1;
8689
0
        }
8690
0
        else {
8691
0
            int res;
8692
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
8693
0
                goto failed;
8694
0
            }
8695
0
            res = obj2ast_expr(state, tmp, &iter, "iter", arena);
8696
0
            _Py_LeaveRecursiveCall();
8697
0
            if (res != 0) goto failed;
8698
0
            Py_CLEAR(tmp);
8699
0
        }
8700
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
8701
0
            return -1;
8702
0
        }
8703
0
        if (tmp == NULL) {
8704
0
            tmp = PyList_New(0);
8705
0
            if (tmp == NULL) {
8706
0
                return -1;
8707
0
            }
8708
0
        }
8709
0
        {
8710
0
            int res;
8711
0
            Py_ssize_t len;
8712
0
            Py_ssize_t i;
8713
0
            if (!PyList_Check(tmp)) {
8714
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %T", tmp);
8715
0
                goto failed;
8716
0
            }
8717
0
            len = PyList_GET_SIZE(tmp);
8718
0
            body = _Py_asdl_stmt_seq_new(len, arena);
8719
0
            if (body == NULL) goto failed;
8720
0
            for (i = 0; i < len; i++) {
8721
0
                stmt_ty val;
8722
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8723
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
8724
0
                    goto failed;
8725
0
                }
8726
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
8727
0
                _Py_LeaveRecursiveCall();
8728
0
                Py_DECREF(tmp2);
8729
0
                if (res != 0) goto failed;
8730
0
                if (len != PyList_GET_SIZE(tmp)) {
8731
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
8732
0
                    goto failed;
8733
0
                }
8734
0
                asdl_seq_SET(body, i, val);
8735
0
            }
8736
0
            Py_CLEAR(tmp);
8737
0
        }
8738
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
8739
0
            return -1;
8740
0
        }
8741
0
        if (tmp == NULL) {
8742
0
            tmp = PyList_New(0);
8743
0
            if (tmp == NULL) {
8744
0
                return -1;
8745
0
            }
8746
0
        }
8747
0
        {
8748
0
            int res;
8749
0
            Py_ssize_t len;
8750
0
            Py_ssize_t i;
8751
0
            if (!PyList_Check(tmp)) {
8752
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %T", tmp);
8753
0
                goto failed;
8754
0
            }
8755
0
            len = PyList_GET_SIZE(tmp);
8756
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
8757
0
            if (orelse == NULL) goto failed;
8758
0
            for (i = 0; i < len; i++) {
8759
0
                stmt_ty val;
8760
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8761
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
8762
0
                    goto failed;
8763
0
                }
8764
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
8765
0
                _Py_LeaveRecursiveCall();
8766
0
                Py_DECREF(tmp2);
8767
0
                if (res != 0) goto failed;
8768
0
                if (len != PyList_GET_SIZE(tmp)) {
8769
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
8770
0
                    goto failed;
8771
0
                }
8772
0
                asdl_seq_SET(orelse, i, val);
8773
0
            }
8774
0
            Py_CLEAR(tmp);
8775
0
        }
8776
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
8777
0
            return -1;
8778
0
        }
8779
0
        if (tmp == NULL || tmp == Py_None) {
8780
0
            Py_CLEAR(tmp);
8781
0
            type_comment = NULL;
8782
0
        }
8783
0
        else {
8784
0
            int res;
8785
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
8786
0
                goto failed;
8787
0
            }
8788
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
8789
0
                                 arena);
8790
0
            _Py_LeaveRecursiveCall();
8791
0
            if (res != 0) goto failed;
8792
0
            Py_CLEAR(tmp);
8793
0
        }
8794
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
8795
0
                               lineno, col_offset, end_lineno, end_col_offset,
8796
0
                               arena);
8797
0
        if (*out == NULL) goto failed;
8798
0
        return 0;
8799
0
    }
8800
0
    tp = state->While_type;
8801
0
    isinstance = PyObject_IsInstance(obj, tp);
8802
0
    if (isinstance == -1) {
8803
0
        return -1;
8804
0
    }
8805
0
    if (isinstance) {
8806
0
        expr_ty test;
8807
0
        asdl_stmt_seq* body;
8808
0
        asdl_stmt_seq* orelse;
8809
8810
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
8811
0
            return -1;
8812
0
        }
8813
0
        if (tmp == NULL) {
8814
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
8815
0
            return -1;
8816
0
        }
8817
0
        else {
8818
0
            int res;
8819
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
8820
0
                goto failed;
8821
0
            }
8822
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
8823
0
            _Py_LeaveRecursiveCall();
8824
0
            if (res != 0) goto failed;
8825
0
            Py_CLEAR(tmp);
8826
0
        }
8827
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
8828
0
            return -1;
8829
0
        }
8830
0
        if (tmp == NULL) {
8831
0
            tmp = PyList_New(0);
8832
0
            if (tmp == NULL) {
8833
0
                return -1;
8834
0
            }
8835
0
        }
8836
0
        {
8837
0
            int res;
8838
0
            Py_ssize_t len;
8839
0
            Py_ssize_t i;
8840
0
            if (!PyList_Check(tmp)) {
8841
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %T", tmp);
8842
0
                goto failed;
8843
0
            }
8844
0
            len = PyList_GET_SIZE(tmp);
8845
0
            body = _Py_asdl_stmt_seq_new(len, arena);
8846
0
            if (body == NULL) goto failed;
8847
0
            for (i = 0; i < len; i++) {
8848
0
                stmt_ty val;
8849
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8850
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
8851
0
                    goto failed;
8852
0
                }
8853
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
8854
0
                _Py_LeaveRecursiveCall();
8855
0
                Py_DECREF(tmp2);
8856
0
                if (res != 0) goto failed;
8857
0
                if (len != PyList_GET_SIZE(tmp)) {
8858
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
8859
0
                    goto failed;
8860
0
                }
8861
0
                asdl_seq_SET(body, i, val);
8862
0
            }
8863
0
            Py_CLEAR(tmp);
8864
0
        }
8865
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
8866
0
            return -1;
8867
0
        }
8868
0
        if (tmp == NULL) {
8869
0
            tmp = PyList_New(0);
8870
0
            if (tmp == NULL) {
8871
0
                return -1;
8872
0
            }
8873
0
        }
8874
0
        {
8875
0
            int res;
8876
0
            Py_ssize_t len;
8877
0
            Py_ssize_t i;
8878
0
            if (!PyList_Check(tmp)) {
8879
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %T", tmp);
8880
0
                goto failed;
8881
0
            }
8882
0
            len = PyList_GET_SIZE(tmp);
8883
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
8884
0
            if (orelse == NULL) goto failed;
8885
0
            for (i = 0; i < len; i++) {
8886
0
                stmt_ty val;
8887
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8888
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
8889
0
                    goto failed;
8890
0
                }
8891
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
8892
0
                _Py_LeaveRecursiveCall();
8893
0
                Py_DECREF(tmp2);
8894
0
                if (res != 0) goto failed;
8895
0
                if (len != PyList_GET_SIZE(tmp)) {
8896
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
8897
0
                    goto failed;
8898
0
                }
8899
0
                asdl_seq_SET(orelse, i, val);
8900
0
            }
8901
0
            Py_CLEAR(tmp);
8902
0
        }
8903
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
8904
0
                            end_col_offset, arena);
8905
0
        if (*out == NULL) goto failed;
8906
0
        return 0;
8907
0
    }
8908
0
    tp = state->If_type;
8909
0
    isinstance = PyObject_IsInstance(obj, tp);
8910
0
    if (isinstance == -1) {
8911
0
        return -1;
8912
0
    }
8913
0
    if (isinstance) {
8914
0
        expr_ty test;
8915
0
        asdl_stmt_seq* body;
8916
0
        asdl_stmt_seq* orelse;
8917
8918
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
8919
0
            return -1;
8920
0
        }
8921
0
        if (tmp == NULL) {
8922
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
8923
0
            return -1;
8924
0
        }
8925
0
        else {
8926
0
            int res;
8927
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
8928
0
                goto failed;
8929
0
            }
8930
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
8931
0
            _Py_LeaveRecursiveCall();
8932
0
            if (res != 0) goto failed;
8933
0
            Py_CLEAR(tmp);
8934
0
        }
8935
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
8936
0
            return -1;
8937
0
        }
8938
0
        if (tmp == NULL) {
8939
0
            tmp = PyList_New(0);
8940
0
            if (tmp == NULL) {
8941
0
                return -1;
8942
0
            }
8943
0
        }
8944
0
        {
8945
0
            int res;
8946
0
            Py_ssize_t len;
8947
0
            Py_ssize_t i;
8948
0
            if (!PyList_Check(tmp)) {
8949
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %T", tmp);
8950
0
                goto failed;
8951
0
            }
8952
0
            len = PyList_GET_SIZE(tmp);
8953
0
            body = _Py_asdl_stmt_seq_new(len, arena);
8954
0
            if (body == NULL) goto failed;
8955
0
            for (i = 0; i < len; i++) {
8956
0
                stmt_ty val;
8957
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8958
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
8959
0
                    goto failed;
8960
0
                }
8961
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
8962
0
                _Py_LeaveRecursiveCall();
8963
0
                Py_DECREF(tmp2);
8964
0
                if (res != 0) goto failed;
8965
0
                if (len != PyList_GET_SIZE(tmp)) {
8966
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
8967
0
                    goto failed;
8968
0
                }
8969
0
                asdl_seq_SET(body, i, val);
8970
0
            }
8971
0
            Py_CLEAR(tmp);
8972
0
        }
8973
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
8974
0
            return -1;
8975
0
        }
8976
0
        if (tmp == NULL) {
8977
0
            tmp = PyList_New(0);
8978
0
            if (tmp == NULL) {
8979
0
                return -1;
8980
0
            }
8981
0
        }
8982
0
        {
8983
0
            int res;
8984
0
            Py_ssize_t len;
8985
0
            Py_ssize_t i;
8986
0
            if (!PyList_Check(tmp)) {
8987
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %T", tmp);
8988
0
                goto failed;
8989
0
            }
8990
0
            len = PyList_GET_SIZE(tmp);
8991
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
8992
0
            if (orelse == NULL) goto failed;
8993
0
            for (i = 0; i < len; i++) {
8994
0
                stmt_ty val;
8995
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
8996
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
8997
0
                    goto failed;
8998
0
                }
8999
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
9000
0
                _Py_LeaveRecursiveCall();
9001
0
                Py_DECREF(tmp2);
9002
0
                if (res != 0) goto failed;
9003
0
                if (len != PyList_GET_SIZE(tmp)) {
9004
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
9005
0
                    goto failed;
9006
0
                }
9007
0
                asdl_seq_SET(orelse, i, val);
9008
0
            }
9009
0
            Py_CLEAR(tmp);
9010
0
        }
9011
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
9012
0
                         end_col_offset, arena);
9013
0
        if (*out == NULL) goto failed;
9014
0
        return 0;
9015
0
    }
9016
0
    tp = state->With_type;
9017
0
    isinstance = PyObject_IsInstance(obj, tp);
9018
0
    if (isinstance == -1) {
9019
0
        return -1;
9020
0
    }
9021
0
    if (isinstance) {
9022
0
        asdl_withitem_seq* items;
9023
0
        asdl_stmt_seq* body;
9024
0
        string type_comment;
9025
9026
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
9027
0
            return -1;
9028
0
        }
9029
0
        if (tmp == NULL) {
9030
0
            tmp = PyList_New(0);
9031
0
            if (tmp == NULL) {
9032
0
                return -1;
9033
0
            }
9034
0
        }
9035
0
        {
9036
0
            int res;
9037
0
            Py_ssize_t len;
9038
0
            Py_ssize_t i;
9039
0
            if (!PyList_Check(tmp)) {
9040
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %T", tmp);
9041
0
                goto failed;
9042
0
            }
9043
0
            len = PyList_GET_SIZE(tmp);
9044
0
            items = _Py_asdl_withitem_seq_new(len, arena);
9045
0
            if (items == NULL) goto failed;
9046
0
            for (i = 0; i < len; i++) {
9047
0
                withitem_ty val;
9048
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9049
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
9050
0
                    goto failed;
9051
0
                }
9052
0
                res = obj2ast_withitem(state, tmp2, &val, "items", arena);
9053
0
                _Py_LeaveRecursiveCall();
9054
0
                Py_DECREF(tmp2);
9055
0
                if (res != 0) goto failed;
9056
0
                if (len != PyList_GET_SIZE(tmp)) {
9057
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
9058
0
                    goto failed;
9059
0
                }
9060
0
                asdl_seq_SET(items, i, val);
9061
0
            }
9062
0
            Py_CLEAR(tmp);
9063
0
        }
9064
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
9065
0
            return -1;
9066
0
        }
9067
0
        if (tmp == NULL) {
9068
0
            tmp = PyList_New(0);
9069
0
            if (tmp == NULL) {
9070
0
                return -1;
9071
0
            }
9072
0
        }
9073
0
        {
9074
0
            int res;
9075
0
            Py_ssize_t len;
9076
0
            Py_ssize_t i;
9077
0
            if (!PyList_Check(tmp)) {
9078
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %T", tmp);
9079
0
                goto failed;
9080
0
            }
9081
0
            len = PyList_GET_SIZE(tmp);
9082
0
            body = _Py_asdl_stmt_seq_new(len, arena);
9083
0
            if (body == NULL) goto failed;
9084
0
            for (i = 0; i < len; i++) {
9085
0
                stmt_ty val;
9086
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9087
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
9088
0
                    goto failed;
9089
0
                }
9090
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
9091
0
                _Py_LeaveRecursiveCall();
9092
0
                Py_DECREF(tmp2);
9093
0
                if (res != 0) goto failed;
9094
0
                if (len != PyList_GET_SIZE(tmp)) {
9095
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
9096
0
                    goto failed;
9097
0
                }
9098
0
                asdl_seq_SET(body, i, val);
9099
0
            }
9100
0
            Py_CLEAR(tmp);
9101
0
        }
9102
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
9103
0
            return -1;
9104
0
        }
9105
0
        if (tmp == NULL || tmp == Py_None) {
9106
0
            Py_CLEAR(tmp);
9107
0
            type_comment = NULL;
9108
0
        }
9109
0
        else {
9110
0
            int res;
9111
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
9112
0
                goto failed;
9113
0
            }
9114
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
9115
0
                                 arena);
9116
0
            _Py_LeaveRecursiveCall();
9117
0
            if (res != 0) goto failed;
9118
0
            Py_CLEAR(tmp);
9119
0
        }
9120
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
9121
0
                           end_lineno, end_col_offset, arena);
9122
0
        if (*out == NULL) goto failed;
9123
0
        return 0;
9124
0
    }
9125
0
    tp = state->AsyncWith_type;
9126
0
    isinstance = PyObject_IsInstance(obj, tp);
9127
0
    if (isinstance == -1) {
9128
0
        return -1;
9129
0
    }
9130
0
    if (isinstance) {
9131
0
        asdl_withitem_seq* items;
9132
0
        asdl_stmt_seq* body;
9133
0
        string type_comment;
9134
9135
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
9136
0
            return -1;
9137
0
        }
9138
0
        if (tmp == NULL) {
9139
0
            tmp = PyList_New(0);
9140
0
            if (tmp == NULL) {
9141
0
                return -1;
9142
0
            }
9143
0
        }
9144
0
        {
9145
0
            int res;
9146
0
            Py_ssize_t len;
9147
0
            Py_ssize_t i;
9148
0
            if (!PyList_Check(tmp)) {
9149
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %T", tmp);
9150
0
                goto failed;
9151
0
            }
9152
0
            len = PyList_GET_SIZE(tmp);
9153
0
            items = _Py_asdl_withitem_seq_new(len, arena);
9154
0
            if (items == NULL) goto failed;
9155
0
            for (i = 0; i < len; i++) {
9156
0
                withitem_ty val;
9157
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9158
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
9159
0
                    goto failed;
9160
0
                }
9161
0
                res = obj2ast_withitem(state, tmp2, &val, "items", arena);
9162
0
                _Py_LeaveRecursiveCall();
9163
0
                Py_DECREF(tmp2);
9164
0
                if (res != 0) goto failed;
9165
0
                if (len != PyList_GET_SIZE(tmp)) {
9166
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
9167
0
                    goto failed;
9168
0
                }
9169
0
                asdl_seq_SET(items, i, val);
9170
0
            }
9171
0
            Py_CLEAR(tmp);
9172
0
        }
9173
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
9174
0
            return -1;
9175
0
        }
9176
0
        if (tmp == NULL) {
9177
0
            tmp = PyList_New(0);
9178
0
            if (tmp == NULL) {
9179
0
                return -1;
9180
0
            }
9181
0
        }
9182
0
        {
9183
0
            int res;
9184
0
            Py_ssize_t len;
9185
0
            Py_ssize_t i;
9186
0
            if (!PyList_Check(tmp)) {
9187
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %T", tmp);
9188
0
                goto failed;
9189
0
            }
9190
0
            len = PyList_GET_SIZE(tmp);
9191
0
            body = _Py_asdl_stmt_seq_new(len, arena);
9192
0
            if (body == NULL) goto failed;
9193
0
            for (i = 0; i < len; i++) {
9194
0
                stmt_ty val;
9195
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9196
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
9197
0
                    goto failed;
9198
0
                }
9199
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
9200
0
                _Py_LeaveRecursiveCall();
9201
0
                Py_DECREF(tmp2);
9202
0
                if (res != 0) goto failed;
9203
0
                if (len != PyList_GET_SIZE(tmp)) {
9204
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
9205
0
                    goto failed;
9206
0
                }
9207
0
                asdl_seq_SET(body, i, val);
9208
0
            }
9209
0
            Py_CLEAR(tmp);
9210
0
        }
9211
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
9212
0
            return -1;
9213
0
        }
9214
0
        if (tmp == NULL || tmp == Py_None) {
9215
0
            Py_CLEAR(tmp);
9216
0
            type_comment = NULL;
9217
0
        }
9218
0
        else {
9219
0
            int res;
9220
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
9221
0
                goto failed;
9222
0
            }
9223
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
9224
0
                                 arena);
9225
0
            _Py_LeaveRecursiveCall();
9226
0
            if (res != 0) goto failed;
9227
0
            Py_CLEAR(tmp);
9228
0
        }
9229
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
9230
0
                                end_lineno, end_col_offset, arena);
9231
0
        if (*out == NULL) goto failed;
9232
0
        return 0;
9233
0
    }
9234
0
    tp = state->Match_type;
9235
0
    isinstance = PyObject_IsInstance(obj, tp);
9236
0
    if (isinstance == -1) {
9237
0
        return -1;
9238
0
    }
9239
0
    if (isinstance) {
9240
0
        expr_ty subject;
9241
0
        asdl_match_case_seq* cases;
9242
9243
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
9244
0
            return -1;
9245
0
        }
9246
0
        if (tmp == NULL) {
9247
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
9248
0
            return -1;
9249
0
        }
9250
0
        else {
9251
0
            int res;
9252
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
9253
0
                goto failed;
9254
0
            }
9255
0
            res = obj2ast_expr(state, tmp, &subject, "subject", arena);
9256
0
            _Py_LeaveRecursiveCall();
9257
0
            if (res != 0) goto failed;
9258
0
            Py_CLEAR(tmp);
9259
0
        }
9260
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
9261
0
            return -1;
9262
0
        }
9263
0
        if (tmp == NULL) {
9264
0
            tmp = PyList_New(0);
9265
0
            if (tmp == NULL) {
9266
0
                return -1;
9267
0
            }
9268
0
        }
9269
0
        {
9270
0
            int res;
9271
0
            Py_ssize_t len;
9272
0
            Py_ssize_t i;
9273
0
            if (!PyList_Check(tmp)) {
9274
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %T", tmp);
9275
0
                goto failed;
9276
0
            }
9277
0
            len = PyList_GET_SIZE(tmp);
9278
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
9279
0
            if (cases == NULL) goto failed;
9280
0
            for (i = 0; i < len; i++) {
9281
0
                match_case_ty val;
9282
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9283
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
9284
0
                    goto failed;
9285
0
                }
9286
0
                res = obj2ast_match_case(state, tmp2, &val, "cases", arena);
9287
0
                _Py_LeaveRecursiveCall();
9288
0
                Py_DECREF(tmp2);
9289
0
                if (res != 0) goto failed;
9290
0
                if (len != PyList_GET_SIZE(tmp)) {
9291
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
9292
0
                    goto failed;
9293
0
                }
9294
0
                asdl_seq_SET(cases, i, val);
9295
0
            }
9296
0
            Py_CLEAR(tmp);
9297
0
        }
9298
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
9299
0
                            end_col_offset, arena);
9300
0
        if (*out == NULL) goto failed;
9301
0
        return 0;
9302
0
    }
9303
0
    tp = state->Raise_type;
9304
0
    isinstance = PyObject_IsInstance(obj, tp);
9305
0
    if (isinstance == -1) {
9306
0
        return -1;
9307
0
    }
9308
0
    if (isinstance) {
9309
0
        expr_ty exc;
9310
0
        expr_ty cause;
9311
9312
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
9313
0
            return -1;
9314
0
        }
9315
0
        if (tmp == NULL || tmp == Py_None) {
9316
0
            Py_CLEAR(tmp);
9317
0
            exc = NULL;
9318
0
        }
9319
0
        else {
9320
0
            int res;
9321
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
9322
0
                goto failed;
9323
0
            }
9324
0
            res = obj2ast_expr(state, tmp, &exc, "exc", arena);
9325
0
            _Py_LeaveRecursiveCall();
9326
0
            if (res != 0) goto failed;
9327
0
            Py_CLEAR(tmp);
9328
0
        }
9329
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
9330
0
            return -1;
9331
0
        }
9332
0
        if (tmp == NULL || tmp == Py_None) {
9333
0
            Py_CLEAR(tmp);
9334
0
            cause = NULL;
9335
0
        }
9336
0
        else {
9337
0
            int res;
9338
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
9339
0
                goto failed;
9340
0
            }
9341
0
            res = obj2ast_expr(state, tmp, &cause, "cause", arena);
9342
0
            _Py_LeaveRecursiveCall();
9343
0
            if (res != 0) goto failed;
9344
0
            Py_CLEAR(tmp);
9345
0
        }
9346
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
9347
0
                            end_col_offset, arena);
9348
0
        if (*out == NULL) goto failed;
9349
0
        return 0;
9350
0
    }
9351
0
    tp = state->Try_type;
9352
0
    isinstance = PyObject_IsInstance(obj, tp);
9353
0
    if (isinstance == -1) {
9354
0
        return -1;
9355
0
    }
9356
0
    if (isinstance) {
9357
0
        asdl_stmt_seq* body;
9358
0
        asdl_excepthandler_seq* handlers;
9359
0
        asdl_stmt_seq* orelse;
9360
0
        asdl_stmt_seq* finalbody;
9361
9362
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
9363
0
            return -1;
9364
0
        }
9365
0
        if (tmp == NULL) {
9366
0
            tmp = PyList_New(0);
9367
0
            if (tmp == NULL) {
9368
0
                return -1;
9369
0
            }
9370
0
        }
9371
0
        {
9372
0
            int res;
9373
0
            Py_ssize_t len;
9374
0
            Py_ssize_t i;
9375
0
            if (!PyList_Check(tmp)) {
9376
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %T", tmp);
9377
0
                goto failed;
9378
0
            }
9379
0
            len = PyList_GET_SIZE(tmp);
9380
0
            body = _Py_asdl_stmt_seq_new(len, arena);
9381
0
            if (body == NULL) goto failed;
9382
0
            for (i = 0; i < len; i++) {
9383
0
                stmt_ty val;
9384
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9385
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
9386
0
                    goto failed;
9387
0
                }
9388
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
9389
0
                _Py_LeaveRecursiveCall();
9390
0
                Py_DECREF(tmp2);
9391
0
                if (res != 0) goto failed;
9392
0
                if (len != PyList_GET_SIZE(tmp)) {
9393
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
9394
0
                    goto failed;
9395
0
                }
9396
0
                asdl_seq_SET(body, i, val);
9397
0
            }
9398
0
            Py_CLEAR(tmp);
9399
0
        }
9400
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
9401
0
            return -1;
9402
0
        }
9403
0
        if (tmp == NULL) {
9404
0
            tmp = PyList_New(0);
9405
0
            if (tmp == NULL) {
9406
0
                return -1;
9407
0
            }
9408
0
        }
9409
0
        {
9410
0
            int res;
9411
0
            Py_ssize_t len;
9412
0
            Py_ssize_t i;
9413
0
            if (!PyList_Check(tmp)) {
9414
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %T", tmp);
9415
0
                goto failed;
9416
0
            }
9417
0
            len = PyList_GET_SIZE(tmp);
9418
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
9419
0
            if (handlers == NULL) goto failed;
9420
0
            for (i = 0; i < len; i++) {
9421
0
                excepthandler_ty val;
9422
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9423
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
9424
0
                    goto failed;
9425
0
                }
9426
0
                res = obj2ast_excepthandler(state, tmp2, &val, "handlers", arena);
9427
0
                _Py_LeaveRecursiveCall();
9428
0
                Py_DECREF(tmp2);
9429
0
                if (res != 0) goto failed;
9430
0
                if (len != PyList_GET_SIZE(tmp)) {
9431
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
9432
0
                    goto failed;
9433
0
                }
9434
0
                asdl_seq_SET(handlers, i, val);
9435
0
            }
9436
0
            Py_CLEAR(tmp);
9437
0
        }
9438
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
9439
0
            return -1;
9440
0
        }
9441
0
        if (tmp == NULL) {
9442
0
            tmp = PyList_New(0);
9443
0
            if (tmp == NULL) {
9444
0
                return -1;
9445
0
            }
9446
0
        }
9447
0
        {
9448
0
            int res;
9449
0
            Py_ssize_t len;
9450
0
            Py_ssize_t i;
9451
0
            if (!PyList_Check(tmp)) {
9452
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %T", tmp);
9453
0
                goto failed;
9454
0
            }
9455
0
            len = PyList_GET_SIZE(tmp);
9456
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
9457
0
            if (orelse == NULL) goto failed;
9458
0
            for (i = 0; i < len; i++) {
9459
0
                stmt_ty val;
9460
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9461
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
9462
0
                    goto failed;
9463
0
                }
9464
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
9465
0
                _Py_LeaveRecursiveCall();
9466
0
                Py_DECREF(tmp2);
9467
0
                if (res != 0) goto failed;
9468
0
                if (len != PyList_GET_SIZE(tmp)) {
9469
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
9470
0
                    goto failed;
9471
0
                }
9472
0
                asdl_seq_SET(orelse, i, val);
9473
0
            }
9474
0
            Py_CLEAR(tmp);
9475
0
        }
9476
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
9477
0
            return -1;
9478
0
        }
9479
0
        if (tmp == NULL) {
9480
0
            tmp = PyList_New(0);
9481
0
            if (tmp == NULL) {
9482
0
                return -1;
9483
0
            }
9484
0
        }
9485
0
        {
9486
0
            int res;
9487
0
            Py_ssize_t len;
9488
0
            Py_ssize_t i;
9489
0
            if (!PyList_Check(tmp)) {
9490
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %T", tmp);
9491
0
                goto failed;
9492
0
            }
9493
0
            len = PyList_GET_SIZE(tmp);
9494
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
9495
0
            if (finalbody == NULL) goto failed;
9496
0
            for (i = 0; i < len; i++) {
9497
0
                stmt_ty val;
9498
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9499
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
9500
0
                    goto failed;
9501
0
                }
9502
0
                res = obj2ast_stmt(state, tmp2, &val, "finalbody", arena);
9503
0
                _Py_LeaveRecursiveCall();
9504
0
                Py_DECREF(tmp2);
9505
0
                if (res != 0) goto failed;
9506
0
                if (len != PyList_GET_SIZE(tmp)) {
9507
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
9508
0
                    goto failed;
9509
0
                }
9510
0
                asdl_seq_SET(finalbody, i, val);
9511
0
            }
9512
0
            Py_CLEAR(tmp);
9513
0
        }
9514
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
9515
0
                          col_offset, end_lineno, end_col_offset, arena);
9516
0
        if (*out == NULL) goto failed;
9517
0
        return 0;
9518
0
    }
9519
0
    tp = state->TryStar_type;
9520
0
    isinstance = PyObject_IsInstance(obj, tp);
9521
0
    if (isinstance == -1) {
9522
0
        return -1;
9523
0
    }
9524
0
    if (isinstance) {
9525
0
        asdl_stmt_seq* body;
9526
0
        asdl_excepthandler_seq* handlers;
9527
0
        asdl_stmt_seq* orelse;
9528
0
        asdl_stmt_seq* finalbody;
9529
9530
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
9531
0
            return -1;
9532
0
        }
9533
0
        if (tmp == NULL) {
9534
0
            tmp = PyList_New(0);
9535
0
            if (tmp == NULL) {
9536
0
                return -1;
9537
0
            }
9538
0
        }
9539
0
        {
9540
0
            int res;
9541
0
            Py_ssize_t len;
9542
0
            Py_ssize_t i;
9543
0
            if (!PyList_Check(tmp)) {
9544
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %T", tmp);
9545
0
                goto failed;
9546
0
            }
9547
0
            len = PyList_GET_SIZE(tmp);
9548
0
            body = _Py_asdl_stmt_seq_new(len, arena);
9549
0
            if (body == NULL) goto failed;
9550
0
            for (i = 0; i < len; i++) {
9551
0
                stmt_ty val;
9552
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9553
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
9554
0
                    goto failed;
9555
0
                }
9556
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
9557
0
                _Py_LeaveRecursiveCall();
9558
0
                Py_DECREF(tmp2);
9559
0
                if (res != 0) goto failed;
9560
0
                if (len != PyList_GET_SIZE(tmp)) {
9561
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
9562
0
                    goto failed;
9563
0
                }
9564
0
                asdl_seq_SET(body, i, val);
9565
0
            }
9566
0
            Py_CLEAR(tmp);
9567
0
        }
9568
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
9569
0
            return -1;
9570
0
        }
9571
0
        if (tmp == NULL) {
9572
0
            tmp = PyList_New(0);
9573
0
            if (tmp == NULL) {
9574
0
                return -1;
9575
0
            }
9576
0
        }
9577
0
        {
9578
0
            int res;
9579
0
            Py_ssize_t len;
9580
0
            Py_ssize_t i;
9581
0
            if (!PyList_Check(tmp)) {
9582
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %T", tmp);
9583
0
                goto failed;
9584
0
            }
9585
0
            len = PyList_GET_SIZE(tmp);
9586
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
9587
0
            if (handlers == NULL) goto failed;
9588
0
            for (i = 0; i < len; i++) {
9589
0
                excepthandler_ty val;
9590
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9591
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
9592
0
                    goto failed;
9593
0
                }
9594
0
                res = obj2ast_excepthandler(state, tmp2, &val, "handlers", arena);
9595
0
                _Py_LeaveRecursiveCall();
9596
0
                Py_DECREF(tmp2);
9597
0
                if (res != 0) goto failed;
9598
0
                if (len != PyList_GET_SIZE(tmp)) {
9599
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
9600
0
                    goto failed;
9601
0
                }
9602
0
                asdl_seq_SET(handlers, i, val);
9603
0
            }
9604
0
            Py_CLEAR(tmp);
9605
0
        }
9606
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
9607
0
            return -1;
9608
0
        }
9609
0
        if (tmp == NULL) {
9610
0
            tmp = PyList_New(0);
9611
0
            if (tmp == NULL) {
9612
0
                return -1;
9613
0
            }
9614
0
        }
9615
0
        {
9616
0
            int res;
9617
0
            Py_ssize_t len;
9618
0
            Py_ssize_t i;
9619
0
            if (!PyList_Check(tmp)) {
9620
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %T", tmp);
9621
0
                goto failed;
9622
0
            }
9623
0
            len = PyList_GET_SIZE(tmp);
9624
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
9625
0
            if (orelse == NULL) goto failed;
9626
0
            for (i = 0; i < len; i++) {
9627
0
                stmt_ty val;
9628
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9629
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
9630
0
                    goto failed;
9631
0
                }
9632
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
9633
0
                _Py_LeaveRecursiveCall();
9634
0
                Py_DECREF(tmp2);
9635
0
                if (res != 0) goto failed;
9636
0
                if (len != PyList_GET_SIZE(tmp)) {
9637
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
9638
0
                    goto failed;
9639
0
                }
9640
0
                asdl_seq_SET(orelse, i, val);
9641
0
            }
9642
0
            Py_CLEAR(tmp);
9643
0
        }
9644
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
9645
0
            return -1;
9646
0
        }
9647
0
        if (tmp == NULL) {
9648
0
            tmp = PyList_New(0);
9649
0
            if (tmp == NULL) {
9650
0
                return -1;
9651
0
            }
9652
0
        }
9653
0
        {
9654
0
            int res;
9655
0
            Py_ssize_t len;
9656
0
            Py_ssize_t i;
9657
0
            if (!PyList_Check(tmp)) {
9658
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %T", tmp);
9659
0
                goto failed;
9660
0
            }
9661
0
            len = PyList_GET_SIZE(tmp);
9662
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
9663
0
            if (finalbody == NULL) goto failed;
9664
0
            for (i = 0; i < len; i++) {
9665
0
                stmt_ty val;
9666
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9667
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
9668
0
                    goto failed;
9669
0
                }
9670
0
                res = obj2ast_stmt(state, tmp2, &val, "finalbody", arena);
9671
0
                _Py_LeaveRecursiveCall();
9672
0
                Py_DECREF(tmp2);
9673
0
                if (res != 0) goto failed;
9674
0
                if (len != PyList_GET_SIZE(tmp)) {
9675
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
9676
0
                    goto failed;
9677
0
                }
9678
0
                asdl_seq_SET(finalbody, i, val);
9679
0
            }
9680
0
            Py_CLEAR(tmp);
9681
0
        }
9682
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
9683
0
                              col_offset, end_lineno, end_col_offset, arena);
9684
0
        if (*out == NULL) goto failed;
9685
0
        return 0;
9686
0
    }
9687
0
    tp = state->Assert_type;
9688
0
    isinstance = PyObject_IsInstance(obj, tp);
9689
0
    if (isinstance == -1) {
9690
0
        return -1;
9691
0
    }
9692
0
    if (isinstance) {
9693
0
        expr_ty test;
9694
0
        expr_ty msg;
9695
9696
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
9697
0
            return -1;
9698
0
        }
9699
0
        if (tmp == NULL) {
9700
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
9701
0
            return -1;
9702
0
        }
9703
0
        else {
9704
0
            int res;
9705
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
9706
0
                goto failed;
9707
0
            }
9708
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
9709
0
            _Py_LeaveRecursiveCall();
9710
0
            if (res != 0) goto failed;
9711
0
            Py_CLEAR(tmp);
9712
0
        }
9713
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
9714
0
            return -1;
9715
0
        }
9716
0
        if (tmp == NULL || tmp == Py_None) {
9717
0
            Py_CLEAR(tmp);
9718
0
            msg = NULL;
9719
0
        }
9720
0
        else {
9721
0
            int res;
9722
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
9723
0
                goto failed;
9724
0
            }
9725
0
            res = obj2ast_expr(state, tmp, &msg, "msg", arena);
9726
0
            _Py_LeaveRecursiveCall();
9727
0
            if (res != 0) goto failed;
9728
0
            Py_CLEAR(tmp);
9729
0
        }
9730
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
9731
0
                             end_col_offset, arena);
9732
0
        if (*out == NULL) goto failed;
9733
0
        return 0;
9734
0
    }
9735
0
    tp = state->Import_type;
9736
0
    isinstance = PyObject_IsInstance(obj, tp);
9737
0
    if (isinstance == -1) {
9738
0
        return -1;
9739
0
    }
9740
0
    if (isinstance) {
9741
0
        asdl_alias_seq* names;
9742
0
        int is_lazy;
9743
9744
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
9745
0
            return -1;
9746
0
        }
9747
0
        if (tmp == NULL) {
9748
0
            tmp = PyList_New(0);
9749
0
            if (tmp == NULL) {
9750
0
                return -1;
9751
0
            }
9752
0
        }
9753
0
        {
9754
0
            int res;
9755
0
            Py_ssize_t len;
9756
0
            Py_ssize_t i;
9757
0
            if (!PyList_Check(tmp)) {
9758
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %T", tmp);
9759
0
                goto failed;
9760
0
            }
9761
0
            len = PyList_GET_SIZE(tmp);
9762
0
            names = _Py_asdl_alias_seq_new(len, arena);
9763
0
            if (names == NULL) goto failed;
9764
0
            for (i = 0; i < len; i++) {
9765
0
                alias_ty val;
9766
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9767
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
9768
0
                    goto failed;
9769
0
                }
9770
0
                res = obj2ast_alias(state, tmp2, &val, "names", arena);
9771
0
                _Py_LeaveRecursiveCall();
9772
0
                Py_DECREF(tmp2);
9773
0
                if (res != 0) goto failed;
9774
0
                if (len != PyList_GET_SIZE(tmp)) {
9775
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
9776
0
                    goto failed;
9777
0
                }
9778
0
                asdl_seq_SET(names, i, val);
9779
0
            }
9780
0
            Py_CLEAR(tmp);
9781
0
        }
9782
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
9783
0
            return -1;
9784
0
        }
9785
0
        if (tmp == NULL || tmp == Py_None) {
9786
0
            Py_CLEAR(tmp);
9787
0
            is_lazy = 0;
9788
0
        }
9789
0
        else {
9790
0
            int res;
9791
0
            if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
9792
0
                goto failed;
9793
0
            }
9794
0
            res = obj2ast_int(state, tmp, &is_lazy, "is_lazy", arena);
9795
0
            _Py_LeaveRecursiveCall();
9796
0
            if (res != 0) goto failed;
9797
0
            Py_CLEAR(tmp);
9798
0
        }
9799
0
        *out = _PyAST_Import(names, is_lazy, lineno, col_offset, end_lineno,
9800
0
                             end_col_offset, arena);
9801
0
        if (*out == NULL) goto failed;
9802
0
        return 0;
9803
0
    }
9804
0
    tp = state->ImportFrom_type;
9805
0
    isinstance = PyObject_IsInstance(obj, tp);
9806
0
    if (isinstance == -1) {
9807
0
        return -1;
9808
0
    }
9809
0
    if (isinstance) {
9810
0
        identifier module;
9811
0
        asdl_alias_seq* names;
9812
0
        int level;
9813
0
        int is_lazy;
9814
9815
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
9816
0
            return -1;
9817
0
        }
9818
0
        if (tmp == NULL || tmp == Py_None) {
9819
0
            Py_CLEAR(tmp);
9820
0
            module = NULL;
9821
0
        }
9822
0
        else {
9823
0
            int res;
9824
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
9825
0
                goto failed;
9826
0
            }
9827
0
            res = obj2ast_identifier(state, tmp, &module, "module", arena);
9828
0
            _Py_LeaveRecursiveCall();
9829
0
            if (res != 0) goto failed;
9830
0
            Py_CLEAR(tmp);
9831
0
        }
9832
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
9833
0
            return -1;
9834
0
        }
9835
0
        if (tmp == NULL) {
9836
0
            tmp = PyList_New(0);
9837
0
            if (tmp == NULL) {
9838
0
                return -1;
9839
0
            }
9840
0
        }
9841
0
        {
9842
0
            int res;
9843
0
            Py_ssize_t len;
9844
0
            Py_ssize_t i;
9845
0
            if (!PyList_Check(tmp)) {
9846
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %T", tmp);
9847
0
                goto failed;
9848
0
            }
9849
0
            len = PyList_GET_SIZE(tmp);
9850
0
            names = _Py_asdl_alias_seq_new(len, arena);
9851
0
            if (names == NULL) goto failed;
9852
0
            for (i = 0; i < len; i++) {
9853
0
                alias_ty val;
9854
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9855
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
9856
0
                    goto failed;
9857
0
                }
9858
0
                res = obj2ast_alias(state, tmp2, &val, "names", arena);
9859
0
                _Py_LeaveRecursiveCall();
9860
0
                Py_DECREF(tmp2);
9861
0
                if (res != 0) goto failed;
9862
0
                if (len != PyList_GET_SIZE(tmp)) {
9863
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
9864
0
                    goto failed;
9865
0
                }
9866
0
                asdl_seq_SET(names, i, val);
9867
0
            }
9868
0
            Py_CLEAR(tmp);
9869
0
        }
9870
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
9871
0
            return -1;
9872
0
        }
9873
0
        if (tmp == NULL || tmp == Py_None) {
9874
0
            Py_CLEAR(tmp);
9875
0
            level = 0;
9876
0
        }
9877
0
        else {
9878
0
            int res;
9879
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
9880
0
                goto failed;
9881
0
            }
9882
0
            res = obj2ast_int(state, tmp, &level, "level", arena);
9883
0
            _Py_LeaveRecursiveCall();
9884
0
            if (res != 0) goto failed;
9885
0
            Py_CLEAR(tmp);
9886
0
        }
9887
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
9888
0
            return -1;
9889
0
        }
9890
0
        if (tmp == NULL || tmp == Py_None) {
9891
0
            Py_CLEAR(tmp);
9892
0
            is_lazy = 0;
9893
0
        }
9894
0
        else {
9895
0
            int res;
9896
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
9897
0
                goto failed;
9898
0
            }
9899
0
            res = obj2ast_int(state, tmp, &is_lazy, "is_lazy", arena);
9900
0
            _Py_LeaveRecursiveCall();
9901
0
            if (res != 0) goto failed;
9902
0
            Py_CLEAR(tmp);
9903
0
        }
9904
0
        *out = _PyAST_ImportFrom(module, names, level, is_lazy, lineno,
9905
0
                                 col_offset, end_lineno, end_col_offset, arena);
9906
0
        if (*out == NULL) goto failed;
9907
0
        return 0;
9908
0
    }
9909
0
    tp = state->Global_type;
9910
0
    isinstance = PyObject_IsInstance(obj, tp);
9911
0
    if (isinstance == -1) {
9912
0
        return -1;
9913
0
    }
9914
0
    if (isinstance) {
9915
0
        asdl_identifier_seq* names;
9916
9917
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
9918
0
            return -1;
9919
0
        }
9920
0
        if (tmp == NULL) {
9921
0
            tmp = PyList_New(0);
9922
0
            if (tmp == NULL) {
9923
0
                return -1;
9924
0
            }
9925
0
        }
9926
0
        {
9927
0
            int res;
9928
0
            Py_ssize_t len;
9929
0
            Py_ssize_t i;
9930
0
            if (!PyList_Check(tmp)) {
9931
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %T", tmp);
9932
0
                goto failed;
9933
0
            }
9934
0
            len = PyList_GET_SIZE(tmp);
9935
0
            names = _Py_asdl_identifier_seq_new(len, arena);
9936
0
            if (names == NULL) goto failed;
9937
0
            for (i = 0; i < len; i++) {
9938
0
                identifier val;
9939
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9940
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
9941
0
                    goto failed;
9942
0
                }
9943
0
                res = obj2ast_identifier(state, tmp2, &val, "names", arena);
9944
0
                _Py_LeaveRecursiveCall();
9945
0
                Py_DECREF(tmp2);
9946
0
                if (res != 0) goto failed;
9947
0
                if (len != PyList_GET_SIZE(tmp)) {
9948
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
9949
0
                    goto failed;
9950
0
                }
9951
0
                asdl_seq_SET(names, i, val);
9952
0
            }
9953
0
            Py_CLEAR(tmp);
9954
0
        }
9955
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
9956
0
                             end_col_offset, arena);
9957
0
        if (*out == NULL) goto failed;
9958
0
        return 0;
9959
0
    }
9960
0
    tp = state->Nonlocal_type;
9961
0
    isinstance = PyObject_IsInstance(obj, tp);
9962
0
    if (isinstance == -1) {
9963
0
        return -1;
9964
0
    }
9965
0
    if (isinstance) {
9966
0
        asdl_identifier_seq* names;
9967
9968
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
9969
0
            return -1;
9970
0
        }
9971
0
        if (tmp == NULL) {
9972
0
            tmp = PyList_New(0);
9973
0
            if (tmp == NULL) {
9974
0
                return -1;
9975
0
            }
9976
0
        }
9977
0
        {
9978
0
            int res;
9979
0
            Py_ssize_t len;
9980
0
            Py_ssize_t i;
9981
0
            if (!PyList_Check(tmp)) {
9982
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %T", tmp);
9983
0
                goto failed;
9984
0
            }
9985
0
            len = PyList_GET_SIZE(tmp);
9986
0
            names = _Py_asdl_identifier_seq_new(len, arena);
9987
0
            if (names == NULL) goto failed;
9988
0
            for (i = 0; i < len; i++) {
9989
0
                identifier val;
9990
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
9991
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
9992
0
                    goto failed;
9993
0
                }
9994
0
                res = obj2ast_identifier(state, tmp2, &val, "names", arena);
9995
0
                _Py_LeaveRecursiveCall();
9996
0
                Py_DECREF(tmp2);
9997
0
                if (res != 0) goto failed;
9998
0
                if (len != PyList_GET_SIZE(tmp)) {
9999
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
10000
0
                    goto failed;
10001
0
                }
10002
0
                asdl_seq_SET(names, i, val);
10003
0
            }
10004
0
            Py_CLEAR(tmp);
10005
0
        }
10006
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
10007
0
                               end_col_offset, arena);
10008
0
        if (*out == NULL) goto failed;
10009
0
        return 0;
10010
0
    }
10011
0
    tp = state->Expr_type;
10012
0
    isinstance = PyObject_IsInstance(obj, tp);
10013
0
    if (isinstance == -1) {
10014
0
        return -1;
10015
0
    }
10016
0
    if (isinstance) {
10017
0
        expr_ty value;
10018
10019
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
10020
0
            return -1;
10021
0
        }
10022
0
        if (tmp == NULL) {
10023
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
10024
0
            return -1;
10025
0
        }
10026
0
        else {
10027
0
            int res;
10028
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
10029
0
                goto failed;
10030
0
            }
10031
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
10032
0
            _Py_LeaveRecursiveCall();
10033
0
            if (res != 0) goto failed;
10034
0
            Py_CLEAR(tmp);
10035
0
        }
10036
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
10037
0
                           end_col_offset, arena);
10038
0
        if (*out == NULL) goto failed;
10039
0
        return 0;
10040
0
    }
10041
0
    tp = state->Pass_type;
10042
0
    isinstance = PyObject_IsInstance(obj, tp);
10043
0
    if (isinstance == -1) {
10044
0
        return -1;
10045
0
    }
10046
0
    if (isinstance) {
10047
10048
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
10049
0
                           arena);
10050
0
        if (*out == NULL) goto failed;
10051
0
        return 0;
10052
0
    }
10053
0
    tp = state->Break_type;
10054
0
    isinstance = PyObject_IsInstance(obj, tp);
10055
0
    if (isinstance == -1) {
10056
0
        return -1;
10057
0
    }
10058
0
    if (isinstance) {
10059
10060
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
10061
0
                            arena);
10062
0
        if (*out == NULL) goto failed;
10063
0
        return 0;
10064
0
    }
10065
0
    tp = state->Continue_type;
10066
0
    isinstance = PyObject_IsInstance(obj, tp);
10067
0
    if (isinstance == -1) {
10068
0
        return -1;
10069
0
    }
10070
0
    if (isinstance) {
10071
10072
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
10073
0
                               arena);
10074
0
        if (*out == NULL) goto failed;
10075
0
        return 0;
10076
0
    }
10077
10078
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
10079
0
    failed:
10080
0
    Py_XDECREF(tmp);
10081
0
    return -1;
10082
0
}
10083
10084
int
10085
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, const char*
10086
             field, PyArena* arena)
10087
0
{
10088
0
    int isinstance;
10089
10090
0
    PyObject *tmp = NULL;
10091
0
    PyObject *tp;
10092
0
    int lineno;
10093
0
    int col_offset;
10094
0
    int end_lineno;
10095
0
    int end_col_offset;
10096
10097
0
    if (obj == Py_None) {
10098
0
        *out = NULL;
10099
0
        return 0;
10100
0
    }
10101
0
    tp = state->expr_type;
10102
0
    isinstance = PyObject_IsInstance(obj, tp);
10103
0
    if (isinstance == -1) {
10104
0
        return 1;
10105
0
    }
10106
0
    if (!isinstance && field != NULL) {
10107
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'expr', got '%T'", field, obj);
10108
0
        return 1;
10109
0
    }
10110
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
10111
0
        return -1;
10112
0
    }
10113
0
    if (tmp == NULL) {
10114
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
10115
0
        return -1;
10116
0
    }
10117
0
    else {
10118
0
        int res;
10119
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
10120
0
            goto failed;
10121
0
        }
10122
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
10123
0
        _Py_LeaveRecursiveCall();
10124
0
        if (res != 0) goto failed;
10125
0
        Py_CLEAR(tmp);
10126
0
    }
10127
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
10128
0
        return -1;
10129
0
    }
10130
0
    if (tmp == NULL) {
10131
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
10132
0
        return -1;
10133
0
    }
10134
0
    else {
10135
0
        int res;
10136
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
10137
0
            goto failed;
10138
0
        }
10139
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
10140
0
        _Py_LeaveRecursiveCall();
10141
0
        if (res != 0) goto failed;
10142
0
        Py_CLEAR(tmp);
10143
0
    }
10144
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
10145
0
        return -1;
10146
0
    }
10147
0
    if (tmp == NULL || tmp == Py_None) {
10148
0
        Py_CLEAR(tmp);
10149
0
        end_lineno = lineno;
10150
0
    }
10151
0
    else {
10152
0
        int res;
10153
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
10154
0
            goto failed;
10155
0
        }
10156
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
10157
0
        _Py_LeaveRecursiveCall();
10158
0
        if (res != 0) goto failed;
10159
0
        Py_CLEAR(tmp);
10160
0
    }
10161
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
10162
0
        return -1;
10163
0
    }
10164
0
    if (tmp == NULL || tmp == Py_None) {
10165
0
        Py_CLEAR(tmp);
10166
0
        end_col_offset = col_offset;
10167
0
    }
10168
0
    else {
10169
0
        int res;
10170
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
10171
0
            goto failed;
10172
0
        }
10173
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
10174
0
        _Py_LeaveRecursiveCall();
10175
0
        if (res != 0) goto failed;
10176
0
        Py_CLEAR(tmp);
10177
0
    }
10178
0
    tp = state->BoolOp_type;
10179
0
    isinstance = PyObject_IsInstance(obj, tp);
10180
0
    if (isinstance == -1) {
10181
0
        return -1;
10182
0
    }
10183
0
    if (isinstance) {
10184
0
        boolop_ty op;
10185
0
        asdl_expr_seq* values;
10186
10187
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
10188
0
            return -1;
10189
0
        }
10190
0
        if (tmp == NULL) {
10191
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
10192
0
            return -1;
10193
0
        }
10194
0
        else {
10195
0
            int res;
10196
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
10197
0
                goto failed;
10198
0
            }
10199
0
            res = obj2ast_boolop(state, tmp, &op, "op", arena);
10200
0
            _Py_LeaveRecursiveCall();
10201
0
            if (res != 0) goto failed;
10202
0
            Py_CLEAR(tmp);
10203
0
        }
10204
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
10205
0
            return -1;
10206
0
        }
10207
0
        if (tmp == NULL) {
10208
0
            tmp = PyList_New(0);
10209
0
            if (tmp == NULL) {
10210
0
                return -1;
10211
0
            }
10212
0
        }
10213
0
        {
10214
0
            int res;
10215
0
            Py_ssize_t len;
10216
0
            Py_ssize_t i;
10217
0
            if (!PyList_Check(tmp)) {
10218
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %T", tmp);
10219
0
                goto failed;
10220
0
            }
10221
0
            len = PyList_GET_SIZE(tmp);
10222
0
            values = _Py_asdl_expr_seq_new(len, arena);
10223
0
            if (values == NULL) goto failed;
10224
0
            for (i = 0; i < len; i++) {
10225
0
                expr_ty val;
10226
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10227
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
10228
0
                    goto failed;
10229
0
                }
10230
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
10231
0
                _Py_LeaveRecursiveCall();
10232
0
                Py_DECREF(tmp2);
10233
0
                if (res != 0) goto failed;
10234
0
                if (len != PyList_GET_SIZE(tmp)) {
10235
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
10236
0
                    goto failed;
10237
0
                }
10238
0
                asdl_seq_SET(values, i, val);
10239
0
            }
10240
0
            Py_CLEAR(tmp);
10241
0
        }
10242
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
10243
0
                             end_col_offset, arena);
10244
0
        if (*out == NULL) goto failed;
10245
0
        return 0;
10246
0
    }
10247
0
    tp = state->NamedExpr_type;
10248
0
    isinstance = PyObject_IsInstance(obj, tp);
10249
0
    if (isinstance == -1) {
10250
0
        return -1;
10251
0
    }
10252
0
    if (isinstance) {
10253
0
        expr_ty target;
10254
0
        expr_ty value;
10255
10256
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
10257
0
            return -1;
10258
0
        }
10259
0
        if (tmp == NULL) {
10260
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
10261
0
            return -1;
10262
0
        }
10263
0
        else {
10264
0
            int res;
10265
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
10266
0
                goto failed;
10267
0
            }
10268
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
10269
0
            _Py_LeaveRecursiveCall();
10270
0
            if (res != 0) goto failed;
10271
0
            Py_CLEAR(tmp);
10272
0
        }
10273
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
10274
0
            return -1;
10275
0
        }
10276
0
        if (tmp == NULL) {
10277
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
10278
0
            return -1;
10279
0
        }
10280
0
        else {
10281
0
            int res;
10282
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
10283
0
                goto failed;
10284
0
            }
10285
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
10286
0
            _Py_LeaveRecursiveCall();
10287
0
            if (res != 0) goto failed;
10288
0
            Py_CLEAR(tmp);
10289
0
        }
10290
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
10291
0
                                end_col_offset, arena);
10292
0
        if (*out == NULL) goto failed;
10293
0
        return 0;
10294
0
    }
10295
0
    tp = state->BinOp_type;
10296
0
    isinstance = PyObject_IsInstance(obj, tp);
10297
0
    if (isinstance == -1) {
10298
0
        return -1;
10299
0
    }
10300
0
    if (isinstance) {
10301
0
        expr_ty left;
10302
0
        operator_ty op;
10303
0
        expr_ty right;
10304
10305
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
10306
0
            return -1;
10307
0
        }
10308
0
        if (tmp == NULL) {
10309
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
10310
0
            return -1;
10311
0
        }
10312
0
        else {
10313
0
            int res;
10314
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
10315
0
                goto failed;
10316
0
            }
10317
0
            res = obj2ast_expr(state, tmp, &left, "left", arena);
10318
0
            _Py_LeaveRecursiveCall();
10319
0
            if (res != 0) goto failed;
10320
0
            Py_CLEAR(tmp);
10321
0
        }
10322
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
10323
0
            return -1;
10324
0
        }
10325
0
        if (tmp == NULL) {
10326
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
10327
0
            return -1;
10328
0
        }
10329
0
        else {
10330
0
            int res;
10331
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
10332
0
                goto failed;
10333
0
            }
10334
0
            res = obj2ast_operator(state, tmp, &op, "op", arena);
10335
0
            _Py_LeaveRecursiveCall();
10336
0
            if (res != 0) goto failed;
10337
0
            Py_CLEAR(tmp);
10338
0
        }
10339
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
10340
0
            return -1;
10341
0
        }
10342
0
        if (tmp == NULL) {
10343
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
10344
0
            return -1;
10345
0
        }
10346
0
        else {
10347
0
            int res;
10348
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
10349
0
                goto failed;
10350
0
            }
10351
0
            res = obj2ast_expr(state, tmp, &right, "right", arena);
10352
0
            _Py_LeaveRecursiveCall();
10353
0
            if (res != 0) goto failed;
10354
0
            Py_CLEAR(tmp);
10355
0
        }
10356
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
10357
0
                            end_col_offset, arena);
10358
0
        if (*out == NULL) goto failed;
10359
0
        return 0;
10360
0
    }
10361
0
    tp = state->UnaryOp_type;
10362
0
    isinstance = PyObject_IsInstance(obj, tp);
10363
0
    if (isinstance == -1) {
10364
0
        return -1;
10365
0
    }
10366
0
    if (isinstance) {
10367
0
        unaryop_ty op;
10368
0
        expr_ty operand;
10369
10370
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
10371
0
            return -1;
10372
0
        }
10373
0
        if (tmp == NULL) {
10374
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
10375
0
            return -1;
10376
0
        }
10377
0
        else {
10378
0
            int res;
10379
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
10380
0
                goto failed;
10381
0
            }
10382
0
            res = obj2ast_unaryop(state, tmp, &op, "op", arena);
10383
0
            _Py_LeaveRecursiveCall();
10384
0
            if (res != 0) goto failed;
10385
0
            Py_CLEAR(tmp);
10386
0
        }
10387
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
10388
0
            return -1;
10389
0
        }
10390
0
        if (tmp == NULL) {
10391
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
10392
0
            return -1;
10393
0
        }
10394
0
        else {
10395
0
            int res;
10396
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
10397
0
                goto failed;
10398
0
            }
10399
0
            res = obj2ast_expr(state, tmp, &operand, "operand", arena);
10400
0
            _Py_LeaveRecursiveCall();
10401
0
            if (res != 0) goto failed;
10402
0
            Py_CLEAR(tmp);
10403
0
        }
10404
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
10405
0
                              end_col_offset, arena);
10406
0
        if (*out == NULL) goto failed;
10407
0
        return 0;
10408
0
    }
10409
0
    tp = state->Lambda_type;
10410
0
    isinstance = PyObject_IsInstance(obj, tp);
10411
0
    if (isinstance == -1) {
10412
0
        return -1;
10413
0
    }
10414
0
    if (isinstance) {
10415
0
        arguments_ty args;
10416
0
        expr_ty body;
10417
10418
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
10419
0
            return -1;
10420
0
        }
10421
0
        if (tmp == NULL) {
10422
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
10423
0
            return -1;
10424
0
        }
10425
0
        else {
10426
0
            int res;
10427
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
10428
0
                goto failed;
10429
0
            }
10430
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
10431
0
            _Py_LeaveRecursiveCall();
10432
0
            if (res != 0) goto failed;
10433
0
            Py_CLEAR(tmp);
10434
0
        }
10435
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10436
0
            return -1;
10437
0
        }
10438
0
        if (tmp == NULL) {
10439
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
10440
0
            return -1;
10441
0
        }
10442
0
        else {
10443
0
            int res;
10444
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
10445
0
                goto failed;
10446
0
            }
10447
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
10448
0
            _Py_LeaveRecursiveCall();
10449
0
            if (res != 0) goto failed;
10450
0
            Py_CLEAR(tmp);
10451
0
        }
10452
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
10453
0
                             end_col_offset, arena);
10454
0
        if (*out == NULL) goto failed;
10455
0
        return 0;
10456
0
    }
10457
0
    tp = state->IfExp_type;
10458
0
    isinstance = PyObject_IsInstance(obj, tp);
10459
0
    if (isinstance == -1) {
10460
0
        return -1;
10461
0
    }
10462
0
    if (isinstance) {
10463
0
        expr_ty test;
10464
0
        expr_ty body;
10465
0
        expr_ty orelse;
10466
10467
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
10468
0
            return -1;
10469
0
        }
10470
0
        if (tmp == NULL) {
10471
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
10472
0
            return -1;
10473
0
        }
10474
0
        else {
10475
0
            int res;
10476
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
10477
0
                goto failed;
10478
0
            }
10479
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
10480
0
            _Py_LeaveRecursiveCall();
10481
0
            if (res != 0) goto failed;
10482
0
            Py_CLEAR(tmp);
10483
0
        }
10484
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10485
0
            return -1;
10486
0
        }
10487
0
        if (tmp == NULL) {
10488
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
10489
0
            return -1;
10490
0
        }
10491
0
        else {
10492
0
            int res;
10493
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
10494
0
                goto failed;
10495
0
            }
10496
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
10497
0
            _Py_LeaveRecursiveCall();
10498
0
            if (res != 0) goto failed;
10499
0
            Py_CLEAR(tmp);
10500
0
        }
10501
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
10502
0
            return -1;
10503
0
        }
10504
0
        if (tmp == NULL) {
10505
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
10506
0
            return -1;
10507
0
        }
10508
0
        else {
10509
0
            int res;
10510
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
10511
0
                goto failed;
10512
0
            }
10513
0
            res = obj2ast_expr(state, tmp, &orelse, "orelse", arena);
10514
0
            _Py_LeaveRecursiveCall();
10515
0
            if (res != 0) goto failed;
10516
0
            Py_CLEAR(tmp);
10517
0
        }
10518
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
10519
0
                            end_col_offset, arena);
10520
0
        if (*out == NULL) goto failed;
10521
0
        return 0;
10522
0
    }
10523
0
    tp = state->Dict_type;
10524
0
    isinstance = PyObject_IsInstance(obj, tp);
10525
0
    if (isinstance == -1) {
10526
0
        return -1;
10527
0
    }
10528
0
    if (isinstance) {
10529
0
        asdl_expr_seq* keys;
10530
0
        asdl_expr_seq* values;
10531
10532
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
10533
0
            return -1;
10534
0
        }
10535
0
        if (tmp == NULL) {
10536
0
            tmp = PyList_New(0);
10537
0
            if (tmp == NULL) {
10538
0
                return -1;
10539
0
            }
10540
0
        }
10541
0
        {
10542
0
            int res;
10543
0
            Py_ssize_t len;
10544
0
            Py_ssize_t i;
10545
0
            if (!PyList_Check(tmp)) {
10546
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %T", tmp);
10547
0
                goto failed;
10548
0
            }
10549
0
            len = PyList_GET_SIZE(tmp);
10550
0
            keys = _Py_asdl_expr_seq_new(len, arena);
10551
0
            if (keys == NULL) goto failed;
10552
0
            for (i = 0; i < len; i++) {
10553
0
                expr_ty val;
10554
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10555
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
10556
0
                    goto failed;
10557
0
                }
10558
0
                res = obj2ast_expr(state, tmp2, &val, "keys", arena);
10559
0
                _Py_LeaveRecursiveCall();
10560
0
                Py_DECREF(tmp2);
10561
0
                if (res != 0) goto failed;
10562
0
                if (len != PyList_GET_SIZE(tmp)) {
10563
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
10564
0
                    goto failed;
10565
0
                }
10566
0
                asdl_seq_SET(keys, i, val);
10567
0
            }
10568
0
            Py_CLEAR(tmp);
10569
0
        }
10570
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
10571
0
            return -1;
10572
0
        }
10573
0
        if (tmp == NULL) {
10574
0
            tmp = PyList_New(0);
10575
0
            if (tmp == NULL) {
10576
0
                return -1;
10577
0
            }
10578
0
        }
10579
0
        {
10580
0
            int res;
10581
0
            Py_ssize_t len;
10582
0
            Py_ssize_t i;
10583
0
            if (!PyList_Check(tmp)) {
10584
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %T", tmp);
10585
0
                goto failed;
10586
0
            }
10587
0
            len = PyList_GET_SIZE(tmp);
10588
0
            values = _Py_asdl_expr_seq_new(len, arena);
10589
0
            if (values == NULL) goto failed;
10590
0
            for (i = 0; i < len; i++) {
10591
0
                expr_ty val;
10592
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10593
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
10594
0
                    goto failed;
10595
0
                }
10596
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
10597
0
                _Py_LeaveRecursiveCall();
10598
0
                Py_DECREF(tmp2);
10599
0
                if (res != 0) goto failed;
10600
0
                if (len != PyList_GET_SIZE(tmp)) {
10601
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
10602
0
                    goto failed;
10603
0
                }
10604
0
                asdl_seq_SET(values, i, val);
10605
0
            }
10606
0
            Py_CLEAR(tmp);
10607
0
        }
10608
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
10609
0
                           end_col_offset, arena);
10610
0
        if (*out == NULL) goto failed;
10611
0
        return 0;
10612
0
    }
10613
0
    tp = state->Set_type;
10614
0
    isinstance = PyObject_IsInstance(obj, tp);
10615
0
    if (isinstance == -1) {
10616
0
        return -1;
10617
0
    }
10618
0
    if (isinstance) {
10619
0
        asdl_expr_seq* elts;
10620
10621
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
10622
0
            return -1;
10623
0
        }
10624
0
        if (tmp == NULL) {
10625
0
            tmp = PyList_New(0);
10626
0
            if (tmp == NULL) {
10627
0
                return -1;
10628
0
            }
10629
0
        }
10630
0
        {
10631
0
            int res;
10632
0
            Py_ssize_t len;
10633
0
            Py_ssize_t i;
10634
0
            if (!PyList_Check(tmp)) {
10635
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %T", tmp);
10636
0
                goto failed;
10637
0
            }
10638
0
            len = PyList_GET_SIZE(tmp);
10639
0
            elts = _Py_asdl_expr_seq_new(len, arena);
10640
0
            if (elts == NULL) goto failed;
10641
0
            for (i = 0; i < len; i++) {
10642
0
                expr_ty val;
10643
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10644
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
10645
0
                    goto failed;
10646
0
                }
10647
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
10648
0
                _Py_LeaveRecursiveCall();
10649
0
                Py_DECREF(tmp2);
10650
0
                if (res != 0) goto failed;
10651
0
                if (len != PyList_GET_SIZE(tmp)) {
10652
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
10653
0
                    goto failed;
10654
0
                }
10655
0
                asdl_seq_SET(elts, i, val);
10656
0
            }
10657
0
            Py_CLEAR(tmp);
10658
0
        }
10659
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
10660
0
                          arena);
10661
0
        if (*out == NULL) goto failed;
10662
0
        return 0;
10663
0
    }
10664
0
    tp = state->ListComp_type;
10665
0
    isinstance = PyObject_IsInstance(obj, tp);
10666
0
    if (isinstance == -1) {
10667
0
        return -1;
10668
0
    }
10669
0
    if (isinstance) {
10670
0
        expr_ty elt;
10671
0
        asdl_comprehension_seq* generators;
10672
10673
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
10674
0
            return -1;
10675
0
        }
10676
0
        if (tmp == NULL) {
10677
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
10678
0
            return -1;
10679
0
        }
10680
0
        else {
10681
0
            int res;
10682
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
10683
0
                goto failed;
10684
0
            }
10685
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
10686
0
            _Py_LeaveRecursiveCall();
10687
0
            if (res != 0) goto failed;
10688
0
            Py_CLEAR(tmp);
10689
0
        }
10690
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
10691
0
            return -1;
10692
0
        }
10693
0
        if (tmp == NULL) {
10694
0
            tmp = PyList_New(0);
10695
0
            if (tmp == NULL) {
10696
0
                return -1;
10697
0
            }
10698
0
        }
10699
0
        {
10700
0
            int res;
10701
0
            Py_ssize_t len;
10702
0
            Py_ssize_t i;
10703
0
            if (!PyList_Check(tmp)) {
10704
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %T", tmp);
10705
0
                goto failed;
10706
0
            }
10707
0
            len = PyList_GET_SIZE(tmp);
10708
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
10709
0
            if (generators == NULL) goto failed;
10710
0
            for (i = 0; i < len; i++) {
10711
0
                comprehension_ty val;
10712
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10713
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
10714
0
                    goto failed;
10715
0
                }
10716
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
10717
0
                _Py_LeaveRecursiveCall();
10718
0
                Py_DECREF(tmp2);
10719
0
                if (res != 0) goto failed;
10720
0
                if (len != PyList_GET_SIZE(tmp)) {
10721
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
10722
0
                    goto failed;
10723
0
                }
10724
0
                asdl_seq_SET(generators, i, val);
10725
0
            }
10726
0
            Py_CLEAR(tmp);
10727
0
        }
10728
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
10729
0
                               end_col_offset, arena);
10730
0
        if (*out == NULL) goto failed;
10731
0
        return 0;
10732
0
    }
10733
0
    tp = state->SetComp_type;
10734
0
    isinstance = PyObject_IsInstance(obj, tp);
10735
0
    if (isinstance == -1) {
10736
0
        return -1;
10737
0
    }
10738
0
    if (isinstance) {
10739
0
        expr_ty elt;
10740
0
        asdl_comprehension_seq* generators;
10741
10742
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
10743
0
            return -1;
10744
0
        }
10745
0
        if (tmp == NULL) {
10746
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
10747
0
            return -1;
10748
0
        }
10749
0
        else {
10750
0
            int res;
10751
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
10752
0
                goto failed;
10753
0
            }
10754
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
10755
0
            _Py_LeaveRecursiveCall();
10756
0
            if (res != 0) goto failed;
10757
0
            Py_CLEAR(tmp);
10758
0
        }
10759
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
10760
0
            return -1;
10761
0
        }
10762
0
        if (tmp == NULL) {
10763
0
            tmp = PyList_New(0);
10764
0
            if (tmp == NULL) {
10765
0
                return -1;
10766
0
            }
10767
0
        }
10768
0
        {
10769
0
            int res;
10770
0
            Py_ssize_t len;
10771
0
            Py_ssize_t i;
10772
0
            if (!PyList_Check(tmp)) {
10773
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %T", tmp);
10774
0
                goto failed;
10775
0
            }
10776
0
            len = PyList_GET_SIZE(tmp);
10777
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
10778
0
            if (generators == NULL) goto failed;
10779
0
            for (i = 0; i < len; i++) {
10780
0
                comprehension_ty val;
10781
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10782
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
10783
0
                    goto failed;
10784
0
                }
10785
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
10786
0
                _Py_LeaveRecursiveCall();
10787
0
                Py_DECREF(tmp2);
10788
0
                if (res != 0) goto failed;
10789
0
                if (len != PyList_GET_SIZE(tmp)) {
10790
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
10791
0
                    goto failed;
10792
0
                }
10793
0
                asdl_seq_SET(generators, i, val);
10794
0
            }
10795
0
            Py_CLEAR(tmp);
10796
0
        }
10797
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
10798
0
                              end_col_offset, arena);
10799
0
        if (*out == NULL) goto failed;
10800
0
        return 0;
10801
0
    }
10802
0
    tp = state->DictComp_type;
10803
0
    isinstance = PyObject_IsInstance(obj, tp);
10804
0
    if (isinstance == -1) {
10805
0
        return -1;
10806
0
    }
10807
0
    if (isinstance) {
10808
0
        expr_ty key;
10809
0
        expr_ty value;
10810
0
        asdl_comprehension_seq* generators;
10811
10812
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
10813
0
            return -1;
10814
0
        }
10815
0
        if (tmp == NULL) {
10816
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
10817
0
            return -1;
10818
0
        }
10819
0
        else {
10820
0
            int res;
10821
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
10822
0
                goto failed;
10823
0
            }
10824
0
            res = obj2ast_expr(state, tmp, &key, "key", arena);
10825
0
            _Py_LeaveRecursiveCall();
10826
0
            if (res != 0) goto failed;
10827
0
            Py_CLEAR(tmp);
10828
0
        }
10829
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
10830
0
            return -1;
10831
0
        }
10832
0
        if (tmp == NULL || tmp == Py_None) {
10833
0
            Py_CLEAR(tmp);
10834
0
            value = NULL;
10835
0
        }
10836
0
        else {
10837
0
            int res;
10838
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
10839
0
                goto failed;
10840
0
            }
10841
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
10842
0
            _Py_LeaveRecursiveCall();
10843
0
            if (res != 0) goto failed;
10844
0
            Py_CLEAR(tmp);
10845
0
        }
10846
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
10847
0
            return -1;
10848
0
        }
10849
0
        if (tmp == NULL) {
10850
0
            tmp = PyList_New(0);
10851
0
            if (tmp == NULL) {
10852
0
                return -1;
10853
0
            }
10854
0
        }
10855
0
        {
10856
0
            int res;
10857
0
            Py_ssize_t len;
10858
0
            Py_ssize_t i;
10859
0
            if (!PyList_Check(tmp)) {
10860
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %T", tmp);
10861
0
                goto failed;
10862
0
            }
10863
0
            len = PyList_GET_SIZE(tmp);
10864
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
10865
0
            if (generators == NULL) goto failed;
10866
0
            for (i = 0; i < len; i++) {
10867
0
                comprehension_ty val;
10868
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10869
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
10870
0
                    goto failed;
10871
0
                }
10872
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
10873
0
                _Py_LeaveRecursiveCall();
10874
0
                Py_DECREF(tmp2);
10875
0
                if (res != 0) goto failed;
10876
0
                if (len != PyList_GET_SIZE(tmp)) {
10877
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
10878
0
                    goto failed;
10879
0
                }
10880
0
                asdl_seq_SET(generators, i, val);
10881
0
            }
10882
0
            Py_CLEAR(tmp);
10883
0
        }
10884
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
10885
0
                               end_lineno, end_col_offset, arena);
10886
0
        if (*out == NULL) goto failed;
10887
0
        return 0;
10888
0
    }
10889
0
    tp = state->GeneratorExp_type;
10890
0
    isinstance = PyObject_IsInstance(obj, tp);
10891
0
    if (isinstance == -1) {
10892
0
        return -1;
10893
0
    }
10894
0
    if (isinstance) {
10895
0
        expr_ty elt;
10896
0
        asdl_comprehension_seq* generators;
10897
10898
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
10899
0
            return -1;
10900
0
        }
10901
0
        if (tmp == NULL) {
10902
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
10903
0
            return -1;
10904
0
        }
10905
0
        else {
10906
0
            int res;
10907
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
10908
0
                goto failed;
10909
0
            }
10910
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
10911
0
            _Py_LeaveRecursiveCall();
10912
0
            if (res != 0) goto failed;
10913
0
            Py_CLEAR(tmp);
10914
0
        }
10915
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
10916
0
            return -1;
10917
0
        }
10918
0
        if (tmp == NULL) {
10919
0
            tmp = PyList_New(0);
10920
0
            if (tmp == NULL) {
10921
0
                return -1;
10922
0
            }
10923
0
        }
10924
0
        {
10925
0
            int res;
10926
0
            Py_ssize_t len;
10927
0
            Py_ssize_t i;
10928
0
            if (!PyList_Check(tmp)) {
10929
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %T", tmp);
10930
0
                goto failed;
10931
0
            }
10932
0
            len = PyList_GET_SIZE(tmp);
10933
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
10934
0
            if (generators == NULL) goto failed;
10935
0
            for (i = 0; i < len; i++) {
10936
0
                comprehension_ty val;
10937
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10938
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
10939
0
                    goto failed;
10940
0
                }
10941
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
10942
0
                _Py_LeaveRecursiveCall();
10943
0
                Py_DECREF(tmp2);
10944
0
                if (res != 0) goto failed;
10945
0
                if (len != PyList_GET_SIZE(tmp)) {
10946
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
10947
0
                    goto failed;
10948
0
                }
10949
0
                asdl_seq_SET(generators, i, val);
10950
0
            }
10951
0
            Py_CLEAR(tmp);
10952
0
        }
10953
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
10954
0
                                   end_lineno, end_col_offset, arena);
10955
0
        if (*out == NULL) goto failed;
10956
0
        return 0;
10957
0
    }
10958
0
    tp = state->Await_type;
10959
0
    isinstance = PyObject_IsInstance(obj, tp);
10960
0
    if (isinstance == -1) {
10961
0
        return -1;
10962
0
    }
10963
0
    if (isinstance) {
10964
0
        expr_ty value;
10965
10966
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
10967
0
            return -1;
10968
0
        }
10969
0
        if (tmp == NULL) {
10970
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
10971
0
            return -1;
10972
0
        }
10973
0
        else {
10974
0
            int res;
10975
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
10976
0
                goto failed;
10977
0
            }
10978
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
10979
0
            _Py_LeaveRecursiveCall();
10980
0
            if (res != 0) goto failed;
10981
0
            Py_CLEAR(tmp);
10982
0
        }
10983
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
10984
0
                            end_col_offset, arena);
10985
0
        if (*out == NULL) goto failed;
10986
0
        return 0;
10987
0
    }
10988
0
    tp = state->Yield_type;
10989
0
    isinstance = PyObject_IsInstance(obj, tp);
10990
0
    if (isinstance == -1) {
10991
0
        return -1;
10992
0
    }
10993
0
    if (isinstance) {
10994
0
        expr_ty value;
10995
10996
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
10997
0
            return -1;
10998
0
        }
10999
0
        if (tmp == NULL || tmp == Py_None) {
11000
0
            Py_CLEAR(tmp);
11001
0
            value = NULL;
11002
0
        }
11003
0
        else {
11004
0
            int res;
11005
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
11006
0
                goto failed;
11007
0
            }
11008
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11009
0
            _Py_LeaveRecursiveCall();
11010
0
            if (res != 0) goto failed;
11011
0
            Py_CLEAR(tmp);
11012
0
        }
11013
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
11014
0
                            end_col_offset, arena);
11015
0
        if (*out == NULL) goto failed;
11016
0
        return 0;
11017
0
    }
11018
0
    tp = state->YieldFrom_type;
11019
0
    isinstance = PyObject_IsInstance(obj, tp);
11020
0
    if (isinstance == -1) {
11021
0
        return -1;
11022
0
    }
11023
0
    if (isinstance) {
11024
0
        expr_ty value;
11025
11026
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11027
0
            return -1;
11028
0
        }
11029
0
        if (tmp == NULL) {
11030
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
11031
0
            return -1;
11032
0
        }
11033
0
        else {
11034
0
            int res;
11035
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
11036
0
                goto failed;
11037
0
            }
11038
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11039
0
            _Py_LeaveRecursiveCall();
11040
0
            if (res != 0) goto failed;
11041
0
            Py_CLEAR(tmp);
11042
0
        }
11043
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
11044
0
                                end_col_offset, arena);
11045
0
        if (*out == NULL) goto failed;
11046
0
        return 0;
11047
0
    }
11048
0
    tp = state->Compare_type;
11049
0
    isinstance = PyObject_IsInstance(obj, tp);
11050
0
    if (isinstance == -1) {
11051
0
        return -1;
11052
0
    }
11053
0
    if (isinstance) {
11054
0
        expr_ty left;
11055
0
        asdl_int_seq* ops;
11056
0
        asdl_expr_seq* comparators;
11057
11058
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
11059
0
            return -1;
11060
0
        }
11061
0
        if (tmp == NULL) {
11062
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
11063
0
            return -1;
11064
0
        }
11065
0
        else {
11066
0
            int res;
11067
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
11068
0
                goto failed;
11069
0
            }
11070
0
            res = obj2ast_expr(state, tmp, &left, "left", arena);
11071
0
            _Py_LeaveRecursiveCall();
11072
0
            if (res != 0) goto failed;
11073
0
            Py_CLEAR(tmp);
11074
0
        }
11075
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
11076
0
            return -1;
11077
0
        }
11078
0
        if (tmp == NULL) {
11079
0
            tmp = PyList_New(0);
11080
0
            if (tmp == NULL) {
11081
0
                return -1;
11082
0
            }
11083
0
        }
11084
0
        {
11085
0
            int res;
11086
0
            Py_ssize_t len;
11087
0
            Py_ssize_t i;
11088
0
            if (!PyList_Check(tmp)) {
11089
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %T", tmp);
11090
0
                goto failed;
11091
0
            }
11092
0
            len = PyList_GET_SIZE(tmp);
11093
0
            ops = _Py_asdl_int_seq_new(len, arena);
11094
0
            if (ops == NULL) goto failed;
11095
0
            for (i = 0; i < len; i++) {
11096
0
                cmpop_ty val;
11097
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11098
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
11099
0
                    goto failed;
11100
0
                }
11101
0
                res = obj2ast_cmpop(state, tmp2, &val, "ops", arena);
11102
0
                _Py_LeaveRecursiveCall();
11103
0
                Py_DECREF(tmp2);
11104
0
                if (res != 0) goto failed;
11105
0
                if (len != PyList_GET_SIZE(tmp)) {
11106
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
11107
0
                    goto failed;
11108
0
                }
11109
0
                asdl_seq_SET(ops, i, val);
11110
0
            }
11111
0
            Py_CLEAR(tmp);
11112
0
        }
11113
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
11114
0
            return -1;
11115
0
        }
11116
0
        if (tmp == NULL) {
11117
0
            tmp = PyList_New(0);
11118
0
            if (tmp == NULL) {
11119
0
                return -1;
11120
0
            }
11121
0
        }
11122
0
        {
11123
0
            int res;
11124
0
            Py_ssize_t len;
11125
0
            Py_ssize_t i;
11126
0
            if (!PyList_Check(tmp)) {
11127
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %T", tmp);
11128
0
                goto failed;
11129
0
            }
11130
0
            len = PyList_GET_SIZE(tmp);
11131
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
11132
0
            if (comparators == NULL) goto failed;
11133
0
            for (i = 0; i < len; i++) {
11134
0
                expr_ty val;
11135
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11136
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
11137
0
                    goto failed;
11138
0
                }
11139
0
                res = obj2ast_expr(state, tmp2, &val, "comparators", arena);
11140
0
                _Py_LeaveRecursiveCall();
11141
0
                Py_DECREF(tmp2);
11142
0
                if (res != 0) goto failed;
11143
0
                if (len != PyList_GET_SIZE(tmp)) {
11144
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
11145
0
                    goto failed;
11146
0
                }
11147
0
                asdl_seq_SET(comparators, i, val);
11148
0
            }
11149
0
            Py_CLEAR(tmp);
11150
0
        }
11151
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
11152
0
                              end_lineno, end_col_offset, arena);
11153
0
        if (*out == NULL) goto failed;
11154
0
        return 0;
11155
0
    }
11156
0
    tp = state->Call_type;
11157
0
    isinstance = PyObject_IsInstance(obj, tp);
11158
0
    if (isinstance == -1) {
11159
0
        return -1;
11160
0
    }
11161
0
    if (isinstance) {
11162
0
        expr_ty func;
11163
0
        asdl_expr_seq* args;
11164
0
        asdl_keyword_seq* keywords;
11165
11166
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
11167
0
            return -1;
11168
0
        }
11169
0
        if (tmp == NULL) {
11170
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
11171
0
            return -1;
11172
0
        }
11173
0
        else {
11174
0
            int res;
11175
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
11176
0
                goto failed;
11177
0
            }
11178
0
            res = obj2ast_expr(state, tmp, &func, "func", arena);
11179
0
            _Py_LeaveRecursiveCall();
11180
0
            if (res != 0) goto failed;
11181
0
            Py_CLEAR(tmp);
11182
0
        }
11183
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11184
0
            return -1;
11185
0
        }
11186
0
        if (tmp == NULL) {
11187
0
            tmp = PyList_New(0);
11188
0
            if (tmp == NULL) {
11189
0
                return -1;
11190
0
            }
11191
0
        }
11192
0
        {
11193
0
            int res;
11194
0
            Py_ssize_t len;
11195
0
            Py_ssize_t i;
11196
0
            if (!PyList_Check(tmp)) {
11197
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %T", tmp);
11198
0
                goto failed;
11199
0
            }
11200
0
            len = PyList_GET_SIZE(tmp);
11201
0
            args = _Py_asdl_expr_seq_new(len, arena);
11202
0
            if (args == NULL) goto failed;
11203
0
            for (i = 0; i < len; i++) {
11204
0
                expr_ty val;
11205
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11206
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
11207
0
                    goto failed;
11208
0
                }
11209
0
                res = obj2ast_expr(state, tmp2, &val, "args", arena);
11210
0
                _Py_LeaveRecursiveCall();
11211
0
                Py_DECREF(tmp2);
11212
0
                if (res != 0) goto failed;
11213
0
                if (len != PyList_GET_SIZE(tmp)) {
11214
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
11215
0
                    goto failed;
11216
0
                }
11217
0
                asdl_seq_SET(args, i, val);
11218
0
            }
11219
0
            Py_CLEAR(tmp);
11220
0
        }
11221
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11222
0
            return -1;
11223
0
        }
11224
0
        if (tmp == NULL) {
11225
0
            tmp = PyList_New(0);
11226
0
            if (tmp == NULL) {
11227
0
                return -1;
11228
0
            }
11229
0
        }
11230
0
        {
11231
0
            int res;
11232
0
            Py_ssize_t len;
11233
0
            Py_ssize_t i;
11234
0
            if (!PyList_Check(tmp)) {
11235
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %T", tmp);
11236
0
                goto failed;
11237
0
            }
11238
0
            len = PyList_GET_SIZE(tmp);
11239
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11240
0
            if (keywords == NULL) goto failed;
11241
0
            for (i = 0; i < len; i++) {
11242
0
                keyword_ty val;
11243
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11244
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
11245
0
                    goto failed;
11246
0
                }
11247
0
                res = obj2ast_keyword(state, tmp2, &val, "keywords", arena);
11248
0
                _Py_LeaveRecursiveCall();
11249
0
                Py_DECREF(tmp2);
11250
0
                if (res != 0) goto failed;
11251
0
                if (len != PyList_GET_SIZE(tmp)) {
11252
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
11253
0
                    goto failed;
11254
0
                }
11255
0
                asdl_seq_SET(keywords, i, val);
11256
0
            }
11257
0
            Py_CLEAR(tmp);
11258
0
        }
11259
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
11260
0
                           end_lineno, end_col_offset, arena);
11261
0
        if (*out == NULL) goto failed;
11262
0
        return 0;
11263
0
    }
11264
0
    tp = state->FormattedValue_type;
11265
0
    isinstance = PyObject_IsInstance(obj, tp);
11266
0
    if (isinstance == -1) {
11267
0
        return -1;
11268
0
    }
11269
0
    if (isinstance) {
11270
0
        expr_ty value;
11271
0
        int conversion;
11272
0
        expr_ty format_spec;
11273
11274
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11275
0
            return -1;
11276
0
        }
11277
0
        if (tmp == NULL) {
11278
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
11279
0
            return -1;
11280
0
        }
11281
0
        else {
11282
0
            int res;
11283
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
11284
0
                goto failed;
11285
0
            }
11286
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11287
0
            _Py_LeaveRecursiveCall();
11288
0
            if (res != 0) goto failed;
11289
0
            Py_CLEAR(tmp);
11290
0
        }
11291
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
11292
0
            return -1;
11293
0
        }
11294
0
        if (tmp == NULL) {
11295
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
11296
0
            return -1;
11297
0
        }
11298
0
        else {
11299
0
            int res;
11300
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
11301
0
                goto failed;
11302
0
            }
11303
0
            res = obj2ast_int(state, tmp, &conversion, "conversion", arena);
11304
0
            _Py_LeaveRecursiveCall();
11305
0
            if (res != 0) goto failed;
11306
0
            Py_CLEAR(tmp);
11307
0
        }
11308
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
11309
0
            return -1;
11310
0
        }
11311
0
        if (tmp == NULL || tmp == Py_None) {
11312
0
            Py_CLEAR(tmp);
11313
0
            format_spec = NULL;
11314
0
        }
11315
0
        else {
11316
0
            int res;
11317
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
11318
0
                goto failed;
11319
0
            }
11320
0
            res = obj2ast_expr(state, tmp, &format_spec, "format_spec", arena);
11321
0
            _Py_LeaveRecursiveCall();
11322
0
            if (res != 0) goto failed;
11323
0
            Py_CLEAR(tmp);
11324
0
        }
11325
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
11326
0
                                     col_offset, end_lineno, end_col_offset,
11327
0
                                     arena);
11328
0
        if (*out == NULL) goto failed;
11329
0
        return 0;
11330
0
    }
11331
0
    tp = state->Interpolation_type;
11332
0
    isinstance = PyObject_IsInstance(obj, tp);
11333
0
    if (isinstance == -1) {
11334
0
        return -1;
11335
0
    }
11336
0
    if (isinstance) {
11337
0
        expr_ty value;
11338
0
        constant str;
11339
0
        int conversion;
11340
0
        expr_ty format_spec;
11341
11342
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11343
0
            return -1;
11344
0
        }
11345
0
        if (tmp == NULL) {
11346
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
11347
0
            return -1;
11348
0
        }
11349
0
        else {
11350
0
            int res;
11351
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
11352
0
                goto failed;
11353
0
            }
11354
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11355
0
            _Py_LeaveRecursiveCall();
11356
0
            if (res != 0) goto failed;
11357
0
            Py_CLEAR(tmp);
11358
0
        }
11359
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
11360
0
            return -1;
11361
0
        }
11362
0
        if (tmp == NULL) {
11363
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
11364
0
            return -1;
11365
0
        }
11366
0
        else {
11367
0
            int res;
11368
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
11369
0
                goto failed;
11370
0
            }
11371
0
            res = obj2ast_constant(state, tmp, &str, "str", arena);
11372
0
            _Py_LeaveRecursiveCall();
11373
0
            if (res != 0) goto failed;
11374
0
            Py_CLEAR(tmp);
11375
0
        }
11376
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
11377
0
            return -1;
11378
0
        }
11379
0
        if (tmp == NULL) {
11380
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
11381
0
            return -1;
11382
0
        }
11383
0
        else {
11384
0
            int res;
11385
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
11386
0
                goto failed;
11387
0
            }
11388
0
            res = obj2ast_int(state, tmp, &conversion, "conversion", arena);
11389
0
            _Py_LeaveRecursiveCall();
11390
0
            if (res != 0) goto failed;
11391
0
            Py_CLEAR(tmp);
11392
0
        }
11393
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
11394
0
            return -1;
11395
0
        }
11396
0
        if (tmp == NULL || tmp == Py_None) {
11397
0
            Py_CLEAR(tmp);
11398
0
            format_spec = NULL;
11399
0
        }
11400
0
        else {
11401
0
            int res;
11402
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
11403
0
                goto failed;
11404
0
            }
11405
0
            res = obj2ast_expr(state, tmp, &format_spec, "format_spec", arena);
11406
0
            _Py_LeaveRecursiveCall();
11407
0
            if (res != 0) goto failed;
11408
0
            Py_CLEAR(tmp);
11409
0
        }
11410
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
11411
0
                                    lineno, col_offset, end_lineno,
11412
0
                                    end_col_offset, arena);
11413
0
        if (*out == NULL) goto failed;
11414
0
        return 0;
11415
0
    }
11416
0
    tp = state->JoinedStr_type;
11417
0
    isinstance = PyObject_IsInstance(obj, tp);
11418
0
    if (isinstance == -1) {
11419
0
        return -1;
11420
0
    }
11421
0
    if (isinstance) {
11422
0
        asdl_expr_seq* values;
11423
11424
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
11425
0
            return -1;
11426
0
        }
11427
0
        if (tmp == NULL) {
11428
0
            tmp = PyList_New(0);
11429
0
            if (tmp == NULL) {
11430
0
                return -1;
11431
0
            }
11432
0
        }
11433
0
        {
11434
0
            int res;
11435
0
            Py_ssize_t len;
11436
0
            Py_ssize_t i;
11437
0
            if (!PyList_Check(tmp)) {
11438
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %T", tmp);
11439
0
                goto failed;
11440
0
            }
11441
0
            len = PyList_GET_SIZE(tmp);
11442
0
            values = _Py_asdl_expr_seq_new(len, arena);
11443
0
            if (values == NULL) goto failed;
11444
0
            for (i = 0; i < len; i++) {
11445
0
                expr_ty val;
11446
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11447
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
11448
0
                    goto failed;
11449
0
                }
11450
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
11451
0
                _Py_LeaveRecursiveCall();
11452
0
                Py_DECREF(tmp2);
11453
0
                if (res != 0) goto failed;
11454
0
                if (len != PyList_GET_SIZE(tmp)) {
11455
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
11456
0
                    goto failed;
11457
0
                }
11458
0
                asdl_seq_SET(values, i, val);
11459
0
            }
11460
0
            Py_CLEAR(tmp);
11461
0
        }
11462
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
11463
0
                                end_col_offset, arena);
11464
0
        if (*out == NULL) goto failed;
11465
0
        return 0;
11466
0
    }
11467
0
    tp = state->TemplateStr_type;
11468
0
    isinstance = PyObject_IsInstance(obj, tp);
11469
0
    if (isinstance == -1) {
11470
0
        return -1;
11471
0
    }
11472
0
    if (isinstance) {
11473
0
        asdl_expr_seq* values;
11474
11475
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
11476
0
            return -1;
11477
0
        }
11478
0
        if (tmp == NULL) {
11479
0
            tmp = PyList_New(0);
11480
0
            if (tmp == NULL) {
11481
0
                return -1;
11482
0
            }
11483
0
        }
11484
0
        {
11485
0
            int res;
11486
0
            Py_ssize_t len;
11487
0
            Py_ssize_t i;
11488
0
            if (!PyList_Check(tmp)) {
11489
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %T", tmp);
11490
0
                goto failed;
11491
0
            }
11492
0
            len = PyList_GET_SIZE(tmp);
11493
0
            values = _Py_asdl_expr_seq_new(len, arena);
11494
0
            if (values == NULL) goto failed;
11495
0
            for (i = 0; i < len; i++) {
11496
0
                expr_ty val;
11497
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11498
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
11499
0
                    goto failed;
11500
0
                }
11501
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
11502
0
                _Py_LeaveRecursiveCall();
11503
0
                Py_DECREF(tmp2);
11504
0
                if (res != 0) goto failed;
11505
0
                if (len != PyList_GET_SIZE(tmp)) {
11506
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
11507
0
                    goto failed;
11508
0
                }
11509
0
                asdl_seq_SET(values, i, val);
11510
0
            }
11511
0
            Py_CLEAR(tmp);
11512
0
        }
11513
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
11514
0
                                  end_col_offset, arena);
11515
0
        if (*out == NULL) goto failed;
11516
0
        return 0;
11517
0
    }
11518
0
    tp = state->Constant_type;
11519
0
    isinstance = PyObject_IsInstance(obj, tp);
11520
0
    if (isinstance == -1) {
11521
0
        return -1;
11522
0
    }
11523
0
    if (isinstance) {
11524
0
        constant value;
11525
0
        string kind;
11526
11527
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11528
0
            return -1;
11529
0
        }
11530
0
        if (tmp == NULL) {
11531
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
11532
0
            return -1;
11533
0
        }
11534
0
        else {
11535
0
            int res;
11536
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
11537
0
                goto failed;
11538
0
            }
11539
0
            res = obj2ast_constant(state, tmp, &value, "value", arena);
11540
0
            _Py_LeaveRecursiveCall();
11541
0
            if (res != 0) goto failed;
11542
0
            Py_CLEAR(tmp);
11543
0
        }
11544
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
11545
0
            return -1;
11546
0
        }
11547
0
        if (tmp == NULL || tmp == Py_None) {
11548
0
            Py_CLEAR(tmp);
11549
0
            kind = NULL;
11550
0
        }
11551
0
        else {
11552
0
            int res;
11553
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
11554
0
                goto failed;
11555
0
            }
11556
0
            res = obj2ast_string(state, tmp, &kind, "kind", arena);
11557
0
            _Py_LeaveRecursiveCall();
11558
0
            if (res != 0) goto failed;
11559
0
            Py_CLEAR(tmp);
11560
0
        }
11561
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
11562
0
                               end_col_offset, arena);
11563
0
        if (*out == NULL) goto failed;
11564
0
        return 0;
11565
0
    }
11566
0
    tp = state->Attribute_type;
11567
0
    isinstance = PyObject_IsInstance(obj, tp);
11568
0
    if (isinstance == -1) {
11569
0
        return -1;
11570
0
    }
11571
0
    if (isinstance) {
11572
0
        expr_ty value;
11573
0
        identifier attr;
11574
0
        expr_context_ty ctx;
11575
11576
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11577
0
            return -1;
11578
0
        }
11579
0
        if (tmp == NULL) {
11580
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
11581
0
            return -1;
11582
0
        }
11583
0
        else {
11584
0
            int res;
11585
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
11586
0
                goto failed;
11587
0
            }
11588
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11589
0
            _Py_LeaveRecursiveCall();
11590
0
            if (res != 0) goto failed;
11591
0
            Py_CLEAR(tmp);
11592
0
        }
11593
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
11594
0
            return -1;
11595
0
        }
11596
0
        if (tmp == NULL) {
11597
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
11598
0
            return -1;
11599
0
        }
11600
0
        else {
11601
0
            int res;
11602
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
11603
0
                goto failed;
11604
0
            }
11605
0
            res = obj2ast_identifier(state, tmp, &attr, "attr", arena);
11606
0
            _Py_LeaveRecursiveCall();
11607
0
            if (res != 0) goto failed;
11608
0
            Py_CLEAR(tmp);
11609
0
        }
11610
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
11611
0
            return -1;
11612
0
        }
11613
0
        if (tmp == NULL) {
11614
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
11615
0
            return -1;
11616
0
        }
11617
0
        else {
11618
0
            int res;
11619
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
11620
0
                goto failed;
11621
0
            }
11622
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
11623
0
            _Py_LeaveRecursiveCall();
11624
0
            if (res != 0) goto failed;
11625
0
            Py_CLEAR(tmp);
11626
0
        }
11627
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
11628
0
                                end_lineno, end_col_offset, arena);
11629
0
        if (*out == NULL) goto failed;
11630
0
        return 0;
11631
0
    }
11632
0
    tp = state->Subscript_type;
11633
0
    isinstance = PyObject_IsInstance(obj, tp);
11634
0
    if (isinstance == -1) {
11635
0
        return -1;
11636
0
    }
11637
0
    if (isinstance) {
11638
0
        expr_ty value;
11639
0
        expr_ty slice;
11640
0
        expr_context_ty ctx;
11641
11642
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11643
0
            return -1;
11644
0
        }
11645
0
        if (tmp == NULL) {
11646
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
11647
0
            return -1;
11648
0
        }
11649
0
        else {
11650
0
            int res;
11651
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
11652
0
                goto failed;
11653
0
            }
11654
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11655
0
            _Py_LeaveRecursiveCall();
11656
0
            if (res != 0) goto failed;
11657
0
            Py_CLEAR(tmp);
11658
0
        }
11659
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
11660
0
            return -1;
11661
0
        }
11662
0
        if (tmp == NULL) {
11663
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
11664
0
            return -1;
11665
0
        }
11666
0
        else {
11667
0
            int res;
11668
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
11669
0
                goto failed;
11670
0
            }
11671
0
            res = obj2ast_expr(state, tmp, &slice, "slice", arena);
11672
0
            _Py_LeaveRecursiveCall();
11673
0
            if (res != 0) goto failed;
11674
0
            Py_CLEAR(tmp);
11675
0
        }
11676
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
11677
0
            return -1;
11678
0
        }
11679
0
        if (tmp == NULL) {
11680
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
11681
0
            return -1;
11682
0
        }
11683
0
        else {
11684
0
            int res;
11685
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
11686
0
                goto failed;
11687
0
            }
11688
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
11689
0
            _Py_LeaveRecursiveCall();
11690
0
            if (res != 0) goto failed;
11691
0
            Py_CLEAR(tmp);
11692
0
        }
11693
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
11694
0
                                end_lineno, end_col_offset, arena);
11695
0
        if (*out == NULL) goto failed;
11696
0
        return 0;
11697
0
    }
11698
0
    tp = state->Starred_type;
11699
0
    isinstance = PyObject_IsInstance(obj, tp);
11700
0
    if (isinstance == -1) {
11701
0
        return -1;
11702
0
    }
11703
0
    if (isinstance) {
11704
0
        expr_ty value;
11705
0
        expr_context_ty ctx;
11706
11707
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11708
0
            return -1;
11709
0
        }
11710
0
        if (tmp == NULL) {
11711
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
11712
0
            return -1;
11713
0
        }
11714
0
        else {
11715
0
            int res;
11716
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
11717
0
                goto failed;
11718
0
            }
11719
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11720
0
            _Py_LeaveRecursiveCall();
11721
0
            if (res != 0) goto failed;
11722
0
            Py_CLEAR(tmp);
11723
0
        }
11724
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
11725
0
            return -1;
11726
0
        }
11727
0
        if (tmp == NULL) {
11728
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
11729
0
            return -1;
11730
0
        }
11731
0
        else {
11732
0
            int res;
11733
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
11734
0
                goto failed;
11735
0
            }
11736
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
11737
0
            _Py_LeaveRecursiveCall();
11738
0
            if (res != 0) goto failed;
11739
0
            Py_CLEAR(tmp);
11740
0
        }
11741
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
11742
0
                              end_col_offset, arena);
11743
0
        if (*out == NULL) goto failed;
11744
0
        return 0;
11745
0
    }
11746
0
    tp = state->Name_type;
11747
0
    isinstance = PyObject_IsInstance(obj, tp);
11748
0
    if (isinstance == -1) {
11749
0
        return -1;
11750
0
    }
11751
0
    if (isinstance) {
11752
0
        identifier id;
11753
0
        expr_context_ty ctx;
11754
11755
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
11756
0
            return -1;
11757
0
        }
11758
0
        if (tmp == NULL) {
11759
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
11760
0
            return -1;
11761
0
        }
11762
0
        else {
11763
0
            int res;
11764
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
11765
0
                goto failed;
11766
0
            }
11767
0
            res = obj2ast_identifier(state, tmp, &id, "id", arena);
11768
0
            _Py_LeaveRecursiveCall();
11769
0
            if (res != 0) goto failed;
11770
0
            Py_CLEAR(tmp);
11771
0
        }
11772
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
11773
0
            return -1;
11774
0
        }
11775
0
        if (tmp == NULL) {
11776
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
11777
0
            return -1;
11778
0
        }
11779
0
        else {
11780
0
            int res;
11781
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
11782
0
                goto failed;
11783
0
            }
11784
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
11785
0
            _Py_LeaveRecursiveCall();
11786
0
            if (res != 0) goto failed;
11787
0
            Py_CLEAR(tmp);
11788
0
        }
11789
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
11790
0
                           end_col_offset, arena);
11791
0
        if (*out == NULL) goto failed;
11792
0
        return 0;
11793
0
    }
11794
0
    tp = state->List_type;
11795
0
    isinstance = PyObject_IsInstance(obj, tp);
11796
0
    if (isinstance == -1) {
11797
0
        return -1;
11798
0
    }
11799
0
    if (isinstance) {
11800
0
        asdl_expr_seq* elts;
11801
0
        expr_context_ty ctx;
11802
11803
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
11804
0
            return -1;
11805
0
        }
11806
0
        if (tmp == NULL) {
11807
0
            tmp = PyList_New(0);
11808
0
            if (tmp == NULL) {
11809
0
                return -1;
11810
0
            }
11811
0
        }
11812
0
        {
11813
0
            int res;
11814
0
            Py_ssize_t len;
11815
0
            Py_ssize_t i;
11816
0
            if (!PyList_Check(tmp)) {
11817
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %T", tmp);
11818
0
                goto failed;
11819
0
            }
11820
0
            len = PyList_GET_SIZE(tmp);
11821
0
            elts = _Py_asdl_expr_seq_new(len, arena);
11822
0
            if (elts == NULL) goto failed;
11823
0
            for (i = 0; i < len; i++) {
11824
0
                expr_ty val;
11825
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11826
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
11827
0
                    goto failed;
11828
0
                }
11829
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
11830
0
                _Py_LeaveRecursiveCall();
11831
0
                Py_DECREF(tmp2);
11832
0
                if (res != 0) goto failed;
11833
0
                if (len != PyList_GET_SIZE(tmp)) {
11834
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
11835
0
                    goto failed;
11836
0
                }
11837
0
                asdl_seq_SET(elts, i, val);
11838
0
            }
11839
0
            Py_CLEAR(tmp);
11840
0
        }
11841
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
11842
0
            return -1;
11843
0
        }
11844
0
        if (tmp == NULL) {
11845
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
11846
0
            return -1;
11847
0
        }
11848
0
        else {
11849
0
            int res;
11850
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
11851
0
                goto failed;
11852
0
            }
11853
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
11854
0
            _Py_LeaveRecursiveCall();
11855
0
            if (res != 0) goto failed;
11856
0
            Py_CLEAR(tmp);
11857
0
        }
11858
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
11859
0
                           end_col_offset, arena);
11860
0
        if (*out == NULL) goto failed;
11861
0
        return 0;
11862
0
    }
11863
0
    tp = state->Tuple_type;
11864
0
    isinstance = PyObject_IsInstance(obj, tp);
11865
0
    if (isinstance == -1) {
11866
0
        return -1;
11867
0
    }
11868
0
    if (isinstance) {
11869
0
        asdl_expr_seq* elts;
11870
0
        expr_context_ty ctx;
11871
11872
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
11873
0
            return -1;
11874
0
        }
11875
0
        if (tmp == NULL) {
11876
0
            tmp = PyList_New(0);
11877
0
            if (tmp == NULL) {
11878
0
                return -1;
11879
0
            }
11880
0
        }
11881
0
        {
11882
0
            int res;
11883
0
            Py_ssize_t len;
11884
0
            Py_ssize_t i;
11885
0
            if (!PyList_Check(tmp)) {
11886
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %T", tmp);
11887
0
                goto failed;
11888
0
            }
11889
0
            len = PyList_GET_SIZE(tmp);
11890
0
            elts = _Py_asdl_expr_seq_new(len, arena);
11891
0
            if (elts == NULL) goto failed;
11892
0
            for (i = 0; i < len; i++) {
11893
0
                expr_ty val;
11894
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11895
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
11896
0
                    goto failed;
11897
0
                }
11898
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
11899
0
                _Py_LeaveRecursiveCall();
11900
0
                Py_DECREF(tmp2);
11901
0
                if (res != 0) goto failed;
11902
0
                if (len != PyList_GET_SIZE(tmp)) {
11903
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
11904
0
                    goto failed;
11905
0
                }
11906
0
                asdl_seq_SET(elts, i, val);
11907
0
            }
11908
0
            Py_CLEAR(tmp);
11909
0
        }
11910
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
11911
0
            return -1;
11912
0
        }
11913
0
        if (tmp == NULL) {
11914
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
11915
0
            return -1;
11916
0
        }
11917
0
        else {
11918
0
            int res;
11919
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
11920
0
                goto failed;
11921
0
            }
11922
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
11923
0
            _Py_LeaveRecursiveCall();
11924
0
            if (res != 0) goto failed;
11925
0
            Py_CLEAR(tmp);
11926
0
        }
11927
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
11928
0
                            end_col_offset, arena);
11929
0
        if (*out == NULL) goto failed;
11930
0
        return 0;
11931
0
    }
11932
0
    tp = state->Slice_type;
11933
0
    isinstance = PyObject_IsInstance(obj, tp);
11934
0
    if (isinstance == -1) {
11935
0
        return -1;
11936
0
    }
11937
0
    if (isinstance) {
11938
0
        expr_ty lower;
11939
0
        expr_ty upper;
11940
0
        expr_ty step;
11941
11942
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
11943
0
            return -1;
11944
0
        }
11945
0
        if (tmp == NULL || tmp == Py_None) {
11946
0
            Py_CLEAR(tmp);
11947
0
            lower = NULL;
11948
0
        }
11949
0
        else {
11950
0
            int res;
11951
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
11952
0
                goto failed;
11953
0
            }
11954
0
            res = obj2ast_expr(state, tmp, &lower, "lower", arena);
11955
0
            _Py_LeaveRecursiveCall();
11956
0
            if (res != 0) goto failed;
11957
0
            Py_CLEAR(tmp);
11958
0
        }
11959
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
11960
0
            return -1;
11961
0
        }
11962
0
        if (tmp == NULL || tmp == Py_None) {
11963
0
            Py_CLEAR(tmp);
11964
0
            upper = NULL;
11965
0
        }
11966
0
        else {
11967
0
            int res;
11968
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
11969
0
                goto failed;
11970
0
            }
11971
0
            res = obj2ast_expr(state, tmp, &upper, "upper", arena);
11972
0
            _Py_LeaveRecursiveCall();
11973
0
            if (res != 0) goto failed;
11974
0
            Py_CLEAR(tmp);
11975
0
        }
11976
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
11977
0
            return -1;
11978
0
        }
11979
0
        if (tmp == NULL || tmp == Py_None) {
11980
0
            Py_CLEAR(tmp);
11981
0
            step = NULL;
11982
0
        }
11983
0
        else {
11984
0
            int res;
11985
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
11986
0
                goto failed;
11987
0
            }
11988
0
            res = obj2ast_expr(state, tmp, &step, "step", arena);
11989
0
            _Py_LeaveRecursiveCall();
11990
0
            if (res != 0) goto failed;
11991
0
            Py_CLEAR(tmp);
11992
0
        }
11993
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
11994
0
                            end_col_offset, arena);
11995
0
        if (*out == NULL) goto failed;
11996
0
        return 0;
11997
0
    }
11998
11999
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
12000
0
    failed:
12001
0
    Py_XDECREF(tmp);
12002
0
    return -1;
12003
0
}
12004
12005
int
12006
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
12007
                     out, const char* field, PyArena* arena)
12008
0
{
12009
0
    int isinstance;
12010
12011
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
12012
0
    if (isinstance == -1) {
12013
0
        return -1;
12014
0
    }
12015
0
    if (isinstance) {
12016
0
        *out = Load;
12017
0
        return 0;
12018
0
    }
12019
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
12020
0
    if (isinstance == -1) {
12021
0
        return -1;
12022
0
    }
12023
0
    if (isinstance) {
12024
0
        *out = Store;
12025
0
        return 0;
12026
0
    }
12027
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
12028
0
    if (isinstance == -1) {
12029
0
        return -1;
12030
0
    }
12031
0
    if (isinstance) {
12032
0
        *out = Del;
12033
0
        return 0;
12034
0
    }
12035
12036
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
12037
0
    return -1;
12038
0
}
12039
12040
int
12041
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, const
12042
               char* field, PyArena* arena)
12043
0
{
12044
0
    int isinstance;
12045
12046
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
12047
0
    if (isinstance == -1) {
12048
0
        return -1;
12049
0
    }
12050
0
    if (isinstance) {
12051
0
        *out = And;
12052
0
        return 0;
12053
0
    }
12054
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
12055
0
    if (isinstance == -1) {
12056
0
        return -1;
12057
0
    }
12058
0
    if (isinstance) {
12059
0
        *out = Or;
12060
0
        return 0;
12061
0
    }
12062
12063
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
12064
0
    return -1;
12065
0
}
12066
12067
int
12068
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
12069
                 const char* field, PyArena* arena)
12070
0
{
12071
0
    int isinstance;
12072
12073
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
12074
0
    if (isinstance == -1) {
12075
0
        return -1;
12076
0
    }
12077
0
    if (isinstance) {
12078
0
        *out = Add;
12079
0
        return 0;
12080
0
    }
12081
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
12082
0
    if (isinstance == -1) {
12083
0
        return -1;
12084
0
    }
12085
0
    if (isinstance) {
12086
0
        *out = Sub;
12087
0
        return 0;
12088
0
    }
12089
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
12090
0
    if (isinstance == -1) {
12091
0
        return -1;
12092
0
    }
12093
0
    if (isinstance) {
12094
0
        *out = Mult;
12095
0
        return 0;
12096
0
    }
12097
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
12098
0
    if (isinstance == -1) {
12099
0
        return -1;
12100
0
    }
12101
0
    if (isinstance) {
12102
0
        *out = MatMult;
12103
0
        return 0;
12104
0
    }
12105
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
12106
0
    if (isinstance == -1) {
12107
0
        return -1;
12108
0
    }
12109
0
    if (isinstance) {
12110
0
        *out = Div;
12111
0
        return 0;
12112
0
    }
12113
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
12114
0
    if (isinstance == -1) {
12115
0
        return -1;
12116
0
    }
12117
0
    if (isinstance) {
12118
0
        *out = Mod;
12119
0
        return 0;
12120
0
    }
12121
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
12122
0
    if (isinstance == -1) {
12123
0
        return -1;
12124
0
    }
12125
0
    if (isinstance) {
12126
0
        *out = Pow;
12127
0
        return 0;
12128
0
    }
12129
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
12130
0
    if (isinstance == -1) {
12131
0
        return -1;
12132
0
    }
12133
0
    if (isinstance) {
12134
0
        *out = LShift;
12135
0
        return 0;
12136
0
    }
12137
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
12138
0
    if (isinstance == -1) {
12139
0
        return -1;
12140
0
    }
12141
0
    if (isinstance) {
12142
0
        *out = RShift;
12143
0
        return 0;
12144
0
    }
12145
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
12146
0
    if (isinstance == -1) {
12147
0
        return -1;
12148
0
    }
12149
0
    if (isinstance) {
12150
0
        *out = BitOr;
12151
0
        return 0;
12152
0
    }
12153
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
12154
0
    if (isinstance == -1) {
12155
0
        return -1;
12156
0
    }
12157
0
    if (isinstance) {
12158
0
        *out = BitXor;
12159
0
        return 0;
12160
0
    }
12161
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
12162
0
    if (isinstance == -1) {
12163
0
        return -1;
12164
0
    }
12165
0
    if (isinstance) {
12166
0
        *out = BitAnd;
12167
0
        return 0;
12168
0
    }
12169
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
12170
0
    if (isinstance == -1) {
12171
0
        return -1;
12172
0
    }
12173
0
    if (isinstance) {
12174
0
        *out = FloorDiv;
12175
0
        return 0;
12176
0
    }
12177
12178
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
12179
0
    return -1;
12180
0
}
12181
12182
int
12183
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out, const
12184
                char* field, PyArena* arena)
12185
0
{
12186
0
    int isinstance;
12187
12188
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
12189
0
    if (isinstance == -1) {
12190
0
        return -1;
12191
0
    }
12192
0
    if (isinstance) {
12193
0
        *out = Invert;
12194
0
        return 0;
12195
0
    }
12196
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
12197
0
    if (isinstance == -1) {
12198
0
        return -1;
12199
0
    }
12200
0
    if (isinstance) {
12201
0
        *out = Not;
12202
0
        return 0;
12203
0
    }
12204
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
12205
0
    if (isinstance == -1) {
12206
0
        return -1;
12207
0
    }
12208
0
    if (isinstance) {
12209
0
        *out = UAdd;
12210
0
        return 0;
12211
0
    }
12212
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
12213
0
    if (isinstance == -1) {
12214
0
        return -1;
12215
0
    }
12216
0
    if (isinstance) {
12217
0
        *out = USub;
12218
0
        return 0;
12219
0
    }
12220
12221
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
12222
0
    return -1;
12223
0
}
12224
12225
int
12226
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, const
12227
              char* field, PyArena* arena)
12228
0
{
12229
0
    int isinstance;
12230
12231
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
12232
0
    if (isinstance == -1) {
12233
0
        return -1;
12234
0
    }
12235
0
    if (isinstance) {
12236
0
        *out = Eq;
12237
0
        return 0;
12238
0
    }
12239
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
12240
0
    if (isinstance == -1) {
12241
0
        return -1;
12242
0
    }
12243
0
    if (isinstance) {
12244
0
        *out = NotEq;
12245
0
        return 0;
12246
0
    }
12247
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
12248
0
    if (isinstance == -1) {
12249
0
        return -1;
12250
0
    }
12251
0
    if (isinstance) {
12252
0
        *out = Lt;
12253
0
        return 0;
12254
0
    }
12255
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
12256
0
    if (isinstance == -1) {
12257
0
        return -1;
12258
0
    }
12259
0
    if (isinstance) {
12260
0
        *out = LtE;
12261
0
        return 0;
12262
0
    }
12263
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
12264
0
    if (isinstance == -1) {
12265
0
        return -1;
12266
0
    }
12267
0
    if (isinstance) {
12268
0
        *out = Gt;
12269
0
        return 0;
12270
0
    }
12271
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
12272
0
    if (isinstance == -1) {
12273
0
        return -1;
12274
0
    }
12275
0
    if (isinstance) {
12276
0
        *out = GtE;
12277
0
        return 0;
12278
0
    }
12279
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
12280
0
    if (isinstance == -1) {
12281
0
        return -1;
12282
0
    }
12283
0
    if (isinstance) {
12284
0
        *out = Is;
12285
0
        return 0;
12286
0
    }
12287
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
12288
0
    if (isinstance == -1) {
12289
0
        return -1;
12290
0
    }
12291
0
    if (isinstance) {
12292
0
        *out = IsNot;
12293
0
        return 0;
12294
0
    }
12295
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
12296
0
    if (isinstance == -1) {
12297
0
        return -1;
12298
0
    }
12299
0
    if (isinstance) {
12300
0
        *out = In;
12301
0
        return 0;
12302
0
    }
12303
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
12304
0
    if (isinstance == -1) {
12305
0
        return -1;
12306
0
    }
12307
0
    if (isinstance) {
12308
0
        *out = NotIn;
12309
0
        return 0;
12310
0
    }
12311
12312
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
12313
0
    return -1;
12314
0
}
12315
12316
int
12317
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
12318
                      out, const char* field, PyArena* arena)
12319
0
{
12320
0
    PyObject* tmp = NULL;
12321
0
    expr_ty target;
12322
0
    expr_ty iter;
12323
0
    asdl_expr_seq* ifs;
12324
0
    int is_async;
12325
12326
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12327
0
        return -1;
12328
0
    }
12329
0
    if (tmp == NULL) {
12330
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
12331
0
        return -1;
12332
0
    }
12333
0
    else {
12334
0
        int res;
12335
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
12336
0
            goto failed;
12337
0
        }
12338
0
        res = obj2ast_expr(state, tmp, &target, "target", arena);
12339
0
        _Py_LeaveRecursiveCall();
12340
0
        if (res != 0) goto failed;
12341
0
        Py_CLEAR(tmp);
12342
0
    }
12343
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12344
0
        return -1;
12345
0
    }
12346
0
    if (tmp == NULL) {
12347
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
12348
0
        return -1;
12349
0
    }
12350
0
    else {
12351
0
        int res;
12352
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
12353
0
            goto failed;
12354
0
        }
12355
0
        res = obj2ast_expr(state, tmp, &iter, "iter", arena);
12356
0
        _Py_LeaveRecursiveCall();
12357
0
        if (res != 0) goto failed;
12358
0
        Py_CLEAR(tmp);
12359
0
    }
12360
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
12361
0
        return -1;
12362
0
    }
12363
0
    if (tmp == NULL) {
12364
0
        tmp = PyList_New(0);
12365
0
        if (tmp == NULL) {
12366
0
            return -1;
12367
0
        }
12368
0
    }
12369
0
    {
12370
0
        int res;
12371
0
        Py_ssize_t len;
12372
0
        Py_ssize_t i;
12373
0
        if (!PyList_Check(tmp)) {
12374
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %T", tmp);
12375
0
            goto failed;
12376
0
        }
12377
0
        len = PyList_GET_SIZE(tmp);
12378
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
12379
0
        if (ifs == NULL) goto failed;
12380
0
        for (i = 0; i < len; i++) {
12381
0
            expr_ty val;
12382
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12383
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
12384
0
                goto failed;
12385
0
            }
12386
0
            res = obj2ast_expr(state, tmp2, &val, "ifs", arena);
12387
0
            _Py_LeaveRecursiveCall();
12388
0
            Py_DECREF(tmp2);
12389
0
            if (res != 0) goto failed;
12390
0
            if (len != PyList_GET_SIZE(tmp)) {
12391
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
12392
0
                goto failed;
12393
0
            }
12394
0
            asdl_seq_SET(ifs, i, val);
12395
0
        }
12396
0
        Py_CLEAR(tmp);
12397
0
    }
12398
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
12399
0
        return -1;
12400
0
    }
12401
0
    if (tmp == NULL) {
12402
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
12403
0
        return -1;
12404
0
    }
12405
0
    else {
12406
0
        int res;
12407
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
12408
0
            goto failed;
12409
0
        }
12410
0
        res = obj2ast_int(state, tmp, &is_async, "is_async", arena);
12411
0
        _Py_LeaveRecursiveCall();
12412
0
        if (res != 0) goto failed;
12413
0
        Py_CLEAR(tmp);
12414
0
    }
12415
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
12416
0
    if (*out == NULL) goto failed;
12417
0
    return 0;
12418
0
failed:
12419
0
    Py_XDECREF(tmp);
12420
0
    return -1;
12421
0
}
12422
12423
int
12424
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
12425
                      out, const char* field, PyArena* arena)
12426
0
{
12427
0
    int isinstance;
12428
12429
0
    PyObject *tmp = NULL;
12430
0
    PyObject *tp;
12431
0
    int lineno;
12432
0
    int col_offset;
12433
0
    int end_lineno;
12434
0
    int end_col_offset;
12435
12436
0
    if (obj == Py_None) {
12437
0
        *out = NULL;
12438
0
        return 0;
12439
0
    }
12440
0
    tp = state->excepthandler_type;
12441
0
    isinstance = PyObject_IsInstance(obj, tp);
12442
0
    if (isinstance == -1) {
12443
0
        return 1;
12444
0
    }
12445
0
    if (!isinstance && field != NULL) {
12446
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'excepthandler', got '%T'", field, obj);
12447
0
        return 1;
12448
0
    }
12449
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
12450
0
        return -1;
12451
0
    }
12452
0
    if (tmp == NULL) {
12453
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
12454
0
        return -1;
12455
0
    }
12456
0
    else {
12457
0
        int res;
12458
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
12459
0
            goto failed;
12460
0
        }
12461
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
12462
0
        _Py_LeaveRecursiveCall();
12463
0
        if (res != 0) goto failed;
12464
0
        Py_CLEAR(tmp);
12465
0
    }
12466
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
12467
0
        return -1;
12468
0
    }
12469
0
    if (tmp == NULL) {
12470
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
12471
0
        return -1;
12472
0
    }
12473
0
    else {
12474
0
        int res;
12475
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
12476
0
            goto failed;
12477
0
        }
12478
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
12479
0
        _Py_LeaveRecursiveCall();
12480
0
        if (res != 0) goto failed;
12481
0
        Py_CLEAR(tmp);
12482
0
    }
12483
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
12484
0
        return -1;
12485
0
    }
12486
0
    if (tmp == NULL || tmp == Py_None) {
12487
0
        Py_CLEAR(tmp);
12488
0
        end_lineno = lineno;
12489
0
    }
12490
0
    else {
12491
0
        int res;
12492
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
12493
0
            goto failed;
12494
0
        }
12495
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
12496
0
        _Py_LeaveRecursiveCall();
12497
0
        if (res != 0) goto failed;
12498
0
        Py_CLEAR(tmp);
12499
0
    }
12500
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
12501
0
        return -1;
12502
0
    }
12503
0
    if (tmp == NULL || tmp == Py_None) {
12504
0
        Py_CLEAR(tmp);
12505
0
        end_col_offset = col_offset;
12506
0
    }
12507
0
    else {
12508
0
        int res;
12509
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
12510
0
            goto failed;
12511
0
        }
12512
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
12513
0
        _Py_LeaveRecursiveCall();
12514
0
        if (res != 0) goto failed;
12515
0
        Py_CLEAR(tmp);
12516
0
    }
12517
0
    tp = state->ExceptHandler_type;
12518
0
    isinstance = PyObject_IsInstance(obj, tp);
12519
0
    if (isinstance == -1) {
12520
0
        return -1;
12521
0
    }
12522
0
    if (isinstance) {
12523
0
        expr_ty type;
12524
0
        identifier name;
12525
0
        asdl_stmt_seq* body;
12526
12527
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
12528
0
            return -1;
12529
0
        }
12530
0
        if (tmp == NULL || tmp == Py_None) {
12531
0
            Py_CLEAR(tmp);
12532
0
            type = NULL;
12533
0
        }
12534
0
        else {
12535
0
            int res;
12536
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
12537
0
                goto failed;
12538
0
            }
12539
0
            res = obj2ast_expr(state, tmp, &type, "type", arena);
12540
0
            _Py_LeaveRecursiveCall();
12541
0
            if (res != 0) goto failed;
12542
0
            Py_CLEAR(tmp);
12543
0
        }
12544
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12545
0
            return -1;
12546
0
        }
12547
0
        if (tmp == NULL || tmp == Py_None) {
12548
0
            Py_CLEAR(tmp);
12549
0
            name = NULL;
12550
0
        }
12551
0
        else {
12552
0
            int res;
12553
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
12554
0
                goto failed;
12555
0
            }
12556
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
12557
0
            _Py_LeaveRecursiveCall();
12558
0
            if (res != 0) goto failed;
12559
0
            Py_CLEAR(tmp);
12560
0
        }
12561
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12562
0
            return -1;
12563
0
        }
12564
0
        if (tmp == NULL) {
12565
0
            tmp = PyList_New(0);
12566
0
            if (tmp == NULL) {
12567
0
                return -1;
12568
0
            }
12569
0
        }
12570
0
        {
12571
0
            int res;
12572
0
            Py_ssize_t len;
12573
0
            Py_ssize_t i;
12574
0
            if (!PyList_Check(tmp)) {
12575
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %T", tmp);
12576
0
                goto failed;
12577
0
            }
12578
0
            len = PyList_GET_SIZE(tmp);
12579
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12580
0
            if (body == NULL) goto failed;
12581
0
            for (i = 0; i < len; i++) {
12582
0
                stmt_ty val;
12583
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12584
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
12585
0
                    goto failed;
12586
0
                }
12587
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12588
0
                _Py_LeaveRecursiveCall();
12589
0
                Py_DECREF(tmp2);
12590
0
                if (res != 0) goto failed;
12591
0
                if (len != PyList_GET_SIZE(tmp)) {
12592
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
12593
0
                    goto failed;
12594
0
                }
12595
0
                asdl_seq_SET(body, i, val);
12596
0
            }
12597
0
            Py_CLEAR(tmp);
12598
0
        }
12599
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
12600
0
                                    end_lineno, end_col_offset, arena);
12601
0
        if (*out == NULL) goto failed;
12602
0
        return 0;
12603
0
    }
12604
12605
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
12606
0
    failed:
12607
0
    Py_XDECREF(tmp);
12608
0
    return -1;
12609
0
}
12610
12611
int
12612
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
12613
                  const char* field, PyArena* arena)
12614
0
{
12615
0
    PyObject* tmp = NULL;
12616
0
    asdl_arg_seq* posonlyargs;
12617
0
    asdl_arg_seq* args;
12618
0
    arg_ty vararg;
12619
0
    asdl_arg_seq* kwonlyargs;
12620
0
    asdl_expr_seq* kw_defaults;
12621
0
    arg_ty kwarg;
12622
0
    asdl_expr_seq* defaults;
12623
12624
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
12625
0
        return -1;
12626
0
    }
12627
0
    if (tmp == NULL) {
12628
0
        tmp = PyList_New(0);
12629
0
        if (tmp == NULL) {
12630
0
            return -1;
12631
0
        }
12632
0
    }
12633
0
    {
12634
0
        int res;
12635
0
        Py_ssize_t len;
12636
0
        Py_ssize_t i;
12637
0
        if (!PyList_Check(tmp)) {
12638
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %T", tmp);
12639
0
            goto failed;
12640
0
        }
12641
0
        len = PyList_GET_SIZE(tmp);
12642
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
12643
0
        if (posonlyargs == NULL) goto failed;
12644
0
        for (i = 0; i < len; i++) {
12645
0
            arg_ty val;
12646
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12647
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12648
0
                goto failed;
12649
0
            }
12650
0
            res = obj2ast_arg(state, tmp2, &val, "posonlyargs", arena);
12651
0
            _Py_LeaveRecursiveCall();
12652
0
            Py_DECREF(tmp2);
12653
0
            if (res != 0) goto failed;
12654
0
            if (len != PyList_GET_SIZE(tmp)) {
12655
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
12656
0
                goto failed;
12657
0
            }
12658
0
            asdl_seq_SET(posonlyargs, i, val);
12659
0
        }
12660
0
        Py_CLEAR(tmp);
12661
0
    }
12662
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
12663
0
        return -1;
12664
0
    }
12665
0
    if (tmp == NULL) {
12666
0
        tmp = PyList_New(0);
12667
0
        if (tmp == NULL) {
12668
0
            return -1;
12669
0
        }
12670
0
    }
12671
0
    {
12672
0
        int res;
12673
0
        Py_ssize_t len;
12674
0
        Py_ssize_t i;
12675
0
        if (!PyList_Check(tmp)) {
12676
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %T", tmp);
12677
0
            goto failed;
12678
0
        }
12679
0
        len = PyList_GET_SIZE(tmp);
12680
0
        args = _Py_asdl_arg_seq_new(len, arena);
12681
0
        if (args == NULL) goto failed;
12682
0
        for (i = 0; i < len; i++) {
12683
0
            arg_ty val;
12684
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12685
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12686
0
                goto failed;
12687
0
            }
12688
0
            res = obj2ast_arg(state, tmp2, &val, "args", arena);
12689
0
            _Py_LeaveRecursiveCall();
12690
0
            Py_DECREF(tmp2);
12691
0
            if (res != 0) goto failed;
12692
0
            if (len != PyList_GET_SIZE(tmp)) {
12693
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
12694
0
                goto failed;
12695
0
            }
12696
0
            asdl_seq_SET(args, i, val);
12697
0
        }
12698
0
        Py_CLEAR(tmp);
12699
0
    }
12700
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
12701
0
        return -1;
12702
0
    }
12703
0
    if (tmp == NULL || tmp == Py_None) {
12704
0
        Py_CLEAR(tmp);
12705
0
        vararg = NULL;
12706
0
    }
12707
0
    else {
12708
0
        int res;
12709
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12710
0
            goto failed;
12711
0
        }
12712
0
        res = obj2ast_arg(state, tmp, &vararg, "vararg", arena);
12713
0
        _Py_LeaveRecursiveCall();
12714
0
        if (res != 0) goto failed;
12715
0
        Py_CLEAR(tmp);
12716
0
    }
12717
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
12718
0
        return -1;
12719
0
    }
12720
0
    if (tmp == NULL) {
12721
0
        tmp = PyList_New(0);
12722
0
        if (tmp == NULL) {
12723
0
            return -1;
12724
0
        }
12725
0
    }
12726
0
    {
12727
0
        int res;
12728
0
        Py_ssize_t len;
12729
0
        Py_ssize_t i;
12730
0
        if (!PyList_Check(tmp)) {
12731
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %T", tmp);
12732
0
            goto failed;
12733
0
        }
12734
0
        len = PyList_GET_SIZE(tmp);
12735
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
12736
0
        if (kwonlyargs == NULL) goto failed;
12737
0
        for (i = 0; i < len; i++) {
12738
0
            arg_ty val;
12739
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12740
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12741
0
                goto failed;
12742
0
            }
12743
0
            res = obj2ast_arg(state, tmp2, &val, "kwonlyargs", arena);
12744
0
            _Py_LeaveRecursiveCall();
12745
0
            Py_DECREF(tmp2);
12746
0
            if (res != 0) goto failed;
12747
0
            if (len != PyList_GET_SIZE(tmp)) {
12748
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
12749
0
                goto failed;
12750
0
            }
12751
0
            asdl_seq_SET(kwonlyargs, i, val);
12752
0
        }
12753
0
        Py_CLEAR(tmp);
12754
0
    }
12755
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
12756
0
        return -1;
12757
0
    }
12758
0
    if (tmp == NULL) {
12759
0
        tmp = PyList_New(0);
12760
0
        if (tmp == NULL) {
12761
0
            return -1;
12762
0
        }
12763
0
    }
12764
0
    {
12765
0
        int res;
12766
0
        Py_ssize_t len;
12767
0
        Py_ssize_t i;
12768
0
        if (!PyList_Check(tmp)) {
12769
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %T", tmp);
12770
0
            goto failed;
12771
0
        }
12772
0
        len = PyList_GET_SIZE(tmp);
12773
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
12774
0
        if (kw_defaults == NULL) goto failed;
12775
0
        for (i = 0; i < len; i++) {
12776
0
            expr_ty val;
12777
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12778
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12779
0
                goto failed;
12780
0
            }
12781
0
            res = obj2ast_expr(state, tmp2, &val, "kw_defaults", arena);
12782
0
            _Py_LeaveRecursiveCall();
12783
0
            Py_DECREF(tmp2);
12784
0
            if (res != 0) goto failed;
12785
0
            if (len != PyList_GET_SIZE(tmp)) {
12786
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
12787
0
                goto failed;
12788
0
            }
12789
0
            asdl_seq_SET(kw_defaults, i, val);
12790
0
        }
12791
0
        Py_CLEAR(tmp);
12792
0
    }
12793
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
12794
0
        return -1;
12795
0
    }
12796
0
    if (tmp == NULL || tmp == Py_None) {
12797
0
        Py_CLEAR(tmp);
12798
0
        kwarg = NULL;
12799
0
    }
12800
0
    else {
12801
0
        int res;
12802
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12803
0
            goto failed;
12804
0
        }
12805
0
        res = obj2ast_arg(state, tmp, &kwarg, "kwarg", arena);
12806
0
        _Py_LeaveRecursiveCall();
12807
0
        if (res != 0) goto failed;
12808
0
        Py_CLEAR(tmp);
12809
0
    }
12810
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
12811
0
        return -1;
12812
0
    }
12813
0
    if (tmp == NULL) {
12814
0
        tmp = PyList_New(0);
12815
0
        if (tmp == NULL) {
12816
0
            return -1;
12817
0
        }
12818
0
    }
12819
0
    {
12820
0
        int res;
12821
0
        Py_ssize_t len;
12822
0
        Py_ssize_t i;
12823
0
        if (!PyList_Check(tmp)) {
12824
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %T", tmp);
12825
0
            goto failed;
12826
0
        }
12827
0
        len = PyList_GET_SIZE(tmp);
12828
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
12829
0
        if (defaults == NULL) goto failed;
12830
0
        for (i = 0; i < len; i++) {
12831
0
            expr_ty val;
12832
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12833
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
12834
0
                goto failed;
12835
0
            }
12836
0
            res = obj2ast_expr(state, tmp2, &val, "defaults", arena);
12837
0
            _Py_LeaveRecursiveCall();
12838
0
            Py_DECREF(tmp2);
12839
0
            if (res != 0) goto failed;
12840
0
            if (len != PyList_GET_SIZE(tmp)) {
12841
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
12842
0
                goto failed;
12843
0
            }
12844
0
            asdl_seq_SET(defaults, i, val);
12845
0
        }
12846
0
        Py_CLEAR(tmp);
12847
0
    }
12848
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
12849
0
                            kwarg, defaults, arena);
12850
0
    if (*out == NULL) goto failed;
12851
0
    return 0;
12852
0
failed:
12853
0
    Py_XDECREF(tmp);
12854
0
    return -1;
12855
0
}
12856
12857
int
12858
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, const char*
12859
            field, PyArena* arena)
12860
0
{
12861
0
    PyObject* tmp = NULL;
12862
0
    identifier arg;
12863
0
    expr_ty annotation;
12864
0
    string type_comment;
12865
0
    int lineno;
12866
0
    int col_offset;
12867
0
    int end_lineno;
12868
0
    int end_col_offset;
12869
12870
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
12871
0
        return -1;
12872
0
    }
12873
0
    if (tmp == NULL) {
12874
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
12875
0
        return -1;
12876
0
    }
12877
0
    else {
12878
0
        int res;
12879
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12880
0
            goto failed;
12881
0
        }
12882
0
        res = obj2ast_identifier(state, tmp, &arg, "arg", arena);
12883
0
        _Py_LeaveRecursiveCall();
12884
0
        if (res != 0) goto failed;
12885
0
        Py_CLEAR(tmp);
12886
0
    }
12887
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12888
0
        return -1;
12889
0
    }
12890
0
    if (tmp == NULL || tmp == Py_None) {
12891
0
        Py_CLEAR(tmp);
12892
0
        annotation = NULL;
12893
0
    }
12894
0
    else {
12895
0
        int res;
12896
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12897
0
            goto failed;
12898
0
        }
12899
0
        res = obj2ast_expr(state, tmp, &annotation, "annotation", arena);
12900
0
        _Py_LeaveRecursiveCall();
12901
0
        if (res != 0) goto failed;
12902
0
        Py_CLEAR(tmp);
12903
0
    }
12904
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12905
0
        return -1;
12906
0
    }
12907
0
    if (tmp == NULL || tmp == Py_None) {
12908
0
        Py_CLEAR(tmp);
12909
0
        type_comment = NULL;
12910
0
    }
12911
0
    else {
12912
0
        int res;
12913
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12914
0
            goto failed;
12915
0
        }
12916
0
        res = obj2ast_string(state, tmp, &type_comment, "type_comment", arena);
12917
0
        _Py_LeaveRecursiveCall();
12918
0
        if (res != 0) goto failed;
12919
0
        Py_CLEAR(tmp);
12920
0
    }
12921
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
12922
0
        return -1;
12923
0
    }
12924
0
    if (tmp == NULL) {
12925
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
12926
0
        return -1;
12927
0
    }
12928
0
    else {
12929
0
        int res;
12930
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12931
0
            goto failed;
12932
0
        }
12933
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
12934
0
        _Py_LeaveRecursiveCall();
12935
0
        if (res != 0) goto failed;
12936
0
        Py_CLEAR(tmp);
12937
0
    }
12938
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
12939
0
        return -1;
12940
0
    }
12941
0
    if (tmp == NULL) {
12942
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
12943
0
        return -1;
12944
0
    }
12945
0
    else {
12946
0
        int res;
12947
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12948
0
            goto failed;
12949
0
        }
12950
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
12951
0
        _Py_LeaveRecursiveCall();
12952
0
        if (res != 0) goto failed;
12953
0
        Py_CLEAR(tmp);
12954
0
    }
12955
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
12956
0
        return -1;
12957
0
    }
12958
0
    if (tmp == NULL || tmp == Py_None) {
12959
0
        Py_CLEAR(tmp);
12960
0
        end_lineno = lineno;
12961
0
    }
12962
0
    else {
12963
0
        int res;
12964
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12965
0
            goto failed;
12966
0
        }
12967
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
12968
0
        _Py_LeaveRecursiveCall();
12969
0
        if (res != 0) goto failed;
12970
0
        Py_CLEAR(tmp);
12971
0
    }
12972
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
12973
0
        return -1;
12974
0
    }
12975
0
    if (tmp == NULL || tmp == Py_None) {
12976
0
        Py_CLEAR(tmp);
12977
0
        end_col_offset = col_offset;
12978
0
    }
12979
0
    else {
12980
0
        int res;
12981
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
12982
0
            goto failed;
12983
0
        }
12984
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
12985
0
        _Py_LeaveRecursiveCall();
12986
0
        if (res != 0) goto failed;
12987
0
        Py_CLEAR(tmp);
12988
0
    }
12989
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
12990
0
                      end_lineno, end_col_offset, arena);
12991
0
    if (*out == NULL) goto failed;
12992
0
    return 0;
12993
0
failed:
12994
0
    Py_XDECREF(tmp);
12995
0
    return -1;
12996
0
}
12997
12998
int
12999
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out, const
13000
                char* field, PyArena* arena)
13001
0
{
13002
0
    PyObject* tmp = NULL;
13003
0
    identifier arg;
13004
0
    expr_ty value;
13005
0
    int lineno;
13006
0
    int col_offset;
13007
0
    int end_lineno;
13008
0
    int end_col_offset;
13009
13010
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
13011
0
        return -1;
13012
0
    }
13013
0
    if (tmp == NULL || tmp == Py_None) {
13014
0
        Py_CLEAR(tmp);
13015
0
        arg = NULL;
13016
0
    }
13017
0
    else {
13018
0
        int res;
13019
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
13020
0
            goto failed;
13021
0
        }
13022
0
        res = obj2ast_identifier(state, tmp, &arg, "arg", arena);
13023
0
        _Py_LeaveRecursiveCall();
13024
0
        if (res != 0) goto failed;
13025
0
        Py_CLEAR(tmp);
13026
0
    }
13027
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13028
0
        return -1;
13029
0
    }
13030
0
    if (tmp == NULL) {
13031
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
13032
0
        return -1;
13033
0
    }
13034
0
    else {
13035
0
        int res;
13036
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
13037
0
            goto failed;
13038
0
        }
13039
0
        res = obj2ast_expr(state, tmp, &value, "value", arena);
13040
0
        _Py_LeaveRecursiveCall();
13041
0
        if (res != 0) goto failed;
13042
0
        Py_CLEAR(tmp);
13043
0
    }
13044
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13045
0
        return -1;
13046
0
    }
13047
0
    if (tmp == NULL) {
13048
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
13049
0
        return -1;
13050
0
    }
13051
0
    else {
13052
0
        int res;
13053
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
13054
0
            goto failed;
13055
0
        }
13056
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
13057
0
        _Py_LeaveRecursiveCall();
13058
0
        if (res != 0) goto failed;
13059
0
        Py_CLEAR(tmp);
13060
0
    }
13061
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13062
0
        return -1;
13063
0
    }
13064
0
    if (tmp == NULL) {
13065
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
13066
0
        return -1;
13067
0
    }
13068
0
    else {
13069
0
        int res;
13070
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
13071
0
            goto failed;
13072
0
        }
13073
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
13074
0
        _Py_LeaveRecursiveCall();
13075
0
        if (res != 0) goto failed;
13076
0
        Py_CLEAR(tmp);
13077
0
    }
13078
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13079
0
        return -1;
13080
0
    }
13081
0
    if (tmp == NULL || tmp == Py_None) {
13082
0
        Py_CLEAR(tmp);
13083
0
        end_lineno = lineno;
13084
0
    }
13085
0
    else {
13086
0
        int res;
13087
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
13088
0
            goto failed;
13089
0
        }
13090
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
13091
0
        _Py_LeaveRecursiveCall();
13092
0
        if (res != 0) goto failed;
13093
0
        Py_CLEAR(tmp);
13094
0
    }
13095
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13096
0
        return -1;
13097
0
    }
13098
0
    if (tmp == NULL || tmp == Py_None) {
13099
0
        Py_CLEAR(tmp);
13100
0
        end_col_offset = col_offset;
13101
0
    }
13102
0
    else {
13103
0
        int res;
13104
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
13105
0
            goto failed;
13106
0
        }
13107
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
13108
0
        _Py_LeaveRecursiveCall();
13109
0
        if (res != 0) goto failed;
13110
0
        Py_CLEAR(tmp);
13111
0
    }
13112
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
13113
0
                          end_col_offset, arena);
13114
0
    if (*out == NULL) goto failed;
13115
0
    return 0;
13116
0
failed:
13117
0
    Py_XDECREF(tmp);
13118
0
    return -1;
13119
0
}
13120
13121
int
13122
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, const
13123
              char* field, PyArena* arena)
13124
0
{
13125
0
    PyObject* tmp = NULL;
13126
0
    identifier name;
13127
0
    identifier asname;
13128
0
    int lineno;
13129
0
    int col_offset;
13130
0
    int end_lineno;
13131
0
    int end_col_offset;
13132
13133
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
13134
0
        return -1;
13135
0
    }
13136
0
    if (tmp == NULL) {
13137
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
13138
0
        return -1;
13139
0
    }
13140
0
    else {
13141
0
        int res;
13142
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
13143
0
            goto failed;
13144
0
        }
13145
0
        res = obj2ast_identifier(state, tmp, &name, "name", arena);
13146
0
        _Py_LeaveRecursiveCall();
13147
0
        if (res != 0) goto failed;
13148
0
        Py_CLEAR(tmp);
13149
0
    }
13150
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
13151
0
        return -1;
13152
0
    }
13153
0
    if (tmp == NULL || tmp == Py_None) {
13154
0
        Py_CLEAR(tmp);
13155
0
        asname = NULL;
13156
0
    }
13157
0
    else {
13158
0
        int res;
13159
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
13160
0
            goto failed;
13161
0
        }
13162
0
        res = obj2ast_identifier(state, tmp, &asname, "asname", arena);
13163
0
        _Py_LeaveRecursiveCall();
13164
0
        if (res != 0) goto failed;
13165
0
        Py_CLEAR(tmp);
13166
0
    }
13167
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13168
0
        return -1;
13169
0
    }
13170
0
    if (tmp == NULL) {
13171
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
13172
0
        return -1;
13173
0
    }
13174
0
    else {
13175
0
        int res;
13176
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
13177
0
            goto failed;
13178
0
        }
13179
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
13180
0
        _Py_LeaveRecursiveCall();
13181
0
        if (res != 0) goto failed;
13182
0
        Py_CLEAR(tmp);
13183
0
    }
13184
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13185
0
        return -1;
13186
0
    }
13187
0
    if (tmp == NULL) {
13188
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
13189
0
        return -1;
13190
0
    }
13191
0
    else {
13192
0
        int res;
13193
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
13194
0
            goto failed;
13195
0
        }
13196
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
13197
0
        _Py_LeaveRecursiveCall();
13198
0
        if (res != 0) goto failed;
13199
0
        Py_CLEAR(tmp);
13200
0
    }
13201
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13202
0
        return -1;
13203
0
    }
13204
0
    if (tmp == NULL || tmp == Py_None) {
13205
0
        Py_CLEAR(tmp);
13206
0
        end_lineno = lineno;
13207
0
    }
13208
0
    else {
13209
0
        int res;
13210
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
13211
0
            goto failed;
13212
0
        }
13213
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
13214
0
        _Py_LeaveRecursiveCall();
13215
0
        if (res != 0) goto failed;
13216
0
        Py_CLEAR(tmp);
13217
0
    }
13218
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13219
0
        return -1;
13220
0
    }
13221
0
    if (tmp == NULL || tmp == Py_None) {
13222
0
        Py_CLEAR(tmp);
13223
0
        end_col_offset = col_offset;
13224
0
    }
13225
0
    else {
13226
0
        int res;
13227
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
13228
0
            goto failed;
13229
0
        }
13230
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
13231
0
        _Py_LeaveRecursiveCall();
13232
0
        if (res != 0) goto failed;
13233
0
        Py_CLEAR(tmp);
13234
0
    }
13235
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
13236
0
                        end_col_offset, arena);
13237
0
    if (*out == NULL) goto failed;
13238
0
    return 0;
13239
0
failed:
13240
0
    Py_XDECREF(tmp);
13241
0
    return -1;
13242
0
}
13243
13244
int
13245
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
13246
                 const char* field, PyArena* arena)
13247
0
{
13248
0
    PyObject* tmp = NULL;
13249
0
    expr_ty context_expr;
13250
0
    expr_ty optional_vars;
13251
13252
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
13253
0
        return -1;
13254
0
    }
13255
0
    if (tmp == NULL) {
13256
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
13257
0
        return -1;
13258
0
    }
13259
0
    else {
13260
0
        int res;
13261
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
13262
0
            goto failed;
13263
0
        }
13264
0
        res = obj2ast_expr(state, tmp, &context_expr, "context_expr", arena);
13265
0
        _Py_LeaveRecursiveCall();
13266
0
        if (res != 0) goto failed;
13267
0
        Py_CLEAR(tmp);
13268
0
    }
13269
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
13270
0
        return -1;
13271
0
    }
13272
0
    if (tmp == NULL || tmp == Py_None) {
13273
0
        Py_CLEAR(tmp);
13274
0
        optional_vars = NULL;
13275
0
    }
13276
0
    else {
13277
0
        int res;
13278
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
13279
0
            goto failed;
13280
0
        }
13281
0
        res = obj2ast_expr(state, tmp, &optional_vars, "optional_vars", arena);
13282
0
        _Py_LeaveRecursiveCall();
13283
0
        if (res != 0) goto failed;
13284
0
        Py_CLEAR(tmp);
13285
0
    }
13286
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
13287
0
    if (*out == NULL) goto failed;
13288
0
    return 0;
13289
0
failed:
13290
0
    Py_XDECREF(tmp);
13291
0
    return -1;
13292
0
}
13293
13294
int
13295
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
13296
                   const char* field, PyArena* arena)
13297
0
{
13298
0
    PyObject* tmp = NULL;
13299
0
    pattern_ty pattern;
13300
0
    expr_ty guard;
13301
0
    asdl_stmt_seq* body;
13302
13303
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
13304
0
        return -1;
13305
0
    }
13306
0
    if (tmp == NULL) {
13307
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
13308
0
        return -1;
13309
0
    }
13310
0
    else {
13311
0
        int res;
13312
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
13313
0
            goto failed;
13314
0
        }
13315
0
        res = obj2ast_pattern(state, tmp, &pattern, "pattern", arena);
13316
0
        _Py_LeaveRecursiveCall();
13317
0
        if (res != 0) goto failed;
13318
0
        Py_CLEAR(tmp);
13319
0
    }
13320
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
13321
0
        return -1;
13322
0
    }
13323
0
    if (tmp == NULL || tmp == Py_None) {
13324
0
        Py_CLEAR(tmp);
13325
0
        guard = NULL;
13326
0
    }
13327
0
    else {
13328
0
        int res;
13329
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
13330
0
            goto failed;
13331
0
        }
13332
0
        res = obj2ast_expr(state, tmp, &guard, "guard", arena);
13333
0
        _Py_LeaveRecursiveCall();
13334
0
        if (res != 0) goto failed;
13335
0
        Py_CLEAR(tmp);
13336
0
    }
13337
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13338
0
        return -1;
13339
0
    }
13340
0
    if (tmp == NULL) {
13341
0
        tmp = PyList_New(0);
13342
0
        if (tmp == NULL) {
13343
0
            return -1;
13344
0
        }
13345
0
    }
13346
0
    {
13347
0
        int res;
13348
0
        Py_ssize_t len;
13349
0
        Py_ssize_t i;
13350
0
        if (!PyList_Check(tmp)) {
13351
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %T", tmp);
13352
0
            goto failed;
13353
0
        }
13354
0
        len = PyList_GET_SIZE(tmp);
13355
0
        body = _Py_asdl_stmt_seq_new(len, arena);
13356
0
        if (body == NULL) goto failed;
13357
0
        for (i = 0; i < len; i++) {
13358
0
            stmt_ty val;
13359
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13360
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
13361
0
                goto failed;
13362
0
            }
13363
0
            res = obj2ast_stmt(state, tmp2, &val, "body", arena);
13364
0
            _Py_LeaveRecursiveCall();
13365
0
            Py_DECREF(tmp2);
13366
0
            if (res != 0) goto failed;
13367
0
            if (len != PyList_GET_SIZE(tmp)) {
13368
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
13369
0
                goto failed;
13370
0
            }
13371
0
            asdl_seq_SET(body, i, val);
13372
0
        }
13373
0
        Py_CLEAR(tmp);
13374
0
    }
13375
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
13376
0
    if (*out == NULL) goto failed;
13377
0
    return 0;
13378
0
failed:
13379
0
    Py_XDECREF(tmp);
13380
0
    return -1;
13381
0
}
13382
13383
int
13384
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out, const
13385
                char* field, PyArena* arena)
13386
0
{
13387
0
    int isinstance;
13388
13389
0
    PyObject *tmp = NULL;
13390
0
    PyObject *tp;
13391
0
    int lineno;
13392
0
    int col_offset;
13393
0
    int end_lineno;
13394
0
    int end_col_offset;
13395
13396
0
    if (obj == Py_None) {
13397
0
        *out = NULL;
13398
0
        return 0;
13399
0
    }
13400
0
    tp = state->pattern_type;
13401
0
    isinstance = PyObject_IsInstance(obj, tp);
13402
0
    if (isinstance == -1) {
13403
0
        return 1;
13404
0
    }
13405
0
    if (!isinstance && field != NULL) {
13406
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'pattern', got '%T'", field, obj);
13407
0
        return 1;
13408
0
    }
13409
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13410
0
        return -1;
13411
0
    }
13412
0
    if (tmp == NULL) {
13413
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
13414
0
        return -1;
13415
0
    }
13416
0
    else {
13417
0
        int res;
13418
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
13419
0
            goto failed;
13420
0
        }
13421
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
13422
0
        _Py_LeaveRecursiveCall();
13423
0
        if (res != 0) goto failed;
13424
0
        Py_CLEAR(tmp);
13425
0
    }
13426
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13427
0
        return -1;
13428
0
    }
13429
0
    if (tmp == NULL) {
13430
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
13431
0
        return -1;
13432
0
    }
13433
0
    else {
13434
0
        int res;
13435
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
13436
0
            goto failed;
13437
0
        }
13438
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
13439
0
        _Py_LeaveRecursiveCall();
13440
0
        if (res != 0) goto failed;
13441
0
        Py_CLEAR(tmp);
13442
0
    }
13443
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13444
0
        return -1;
13445
0
    }
13446
0
    if (tmp == NULL) {
13447
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
13448
0
        return -1;
13449
0
    }
13450
0
    else {
13451
0
        int res;
13452
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
13453
0
            goto failed;
13454
0
        }
13455
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
13456
0
        _Py_LeaveRecursiveCall();
13457
0
        if (res != 0) goto failed;
13458
0
        Py_CLEAR(tmp);
13459
0
    }
13460
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13461
0
        return -1;
13462
0
    }
13463
0
    if (tmp == NULL) {
13464
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
13465
0
        return -1;
13466
0
    }
13467
0
    else {
13468
0
        int res;
13469
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
13470
0
            goto failed;
13471
0
        }
13472
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
13473
0
        _Py_LeaveRecursiveCall();
13474
0
        if (res != 0) goto failed;
13475
0
        Py_CLEAR(tmp);
13476
0
    }
13477
0
    tp = state->MatchValue_type;
13478
0
    isinstance = PyObject_IsInstance(obj, tp);
13479
0
    if (isinstance == -1) {
13480
0
        return -1;
13481
0
    }
13482
0
    if (isinstance) {
13483
0
        expr_ty value;
13484
13485
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13486
0
            return -1;
13487
0
        }
13488
0
        if (tmp == NULL) {
13489
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
13490
0
            return -1;
13491
0
        }
13492
0
        else {
13493
0
            int res;
13494
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
13495
0
                goto failed;
13496
0
            }
13497
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
13498
0
            _Py_LeaveRecursiveCall();
13499
0
            if (res != 0) goto failed;
13500
0
            Py_CLEAR(tmp);
13501
0
        }
13502
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
13503
0
                                 end_col_offset, arena);
13504
0
        if (*out == NULL) goto failed;
13505
0
        return 0;
13506
0
    }
13507
0
    tp = state->MatchSingleton_type;
13508
0
    isinstance = PyObject_IsInstance(obj, tp);
13509
0
    if (isinstance == -1) {
13510
0
        return -1;
13511
0
    }
13512
0
    if (isinstance) {
13513
0
        constant value;
13514
13515
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13516
0
            return -1;
13517
0
        }
13518
0
        if (tmp == NULL) {
13519
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
13520
0
            return -1;
13521
0
        }
13522
0
        else {
13523
0
            int res;
13524
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
13525
0
                goto failed;
13526
0
            }
13527
0
            res = obj2ast_constant(state, tmp, &value, "value", arena);
13528
0
            _Py_LeaveRecursiveCall();
13529
0
            if (res != 0) goto failed;
13530
0
            Py_CLEAR(tmp);
13531
0
        }
13532
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
13533
0
                                     end_col_offset, arena);
13534
0
        if (*out == NULL) goto failed;
13535
0
        return 0;
13536
0
    }
13537
0
    tp = state->MatchSequence_type;
13538
0
    isinstance = PyObject_IsInstance(obj, tp);
13539
0
    if (isinstance == -1) {
13540
0
        return -1;
13541
0
    }
13542
0
    if (isinstance) {
13543
0
        asdl_pattern_seq* patterns;
13544
13545
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
13546
0
            return -1;
13547
0
        }
13548
0
        if (tmp == NULL) {
13549
0
            tmp = PyList_New(0);
13550
0
            if (tmp == NULL) {
13551
0
                return -1;
13552
0
            }
13553
0
        }
13554
0
        {
13555
0
            int res;
13556
0
            Py_ssize_t len;
13557
0
            Py_ssize_t i;
13558
0
            if (!PyList_Check(tmp)) {
13559
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %T", tmp);
13560
0
                goto failed;
13561
0
            }
13562
0
            len = PyList_GET_SIZE(tmp);
13563
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
13564
0
            if (patterns == NULL) goto failed;
13565
0
            for (i = 0; i < len; i++) {
13566
0
                pattern_ty val;
13567
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13568
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
13569
0
                    goto failed;
13570
0
                }
13571
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
13572
0
                _Py_LeaveRecursiveCall();
13573
0
                Py_DECREF(tmp2);
13574
0
                if (res != 0) goto failed;
13575
0
                if (len != PyList_GET_SIZE(tmp)) {
13576
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
13577
0
                    goto failed;
13578
0
                }
13579
0
                asdl_seq_SET(patterns, i, val);
13580
0
            }
13581
0
            Py_CLEAR(tmp);
13582
0
        }
13583
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
13584
0
                                    end_col_offset, arena);
13585
0
        if (*out == NULL) goto failed;
13586
0
        return 0;
13587
0
    }
13588
0
    tp = state->MatchMapping_type;
13589
0
    isinstance = PyObject_IsInstance(obj, tp);
13590
0
    if (isinstance == -1) {
13591
0
        return -1;
13592
0
    }
13593
0
    if (isinstance) {
13594
0
        asdl_expr_seq* keys;
13595
0
        asdl_pattern_seq* patterns;
13596
0
        identifier rest;
13597
13598
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
13599
0
            return -1;
13600
0
        }
13601
0
        if (tmp == NULL) {
13602
0
            tmp = PyList_New(0);
13603
0
            if (tmp == NULL) {
13604
0
                return -1;
13605
0
            }
13606
0
        }
13607
0
        {
13608
0
            int res;
13609
0
            Py_ssize_t len;
13610
0
            Py_ssize_t i;
13611
0
            if (!PyList_Check(tmp)) {
13612
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %T", tmp);
13613
0
                goto failed;
13614
0
            }
13615
0
            len = PyList_GET_SIZE(tmp);
13616
0
            keys = _Py_asdl_expr_seq_new(len, arena);
13617
0
            if (keys == NULL) goto failed;
13618
0
            for (i = 0; i < len; i++) {
13619
0
                expr_ty val;
13620
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13621
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
13622
0
                    goto failed;
13623
0
                }
13624
0
                res = obj2ast_expr(state, tmp2, &val, "keys", arena);
13625
0
                _Py_LeaveRecursiveCall();
13626
0
                Py_DECREF(tmp2);
13627
0
                if (res != 0) goto failed;
13628
0
                if (len != PyList_GET_SIZE(tmp)) {
13629
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
13630
0
                    goto failed;
13631
0
                }
13632
0
                asdl_seq_SET(keys, i, val);
13633
0
            }
13634
0
            Py_CLEAR(tmp);
13635
0
        }
13636
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
13637
0
            return -1;
13638
0
        }
13639
0
        if (tmp == NULL) {
13640
0
            tmp = PyList_New(0);
13641
0
            if (tmp == NULL) {
13642
0
                return -1;
13643
0
            }
13644
0
        }
13645
0
        {
13646
0
            int res;
13647
0
            Py_ssize_t len;
13648
0
            Py_ssize_t i;
13649
0
            if (!PyList_Check(tmp)) {
13650
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %T", tmp);
13651
0
                goto failed;
13652
0
            }
13653
0
            len = PyList_GET_SIZE(tmp);
13654
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
13655
0
            if (patterns == NULL) goto failed;
13656
0
            for (i = 0; i < len; i++) {
13657
0
                pattern_ty val;
13658
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13659
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
13660
0
                    goto failed;
13661
0
                }
13662
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
13663
0
                _Py_LeaveRecursiveCall();
13664
0
                Py_DECREF(tmp2);
13665
0
                if (res != 0) goto failed;
13666
0
                if (len != PyList_GET_SIZE(tmp)) {
13667
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
13668
0
                    goto failed;
13669
0
                }
13670
0
                asdl_seq_SET(patterns, i, val);
13671
0
            }
13672
0
            Py_CLEAR(tmp);
13673
0
        }
13674
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
13675
0
            return -1;
13676
0
        }
13677
0
        if (tmp == NULL || tmp == Py_None) {
13678
0
            Py_CLEAR(tmp);
13679
0
            rest = NULL;
13680
0
        }
13681
0
        else {
13682
0
            int res;
13683
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
13684
0
                goto failed;
13685
0
            }
13686
0
            res = obj2ast_identifier(state, tmp, &rest, "rest", arena);
13687
0
            _Py_LeaveRecursiveCall();
13688
0
            if (res != 0) goto failed;
13689
0
            Py_CLEAR(tmp);
13690
0
        }
13691
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
13692
0
                                   end_lineno, end_col_offset, arena);
13693
0
        if (*out == NULL) goto failed;
13694
0
        return 0;
13695
0
    }
13696
0
    tp = state->MatchClass_type;
13697
0
    isinstance = PyObject_IsInstance(obj, tp);
13698
0
    if (isinstance == -1) {
13699
0
        return -1;
13700
0
    }
13701
0
    if (isinstance) {
13702
0
        expr_ty cls;
13703
0
        asdl_pattern_seq* patterns;
13704
0
        asdl_identifier_seq* kwd_attrs;
13705
0
        asdl_pattern_seq* kwd_patterns;
13706
13707
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
13708
0
            return -1;
13709
0
        }
13710
0
        if (tmp == NULL) {
13711
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
13712
0
            return -1;
13713
0
        }
13714
0
        else {
13715
0
            int res;
13716
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
13717
0
                goto failed;
13718
0
            }
13719
0
            res = obj2ast_expr(state, tmp, &cls, "cls", arena);
13720
0
            _Py_LeaveRecursiveCall();
13721
0
            if (res != 0) goto failed;
13722
0
            Py_CLEAR(tmp);
13723
0
        }
13724
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
13725
0
            return -1;
13726
0
        }
13727
0
        if (tmp == NULL) {
13728
0
            tmp = PyList_New(0);
13729
0
            if (tmp == NULL) {
13730
0
                return -1;
13731
0
            }
13732
0
        }
13733
0
        {
13734
0
            int res;
13735
0
            Py_ssize_t len;
13736
0
            Py_ssize_t i;
13737
0
            if (!PyList_Check(tmp)) {
13738
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %T", tmp);
13739
0
                goto failed;
13740
0
            }
13741
0
            len = PyList_GET_SIZE(tmp);
13742
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
13743
0
            if (patterns == NULL) goto failed;
13744
0
            for (i = 0; i < len; i++) {
13745
0
                pattern_ty val;
13746
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13747
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
13748
0
                    goto failed;
13749
0
                }
13750
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
13751
0
                _Py_LeaveRecursiveCall();
13752
0
                Py_DECREF(tmp2);
13753
0
                if (res != 0) goto failed;
13754
0
                if (len != PyList_GET_SIZE(tmp)) {
13755
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
13756
0
                    goto failed;
13757
0
                }
13758
0
                asdl_seq_SET(patterns, i, val);
13759
0
            }
13760
0
            Py_CLEAR(tmp);
13761
0
        }
13762
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
13763
0
            return -1;
13764
0
        }
13765
0
        if (tmp == NULL) {
13766
0
            tmp = PyList_New(0);
13767
0
            if (tmp == NULL) {
13768
0
                return -1;
13769
0
            }
13770
0
        }
13771
0
        {
13772
0
            int res;
13773
0
            Py_ssize_t len;
13774
0
            Py_ssize_t i;
13775
0
            if (!PyList_Check(tmp)) {
13776
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %T", tmp);
13777
0
                goto failed;
13778
0
            }
13779
0
            len = PyList_GET_SIZE(tmp);
13780
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
13781
0
            if (kwd_attrs == NULL) goto failed;
13782
0
            for (i = 0; i < len; i++) {
13783
0
                identifier val;
13784
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13785
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
13786
0
                    goto failed;
13787
0
                }
13788
0
                res = obj2ast_identifier(state, tmp2, &val, "kwd_attrs", arena);
13789
0
                _Py_LeaveRecursiveCall();
13790
0
                Py_DECREF(tmp2);
13791
0
                if (res != 0) goto failed;
13792
0
                if (len != PyList_GET_SIZE(tmp)) {
13793
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
13794
0
                    goto failed;
13795
0
                }
13796
0
                asdl_seq_SET(kwd_attrs, i, val);
13797
0
            }
13798
0
            Py_CLEAR(tmp);
13799
0
        }
13800
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
13801
0
            return -1;
13802
0
        }
13803
0
        if (tmp == NULL) {
13804
0
            tmp = PyList_New(0);
13805
0
            if (tmp == NULL) {
13806
0
                return -1;
13807
0
            }
13808
0
        }
13809
0
        {
13810
0
            int res;
13811
0
            Py_ssize_t len;
13812
0
            Py_ssize_t i;
13813
0
            if (!PyList_Check(tmp)) {
13814
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %T", tmp);
13815
0
                goto failed;
13816
0
            }
13817
0
            len = PyList_GET_SIZE(tmp);
13818
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
13819
0
            if (kwd_patterns == NULL) goto failed;
13820
0
            for (i = 0; i < len; i++) {
13821
0
                pattern_ty val;
13822
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13823
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
13824
0
                    goto failed;
13825
0
                }
13826
0
                res = obj2ast_pattern(state, tmp2, &val, "kwd_patterns", arena);
13827
0
                _Py_LeaveRecursiveCall();
13828
0
                Py_DECREF(tmp2);
13829
0
                if (res != 0) goto failed;
13830
0
                if (len != PyList_GET_SIZE(tmp)) {
13831
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
13832
0
                    goto failed;
13833
0
                }
13834
0
                asdl_seq_SET(kwd_patterns, i, val);
13835
0
            }
13836
0
            Py_CLEAR(tmp);
13837
0
        }
13838
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
13839
0
                                 lineno, col_offset, end_lineno,
13840
0
                                 end_col_offset, arena);
13841
0
        if (*out == NULL) goto failed;
13842
0
        return 0;
13843
0
    }
13844
0
    tp = state->MatchStar_type;
13845
0
    isinstance = PyObject_IsInstance(obj, tp);
13846
0
    if (isinstance == -1) {
13847
0
        return -1;
13848
0
    }
13849
0
    if (isinstance) {
13850
0
        identifier name;
13851
13852
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
13853
0
            return -1;
13854
0
        }
13855
0
        if (tmp == NULL || tmp == Py_None) {
13856
0
            Py_CLEAR(tmp);
13857
0
            name = NULL;
13858
0
        }
13859
0
        else {
13860
0
            int res;
13861
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
13862
0
                goto failed;
13863
0
            }
13864
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
13865
0
            _Py_LeaveRecursiveCall();
13866
0
            if (res != 0) goto failed;
13867
0
            Py_CLEAR(tmp);
13868
0
        }
13869
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
13870
0
                                end_col_offset, arena);
13871
0
        if (*out == NULL) goto failed;
13872
0
        return 0;
13873
0
    }
13874
0
    tp = state->MatchAs_type;
13875
0
    isinstance = PyObject_IsInstance(obj, tp);
13876
0
    if (isinstance == -1) {
13877
0
        return -1;
13878
0
    }
13879
0
    if (isinstance) {
13880
0
        pattern_ty pattern;
13881
0
        identifier name;
13882
13883
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
13884
0
            return -1;
13885
0
        }
13886
0
        if (tmp == NULL || tmp == Py_None) {
13887
0
            Py_CLEAR(tmp);
13888
0
            pattern = NULL;
13889
0
        }
13890
0
        else {
13891
0
            int res;
13892
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
13893
0
                goto failed;
13894
0
            }
13895
0
            res = obj2ast_pattern(state, tmp, &pattern, "pattern", arena);
13896
0
            _Py_LeaveRecursiveCall();
13897
0
            if (res != 0) goto failed;
13898
0
            Py_CLEAR(tmp);
13899
0
        }
13900
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
13901
0
            return -1;
13902
0
        }
13903
0
        if (tmp == NULL || tmp == Py_None) {
13904
0
            Py_CLEAR(tmp);
13905
0
            name = NULL;
13906
0
        }
13907
0
        else {
13908
0
            int res;
13909
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
13910
0
                goto failed;
13911
0
            }
13912
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
13913
0
            _Py_LeaveRecursiveCall();
13914
0
            if (res != 0) goto failed;
13915
0
            Py_CLEAR(tmp);
13916
0
        }
13917
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
13918
0
                              end_col_offset, arena);
13919
0
        if (*out == NULL) goto failed;
13920
0
        return 0;
13921
0
    }
13922
0
    tp = state->MatchOr_type;
13923
0
    isinstance = PyObject_IsInstance(obj, tp);
13924
0
    if (isinstance == -1) {
13925
0
        return -1;
13926
0
    }
13927
0
    if (isinstance) {
13928
0
        asdl_pattern_seq* patterns;
13929
13930
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
13931
0
            return -1;
13932
0
        }
13933
0
        if (tmp == NULL) {
13934
0
            tmp = PyList_New(0);
13935
0
            if (tmp == NULL) {
13936
0
                return -1;
13937
0
            }
13938
0
        }
13939
0
        {
13940
0
            int res;
13941
0
            Py_ssize_t len;
13942
0
            Py_ssize_t i;
13943
0
            if (!PyList_Check(tmp)) {
13944
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %T", tmp);
13945
0
                goto failed;
13946
0
            }
13947
0
            len = PyList_GET_SIZE(tmp);
13948
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
13949
0
            if (patterns == NULL) goto failed;
13950
0
            for (i = 0; i < len; i++) {
13951
0
                pattern_ty val;
13952
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13953
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
13954
0
                    goto failed;
13955
0
                }
13956
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
13957
0
                _Py_LeaveRecursiveCall();
13958
0
                Py_DECREF(tmp2);
13959
0
                if (res != 0) goto failed;
13960
0
                if (len != PyList_GET_SIZE(tmp)) {
13961
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
13962
0
                    goto failed;
13963
0
                }
13964
0
                asdl_seq_SET(patterns, i, val);
13965
0
            }
13966
0
            Py_CLEAR(tmp);
13967
0
        }
13968
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
13969
0
                              end_col_offset, arena);
13970
0
        if (*out == NULL) goto failed;
13971
0
        return 0;
13972
0
    }
13973
13974
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
13975
0
    failed:
13976
0
    Py_XDECREF(tmp);
13977
0
    return -1;
13978
0
}
13979
13980
int
13981
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
13982
                    out, const char* field, PyArena* arena)
13983
0
{
13984
0
    int isinstance;
13985
13986
0
    PyObject *tmp = NULL;
13987
0
    PyObject *tp;
13988
13989
0
    if (obj == Py_None) {
13990
0
        *out = NULL;
13991
0
        return 0;
13992
0
    }
13993
0
    tp = state->type_ignore_type;
13994
0
    isinstance = PyObject_IsInstance(obj, tp);
13995
0
    if (isinstance == -1) {
13996
0
        return 1;
13997
0
    }
13998
0
    if (!isinstance && field != NULL) {
13999
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'type_ignore', got '%T'", field, obj);
14000
0
        return 1;
14001
0
    }
14002
0
    tp = state->TypeIgnore_type;
14003
0
    isinstance = PyObject_IsInstance(obj, tp);
14004
0
    if (isinstance == -1) {
14005
0
        return -1;
14006
0
    }
14007
0
    if (isinstance) {
14008
0
        int lineno;
14009
0
        string tag;
14010
14011
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
14012
0
            return -1;
14013
0
        }
14014
0
        if (tmp == NULL) {
14015
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
14016
0
            return -1;
14017
0
        }
14018
0
        else {
14019
0
            int res;
14020
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
14021
0
                goto failed;
14022
0
            }
14023
0
            res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
14024
0
            _Py_LeaveRecursiveCall();
14025
0
            if (res != 0) goto failed;
14026
0
            Py_CLEAR(tmp);
14027
0
        }
14028
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
14029
0
            return -1;
14030
0
        }
14031
0
        if (tmp == NULL) {
14032
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
14033
0
            return -1;
14034
0
        }
14035
0
        else {
14036
0
            int res;
14037
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
14038
0
                goto failed;
14039
0
            }
14040
0
            res = obj2ast_string(state, tmp, &tag, "tag", arena);
14041
0
            _Py_LeaveRecursiveCall();
14042
0
            if (res != 0) goto failed;
14043
0
            Py_CLEAR(tmp);
14044
0
        }
14045
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
14046
0
        if (*out == NULL) goto failed;
14047
0
        return 0;
14048
0
    }
14049
14050
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
14051
0
    failed:
14052
0
    Py_XDECREF(tmp);
14053
0
    return -1;
14054
0
}
14055
14056
int
14057
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
14058
                   const char* field, PyArena* arena)
14059
0
{
14060
0
    int isinstance;
14061
14062
0
    PyObject *tmp = NULL;
14063
0
    PyObject *tp;
14064
0
    int lineno;
14065
0
    int col_offset;
14066
0
    int end_lineno;
14067
0
    int end_col_offset;
14068
14069
0
    if (obj == Py_None) {
14070
0
        *out = NULL;
14071
0
        return 0;
14072
0
    }
14073
0
    tp = state->type_param_type;
14074
0
    isinstance = PyObject_IsInstance(obj, tp);
14075
0
    if (isinstance == -1) {
14076
0
        return 1;
14077
0
    }
14078
0
    if (!isinstance && field != NULL) {
14079
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'type_param', got '%T'", field, obj);
14080
0
        return 1;
14081
0
    }
14082
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
14083
0
        return -1;
14084
0
    }
14085
0
    if (tmp == NULL) {
14086
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
14087
0
        return -1;
14088
0
    }
14089
0
    else {
14090
0
        int res;
14091
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
14092
0
            goto failed;
14093
0
        }
14094
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
14095
0
        _Py_LeaveRecursiveCall();
14096
0
        if (res != 0) goto failed;
14097
0
        Py_CLEAR(tmp);
14098
0
    }
14099
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
14100
0
        return -1;
14101
0
    }
14102
0
    if (tmp == NULL) {
14103
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
14104
0
        return -1;
14105
0
    }
14106
0
    else {
14107
0
        int res;
14108
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
14109
0
            goto failed;
14110
0
        }
14111
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
14112
0
        _Py_LeaveRecursiveCall();
14113
0
        if (res != 0) goto failed;
14114
0
        Py_CLEAR(tmp);
14115
0
    }
14116
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
14117
0
        return -1;
14118
0
    }
14119
0
    if (tmp == NULL) {
14120
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
14121
0
        return -1;
14122
0
    }
14123
0
    else {
14124
0
        int res;
14125
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
14126
0
            goto failed;
14127
0
        }
14128
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
14129
0
        _Py_LeaveRecursiveCall();
14130
0
        if (res != 0) goto failed;
14131
0
        Py_CLEAR(tmp);
14132
0
    }
14133
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
14134
0
        return -1;
14135
0
    }
14136
0
    if (tmp == NULL) {
14137
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
14138
0
        return -1;
14139
0
    }
14140
0
    else {
14141
0
        int res;
14142
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
14143
0
            goto failed;
14144
0
        }
14145
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
14146
0
        _Py_LeaveRecursiveCall();
14147
0
        if (res != 0) goto failed;
14148
0
        Py_CLEAR(tmp);
14149
0
    }
14150
0
    tp = state->TypeVar_type;
14151
0
    isinstance = PyObject_IsInstance(obj, tp);
14152
0
    if (isinstance == -1) {
14153
0
        return -1;
14154
0
    }
14155
0
    if (isinstance) {
14156
0
        identifier name;
14157
0
        expr_ty bound;
14158
0
        expr_ty default_value;
14159
14160
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
14161
0
            return -1;
14162
0
        }
14163
0
        if (tmp == NULL) {
14164
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
14165
0
            return -1;
14166
0
        }
14167
0
        else {
14168
0
            int res;
14169
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
14170
0
                goto failed;
14171
0
            }
14172
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
14173
0
            _Py_LeaveRecursiveCall();
14174
0
            if (res != 0) goto failed;
14175
0
            Py_CLEAR(tmp);
14176
0
        }
14177
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
14178
0
            return -1;
14179
0
        }
14180
0
        if (tmp == NULL || tmp == Py_None) {
14181
0
            Py_CLEAR(tmp);
14182
0
            bound = NULL;
14183
0
        }
14184
0
        else {
14185
0
            int res;
14186
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
14187
0
                goto failed;
14188
0
            }
14189
0
            res = obj2ast_expr(state, tmp, &bound, "bound", arena);
14190
0
            _Py_LeaveRecursiveCall();
14191
0
            if (res != 0) goto failed;
14192
0
            Py_CLEAR(tmp);
14193
0
        }
14194
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
14195
0
            return -1;
14196
0
        }
14197
0
        if (tmp == NULL || tmp == Py_None) {
14198
0
            Py_CLEAR(tmp);
14199
0
            default_value = NULL;
14200
0
        }
14201
0
        else {
14202
0
            int res;
14203
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
14204
0
                goto failed;
14205
0
            }
14206
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
14207
0
                               arena);
14208
0
            _Py_LeaveRecursiveCall();
14209
0
            if (res != 0) goto failed;
14210
0
            Py_CLEAR(tmp);
14211
0
        }
14212
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
14213
0
                              end_lineno, end_col_offset, arena);
14214
0
        if (*out == NULL) goto failed;
14215
0
        return 0;
14216
0
    }
14217
0
    tp = state->ParamSpec_type;
14218
0
    isinstance = PyObject_IsInstance(obj, tp);
14219
0
    if (isinstance == -1) {
14220
0
        return -1;
14221
0
    }
14222
0
    if (isinstance) {
14223
0
        identifier name;
14224
0
        expr_ty default_value;
14225
14226
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
14227
0
            return -1;
14228
0
        }
14229
0
        if (tmp == NULL) {
14230
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
14231
0
            return -1;
14232
0
        }
14233
0
        else {
14234
0
            int res;
14235
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
14236
0
                goto failed;
14237
0
            }
14238
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
14239
0
            _Py_LeaveRecursiveCall();
14240
0
            if (res != 0) goto failed;
14241
0
            Py_CLEAR(tmp);
14242
0
        }
14243
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
14244
0
            return -1;
14245
0
        }
14246
0
        if (tmp == NULL || tmp == Py_None) {
14247
0
            Py_CLEAR(tmp);
14248
0
            default_value = NULL;
14249
0
        }
14250
0
        else {
14251
0
            int res;
14252
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
14253
0
                goto failed;
14254
0
            }
14255
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
14256
0
                               arena);
14257
0
            _Py_LeaveRecursiveCall();
14258
0
            if (res != 0) goto failed;
14259
0
            Py_CLEAR(tmp);
14260
0
        }
14261
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
14262
0
                                end_lineno, end_col_offset, arena);
14263
0
        if (*out == NULL) goto failed;
14264
0
        return 0;
14265
0
    }
14266
0
    tp = state->TypeVarTuple_type;
14267
0
    isinstance = PyObject_IsInstance(obj, tp);
14268
0
    if (isinstance == -1) {
14269
0
        return -1;
14270
0
    }
14271
0
    if (isinstance) {
14272
0
        identifier name;
14273
0
        expr_ty default_value;
14274
14275
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
14276
0
            return -1;
14277
0
        }
14278
0
        if (tmp == NULL) {
14279
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
14280
0
            return -1;
14281
0
        }
14282
0
        else {
14283
0
            int res;
14284
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
14285
0
                goto failed;
14286
0
            }
14287
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
14288
0
            _Py_LeaveRecursiveCall();
14289
0
            if (res != 0) goto failed;
14290
0
            Py_CLEAR(tmp);
14291
0
        }
14292
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
14293
0
            return -1;
14294
0
        }
14295
0
        if (tmp == NULL || tmp == Py_None) {
14296
0
            Py_CLEAR(tmp);
14297
0
            default_value = NULL;
14298
0
        }
14299
0
        else {
14300
0
            int res;
14301
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
14302
0
                goto failed;
14303
0
            }
14304
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
14305
0
                               arena);
14306
0
            _Py_LeaveRecursiveCall();
14307
0
            if (res != 0) goto failed;
14308
0
            Py_CLEAR(tmp);
14309
0
        }
14310
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
14311
0
                                   end_lineno, end_col_offset, arena);
14312
0
        if (*out == NULL) goto failed;
14313
0
        return 0;
14314
0
    }
14315
14316
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
14317
0
    failed:
14318
0
    Py_XDECREF(tmp);
14319
0
    return -1;
14320
0
}
14321
14322
14323
/* Helper for checking if a node class is abstract in the tests. */
14324
static PyObject *
14325
0
ast_is_abstract(PyObject *Py_UNUSED(module), PyObject *cls) {
14326
0
    struct ast_state *state = get_ast_state();
14327
0
    if (state == NULL) {
14328
0
        return NULL;
14329
0
    }
14330
0
    int contains = PySet_Contains(state->abstract_types, cls);
14331
0
    if (contains == -1) {
14332
0
        return NULL;
14333
0
    }
14334
0
    else if (contains == 1) {
14335
0
        Py_RETURN_TRUE;
14336
0
    }
14337
0
    Py_RETURN_FALSE;
14338
0
}
14339
14340
static struct PyMethodDef astmodule_methods[] = {
14341
    {"_is_abstract", ast_is_abstract, METH_O, NULL},
14342
    {NULL}  /* Sentinel */
14343
};
14344
14345
static int
14346
astmodule_exec(PyObject *m)
14347
9
{
14348
9
    struct ast_state *state = get_ast_state();
14349
9
    if (state == NULL) {
14350
0
        return -1;
14351
0
    }
14352
9
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
14353
0
        return -1;
14354
0
    }
14355
9
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
14356
0
        return -1;
14357
0
    }
14358
9
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
14359
0
        return -1;
14360
0
    }
14361
9
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
14362
0
        return -1;
14363
0
    }
14364
9
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
14365
0
        return -1;
14366
0
    }
14367
9
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
14368
0
        return -1;
14369
0
    }
14370
9
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
14371
0
        return -1;
14372
0
    }
14373
9
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
14374
0
        return -1;
14375
0
    }
14376
9
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
14377
0
        return -1;
14378
0
    }
14379
9
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
14380
0
        {
14381
0
        return -1;
14382
0
    }
14383
9
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
14384
0
        return -1;
14385
0
    }
14386
9
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
14387
0
        return -1;
14388
0
    }
14389
9
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
14390
9
        state->AsyncFunctionDef_type) < 0) {
14391
0
        return -1;
14392
0
    }
14393
9
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
14394
0
        return -1;
14395
0
    }
14396
9
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
14397
0
        return -1;
14398
0
    }
14399
9
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
14400
0
        return -1;
14401
0
    }
14402
9
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
14403
0
        return -1;
14404
0
    }
14405
9
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
14406
0
        return -1;
14407
0
    }
14408
9
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
14409
0
        return -1;
14410
0
    }
14411
9
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
14412
0
        return -1;
14413
0
    }
14414
9
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
14415
0
        return -1;
14416
0
    }
14417
9
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
14418
0
        return -1;
14419
0
    }
14420
9
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
14421
0
        return -1;
14422
0
    }
14423
9
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
14424
0
        return -1;
14425
0
    }
14426
9
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
14427
0
        return -1;
14428
0
    }
14429
9
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
14430
0
        return -1;
14431
0
    }
14432
9
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
14433
0
        return -1;
14434
0
    }
14435
9
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
14436
0
        return -1;
14437
0
    }
14438
9
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
14439
0
        return -1;
14440
0
    }
14441
9
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
14442
0
        return -1;
14443
0
    }
14444
9
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
14445
0
        return -1;
14446
0
    }
14447
9
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
14448
0
        return -1;
14449
0
    }
14450
9
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
14451
0
        return -1;
14452
0
    }
14453
9
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
14454
0
        return -1;
14455
0
    }
14456
9
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
14457
0
        return -1;
14458
0
    }
14459
9
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
14460
0
        return -1;
14461
0
    }
14462
9
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
14463
0
        return -1;
14464
0
    }
14465
9
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
14466
0
        return -1;
14467
0
    }
14468
9
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
14469
0
        return -1;
14470
0
    }
14471
9
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
14472
0
        return -1;
14473
0
    }
14474
9
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
14475
0
        return -1;
14476
0
    }
14477
9
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
14478
0
        return -1;
14479
0
    }
14480
9
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
14481
0
        return -1;
14482
0
    }
14483
9
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
14484
0
        return -1;
14485
0
    }
14486
9
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
14487
0
        return -1;
14488
0
    }
14489
9
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
14490
0
        return -1;
14491
0
    }
14492
9
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
14493
0
        return -1;
14494
0
    }
14495
9
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
14496
0
        return -1;
14497
0
    }
14498
9
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
14499
0
        return -1;
14500
0
    }
14501
9
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
14502
0
        return -1;
14503
0
    }
14504
9
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
14505
0
        return -1;
14506
0
    }
14507
9
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
14508
0
        {
14509
0
        return -1;
14510
0
    }
14511
9
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
14512
0
        return -1;
14513
0
    }
14514
9
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
14515
0
        return -1;
14516
0
    }
14517
9
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
14518
0
        return -1;
14519
0
    }
14520
9
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
14521
0
        return -1;
14522
0
    }
14523
9
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
14524
0
        return -1;
14525
0
    }
14526
9
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
14527
9
        < 0) {
14528
0
        return -1;
14529
0
    }
14530
9
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
14531
9
        0) {
14532
0
        return -1;
14533
0
    }
14534
9
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
14535
0
        return -1;
14536
0
    }
14537
9
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
14538
0
        return -1;
14539
0
    }
14540
9
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
14541
0
        return -1;
14542
0
    }
14543
9
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
14544
0
        return -1;
14545
0
    }
14546
9
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
14547
0
        return -1;
14548
0
    }
14549
9
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
14550
0
        return -1;
14551
0
    }
14552
9
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
14553
0
        return -1;
14554
0
    }
14555
9
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
14556
0
        return -1;
14557
0
    }
14558
9
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
14559
0
        return -1;
14560
0
    }
14561
9
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
14562
0
        return -1;
14563
0
    }
14564
9
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
14565
0
        {
14566
0
        return -1;
14567
0
    }
14568
9
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
14569
0
        return -1;
14570
0
    }
14571
9
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
14572
0
        return -1;
14573
0
    }
14574
9
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
14575
0
        return -1;
14576
0
    }
14577
9
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
14578
0
        return -1;
14579
0
    }
14580
9
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
14581
0
        return -1;
14582
0
    }
14583
9
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
14584
0
        return -1;
14585
0
    }
14586
9
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
14587
0
        return -1;
14588
0
    }
14589
9
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
14590
0
        return -1;
14591
0
    }
14592
9
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
14593
0
        return -1;
14594
0
    }
14595
9
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
14596
0
        return -1;
14597
0
    }
14598
9
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
14599
0
        return -1;
14600
0
    }
14601
9
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
14602
0
        return -1;
14603
0
    }
14604
9
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
14605
0
        return -1;
14606
0
    }
14607
9
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
14608
0
        return -1;
14609
0
    }
14610
9
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
14611
0
        return -1;
14612
0
    }
14613
9
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
14614
0
        return -1;
14615
0
    }
14616
9
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
14617
0
        return -1;
14618
0
    }
14619
9
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
14620
0
        return -1;
14621
0
    }
14622
9
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
14623
0
        return -1;
14624
0
    }
14625
9
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
14626
0
        return -1;
14627
0
    }
14628
9
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
14629
0
        return -1;
14630
0
    }
14631
9
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
14632
0
        return -1;
14633
0
    }
14634
9
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
14635
0
        return -1;
14636
0
    }
14637
9
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
14638
0
        return -1;
14639
0
    }
14640
9
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
14641
0
        return -1;
14642
0
    }
14643
9
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
14644
0
        return -1;
14645
0
    }
14646
9
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
14647
0
        return -1;
14648
0
    }
14649
9
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
14650
0
        return -1;
14651
0
    }
14652
9
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
14653
0
        return -1;
14654
0
    }
14655
9
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
14656
0
        return -1;
14657
0
    }
14658
9
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
14659
0
        return -1;
14660
0
    }
14661
9
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
14662
0
        return -1;
14663
0
    }
14664
9
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
14665
0
        return -1;
14666
0
    }
14667
9
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
14668
0
        return -1;
14669
0
    }
14670
9
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
14671
0
        return -1;
14672
0
    }
14673
9
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
14674
0
        return -1;
14675
0
    }
14676
9
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
14677
9
        0) {
14678
0
        return -1;
14679
0
    }
14680
9
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
14681
9
        0) {
14682
0
        return -1;
14683
0
    }
14684
9
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
14685
9
        0) {
14686
0
        return -1;
14687
0
    }
14688
9
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
14689
0
        return -1;
14690
0
    }
14691
9
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
14692
0
        return -1;
14693
0
    }
14694
9
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
14695
0
        return -1;
14696
0
    }
14697
9
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
14698
0
        return -1;
14699
0
    }
14700
9
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
14701
0
        return -1;
14702
0
    }
14703
9
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
14704
0
        return -1;
14705
0
    }
14706
9
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
14707
0
        return -1;
14708
0
    }
14709
9
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
14710
0
        return -1;
14711
0
    }
14712
9
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
14713
9
        < 0) {
14714
0
        return -1;
14715
0
    }
14716
9
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
14717
9
        0) {
14718
0
        return -1;
14719
0
    }
14720
9
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
14721
0
        {
14722
0
        return -1;
14723
0
    }
14724
9
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
14725
0
        return -1;
14726
0
    }
14727
9
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
14728
0
        return -1;
14729
0
    }
14730
9
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
14731
0
        return -1;
14732
0
    }
14733
9
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
14734
0
        return -1;
14735
0
    }
14736
9
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
14737
0
        return -1;
14738
0
    }
14739
9
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
14740
0
        return -1;
14741
0
    }
14742
9
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
14743
0
        return -1;
14744
0
    }
14745
9
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
14746
0
        return -1;
14747
0
    }
14748
9
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
14749
0
        return -1;
14750
0
    }
14751
9
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
14752
0
        {
14753
0
        return -1;
14754
0
    }
14755
9
    return 0;
14756
9
}
14757
14758
static PyModuleDef_Slot astmodule_slots[] = {
14759
    _Py_ABI_SLOT,
14760
    {Py_mod_exec, astmodule_exec},
14761
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
14762
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
14763
    {0, NULL}
14764
};
14765
14766
static struct PyModuleDef _astmodule = {
14767
    PyModuleDef_HEAD_INIT,
14768
    .m_name = "_ast",
14769
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
14770
    .m_size = 0,
14771
    .m_methods = astmodule_methods,
14772
    .m_slots = astmodule_slots
14773
};
14774
14775
PyMODINIT_FUNC
14776
PyInit__ast(void)
14777
9
{
14778
9
    return PyModuleDef_Init(&_astmodule);
14779
9
}
14780
14781
14782
PyObject* PyAST_mod2obj(mod_ty t)
14783
8.22k
{
14784
8.22k
    struct ast_state *state = get_ast_state();
14785
8.22k
    if (state == NULL) {
14786
0
        return NULL;
14787
0
    }
14788
8.22k
    PyObject *result = ast2obj_mod(state, t);
14789
14790
8.22k
    return result;
14791
8.22k
}
14792
14793
/* mode is 0 for "exec", 1 for "eval", 2 for "single" and 3 for "func_type"
14794
   input */
14795
int PyAst_CheckMode(PyObject *ast, int mode)
14796
0
{
14797
0
    const char * const req_name[] = {"Module", "Expression", "Interactive",
14798
0
                                     "FunctionType"};
14799
14800
0
    struct ast_state *state = get_ast_state();
14801
0
    if (state == NULL) {
14802
0
        return -1;
14803
0
    }
14804
14805
0
    PyObject *req_type[4];
14806
0
    req_type[0] = state->Module_type;
14807
0
    req_type[1] = state->Expression_type;
14808
0
    req_type[2] = state->Interactive_type;
14809
0
    req_type[3] = state->FunctionType_type;
14810
14811
0
    assert(0 <= mode && mode <= 3);
14812
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
14813
0
    if (isinstance == -1) {
14814
0
        return -1;
14815
0
    }
14816
0
    if (!isinstance) {
14817
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %T",
14818
0
                     req_name[mode], ast);
14819
0
        return -1;
14820
0
    }
14821
0
    return 0;
14822
0
}
14823
14824
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
14825
0
{
14826
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
14827
0
        return NULL;
14828
0
    }
14829
14830
0
    struct ast_state *state = get_ast_state();
14831
0
    if (state == NULL) {
14832
0
        return NULL;
14833
0
    }
14834
14835
0
    if (PyAst_CheckMode(ast, mode) < 0) {
14836
0
        return NULL;
14837
0
    }
14838
14839
0
    mod_ty res = NULL;
14840
0
    if (obj2ast_mod(state, ast, &res, NULL, arena) != 0)
14841
0
        return NULL;
14842
0
    else
14843
0
        return res;
14844
0
}
14845
14846
int PyAST_Check(PyObject* obj)
14847
67.1k
{
14848
67.1k
    struct ast_state *state = get_ast_state();
14849
67.1k
    if (state == NULL) {
14850
0
        return -1;
14851
0
    }
14852
67.1k
    return PyObject_IsInstance(obj, state->AST_type);
14853
67.1k
}
14854
14855