Coverage Report

Created: 2026-05-16 06:46

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
108k
{
23
108k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
108k
    struct ast_state *state = &interp->ast;
25
108k
    assert(!state->finalized);
26
108k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
108k
    return state;
30
108k
}
31
32
void _PyAST_Fini(PyInterpreterState *interp)
33
0
{
34
0
    struct ast_state *state = &interp->ast;
35
36
0
    Py_CLEAR(state->AST_type);
37
0
    Py_CLEAR(state->Add_singleton);
38
0
    Py_CLEAR(state->Add_type);
39
0
    Py_CLEAR(state->And_singleton);
40
0
    Py_CLEAR(state->And_type);
41
0
    Py_CLEAR(state->AnnAssign_type);
42
0
    Py_CLEAR(state->Assert_type);
43
0
    Py_CLEAR(state->Assign_type);
44
0
    Py_CLEAR(state->AsyncFor_type);
45
0
    Py_CLEAR(state->AsyncFunctionDef_type);
46
0
    Py_CLEAR(state->AsyncWith_type);
47
0
    Py_CLEAR(state->Attribute_type);
48
0
    Py_CLEAR(state->AugAssign_type);
49
0
    Py_CLEAR(state->Await_type);
50
0
    Py_CLEAR(state->BinOp_type);
51
0
    Py_CLEAR(state->BitAnd_singleton);
52
0
    Py_CLEAR(state->BitAnd_type);
53
0
    Py_CLEAR(state->BitOr_singleton);
54
0
    Py_CLEAR(state->BitOr_type);
55
0
    Py_CLEAR(state->BitXor_singleton);
56
0
    Py_CLEAR(state->BitXor_type);
57
0
    Py_CLEAR(state->BoolOp_type);
58
0
    Py_CLEAR(state->Break_type);
59
0
    Py_CLEAR(state->Call_type);
60
0
    Py_CLEAR(state->ClassDef_type);
61
0
    Py_CLEAR(state->Compare_type);
62
0
    Py_CLEAR(state->Constant_type);
63
0
    Py_CLEAR(state->Continue_type);
64
0
    Py_CLEAR(state->Del_singleton);
65
0
    Py_CLEAR(state->Del_type);
66
0
    Py_CLEAR(state->Delete_type);
67
0
    Py_CLEAR(state->DictComp_type);
68
0
    Py_CLEAR(state->Dict_type);
69
0
    Py_CLEAR(state->Div_singleton);
70
0
    Py_CLEAR(state->Div_type);
71
0
    Py_CLEAR(state->Eq_singleton);
72
0
    Py_CLEAR(state->Eq_type);
73
0
    Py_CLEAR(state->ExceptHandler_type);
74
0
    Py_CLEAR(state->Expr_type);
75
0
    Py_CLEAR(state->Expression_type);
76
0
    Py_CLEAR(state->FloorDiv_singleton);
77
0
    Py_CLEAR(state->FloorDiv_type);
78
0
    Py_CLEAR(state->For_type);
79
0
    Py_CLEAR(state->FormattedValue_type);
80
0
    Py_CLEAR(state->FunctionDef_type);
81
0
    Py_CLEAR(state->FunctionType_type);
82
0
    Py_CLEAR(state->GeneratorExp_type);
83
0
    Py_CLEAR(state->Global_type);
84
0
    Py_CLEAR(state->GtE_singleton);
85
0
    Py_CLEAR(state->GtE_type);
86
0
    Py_CLEAR(state->Gt_singleton);
87
0
    Py_CLEAR(state->Gt_type);
88
0
    Py_CLEAR(state->IfExp_type);
89
0
    Py_CLEAR(state->If_type);
90
0
    Py_CLEAR(state->ImportFrom_type);
91
0
    Py_CLEAR(state->Import_type);
92
0
    Py_CLEAR(state->In_singleton);
93
0
    Py_CLEAR(state->In_type);
94
0
    Py_CLEAR(state->Interactive_type);
95
0
    Py_CLEAR(state->Interpolation_type);
96
0
    Py_CLEAR(state->Invert_singleton);
97
0
    Py_CLEAR(state->Invert_type);
98
0
    Py_CLEAR(state->IsNot_singleton);
99
0
    Py_CLEAR(state->IsNot_type);
100
0
    Py_CLEAR(state->Is_singleton);
101
0
    Py_CLEAR(state->Is_type);
102
0
    Py_CLEAR(state->JoinedStr_type);
103
0
    Py_CLEAR(state->LShift_singleton);
104
0
    Py_CLEAR(state->LShift_type);
105
0
    Py_CLEAR(state->Lambda_type);
106
0
    Py_CLEAR(state->ListComp_type);
107
0
    Py_CLEAR(state->List_type);
108
0
    Py_CLEAR(state->Load_singleton);
109
0
    Py_CLEAR(state->Load_type);
110
0
    Py_CLEAR(state->LtE_singleton);
111
0
    Py_CLEAR(state->LtE_type);
112
0
    Py_CLEAR(state->Lt_singleton);
113
0
    Py_CLEAR(state->Lt_type);
114
0
    Py_CLEAR(state->MatMult_singleton);
115
0
    Py_CLEAR(state->MatMult_type);
116
0
    Py_CLEAR(state->MatchAs_type);
117
0
    Py_CLEAR(state->MatchClass_type);
118
0
    Py_CLEAR(state->MatchMapping_type);
119
0
    Py_CLEAR(state->MatchOr_type);
120
0
    Py_CLEAR(state->MatchSequence_type);
121
0
    Py_CLEAR(state->MatchSingleton_type);
122
0
    Py_CLEAR(state->MatchStar_type);
123
0
    Py_CLEAR(state->MatchValue_type);
124
0
    Py_CLEAR(state->Match_type);
125
0
    Py_CLEAR(state->Mod_singleton);
126
0
    Py_CLEAR(state->Mod_type);
127
0
    Py_CLEAR(state->Module_type);
128
0
    Py_CLEAR(state->Mult_singleton);
129
0
    Py_CLEAR(state->Mult_type);
130
0
    Py_CLEAR(state->Name_type);
131
0
    Py_CLEAR(state->NamedExpr_type);
132
0
    Py_CLEAR(state->Nonlocal_type);
133
0
    Py_CLEAR(state->NotEq_singleton);
134
0
    Py_CLEAR(state->NotEq_type);
135
0
    Py_CLEAR(state->NotIn_singleton);
136
0
    Py_CLEAR(state->NotIn_type);
137
0
    Py_CLEAR(state->Not_singleton);
138
0
    Py_CLEAR(state->Not_type);
139
0
    Py_CLEAR(state->Or_singleton);
140
0
    Py_CLEAR(state->Or_type);
141
0
    Py_CLEAR(state->ParamSpec_type);
142
0
    Py_CLEAR(state->Pass_type);
143
0
    Py_CLEAR(state->Pow_singleton);
144
0
    Py_CLEAR(state->Pow_type);
145
0
    Py_CLEAR(state->RShift_singleton);
146
0
    Py_CLEAR(state->RShift_type);
147
0
    Py_CLEAR(state->Raise_type);
148
0
    Py_CLEAR(state->Return_type);
149
0
    Py_CLEAR(state->SetComp_type);
150
0
    Py_CLEAR(state->Set_type);
151
0
    Py_CLEAR(state->Slice_type);
152
0
    Py_CLEAR(state->Starred_type);
153
0
    Py_CLEAR(state->Store_singleton);
154
0
    Py_CLEAR(state->Store_type);
155
0
    Py_CLEAR(state->Sub_singleton);
156
0
    Py_CLEAR(state->Sub_type);
157
0
    Py_CLEAR(state->Subscript_type);
158
0
    Py_CLEAR(state->TemplateStr_type);
159
0
    Py_CLEAR(state->TryStar_type);
160
0
    Py_CLEAR(state->Try_type);
161
0
    Py_CLEAR(state->Tuple_type);
162
0
    Py_CLEAR(state->TypeAlias_type);
163
0
    Py_CLEAR(state->TypeIgnore_type);
164
0
    Py_CLEAR(state->TypeVarTuple_type);
165
0
    Py_CLEAR(state->TypeVar_type);
166
0
    Py_CLEAR(state->UAdd_singleton);
167
0
    Py_CLEAR(state->UAdd_type);
168
0
    Py_CLEAR(state->USub_singleton);
169
0
    Py_CLEAR(state->USub_type);
170
0
    Py_CLEAR(state->UnaryOp_type);
171
0
    Py_CLEAR(state->While_type);
172
0
    Py_CLEAR(state->With_type);
173
0
    Py_CLEAR(state->YieldFrom_type);
174
0
    Py_CLEAR(state->Yield_type);
175
0
    Py_CLEAR(state->__dict__);
176
0
    Py_CLEAR(state->__doc__);
177
0
    Py_CLEAR(state->__match_args__);
178
0
    Py_CLEAR(state->__module__);
179
0
    Py_CLEAR(state->_attributes);
180
0
    Py_CLEAR(state->_fields);
181
0
    Py_CLEAR(state->abstract_types);
182
0
    Py_CLEAR(state->alias_type);
183
0
    Py_CLEAR(state->annotation);
184
0
    Py_CLEAR(state->arg);
185
0
    Py_CLEAR(state->arg_type);
186
0
    Py_CLEAR(state->args);
187
0
    Py_CLEAR(state->argtypes);
188
0
    Py_CLEAR(state->arguments_type);
189
0
    Py_CLEAR(state->asname);
190
0
    Py_CLEAR(state->ast);
191
0
    Py_CLEAR(state->attr);
192
0
    Py_CLEAR(state->bases);
193
0
    Py_CLEAR(state->body);
194
0
    Py_CLEAR(state->boolop_type);
195
0
    Py_CLEAR(state->bound);
196
0
    Py_CLEAR(state->cases);
197
0
    Py_CLEAR(state->cause);
198
0
    Py_CLEAR(state->cls);
199
0
    Py_CLEAR(state->cmpop_type);
200
0
    Py_CLEAR(state->col_offset);
201
0
    Py_CLEAR(state->comparators);
202
0
    Py_CLEAR(state->comprehension_type);
203
0
    Py_CLEAR(state->context_expr);
204
0
    Py_CLEAR(state->conversion);
205
0
    Py_CLEAR(state->ctx);
206
0
    Py_CLEAR(state->decorator_list);
207
0
    Py_CLEAR(state->default_value);
208
0
    Py_CLEAR(state->defaults);
209
0
    Py_CLEAR(state->elt);
210
0
    Py_CLEAR(state->elts);
211
0
    Py_CLEAR(state->end_col_offset);
212
0
    Py_CLEAR(state->end_lineno);
213
0
    Py_CLEAR(state->exc);
214
0
    Py_CLEAR(state->excepthandler_type);
215
0
    Py_CLEAR(state->expr_context_type);
216
0
    Py_CLEAR(state->expr_type);
217
0
    Py_CLEAR(state->finalbody);
218
0
    Py_CLEAR(state->format_spec);
219
0
    Py_CLEAR(state->func);
220
0
    Py_CLEAR(state->generators);
221
0
    Py_CLEAR(state->guard);
222
0
    Py_CLEAR(state->handlers);
223
0
    Py_CLEAR(state->id);
224
0
    Py_CLEAR(state->ifs);
225
0
    Py_CLEAR(state->is_async);
226
0
    Py_CLEAR(state->is_lazy);
227
0
    Py_CLEAR(state->items);
228
0
    Py_CLEAR(state->iter);
229
0
    Py_CLEAR(state->key);
230
0
    Py_CLEAR(state->keys);
231
0
    Py_CLEAR(state->keyword_type);
232
0
    Py_CLEAR(state->keywords);
233
0
    Py_CLEAR(state->kind);
234
0
    Py_CLEAR(state->kw_defaults);
235
0
    Py_CLEAR(state->kwarg);
236
0
    Py_CLEAR(state->kwd_attrs);
237
0
    Py_CLEAR(state->kwd_patterns);
238
0
    Py_CLEAR(state->kwonlyargs);
239
0
    Py_CLEAR(state->left);
240
0
    Py_CLEAR(state->level);
241
0
    Py_CLEAR(state->lineno);
242
0
    Py_CLEAR(state->lower);
243
0
    Py_CLEAR(state->match_case_type);
244
0
    Py_CLEAR(state->mod_type);
245
0
    Py_CLEAR(state->module);
246
0
    Py_CLEAR(state->msg);
247
0
    Py_CLEAR(state->name);
248
0
    Py_CLEAR(state->names);
249
0
    Py_CLEAR(state->op);
250
0
    Py_CLEAR(state->operand);
251
0
    Py_CLEAR(state->operator_type);
252
0
    Py_CLEAR(state->ops);
253
0
    Py_CLEAR(state->optional_vars);
254
0
    Py_CLEAR(state->orelse);
255
0
    Py_CLEAR(state->pattern);
256
0
    Py_CLEAR(state->pattern_type);
257
0
    Py_CLEAR(state->patterns);
258
0
    Py_CLEAR(state->posonlyargs);
259
0
    Py_CLEAR(state->rest);
260
0
    Py_CLEAR(state->returns);
261
0
    Py_CLEAR(state->right);
262
0
    Py_CLEAR(state->simple);
263
0
    Py_CLEAR(state->slice);
264
0
    Py_CLEAR(state->step);
265
0
    Py_CLEAR(state->stmt_type);
266
0
    Py_CLEAR(state->str);
267
0
    Py_CLEAR(state->subject);
268
0
    Py_CLEAR(state->tag);
269
0
    Py_CLEAR(state->target);
270
0
    Py_CLEAR(state->targets);
271
0
    Py_CLEAR(state->test);
272
0
    Py_CLEAR(state->type);
273
0
    Py_CLEAR(state->type_comment);
274
0
    Py_CLEAR(state->type_ignore_type);
275
0
    Py_CLEAR(state->type_ignores);
276
0
    Py_CLEAR(state->type_param_type);
277
0
    Py_CLEAR(state->type_params);
278
0
    Py_CLEAR(state->unaryop_type);
279
0
    Py_CLEAR(state->upper);
280
0
    Py_CLEAR(state->value);
281
0
    Py_CLEAR(state->values);
282
0
    Py_CLEAR(state->vararg);
283
0
    Py_CLEAR(state->withitem_type);
284
285
0
    state->finalized = 1;
286
0
    state->once = (_PyOnceFlag){0};
287
0
}
288
289
static int init_identifiers(struct ast_state *state)
290
16
{
291
16
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
292
16
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
293
16
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
294
16
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
295
16
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
296
16
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
297
16
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
298
16
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
299
16
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
300
16
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
301
16
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
302
16
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
303
16
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
304
16
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
305
16
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
306
16
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
307
16
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
308
16
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
309
16
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
310
16
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
311
16
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
312
16
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
313
16
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
314
16
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
315
16
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
316
16
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
317
16
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
318
16
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
319
16
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
320
16
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
321
16
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
322
16
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
323
16
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
324
16
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
325
16
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
326
16
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
327
16
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
328
16
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
329
16
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
330
16
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
331
16
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
332
16
    if ((state->is_lazy = PyUnicode_InternFromString("is_lazy")) == NULL) return -1;
333
16
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
334
16
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
335
16
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
336
16
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
337
16
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
338
16
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
339
16
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
340
16
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
341
16
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
342
16
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
343
16
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
344
16
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
345
16
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
346
16
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
347
16
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
348
16
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
349
16
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
350
16
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
351
16
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
352
16
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
353
16
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
354
16
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
355
16
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
356
16
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
357
16
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
358
16
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
359
16
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
360
16
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
361
16
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
362
16
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
363
16
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
364
16
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
365
16
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
366
16
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
367
16
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
368
16
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
369
16
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
370
16
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
371
16
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
372
16
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
373
16
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
374
16
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
375
16
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
376
16
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
377
16
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
378
16
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
379
16
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
380
16
    return 0;
381
16
};
382
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
384
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
385
761k
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
386
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
387
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
388
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
389
1.02M
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
390
10.3k
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
391
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
392
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
393
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
394
1.50k
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
395
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
396
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
397
398
static PyObject* ast2obj_mod(struct ast_state *state, void*);
399
static const char * const Module_fields[]={
400
    "body",
401
    "type_ignores",
402
};
403
static const char * const Interactive_fields[]={
404
    "body",
405
};
406
static const char * const Expression_fields[]={
407
    "body",
408
};
409
static const char * const FunctionType_fields[]={
410
    "argtypes",
411
    "returns",
412
};
413
static const char * const stmt_attributes[] = {
414
    "lineno",
415
    "col_offset",
416
    "end_lineno",
417
    "end_col_offset",
418
};
419
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
420
static const char * const FunctionDef_fields[]={
421
    "name",
422
    "args",
423
    "body",
424
    "decorator_list",
425
    "returns",
426
    "type_comment",
427
    "type_params",
428
};
429
static const char * const AsyncFunctionDef_fields[]={
430
    "name",
431
    "args",
432
    "body",
433
    "decorator_list",
434
    "returns",
435
    "type_comment",
436
    "type_params",
437
};
438
static const char * const ClassDef_fields[]={
439
    "name",
440
    "bases",
441
    "keywords",
442
    "body",
443
    "decorator_list",
444
    "type_params",
445
};
446
static const char * const Return_fields[]={
447
    "value",
448
};
449
static const char * const Delete_fields[]={
450
    "targets",
451
};
452
static const char * const Assign_fields[]={
453
    "targets",
454
    "value",
455
    "type_comment",
456
};
457
static const char * const TypeAlias_fields[]={
458
    "name",
459
    "type_params",
460
    "value",
461
};
462
static const char * const AugAssign_fields[]={
463
    "target",
464
    "op",
465
    "value",
466
};
467
static const char * const AnnAssign_fields[]={
468
    "target",
469
    "annotation",
470
    "value",
471
    "simple",
472
};
473
static const char * const For_fields[]={
474
    "target",
475
    "iter",
476
    "body",
477
    "orelse",
478
    "type_comment",
479
};
480
static const char * const AsyncFor_fields[]={
481
    "target",
482
    "iter",
483
    "body",
484
    "orelse",
485
    "type_comment",
486
};
487
static const char * const While_fields[]={
488
    "test",
489
    "body",
490
    "orelse",
491
};
492
static const char * const If_fields[]={
493
    "test",
494
    "body",
495
    "orelse",
496
};
497
static const char * const With_fields[]={
498
    "items",
499
    "body",
500
    "type_comment",
501
};
502
static const char * const AsyncWith_fields[]={
503
    "items",
504
    "body",
505
    "type_comment",
506
};
507
static const char * const Match_fields[]={
508
    "subject",
509
    "cases",
510
};
511
static const char * const Raise_fields[]={
512
    "exc",
513
    "cause",
514
};
515
static const char * const Try_fields[]={
516
    "body",
517
    "handlers",
518
    "orelse",
519
    "finalbody",
520
};
521
static const char * const TryStar_fields[]={
522
    "body",
523
    "handlers",
524
    "orelse",
525
    "finalbody",
526
};
527
static const char * const Assert_fields[]={
528
    "test",
529
    "msg",
530
};
531
static const char * const Import_fields[]={
532
    "names",
533
    "is_lazy",
534
};
535
static const char * const ImportFrom_fields[]={
536
    "module",
537
    "names",
538
    "level",
539
    "is_lazy",
540
};
541
static const char * const Global_fields[]={
542
    "names",
543
};
544
static const char * const Nonlocal_fields[]={
545
    "names",
546
};
547
static const char * const Expr_fields[]={
548
    "value",
549
};
550
static const char * const expr_attributes[] = {
551
    "lineno",
552
    "col_offset",
553
    "end_lineno",
554
    "end_col_offset",
555
};
556
static PyObject* ast2obj_expr(struct ast_state *state, void*);
557
static const char * const BoolOp_fields[]={
558
    "op",
559
    "values",
560
};
561
static const char * const NamedExpr_fields[]={
562
    "target",
563
    "value",
564
};
565
static const char * const BinOp_fields[]={
566
    "left",
567
    "op",
568
    "right",
569
};
570
static const char * const UnaryOp_fields[]={
571
    "op",
572
    "operand",
573
};
574
static const char * const Lambda_fields[]={
575
    "args",
576
    "body",
577
};
578
static const char * const IfExp_fields[]={
579
    "test",
580
    "body",
581
    "orelse",
582
};
583
static const char * const Dict_fields[]={
584
    "keys",
585
    "values",
586
};
587
static const char * const Set_fields[]={
588
    "elts",
589
};
590
static const char * const ListComp_fields[]={
591
    "elt",
592
    "generators",
593
};
594
static const char * const SetComp_fields[]={
595
    "elt",
596
    "generators",
597
};
598
static const char * const DictComp_fields[]={
599
    "key",
600
    "value",
601
    "generators",
602
};
603
static const char * const GeneratorExp_fields[]={
604
    "elt",
605
    "generators",
606
};
607
static const char * const Await_fields[]={
608
    "value",
609
};
610
static const char * const Yield_fields[]={
611
    "value",
612
};
613
static const char * const YieldFrom_fields[]={
614
    "value",
615
};
616
static const char * const Compare_fields[]={
617
    "left",
618
    "ops",
619
    "comparators",
620
};
621
static const char * const Call_fields[]={
622
    "func",
623
    "args",
624
    "keywords",
625
};
626
static const char * const FormattedValue_fields[]={
627
    "value",
628
    "conversion",
629
    "format_spec",
630
};
631
static const char * const Interpolation_fields[]={
632
    "value",
633
    "str",
634
    "conversion",
635
    "format_spec",
636
};
637
static const char * const JoinedStr_fields[]={
638
    "values",
639
};
640
static const char * const TemplateStr_fields[]={
641
    "values",
642
};
643
static const char * const Constant_fields[]={
644
    "value",
645
    "kind",
646
};
647
static const char * const Attribute_fields[]={
648
    "value",
649
    "attr",
650
    "ctx",
651
};
652
static const char * const Subscript_fields[]={
653
    "value",
654
    "slice",
655
    "ctx",
656
};
657
static const char * const Starred_fields[]={
658
    "value",
659
    "ctx",
660
};
661
static const char * const Name_fields[]={
662
    "id",
663
    "ctx",
664
};
665
static const char * const List_fields[]={
666
    "elts",
667
    "ctx",
668
};
669
static const char * const Tuple_fields[]={
670
    "elts",
671
    "ctx",
672
};
673
static const char * const Slice_fields[]={
674
    "lower",
675
    "upper",
676
    "step",
677
};
678
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
679
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
680
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
681
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
682
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
683
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
684
static const char * const comprehension_fields[]={
685
    "target",
686
    "iter",
687
    "ifs",
688
    "is_async",
689
};
690
static const char * const excepthandler_attributes[] = {
691
    "lineno",
692
    "col_offset",
693
    "end_lineno",
694
    "end_col_offset",
695
};
696
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
697
static const char * const ExceptHandler_fields[]={
698
    "type",
699
    "name",
700
    "body",
701
};
702
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
703
static const char * const arguments_fields[]={
704
    "posonlyargs",
705
    "args",
706
    "vararg",
707
    "kwonlyargs",
708
    "kw_defaults",
709
    "kwarg",
710
    "defaults",
711
};
712
static PyObject* ast2obj_arg(struct ast_state *state, void*);
713
static const char * const arg_attributes[] = {
714
    "lineno",
715
    "col_offset",
716
    "end_lineno",
717
    "end_col_offset",
718
};
719
static const char * const arg_fields[]={
720
    "arg",
721
    "annotation",
722
    "type_comment",
723
};
724
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
725
static const char * const keyword_attributes[] = {
726
    "lineno",
727
    "col_offset",
728
    "end_lineno",
729
    "end_col_offset",
730
};
731
static const char * const keyword_fields[]={
732
    "arg",
733
    "value",
734
};
735
static PyObject* ast2obj_alias(struct ast_state *state, void*);
736
static const char * const alias_attributes[] = {
737
    "lineno",
738
    "col_offset",
739
    "end_lineno",
740
    "end_col_offset",
741
};
742
static const char * const alias_fields[]={
743
    "name",
744
    "asname",
745
};
746
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
747
static const char * const withitem_fields[]={
748
    "context_expr",
749
    "optional_vars",
750
};
751
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
752
static const char * const match_case_fields[]={
753
    "pattern",
754
    "guard",
755
    "body",
756
};
757
static const char * const pattern_attributes[] = {
758
    "lineno",
759
    "col_offset",
760
    "end_lineno",
761
    "end_col_offset",
762
};
763
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
764
static const char * const MatchValue_fields[]={
765
    "value",
766
};
767
static const char * const MatchSingleton_fields[]={
768
    "value",
769
};
770
static const char * const MatchSequence_fields[]={
771
    "patterns",
772
};
773
static const char * const MatchMapping_fields[]={
774
    "keys",
775
    "patterns",
776
    "rest",
777
};
778
static const char * const MatchClass_fields[]={
779
    "cls",
780
    "patterns",
781
    "kwd_attrs",
782
    "kwd_patterns",
783
};
784
static const char * const MatchStar_fields[]={
785
    "name",
786
};
787
static const char * const MatchAs_fields[]={
788
    "pattern",
789
    "name",
790
};
791
static const char * const MatchOr_fields[]={
792
    "patterns",
793
};
794
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
795
static const char * const TypeIgnore_fields[]={
796
    "lineno",
797
    "tag",
798
};
799
static const char * const type_param_attributes[] = {
800
    "lineno",
801
    "col_offset",
802
    "end_lineno",
803
    "end_col_offset",
804
};
805
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
806
static const char * const TypeVar_fields[]={
807
    "name",
808
    "bound",
809
    "default_value",
810
};
811
static const char * const ParamSpec_fields[]={
812
    "name",
813
    "default_value",
814
};
815
static const char * const TypeVarTuple_fields[]={
816
    "name",
817
    "default_value",
818
};
819
820
821
static int
822
add_ast_annotations(struct ast_state *state)
823
16
{
824
16
    bool cond;
825
16
    PyObject *Module_annotations = PyDict_New();
826
16
    if (!Module_annotations) return 0;
827
16
    {
828
16
        PyObject *type = state->stmt_type;
829
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
830
16
        cond = type != NULL;
831
16
        if (!cond) {
832
0
            Py_DECREF(Module_annotations);
833
0
            return 0;
834
0
        }
835
16
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
836
16
        Py_DECREF(type);
837
16
        if (!cond) {
838
0
            Py_DECREF(Module_annotations);
839
0
            return 0;
840
0
        }
841
16
    }
842
16
    {
843
16
        PyObject *type = state->type_ignore_type;
844
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
845
16
        cond = type != NULL;
846
16
        if (!cond) {
847
0
            Py_DECREF(Module_annotations);
848
0
            return 0;
849
0
        }
850
16
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
851
16
                                    == 0;
852
16
        Py_DECREF(type);
853
16
        if (!cond) {
854
0
            Py_DECREF(Module_annotations);
855
0
            return 0;
856
0
        }
857
16
    }
858
16
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
859
16
                                  Module_annotations) == 0;
860
16
    if (!cond) {
861
0
        Py_DECREF(Module_annotations);
862
0
        return 0;
863
0
    }
864
16
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
865
16
                                  Module_annotations) == 0;
866
16
    if (!cond) {
867
0
        Py_DECREF(Module_annotations);
868
0
        return 0;
869
0
    }
870
16
    Py_DECREF(Module_annotations);
871
16
    PyObject *Interactive_annotations = PyDict_New();
872
16
    if (!Interactive_annotations) return 0;
873
16
    {
874
16
        PyObject *type = state->stmt_type;
875
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
876
16
        cond = type != NULL;
877
16
        if (!cond) {
878
0
            Py_DECREF(Interactive_annotations);
879
0
            return 0;
880
0
        }
881
16
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
882
16
        Py_DECREF(type);
883
16
        if (!cond) {
884
0
            Py_DECREF(Interactive_annotations);
885
0
            return 0;
886
0
        }
887
16
    }
888
16
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
889
16
                                  Interactive_annotations) == 0;
890
16
    if (!cond) {
891
0
        Py_DECREF(Interactive_annotations);
892
0
        return 0;
893
0
    }
894
16
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
895
16
                                  Interactive_annotations) == 0;
896
16
    if (!cond) {
897
0
        Py_DECREF(Interactive_annotations);
898
0
        return 0;
899
0
    }
900
16
    Py_DECREF(Interactive_annotations);
901
16
    PyObject *Expression_annotations = PyDict_New();
902
16
    if (!Expression_annotations) return 0;
903
16
    {
904
16
        PyObject *type = state->expr_type;
905
16
        Py_INCREF(type);
906
16
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
907
16
        Py_DECREF(type);
908
16
        if (!cond) {
909
0
            Py_DECREF(Expression_annotations);
910
0
            return 0;
911
0
        }
912
16
    }
913
16
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
914
16
                                  Expression_annotations) == 0;
915
16
    if (!cond) {
916
0
        Py_DECREF(Expression_annotations);
917
0
        return 0;
918
0
    }
919
16
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
920
16
                                  Expression_annotations) == 0;
921
16
    if (!cond) {
922
0
        Py_DECREF(Expression_annotations);
923
0
        return 0;
924
0
    }
925
16
    Py_DECREF(Expression_annotations);
926
16
    PyObject *FunctionType_annotations = PyDict_New();
927
16
    if (!FunctionType_annotations) return 0;
928
16
    {
929
16
        PyObject *type = state->expr_type;
930
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
931
16
        cond = type != NULL;
932
16
        if (!cond) {
933
0
            Py_DECREF(FunctionType_annotations);
934
0
            return 0;
935
0
        }
936
16
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
937
16
                                    == 0;
938
16
        Py_DECREF(type);
939
16
        if (!cond) {
940
0
            Py_DECREF(FunctionType_annotations);
941
0
            return 0;
942
0
        }
943
16
    }
944
16
    {
945
16
        PyObject *type = state->expr_type;
946
16
        Py_INCREF(type);
947
16
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
948
16
                                    == 0;
949
16
        Py_DECREF(type);
950
16
        if (!cond) {
951
0
            Py_DECREF(FunctionType_annotations);
952
0
            return 0;
953
0
        }
954
16
    }
955
16
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
956
16
                                  FunctionType_annotations) == 0;
957
16
    if (!cond) {
958
0
        Py_DECREF(FunctionType_annotations);
959
0
        return 0;
960
0
    }
961
16
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
962
16
                                  FunctionType_annotations) == 0;
963
16
    if (!cond) {
964
0
        Py_DECREF(FunctionType_annotations);
965
0
        return 0;
966
0
    }
967
16
    Py_DECREF(FunctionType_annotations);
968
16
    PyObject *FunctionDef_annotations = PyDict_New();
969
16
    if (!FunctionDef_annotations) return 0;
970
16
    {
971
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
972
16
        Py_INCREF(type);
973
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
974
16
        Py_DECREF(type);
975
16
        if (!cond) {
976
0
            Py_DECREF(FunctionDef_annotations);
977
0
            return 0;
978
0
        }
979
16
    }
980
16
    {
981
16
        PyObject *type = state->arguments_type;
982
16
        Py_INCREF(type);
983
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
984
16
        Py_DECREF(type);
985
16
        if (!cond) {
986
0
            Py_DECREF(FunctionDef_annotations);
987
0
            return 0;
988
0
        }
989
16
    }
990
16
    {
991
16
        PyObject *type = state->stmt_type;
992
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
993
16
        cond = type != NULL;
994
16
        if (!cond) {
995
0
            Py_DECREF(FunctionDef_annotations);
996
0
            return 0;
997
0
        }
998
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
999
16
        Py_DECREF(type);
1000
16
        if (!cond) {
1001
0
            Py_DECREF(FunctionDef_annotations);
1002
0
            return 0;
1003
0
        }
1004
16
    }
1005
16
    {
1006
16
        PyObject *type = state->expr_type;
1007
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1008
16
        cond = type != NULL;
1009
16
        if (!cond) {
1010
0
            Py_DECREF(FunctionDef_annotations);
1011
0
            return 0;
1012
0
        }
1013
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1014
16
                                    type) == 0;
1015
16
        Py_DECREF(type);
1016
16
        if (!cond) {
1017
0
            Py_DECREF(FunctionDef_annotations);
1018
0
            return 0;
1019
0
        }
1020
16
    }
1021
16
    {
1022
16
        PyObject *type = state->expr_type;
1023
16
        type = _Py_union_type_or(type, Py_None);
1024
16
        cond = type != NULL;
1025
16
        if (!cond) {
1026
0
            Py_DECREF(FunctionDef_annotations);
1027
0
            return 0;
1028
0
        }
1029
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1030
16
                                    == 0;
1031
16
        Py_DECREF(type);
1032
16
        if (!cond) {
1033
0
            Py_DECREF(FunctionDef_annotations);
1034
0
            return 0;
1035
0
        }
1036
16
    }
1037
16
    {
1038
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1039
16
        type = _Py_union_type_or(type, Py_None);
1040
16
        cond = type != NULL;
1041
16
        if (!cond) {
1042
0
            Py_DECREF(FunctionDef_annotations);
1043
0
            return 0;
1044
0
        }
1045
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1046
16
                                    type) == 0;
1047
16
        Py_DECREF(type);
1048
16
        if (!cond) {
1049
0
            Py_DECREF(FunctionDef_annotations);
1050
0
            return 0;
1051
0
        }
1052
16
    }
1053
16
    {
1054
16
        PyObject *type = state->type_param_type;
1055
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1056
16
        cond = type != NULL;
1057
16
        if (!cond) {
1058
0
            Py_DECREF(FunctionDef_annotations);
1059
0
            return 0;
1060
0
        }
1061
16
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1062
16
                                    type) == 0;
1063
16
        Py_DECREF(type);
1064
16
        if (!cond) {
1065
0
            Py_DECREF(FunctionDef_annotations);
1066
0
            return 0;
1067
0
        }
1068
16
    }
1069
16
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1070
16
                                  FunctionDef_annotations) == 0;
1071
16
    if (!cond) {
1072
0
        Py_DECREF(FunctionDef_annotations);
1073
0
        return 0;
1074
0
    }
1075
16
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1076
16
                                  FunctionDef_annotations) == 0;
1077
16
    if (!cond) {
1078
0
        Py_DECREF(FunctionDef_annotations);
1079
0
        return 0;
1080
0
    }
1081
16
    Py_DECREF(FunctionDef_annotations);
1082
16
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1083
16
    if (!AsyncFunctionDef_annotations) return 0;
1084
16
    {
1085
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1086
16
        Py_INCREF(type);
1087
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1088
16
                                    == 0;
1089
16
        Py_DECREF(type);
1090
16
        if (!cond) {
1091
0
            Py_DECREF(AsyncFunctionDef_annotations);
1092
0
            return 0;
1093
0
        }
1094
16
    }
1095
16
    {
1096
16
        PyObject *type = state->arguments_type;
1097
16
        Py_INCREF(type);
1098
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1099
16
                                    == 0;
1100
16
        Py_DECREF(type);
1101
16
        if (!cond) {
1102
0
            Py_DECREF(AsyncFunctionDef_annotations);
1103
0
            return 0;
1104
0
        }
1105
16
    }
1106
16
    {
1107
16
        PyObject *type = state->stmt_type;
1108
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1109
16
        cond = type != NULL;
1110
16
        if (!cond) {
1111
0
            Py_DECREF(AsyncFunctionDef_annotations);
1112
0
            return 0;
1113
0
        }
1114
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1115
16
                                    == 0;
1116
16
        Py_DECREF(type);
1117
16
        if (!cond) {
1118
0
            Py_DECREF(AsyncFunctionDef_annotations);
1119
0
            return 0;
1120
0
        }
1121
16
    }
1122
16
    {
1123
16
        PyObject *type = state->expr_type;
1124
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1125
16
        cond = type != NULL;
1126
16
        if (!cond) {
1127
0
            Py_DECREF(AsyncFunctionDef_annotations);
1128
0
            return 0;
1129
0
        }
1130
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1131
16
                                    "decorator_list", type) == 0;
1132
16
        Py_DECREF(type);
1133
16
        if (!cond) {
1134
0
            Py_DECREF(AsyncFunctionDef_annotations);
1135
0
            return 0;
1136
0
        }
1137
16
    }
1138
16
    {
1139
16
        PyObject *type = state->expr_type;
1140
16
        type = _Py_union_type_or(type, Py_None);
1141
16
        cond = type != NULL;
1142
16
        if (!cond) {
1143
0
            Py_DECREF(AsyncFunctionDef_annotations);
1144
0
            return 0;
1145
0
        }
1146
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1147
16
                                    type) == 0;
1148
16
        Py_DECREF(type);
1149
16
        if (!cond) {
1150
0
            Py_DECREF(AsyncFunctionDef_annotations);
1151
0
            return 0;
1152
0
        }
1153
16
    }
1154
16
    {
1155
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1156
16
        type = _Py_union_type_or(type, Py_None);
1157
16
        cond = type != NULL;
1158
16
        if (!cond) {
1159
0
            Py_DECREF(AsyncFunctionDef_annotations);
1160
0
            return 0;
1161
0
        }
1162
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1163
16
                                    "type_comment", type) == 0;
1164
16
        Py_DECREF(type);
1165
16
        if (!cond) {
1166
0
            Py_DECREF(AsyncFunctionDef_annotations);
1167
0
            return 0;
1168
0
        }
1169
16
    }
1170
16
    {
1171
16
        PyObject *type = state->type_param_type;
1172
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1173
16
        cond = type != NULL;
1174
16
        if (!cond) {
1175
0
            Py_DECREF(AsyncFunctionDef_annotations);
1176
0
            return 0;
1177
0
        }
1178
16
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1179
16
                                    "type_params", type) == 0;
1180
16
        Py_DECREF(type);
1181
16
        if (!cond) {
1182
0
            Py_DECREF(AsyncFunctionDef_annotations);
1183
0
            return 0;
1184
0
        }
1185
16
    }
1186
16
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1187
16
                                  AsyncFunctionDef_annotations) == 0;
1188
16
    if (!cond) {
1189
0
        Py_DECREF(AsyncFunctionDef_annotations);
1190
0
        return 0;
1191
0
    }
1192
16
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1193
16
                                  "__annotations__",
1194
16
                                  AsyncFunctionDef_annotations) == 0;
1195
16
    if (!cond) {
1196
0
        Py_DECREF(AsyncFunctionDef_annotations);
1197
0
        return 0;
1198
0
    }
1199
16
    Py_DECREF(AsyncFunctionDef_annotations);
1200
16
    PyObject *ClassDef_annotations = PyDict_New();
1201
16
    if (!ClassDef_annotations) return 0;
1202
16
    {
1203
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1204
16
        Py_INCREF(type);
1205
16
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1206
16
        Py_DECREF(type);
1207
16
        if (!cond) {
1208
0
            Py_DECREF(ClassDef_annotations);
1209
0
            return 0;
1210
0
        }
1211
16
    }
1212
16
    {
1213
16
        PyObject *type = state->expr_type;
1214
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1215
16
        cond = type != NULL;
1216
16
        if (!cond) {
1217
0
            Py_DECREF(ClassDef_annotations);
1218
0
            return 0;
1219
0
        }
1220
16
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1221
16
        Py_DECREF(type);
1222
16
        if (!cond) {
1223
0
            Py_DECREF(ClassDef_annotations);
1224
0
            return 0;
1225
0
        }
1226
16
    }
1227
16
    {
1228
16
        PyObject *type = state->keyword_type;
1229
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1230
16
        cond = type != NULL;
1231
16
        if (!cond) {
1232
0
            Py_DECREF(ClassDef_annotations);
1233
0
            return 0;
1234
0
        }
1235
16
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1236
16
                                    0;
1237
16
        Py_DECREF(type);
1238
16
        if (!cond) {
1239
0
            Py_DECREF(ClassDef_annotations);
1240
0
            return 0;
1241
0
        }
1242
16
    }
1243
16
    {
1244
16
        PyObject *type = state->stmt_type;
1245
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1246
16
        cond = type != NULL;
1247
16
        if (!cond) {
1248
0
            Py_DECREF(ClassDef_annotations);
1249
0
            return 0;
1250
0
        }
1251
16
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1252
16
        Py_DECREF(type);
1253
16
        if (!cond) {
1254
0
            Py_DECREF(ClassDef_annotations);
1255
0
            return 0;
1256
0
        }
1257
16
    }
1258
16
    {
1259
16
        PyObject *type = state->expr_type;
1260
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1261
16
        cond = type != NULL;
1262
16
        if (!cond) {
1263
0
            Py_DECREF(ClassDef_annotations);
1264
0
            return 0;
1265
0
        }
1266
16
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1267
16
                                    type) == 0;
1268
16
        Py_DECREF(type);
1269
16
        if (!cond) {
1270
0
            Py_DECREF(ClassDef_annotations);
1271
0
            return 0;
1272
0
        }
1273
16
    }
1274
16
    {
1275
16
        PyObject *type = state->type_param_type;
1276
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1277
16
        cond = type != NULL;
1278
16
        if (!cond) {
1279
0
            Py_DECREF(ClassDef_annotations);
1280
0
            return 0;
1281
0
        }
1282
16
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1283
16
                                    == 0;
1284
16
        Py_DECREF(type);
1285
16
        if (!cond) {
1286
0
            Py_DECREF(ClassDef_annotations);
1287
0
            return 0;
1288
0
        }
1289
16
    }
1290
16
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1291
16
                                  ClassDef_annotations) == 0;
1292
16
    if (!cond) {
1293
0
        Py_DECREF(ClassDef_annotations);
1294
0
        return 0;
1295
0
    }
1296
16
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1297
16
                                  ClassDef_annotations) == 0;
1298
16
    if (!cond) {
1299
0
        Py_DECREF(ClassDef_annotations);
1300
0
        return 0;
1301
0
    }
1302
16
    Py_DECREF(ClassDef_annotations);
1303
16
    PyObject *Return_annotations = PyDict_New();
1304
16
    if (!Return_annotations) return 0;
1305
16
    {
1306
16
        PyObject *type = state->expr_type;
1307
16
        type = _Py_union_type_or(type, Py_None);
1308
16
        cond = type != NULL;
1309
16
        if (!cond) {
1310
0
            Py_DECREF(Return_annotations);
1311
0
            return 0;
1312
0
        }
1313
16
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1314
16
        Py_DECREF(type);
1315
16
        if (!cond) {
1316
0
            Py_DECREF(Return_annotations);
1317
0
            return 0;
1318
0
        }
1319
16
    }
1320
16
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1321
16
                                  Return_annotations) == 0;
1322
16
    if (!cond) {
1323
0
        Py_DECREF(Return_annotations);
1324
0
        return 0;
1325
0
    }
1326
16
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1327
16
                                  Return_annotations) == 0;
1328
16
    if (!cond) {
1329
0
        Py_DECREF(Return_annotations);
1330
0
        return 0;
1331
0
    }
1332
16
    Py_DECREF(Return_annotations);
1333
16
    PyObject *Delete_annotations = PyDict_New();
1334
16
    if (!Delete_annotations) return 0;
1335
16
    {
1336
16
        PyObject *type = state->expr_type;
1337
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1338
16
        cond = type != NULL;
1339
16
        if (!cond) {
1340
0
            Py_DECREF(Delete_annotations);
1341
0
            return 0;
1342
0
        }
1343
16
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1344
16
        Py_DECREF(type);
1345
16
        if (!cond) {
1346
0
            Py_DECREF(Delete_annotations);
1347
0
            return 0;
1348
0
        }
1349
16
    }
1350
16
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1351
16
                                  Delete_annotations) == 0;
1352
16
    if (!cond) {
1353
0
        Py_DECREF(Delete_annotations);
1354
0
        return 0;
1355
0
    }
1356
16
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1357
16
                                  Delete_annotations) == 0;
1358
16
    if (!cond) {
1359
0
        Py_DECREF(Delete_annotations);
1360
0
        return 0;
1361
0
    }
1362
16
    Py_DECREF(Delete_annotations);
1363
16
    PyObject *Assign_annotations = PyDict_New();
1364
16
    if (!Assign_annotations) return 0;
1365
16
    {
1366
16
        PyObject *type = state->expr_type;
1367
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1368
16
        cond = type != NULL;
1369
16
        if (!cond) {
1370
0
            Py_DECREF(Assign_annotations);
1371
0
            return 0;
1372
0
        }
1373
16
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1374
16
        Py_DECREF(type);
1375
16
        if (!cond) {
1376
0
            Py_DECREF(Assign_annotations);
1377
0
            return 0;
1378
0
        }
1379
16
    }
1380
16
    {
1381
16
        PyObject *type = state->expr_type;
1382
16
        Py_INCREF(type);
1383
16
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1384
16
        Py_DECREF(type);
1385
16
        if (!cond) {
1386
0
            Py_DECREF(Assign_annotations);
1387
0
            return 0;
1388
0
        }
1389
16
    }
1390
16
    {
1391
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1392
16
        type = _Py_union_type_or(type, Py_None);
1393
16
        cond = type != NULL;
1394
16
        if (!cond) {
1395
0
            Py_DECREF(Assign_annotations);
1396
0
            return 0;
1397
0
        }
1398
16
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1399
16
                                    == 0;
1400
16
        Py_DECREF(type);
1401
16
        if (!cond) {
1402
0
            Py_DECREF(Assign_annotations);
1403
0
            return 0;
1404
0
        }
1405
16
    }
1406
16
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1407
16
                                  Assign_annotations) == 0;
1408
16
    if (!cond) {
1409
0
        Py_DECREF(Assign_annotations);
1410
0
        return 0;
1411
0
    }
1412
16
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1413
16
                                  Assign_annotations) == 0;
1414
16
    if (!cond) {
1415
0
        Py_DECREF(Assign_annotations);
1416
0
        return 0;
1417
0
    }
1418
16
    Py_DECREF(Assign_annotations);
1419
16
    PyObject *TypeAlias_annotations = PyDict_New();
1420
16
    if (!TypeAlias_annotations) return 0;
1421
16
    {
1422
16
        PyObject *type = state->expr_type;
1423
16
        Py_INCREF(type);
1424
16
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1425
16
        Py_DECREF(type);
1426
16
        if (!cond) {
1427
0
            Py_DECREF(TypeAlias_annotations);
1428
0
            return 0;
1429
0
        }
1430
16
    }
1431
16
    {
1432
16
        PyObject *type = state->type_param_type;
1433
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1434
16
        cond = type != NULL;
1435
16
        if (!cond) {
1436
0
            Py_DECREF(TypeAlias_annotations);
1437
0
            return 0;
1438
0
        }
1439
16
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1440
16
                                    == 0;
1441
16
        Py_DECREF(type);
1442
16
        if (!cond) {
1443
0
            Py_DECREF(TypeAlias_annotations);
1444
0
            return 0;
1445
0
        }
1446
16
    }
1447
16
    {
1448
16
        PyObject *type = state->expr_type;
1449
16
        Py_INCREF(type);
1450
16
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1451
16
        Py_DECREF(type);
1452
16
        if (!cond) {
1453
0
            Py_DECREF(TypeAlias_annotations);
1454
0
            return 0;
1455
0
        }
1456
16
    }
1457
16
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1458
16
                                  TypeAlias_annotations) == 0;
1459
16
    if (!cond) {
1460
0
        Py_DECREF(TypeAlias_annotations);
1461
0
        return 0;
1462
0
    }
1463
16
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1464
16
                                  TypeAlias_annotations) == 0;
1465
16
    if (!cond) {
1466
0
        Py_DECREF(TypeAlias_annotations);
1467
0
        return 0;
1468
0
    }
1469
16
    Py_DECREF(TypeAlias_annotations);
1470
16
    PyObject *AugAssign_annotations = PyDict_New();
1471
16
    if (!AugAssign_annotations) return 0;
1472
16
    {
1473
16
        PyObject *type = state->expr_type;
1474
16
        Py_INCREF(type);
1475
16
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1476
16
        Py_DECREF(type);
1477
16
        if (!cond) {
1478
0
            Py_DECREF(AugAssign_annotations);
1479
0
            return 0;
1480
0
        }
1481
16
    }
1482
16
    {
1483
16
        PyObject *type = state->operator_type;
1484
16
        Py_INCREF(type);
1485
16
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1486
16
        Py_DECREF(type);
1487
16
        if (!cond) {
1488
0
            Py_DECREF(AugAssign_annotations);
1489
0
            return 0;
1490
0
        }
1491
16
    }
1492
16
    {
1493
16
        PyObject *type = state->expr_type;
1494
16
        Py_INCREF(type);
1495
16
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1496
16
        Py_DECREF(type);
1497
16
        if (!cond) {
1498
0
            Py_DECREF(AugAssign_annotations);
1499
0
            return 0;
1500
0
        }
1501
16
    }
1502
16
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1503
16
                                  AugAssign_annotations) == 0;
1504
16
    if (!cond) {
1505
0
        Py_DECREF(AugAssign_annotations);
1506
0
        return 0;
1507
0
    }
1508
16
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1509
16
                                  AugAssign_annotations) == 0;
1510
16
    if (!cond) {
1511
0
        Py_DECREF(AugAssign_annotations);
1512
0
        return 0;
1513
0
    }
1514
16
    Py_DECREF(AugAssign_annotations);
1515
16
    PyObject *AnnAssign_annotations = PyDict_New();
1516
16
    if (!AnnAssign_annotations) return 0;
1517
16
    {
1518
16
        PyObject *type = state->expr_type;
1519
16
        Py_INCREF(type);
1520
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1521
16
        Py_DECREF(type);
1522
16
        if (!cond) {
1523
0
            Py_DECREF(AnnAssign_annotations);
1524
0
            return 0;
1525
0
        }
1526
16
    }
1527
16
    {
1528
16
        PyObject *type = state->expr_type;
1529
16
        Py_INCREF(type);
1530
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1531
16
                                    == 0;
1532
16
        Py_DECREF(type);
1533
16
        if (!cond) {
1534
0
            Py_DECREF(AnnAssign_annotations);
1535
0
            return 0;
1536
0
        }
1537
16
    }
1538
16
    {
1539
16
        PyObject *type = state->expr_type;
1540
16
        type = _Py_union_type_or(type, Py_None);
1541
16
        cond = type != NULL;
1542
16
        if (!cond) {
1543
0
            Py_DECREF(AnnAssign_annotations);
1544
0
            return 0;
1545
0
        }
1546
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1547
16
        Py_DECREF(type);
1548
16
        if (!cond) {
1549
0
            Py_DECREF(AnnAssign_annotations);
1550
0
            return 0;
1551
0
        }
1552
16
    }
1553
16
    {
1554
16
        PyObject *type = (PyObject *)&PyLong_Type;
1555
16
        Py_INCREF(type);
1556
16
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1557
16
        Py_DECREF(type);
1558
16
        if (!cond) {
1559
0
            Py_DECREF(AnnAssign_annotations);
1560
0
            return 0;
1561
0
        }
1562
16
    }
1563
16
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1564
16
                                  AnnAssign_annotations) == 0;
1565
16
    if (!cond) {
1566
0
        Py_DECREF(AnnAssign_annotations);
1567
0
        return 0;
1568
0
    }
1569
16
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1570
16
                                  AnnAssign_annotations) == 0;
1571
16
    if (!cond) {
1572
0
        Py_DECREF(AnnAssign_annotations);
1573
0
        return 0;
1574
0
    }
1575
16
    Py_DECREF(AnnAssign_annotations);
1576
16
    PyObject *For_annotations = PyDict_New();
1577
16
    if (!For_annotations) return 0;
1578
16
    {
1579
16
        PyObject *type = state->expr_type;
1580
16
        Py_INCREF(type);
1581
16
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1582
16
        Py_DECREF(type);
1583
16
        if (!cond) {
1584
0
            Py_DECREF(For_annotations);
1585
0
            return 0;
1586
0
        }
1587
16
    }
1588
16
    {
1589
16
        PyObject *type = state->expr_type;
1590
16
        Py_INCREF(type);
1591
16
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1592
16
        Py_DECREF(type);
1593
16
        if (!cond) {
1594
0
            Py_DECREF(For_annotations);
1595
0
            return 0;
1596
0
        }
1597
16
    }
1598
16
    {
1599
16
        PyObject *type = state->stmt_type;
1600
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1601
16
        cond = type != NULL;
1602
16
        if (!cond) {
1603
0
            Py_DECREF(For_annotations);
1604
0
            return 0;
1605
0
        }
1606
16
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1607
16
        Py_DECREF(type);
1608
16
        if (!cond) {
1609
0
            Py_DECREF(For_annotations);
1610
0
            return 0;
1611
0
        }
1612
16
    }
1613
16
    {
1614
16
        PyObject *type = state->stmt_type;
1615
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1616
16
        cond = type != NULL;
1617
16
        if (!cond) {
1618
0
            Py_DECREF(For_annotations);
1619
0
            return 0;
1620
0
        }
1621
16
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1622
16
        Py_DECREF(type);
1623
16
        if (!cond) {
1624
0
            Py_DECREF(For_annotations);
1625
0
            return 0;
1626
0
        }
1627
16
    }
1628
16
    {
1629
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1630
16
        type = _Py_union_type_or(type, Py_None);
1631
16
        cond = type != NULL;
1632
16
        if (!cond) {
1633
0
            Py_DECREF(For_annotations);
1634
0
            return 0;
1635
0
        }
1636
16
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1637
16
        Py_DECREF(type);
1638
16
        if (!cond) {
1639
0
            Py_DECREF(For_annotations);
1640
0
            return 0;
1641
0
        }
1642
16
    }
1643
16
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1644
16
                                  For_annotations) == 0;
1645
16
    if (!cond) {
1646
0
        Py_DECREF(For_annotations);
1647
0
        return 0;
1648
0
    }
1649
16
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1650
16
                                  For_annotations) == 0;
1651
16
    if (!cond) {
1652
0
        Py_DECREF(For_annotations);
1653
0
        return 0;
1654
0
    }
1655
16
    Py_DECREF(For_annotations);
1656
16
    PyObject *AsyncFor_annotations = PyDict_New();
1657
16
    if (!AsyncFor_annotations) return 0;
1658
16
    {
1659
16
        PyObject *type = state->expr_type;
1660
16
        Py_INCREF(type);
1661
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1662
16
        Py_DECREF(type);
1663
16
        if (!cond) {
1664
0
            Py_DECREF(AsyncFor_annotations);
1665
0
            return 0;
1666
0
        }
1667
16
    }
1668
16
    {
1669
16
        PyObject *type = state->expr_type;
1670
16
        Py_INCREF(type);
1671
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1672
16
        Py_DECREF(type);
1673
16
        if (!cond) {
1674
0
            Py_DECREF(AsyncFor_annotations);
1675
0
            return 0;
1676
0
        }
1677
16
    }
1678
16
    {
1679
16
        PyObject *type = state->stmt_type;
1680
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1681
16
        cond = type != NULL;
1682
16
        if (!cond) {
1683
0
            Py_DECREF(AsyncFor_annotations);
1684
0
            return 0;
1685
0
        }
1686
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1687
16
        Py_DECREF(type);
1688
16
        if (!cond) {
1689
0
            Py_DECREF(AsyncFor_annotations);
1690
0
            return 0;
1691
0
        }
1692
16
    }
1693
16
    {
1694
16
        PyObject *type = state->stmt_type;
1695
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1696
16
        cond = type != NULL;
1697
16
        if (!cond) {
1698
0
            Py_DECREF(AsyncFor_annotations);
1699
0
            return 0;
1700
0
        }
1701
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1702
16
        Py_DECREF(type);
1703
16
        if (!cond) {
1704
0
            Py_DECREF(AsyncFor_annotations);
1705
0
            return 0;
1706
0
        }
1707
16
    }
1708
16
    {
1709
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1710
16
        type = _Py_union_type_or(type, Py_None);
1711
16
        cond = type != NULL;
1712
16
        if (!cond) {
1713
0
            Py_DECREF(AsyncFor_annotations);
1714
0
            return 0;
1715
0
        }
1716
16
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1717
16
                                    == 0;
1718
16
        Py_DECREF(type);
1719
16
        if (!cond) {
1720
0
            Py_DECREF(AsyncFor_annotations);
1721
0
            return 0;
1722
0
        }
1723
16
    }
1724
16
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1725
16
                                  AsyncFor_annotations) == 0;
1726
16
    if (!cond) {
1727
0
        Py_DECREF(AsyncFor_annotations);
1728
0
        return 0;
1729
0
    }
1730
16
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1731
16
                                  AsyncFor_annotations) == 0;
1732
16
    if (!cond) {
1733
0
        Py_DECREF(AsyncFor_annotations);
1734
0
        return 0;
1735
0
    }
1736
16
    Py_DECREF(AsyncFor_annotations);
1737
16
    PyObject *While_annotations = PyDict_New();
1738
16
    if (!While_annotations) return 0;
1739
16
    {
1740
16
        PyObject *type = state->expr_type;
1741
16
        Py_INCREF(type);
1742
16
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1743
16
        Py_DECREF(type);
1744
16
        if (!cond) {
1745
0
            Py_DECREF(While_annotations);
1746
0
            return 0;
1747
0
        }
1748
16
    }
1749
16
    {
1750
16
        PyObject *type = state->stmt_type;
1751
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1752
16
        cond = type != NULL;
1753
16
        if (!cond) {
1754
0
            Py_DECREF(While_annotations);
1755
0
            return 0;
1756
0
        }
1757
16
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1758
16
        Py_DECREF(type);
1759
16
        if (!cond) {
1760
0
            Py_DECREF(While_annotations);
1761
0
            return 0;
1762
0
        }
1763
16
    }
1764
16
    {
1765
16
        PyObject *type = state->stmt_type;
1766
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1767
16
        cond = type != NULL;
1768
16
        if (!cond) {
1769
0
            Py_DECREF(While_annotations);
1770
0
            return 0;
1771
0
        }
1772
16
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1773
16
        Py_DECREF(type);
1774
16
        if (!cond) {
1775
0
            Py_DECREF(While_annotations);
1776
0
            return 0;
1777
0
        }
1778
16
    }
1779
16
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1780
16
                                  While_annotations) == 0;
1781
16
    if (!cond) {
1782
0
        Py_DECREF(While_annotations);
1783
0
        return 0;
1784
0
    }
1785
16
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1786
16
                                  While_annotations) == 0;
1787
16
    if (!cond) {
1788
0
        Py_DECREF(While_annotations);
1789
0
        return 0;
1790
0
    }
1791
16
    Py_DECREF(While_annotations);
1792
16
    PyObject *If_annotations = PyDict_New();
1793
16
    if (!If_annotations) return 0;
1794
16
    {
1795
16
        PyObject *type = state->expr_type;
1796
16
        Py_INCREF(type);
1797
16
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1798
16
        Py_DECREF(type);
1799
16
        if (!cond) {
1800
0
            Py_DECREF(If_annotations);
1801
0
            return 0;
1802
0
        }
1803
16
    }
1804
16
    {
1805
16
        PyObject *type = state->stmt_type;
1806
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1807
16
        cond = type != NULL;
1808
16
        if (!cond) {
1809
0
            Py_DECREF(If_annotations);
1810
0
            return 0;
1811
0
        }
1812
16
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1813
16
        Py_DECREF(type);
1814
16
        if (!cond) {
1815
0
            Py_DECREF(If_annotations);
1816
0
            return 0;
1817
0
        }
1818
16
    }
1819
16
    {
1820
16
        PyObject *type = state->stmt_type;
1821
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1822
16
        cond = type != NULL;
1823
16
        if (!cond) {
1824
0
            Py_DECREF(If_annotations);
1825
0
            return 0;
1826
0
        }
1827
16
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1828
16
        Py_DECREF(type);
1829
16
        if (!cond) {
1830
0
            Py_DECREF(If_annotations);
1831
0
            return 0;
1832
0
        }
1833
16
    }
1834
16
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1835
16
                                  If_annotations) == 0;
1836
16
    if (!cond) {
1837
0
        Py_DECREF(If_annotations);
1838
0
        return 0;
1839
0
    }
1840
16
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1841
16
                                  If_annotations) == 0;
1842
16
    if (!cond) {
1843
0
        Py_DECREF(If_annotations);
1844
0
        return 0;
1845
0
    }
1846
16
    Py_DECREF(If_annotations);
1847
16
    PyObject *With_annotations = PyDict_New();
1848
16
    if (!With_annotations) return 0;
1849
16
    {
1850
16
        PyObject *type = state->withitem_type;
1851
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1852
16
        cond = type != NULL;
1853
16
        if (!cond) {
1854
0
            Py_DECREF(With_annotations);
1855
0
            return 0;
1856
0
        }
1857
16
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1858
16
        Py_DECREF(type);
1859
16
        if (!cond) {
1860
0
            Py_DECREF(With_annotations);
1861
0
            return 0;
1862
0
        }
1863
16
    }
1864
16
    {
1865
16
        PyObject *type = state->stmt_type;
1866
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1867
16
        cond = type != NULL;
1868
16
        if (!cond) {
1869
0
            Py_DECREF(With_annotations);
1870
0
            return 0;
1871
0
        }
1872
16
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1873
16
        Py_DECREF(type);
1874
16
        if (!cond) {
1875
0
            Py_DECREF(With_annotations);
1876
0
            return 0;
1877
0
        }
1878
16
    }
1879
16
    {
1880
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1881
16
        type = _Py_union_type_or(type, Py_None);
1882
16
        cond = type != NULL;
1883
16
        if (!cond) {
1884
0
            Py_DECREF(With_annotations);
1885
0
            return 0;
1886
0
        }
1887
16
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1888
16
                                    0;
1889
16
        Py_DECREF(type);
1890
16
        if (!cond) {
1891
0
            Py_DECREF(With_annotations);
1892
0
            return 0;
1893
0
        }
1894
16
    }
1895
16
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1896
16
                                  With_annotations) == 0;
1897
16
    if (!cond) {
1898
0
        Py_DECREF(With_annotations);
1899
0
        return 0;
1900
0
    }
1901
16
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1902
16
                                  With_annotations) == 0;
1903
16
    if (!cond) {
1904
0
        Py_DECREF(With_annotations);
1905
0
        return 0;
1906
0
    }
1907
16
    Py_DECREF(With_annotations);
1908
16
    PyObject *AsyncWith_annotations = PyDict_New();
1909
16
    if (!AsyncWith_annotations) return 0;
1910
16
    {
1911
16
        PyObject *type = state->withitem_type;
1912
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1913
16
        cond = type != NULL;
1914
16
        if (!cond) {
1915
0
            Py_DECREF(AsyncWith_annotations);
1916
0
            return 0;
1917
0
        }
1918
16
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1919
16
        Py_DECREF(type);
1920
16
        if (!cond) {
1921
0
            Py_DECREF(AsyncWith_annotations);
1922
0
            return 0;
1923
0
        }
1924
16
    }
1925
16
    {
1926
16
        PyObject *type = state->stmt_type;
1927
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1928
16
        cond = type != NULL;
1929
16
        if (!cond) {
1930
0
            Py_DECREF(AsyncWith_annotations);
1931
0
            return 0;
1932
0
        }
1933
16
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1934
16
        Py_DECREF(type);
1935
16
        if (!cond) {
1936
0
            Py_DECREF(AsyncWith_annotations);
1937
0
            return 0;
1938
0
        }
1939
16
    }
1940
16
    {
1941
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
1942
16
        type = _Py_union_type_or(type, Py_None);
1943
16
        cond = type != NULL;
1944
16
        if (!cond) {
1945
0
            Py_DECREF(AsyncWith_annotations);
1946
0
            return 0;
1947
0
        }
1948
16
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1949
16
                                    type) == 0;
1950
16
        Py_DECREF(type);
1951
16
        if (!cond) {
1952
0
            Py_DECREF(AsyncWith_annotations);
1953
0
            return 0;
1954
0
        }
1955
16
    }
1956
16
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1957
16
                                  AsyncWith_annotations) == 0;
1958
16
    if (!cond) {
1959
0
        Py_DECREF(AsyncWith_annotations);
1960
0
        return 0;
1961
0
    }
1962
16
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1963
16
                                  AsyncWith_annotations) == 0;
1964
16
    if (!cond) {
1965
0
        Py_DECREF(AsyncWith_annotations);
1966
0
        return 0;
1967
0
    }
1968
16
    Py_DECREF(AsyncWith_annotations);
1969
16
    PyObject *Match_annotations = PyDict_New();
1970
16
    if (!Match_annotations) return 0;
1971
16
    {
1972
16
        PyObject *type = state->expr_type;
1973
16
        Py_INCREF(type);
1974
16
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1975
16
        Py_DECREF(type);
1976
16
        if (!cond) {
1977
0
            Py_DECREF(Match_annotations);
1978
0
            return 0;
1979
0
        }
1980
16
    }
1981
16
    {
1982
16
        PyObject *type = state->match_case_type;
1983
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1984
16
        cond = type != NULL;
1985
16
        if (!cond) {
1986
0
            Py_DECREF(Match_annotations);
1987
0
            return 0;
1988
0
        }
1989
16
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1990
16
        Py_DECREF(type);
1991
16
        if (!cond) {
1992
0
            Py_DECREF(Match_annotations);
1993
0
            return 0;
1994
0
        }
1995
16
    }
1996
16
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1997
16
                                  Match_annotations) == 0;
1998
16
    if (!cond) {
1999
0
        Py_DECREF(Match_annotations);
2000
0
        return 0;
2001
0
    }
2002
16
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
2003
16
                                  Match_annotations) == 0;
2004
16
    if (!cond) {
2005
0
        Py_DECREF(Match_annotations);
2006
0
        return 0;
2007
0
    }
2008
16
    Py_DECREF(Match_annotations);
2009
16
    PyObject *Raise_annotations = PyDict_New();
2010
16
    if (!Raise_annotations) return 0;
2011
16
    {
2012
16
        PyObject *type = state->expr_type;
2013
16
        type = _Py_union_type_or(type, Py_None);
2014
16
        cond = type != NULL;
2015
16
        if (!cond) {
2016
0
            Py_DECREF(Raise_annotations);
2017
0
            return 0;
2018
0
        }
2019
16
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2020
16
        Py_DECREF(type);
2021
16
        if (!cond) {
2022
0
            Py_DECREF(Raise_annotations);
2023
0
            return 0;
2024
0
        }
2025
16
    }
2026
16
    {
2027
16
        PyObject *type = state->expr_type;
2028
16
        type = _Py_union_type_or(type, Py_None);
2029
16
        cond = type != NULL;
2030
16
        if (!cond) {
2031
0
            Py_DECREF(Raise_annotations);
2032
0
            return 0;
2033
0
        }
2034
16
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2035
16
        Py_DECREF(type);
2036
16
        if (!cond) {
2037
0
            Py_DECREF(Raise_annotations);
2038
0
            return 0;
2039
0
        }
2040
16
    }
2041
16
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2042
16
                                  Raise_annotations) == 0;
2043
16
    if (!cond) {
2044
0
        Py_DECREF(Raise_annotations);
2045
0
        return 0;
2046
0
    }
2047
16
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2048
16
                                  Raise_annotations) == 0;
2049
16
    if (!cond) {
2050
0
        Py_DECREF(Raise_annotations);
2051
0
        return 0;
2052
0
    }
2053
16
    Py_DECREF(Raise_annotations);
2054
16
    PyObject *Try_annotations = PyDict_New();
2055
16
    if (!Try_annotations) return 0;
2056
16
    {
2057
16
        PyObject *type = state->stmt_type;
2058
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2059
16
        cond = type != NULL;
2060
16
        if (!cond) {
2061
0
            Py_DECREF(Try_annotations);
2062
0
            return 0;
2063
0
        }
2064
16
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2065
16
        Py_DECREF(type);
2066
16
        if (!cond) {
2067
0
            Py_DECREF(Try_annotations);
2068
0
            return 0;
2069
0
        }
2070
16
    }
2071
16
    {
2072
16
        PyObject *type = state->excepthandler_type;
2073
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2074
16
        cond = type != NULL;
2075
16
        if (!cond) {
2076
0
            Py_DECREF(Try_annotations);
2077
0
            return 0;
2078
0
        }
2079
16
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2080
16
        Py_DECREF(type);
2081
16
        if (!cond) {
2082
0
            Py_DECREF(Try_annotations);
2083
0
            return 0;
2084
0
        }
2085
16
    }
2086
16
    {
2087
16
        PyObject *type = state->stmt_type;
2088
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2089
16
        cond = type != NULL;
2090
16
        if (!cond) {
2091
0
            Py_DECREF(Try_annotations);
2092
0
            return 0;
2093
0
        }
2094
16
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2095
16
        Py_DECREF(type);
2096
16
        if (!cond) {
2097
0
            Py_DECREF(Try_annotations);
2098
0
            return 0;
2099
0
        }
2100
16
    }
2101
16
    {
2102
16
        PyObject *type = state->stmt_type;
2103
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2104
16
        cond = type != NULL;
2105
16
        if (!cond) {
2106
0
            Py_DECREF(Try_annotations);
2107
0
            return 0;
2108
0
        }
2109
16
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2110
16
        Py_DECREF(type);
2111
16
        if (!cond) {
2112
0
            Py_DECREF(Try_annotations);
2113
0
            return 0;
2114
0
        }
2115
16
    }
2116
16
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2117
16
                                  Try_annotations) == 0;
2118
16
    if (!cond) {
2119
0
        Py_DECREF(Try_annotations);
2120
0
        return 0;
2121
0
    }
2122
16
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2123
16
                                  Try_annotations) == 0;
2124
16
    if (!cond) {
2125
0
        Py_DECREF(Try_annotations);
2126
0
        return 0;
2127
0
    }
2128
16
    Py_DECREF(Try_annotations);
2129
16
    PyObject *TryStar_annotations = PyDict_New();
2130
16
    if (!TryStar_annotations) return 0;
2131
16
    {
2132
16
        PyObject *type = state->stmt_type;
2133
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2134
16
        cond = type != NULL;
2135
16
        if (!cond) {
2136
0
            Py_DECREF(TryStar_annotations);
2137
0
            return 0;
2138
0
        }
2139
16
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2140
16
        Py_DECREF(type);
2141
16
        if (!cond) {
2142
0
            Py_DECREF(TryStar_annotations);
2143
0
            return 0;
2144
0
        }
2145
16
    }
2146
16
    {
2147
16
        PyObject *type = state->excepthandler_type;
2148
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2149
16
        cond = type != NULL;
2150
16
        if (!cond) {
2151
0
            Py_DECREF(TryStar_annotations);
2152
0
            return 0;
2153
0
        }
2154
16
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2155
16
        Py_DECREF(type);
2156
16
        if (!cond) {
2157
0
            Py_DECREF(TryStar_annotations);
2158
0
            return 0;
2159
0
        }
2160
16
    }
2161
16
    {
2162
16
        PyObject *type = state->stmt_type;
2163
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2164
16
        cond = type != NULL;
2165
16
        if (!cond) {
2166
0
            Py_DECREF(TryStar_annotations);
2167
0
            return 0;
2168
0
        }
2169
16
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2170
16
        Py_DECREF(type);
2171
16
        if (!cond) {
2172
0
            Py_DECREF(TryStar_annotations);
2173
0
            return 0;
2174
0
        }
2175
16
    }
2176
16
    {
2177
16
        PyObject *type = state->stmt_type;
2178
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2179
16
        cond = type != NULL;
2180
16
        if (!cond) {
2181
0
            Py_DECREF(TryStar_annotations);
2182
0
            return 0;
2183
0
        }
2184
16
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2185
16
                                    0;
2186
16
        Py_DECREF(type);
2187
16
        if (!cond) {
2188
0
            Py_DECREF(TryStar_annotations);
2189
0
            return 0;
2190
0
        }
2191
16
    }
2192
16
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2193
16
                                  TryStar_annotations) == 0;
2194
16
    if (!cond) {
2195
0
        Py_DECREF(TryStar_annotations);
2196
0
        return 0;
2197
0
    }
2198
16
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2199
16
                                  TryStar_annotations) == 0;
2200
16
    if (!cond) {
2201
0
        Py_DECREF(TryStar_annotations);
2202
0
        return 0;
2203
0
    }
2204
16
    Py_DECREF(TryStar_annotations);
2205
16
    PyObject *Assert_annotations = PyDict_New();
2206
16
    if (!Assert_annotations) return 0;
2207
16
    {
2208
16
        PyObject *type = state->expr_type;
2209
16
        Py_INCREF(type);
2210
16
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2211
16
        Py_DECREF(type);
2212
16
        if (!cond) {
2213
0
            Py_DECREF(Assert_annotations);
2214
0
            return 0;
2215
0
        }
2216
16
    }
2217
16
    {
2218
16
        PyObject *type = state->expr_type;
2219
16
        type = _Py_union_type_or(type, Py_None);
2220
16
        cond = type != NULL;
2221
16
        if (!cond) {
2222
0
            Py_DECREF(Assert_annotations);
2223
0
            return 0;
2224
0
        }
2225
16
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2226
16
        Py_DECREF(type);
2227
16
        if (!cond) {
2228
0
            Py_DECREF(Assert_annotations);
2229
0
            return 0;
2230
0
        }
2231
16
    }
2232
16
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2233
16
                                  Assert_annotations) == 0;
2234
16
    if (!cond) {
2235
0
        Py_DECREF(Assert_annotations);
2236
0
        return 0;
2237
0
    }
2238
16
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2239
16
                                  Assert_annotations) == 0;
2240
16
    if (!cond) {
2241
0
        Py_DECREF(Assert_annotations);
2242
0
        return 0;
2243
0
    }
2244
16
    Py_DECREF(Assert_annotations);
2245
16
    PyObject *Import_annotations = PyDict_New();
2246
16
    if (!Import_annotations) return 0;
2247
16
    {
2248
16
        PyObject *type = state->alias_type;
2249
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2250
16
        cond = type != NULL;
2251
16
        if (!cond) {
2252
0
            Py_DECREF(Import_annotations);
2253
0
            return 0;
2254
0
        }
2255
16
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2256
16
        Py_DECREF(type);
2257
16
        if (!cond) {
2258
0
            Py_DECREF(Import_annotations);
2259
0
            return 0;
2260
0
        }
2261
16
    }
2262
16
    {
2263
16
        PyObject *type = (PyObject *)&PyLong_Type;
2264
16
        type = _Py_union_type_or(type, Py_None);
2265
16
        cond = type != NULL;
2266
16
        if (!cond) {
2267
0
            Py_DECREF(Import_annotations);
2268
0
            return 0;
2269
0
        }
2270
16
        cond = PyDict_SetItemString(Import_annotations, "is_lazy", type) == 0;
2271
16
        Py_DECREF(type);
2272
16
        if (!cond) {
2273
0
            Py_DECREF(Import_annotations);
2274
0
            return 0;
2275
0
        }
2276
16
    }
2277
16
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2278
16
                                  Import_annotations) == 0;
2279
16
    if (!cond) {
2280
0
        Py_DECREF(Import_annotations);
2281
0
        return 0;
2282
0
    }
2283
16
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2284
16
                                  Import_annotations) == 0;
2285
16
    if (!cond) {
2286
0
        Py_DECREF(Import_annotations);
2287
0
        return 0;
2288
0
    }
2289
16
    Py_DECREF(Import_annotations);
2290
16
    PyObject *ImportFrom_annotations = PyDict_New();
2291
16
    if (!ImportFrom_annotations) return 0;
2292
16
    {
2293
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
2294
16
        type = _Py_union_type_or(type, Py_None);
2295
16
        cond = type != NULL;
2296
16
        if (!cond) {
2297
0
            Py_DECREF(ImportFrom_annotations);
2298
0
            return 0;
2299
0
        }
2300
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2301
16
                                    0;
2302
16
        Py_DECREF(type);
2303
16
        if (!cond) {
2304
0
            Py_DECREF(ImportFrom_annotations);
2305
0
            return 0;
2306
0
        }
2307
16
    }
2308
16
    {
2309
16
        PyObject *type = state->alias_type;
2310
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2311
16
        cond = type != NULL;
2312
16
        if (!cond) {
2313
0
            Py_DECREF(ImportFrom_annotations);
2314
0
            return 0;
2315
0
        }
2316
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2317
16
        Py_DECREF(type);
2318
16
        if (!cond) {
2319
0
            Py_DECREF(ImportFrom_annotations);
2320
0
            return 0;
2321
0
        }
2322
16
    }
2323
16
    {
2324
16
        PyObject *type = (PyObject *)&PyLong_Type;
2325
16
        type = _Py_union_type_or(type, Py_None);
2326
16
        cond = type != NULL;
2327
16
        if (!cond) {
2328
0
            Py_DECREF(ImportFrom_annotations);
2329
0
            return 0;
2330
0
        }
2331
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2332
16
        Py_DECREF(type);
2333
16
        if (!cond) {
2334
0
            Py_DECREF(ImportFrom_annotations);
2335
0
            return 0;
2336
0
        }
2337
16
    }
2338
16
    {
2339
16
        PyObject *type = (PyObject *)&PyLong_Type;
2340
16
        type = _Py_union_type_or(type, Py_None);
2341
16
        cond = type != NULL;
2342
16
        if (!cond) {
2343
0
            Py_DECREF(ImportFrom_annotations);
2344
0
            return 0;
2345
0
        }
2346
16
        cond = PyDict_SetItemString(ImportFrom_annotations, "is_lazy", type) ==
2347
16
                                    0;
2348
16
        Py_DECREF(type);
2349
16
        if (!cond) {
2350
0
            Py_DECREF(ImportFrom_annotations);
2351
0
            return 0;
2352
0
        }
2353
16
    }
2354
16
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2355
16
                                  ImportFrom_annotations) == 0;
2356
16
    if (!cond) {
2357
0
        Py_DECREF(ImportFrom_annotations);
2358
0
        return 0;
2359
0
    }
2360
16
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2361
16
                                  ImportFrom_annotations) == 0;
2362
16
    if (!cond) {
2363
0
        Py_DECREF(ImportFrom_annotations);
2364
0
        return 0;
2365
0
    }
2366
16
    Py_DECREF(ImportFrom_annotations);
2367
16
    PyObject *Global_annotations = PyDict_New();
2368
16
    if (!Global_annotations) return 0;
2369
16
    {
2370
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
2371
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2372
16
        cond = type != NULL;
2373
16
        if (!cond) {
2374
0
            Py_DECREF(Global_annotations);
2375
0
            return 0;
2376
0
        }
2377
16
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2378
16
        Py_DECREF(type);
2379
16
        if (!cond) {
2380
0
            Py_DECREF(Global_annotations);
2381
0
            return 0;
2382
0
        }
2383
16
    }
2384
16
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2385
16
                                  Global_annotations) == 0;
2386
16
    if (!cond) {
2387
0
        Py_DECREF(Global_annotations);
2388
0
        return 0;
2389
0
    }
2390
16
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2391
16
                                  Global_annotations) == 0;
2392
16
    if (!cond) {
2393
0
        Py_DECREF(Global_annotations);
2394
0
        return 0;
2395
0
    }
2396
16
    Py_DECREF(Global_annotations);
2397
16
    PyObject *Nonlocal_annotations = PyDict_New();
2398
16
    if (!Nonlocal_annotations) return 0;
2399
16
    {
2400
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
2401
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2402
16
        cond = type != NULL;
2403
16
        if (!cond) {
2404
0
            Py_DECREF(Nonlocal_annotations);
2405
0
            return 0;
2406
0
        }
2407
16
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2408
16
        Py_DECREF(type);
2409
16
        if (!cond) {
2410
0
            Py_DECREF(Nonlocal_annotations);
2411
0
            return 0;
2412
0
        }
2413
16
    }
2414
16
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2415
16
                                  Nonlocal_annotations) == 0;
2416
16
    if (!cond) {
2417
0
        Py_DECREF(Nonlocal_annotations);
2418
0
        return 0;
2419
0
    }
2420
16
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2421
16
                                  Nonlocal_annotations) == 0;
2422
16
    if (!cond) {
2423
0
        Py_DECREF(Nonlocal_annotations);
2424
0
        return 0;
2425
0
    }
2426
16
    Py_DECREF(Nonlocal_annotations);
2427
16
    PyObject *Expr_annotations = PyDict_New();
2428
16
    if (!Expr_annotations) return 0;
2429
16
    {
2430
16
        PyObject *type = state->expr_type;
2431
16
        Py_INCREF(type);
2432
16
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2433
16
        Py_DECREF(type);
2434
16
        if (!cond) {
2435
0
            Py_DECREF(Expr_annotations);
2436
0
            return 0;
2437
0
        }
2438
16
    }
2439
16
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2440
16
                                  Expr_annotations) == 0;
2441
16
    if (!cond) {
2442
0
        Py_DECREF(Expr_annotations);
2443
0
        return 0;
2444
0
    }
2445
16
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2446
16
                                  Expr_annotations) == 0;
2447
16
    if (!cond) {
2448
0
        Py_DECREF(Expr_annotations);
2449
0
        return 0;
2450
0
    }
2451
16
    Py_DECREF(Expr_annotations);
2452
16
    PyObject *Pass_annotations = PyDict_New();
2453
16
    if (!Pass_annotations) return 0;
2454
16
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2455
16
                                  Pass_annotations) == 0;
2456
16
    if (!cond) {
2457
0
        Py_DECREF(Pass_annotations);
2458
0
        return 0;
2459
0
    }
2460
16
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2461
16
                                  Pass_annotations) == 0;
2462
16
    if (!cond) {
2463
0
        Py_DECREF(Pass_annotations);
2464
0
        return 0;
2465
0
    }
2466
16
    Py_DECREF(Pass_annotations);
2467
16
    PyObject *Break_annotations = PyDict_New();
2468
16
    if (!Break_annotations) return 0;
2469
16
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2470
16
                                  Break_annotations) == 0;
2471
16
    if (!cond) {
2472
0
        Py_DECREF(Break_annotations);
2473
0
        return 0;
2474
0
    }
2475
16
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2476
16
                                  Break_annotations) == 0;
2477
16
    if (!cond) {
2478
0
        Py_DECREF(Break_annotations);
2479
0
        return 0;
2480
0
    }
2481
16
    Py_DECREF(Break_annotations);
2482
16
    PyObject *Continue_annotations = PyDict_New();
2483
16
    if (!Continue_annotations) return 0;
2484
16
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2485
16
                                  Continue_annotations) == 0;
2486
16
    if (!cond) {
2487
0
        Py_DECREF(Continue_annotations);
2488
0
        return 0;
2489
0
    }
2490
16
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2491
16
                                  Continue_annotations) == 0;
2492
16
    if (!cond) {
2493
0
        Py_DECREF(Continue_annotations);
2494
0
        return 0;
2495
0
    }
2496
16
    Py_DECREF(Continue_annotations);
2497
16
    PyObject *BoolOp_annotations = PyDict_New();
2498
16
    if (!BoolOp_annotations) return 0;
2499
16
    {
2500
16
        PyObject *type = state->boolop_type;
2501
16
        Py_INCREF(type);
2502
16
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2503
16
        Py_DECREF(type);
2504
16
        if (!cond) {
2505
0
            Py_DECREF(BoolOp_annotations);
2506
0
            return 0;
2507
0
        }
2508
16
    }
2509
16
    {
2510
16
        PyObject *type = state->expr_type;
2511
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2512
16
        cond = type != NULL;
2513
16
        if (!cond) {
2514
0
            Py_DECREF(BoolOp_annotations);
2515
0
            return 0;
2516
0
        }
2517
16
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2518
16
        Py_DECREF(type);
2519
16
        if (!cond) {
2520
0
            Py_DECREF(BoolOp_annotations);
2521
0
            return 0;
2522
0
        }
2523
16
    }
2524
16
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2525
16
                                  BoolOp_annotations) == 0;
2526
16
    if (!cond) {
2527
0
        Py_DECREF(BoolOp_annotations);
2528
0
        return 0;
2529
0
    }
2530
16
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2531
16
                                  BoolOp_annotations) == 0;
2532
16
    if (!cond) {
2533
0
        Py_DECREF(BoolOp_annotations);
2534
0
        return 0;
2535
0
    }
2536
16
    Py_DECREF(BoolOp_annotations);
2537
16
    PyObject *NamedExpr_annotations = PyDict_New();
2538
16
    if (!NamedExpr_annotations) return 0;
2539
16
    {
2540
16
        PyObject *type = state->expr_type;
2541
16
        Py_INCREF(type);
2542
16
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2543
16
        Py_DECREF(type);
2544
16
        if (!cond) {
2545
0
            Py_DECREF(NamedExpr_annotations);
2546
0
            return 0;
2547
0
        }
2548
16
    }
2549
16
    {
2550
16
        PyObject *type = state->expr_type;
2551
16
        Py_INCREF(type);
2552
16
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2553
16
        Py_DECREF(type);
2554
16
        if (!cond) {
2555
0
            Py_DECREF(NamedExpr_annotations);
2556
0
            return 0;
2557
0
        }
2558
16
    }
2559
16
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2560
16
                                  NamedExpr_annotations) == 0;
2561
16
    if (!cond) {
2562
0
        Py_DECREF(NamedExpr_annotations);
2563
0
        return 0;
2564
0
    }
2565
16
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2566
16
                                  NamedExpr_annotations) == 0;
2567
16
    if (!cond) {
2568
0
        Py_DECREF(NamedExpr_annotations);
2569
0
        return 0;
2570
0
    }
2571
16
    Py_DECREF(NamedExpr_annotations);
2572
16
    PyObject *BinOp_annotations = PyDict_New();
2573
16
    if (!BinOp_annotations) return 0;
2574
16
    {
2575
16
        PyObject *type = state->expr_type;
2576
16
        Py_INCREF(type);
2577
16
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2578
16
        Py_DECREF(type);
2579
16
        if (!cond) {
2580
0
            Py_DECREF(BinOp_annotations);
2581
0
            return 0;
2582
0
        }
2583
16
    }
2584
16
    {
2585
16
        PyObject *type = state->operator_type;
2586
16
        Py_INCREF(type);
2587
16
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2588
16
        Py_DECREF(type);
2589
16
        if (!cond) {
2590
0
            Py_DECREF(BinOp_annotations);
2591
0
            return 0;
2592
0
        }
2593
16
    }
2594
16
    {
2595
16
        PyObject *type = state->expr_type;
2596
16
        Py_INCREF(type);
2597
16
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2598
16
        Py_DECREF(type);
2599
16
        if (!cond) {
2600
0
            Py_DECREF(BinOp_annotations);
2601
0
            return 0;
2602
0
        }
2603
16
    }
2604
16
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2605
16
                                  BinOp_annotations) == 0;
2606
16
    if (!cond) {
2607
0
        Py_DECREF(BinOp_annotations);
2608
0
        return 0;
2609
0
    }
2610
16
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2611
16
                                  BinOp_annotations) == 0;
2612
16
    if (!cond) {
2613
0
        Py_DECREF(BinOp_annotations);
2614
0
        return 0;
2615
0
    }
2616
16
    Py_DECREF(BinOp_annotations);
2617
16
    PyObject *UnaryOp_annotations = PyDict_New();
2618
16
    if (!UnaryOp_annotations) return 0;
2619
16
    {
2620
16
        PyObject *type = state->unaryop_type;
2621
16
        Py_INCREF(type);
2622
16
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2623
16
        Py_DECREF(type);
2624
16
        if (!cond) {
2625
0
            Py_DECREF(UnaryOp_annotations);
2626
0
            return 0;
2627
0
        }
2628
16
    }
2629
16
    {
2630
16
        PyObject *type = state->expr_type;
2631
16
        Py_INCREF(type);
2632
16
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2633
16
        Py_DECREF(type);
2634
16
        if (!cond) {
2635
0
            Py_DECREF(UnaryOp_annotations);
2636
0
            return 0;
2637
0
        }
2638
16
    }
2639
16
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2640
16
                                  UnaryOp_annotations) == 0;
2641
16
    if (!cond) {
2642
0
        Py_DECREF(UnaryOp_annotations);
2643
0
        return 0;
2644
0
    }
2645
16
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2646
16
                                  UnaryOp_annotations) == 0;
2647
16
    if (!cond) {
2648
0
        Py_DECREF(UnaryOp_annotations);
2649
0
        return 0;
2650
0
    }
2651
16
    Py_DECREF(UnaryOp_annotations);
2652
16
    PyObject *Lambda_annotations = PyDict_New();
2653
16
    if (!Lambda_annotations) return 0;
2654
16
    {
2655
16
        PyObject *type = state->arguments_type;
2656
16
        Py_INCREF(type);
2657
16
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2658
16
        Py_DECREF(type);
2659
16
        if (!cond) {
2660
0
            Py_DECREF(Lambda_annotations);
2661
0
            return 0;
2662
0
        }
2663
16
    }
2664
16
    {
2665
16
        PyObject *type = state->expr_type;
2666
16
        Py_INCREF(type);
2667
16
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2668
16
        Py_DECREF(type);
2669
16
        if (!cond) {
2670
0
            Py_DECREF(Lambda_annotations);
2671
0
            return 0;
2672
0
        }
2673
16
    }
2674
16
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2675
16
                                  Lambda_annotations) == 0;
2676
16
    if (!cond) {
2677
0
        Py_DECREF(Lambda_annotations);
2678
0
        return 0;
2679
0
    }
2680
16
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2681
16
                                  Lambda_annotations) == 0;
2682
16
    if (!cond) {
2683
0
        Py_DECREF(Lambda_annotations);
2684
0
        return 0;
2685
0
    }
2686
16
    Py_DECREF(Lambda_annotations);
2687
16
    PyObject *IfExp_annotations = PyDict_New();
2688
16
    if (!IfExp_annotations) return 0;
2689
16
    {
2690
16
        PyObject *type = state->expr_type;
2691
16
        Py_INCREF(type);
2692
16
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2693
16
        Py_DECREF(type);
2694
16
        if (!cond) {
2695
0
            Py_DECREF(IfExp_annotations);
2696
0
            return 0;
2697
0
        }
2698
16
    }
2699
16
    {
2700
16
        PyObject *type = state->expr_type;
2701
16
        Py_INCREF(type);
2702
16
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2703
16
        Py_DECREF(type);
2704
16
        if (!cond) {
2705
0
            Py_DECREF(IfExp_annotations);
2706
0
            return 0;
2707
0
        }
2708
16
    }
2709
16
    {
2710
16
        PyObject *type = state->expr_type;
2711
16
        Py_INCREF(type);
2712
16
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2713
16
        Py_DECREF(type);
2714
16
        if (!cond) {
2715
0
            Py_DECREF(IfExp_annotations);
2716
0
            return 0;
2717
0
        }
2718
16
    }
2719
16
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2720
16
                                  IfExp_annotations) == 0;
2721
16
    if (!cond) {
2722
0
        Py_DECREF(IfExp_annotations);
2723
0
        return 0;
2724
0
    }
2725
16
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2726
16
                                  IfExp_annotations) == 0;
2727
16
    if (!cond) {
2728
0
        Py_DECREF(IfExp_annotations);
2729
0
        return 0;
2730
0
    }
2731
16
    Py_DECREF(IfExp_annotations);
2732
16
    PyObject *Dict_annotations = PyDict_New();
2733
16
    if (!Dict_annotations) return 0;
2734
16
    {
2735
16
        PyObject *type = state->expr_type;
2736
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2737
16
        cond = type != NULL;
2738
16
        if (!cond) {
2739
0
            Py_DECREF(Dict_annotations);
2740
0
            return 0;
2741
0
        }
2742
16
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2743
16
        Py_DECREF(type);
2744
16
        if (!cond) {
2745
0
            Py_DECREF(Dict_annotations);
2746
0
            return 0;
2747
0
        }
2748
16
    }
2749
16
    {
2750
16
        PyObject *type = state->expr_type;
2751
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2752
16
        cond = type != NULL;
2753
16
        if (!cond) {
2754
0
            Py_DECREF(Dict_annotations);
2755
0
            return 0;
2756
0
        }
2757
16
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2758
16
        Py_DECREF(type);
2759
16
        if (!cond) {
2760
0
            Py_DECREF(Dict_annotations);
2761
0
            return 0;
2762
0
        }
2763
16
    }
2764
16
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2765
16
                                  Dict_annotations) == 0;
2766
16
    if (!cond) {
2767
0
        Py_DECREF(Dict_annotations);
2768
0
        return 0;
2769
0
    }
2770
16
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2771
16
                                  Dict_annotations) == 0;
2772
16
    if (!cond) {
2773
0
        Py_DECREF(Dict_annotations);
2774
0
        return 0;
2775
0
    }
2776
16
    Py_DECREF(Dict_annotations);
2777
16
    PyObject *Set_annotations = PyDict_New();
2778
16
    if (!Set_annotations) return 0;
2779
16
    {
2780
16
        PyObject *type = state->expr_type;
2781
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2782
16
        cond = type != NULL;
2783
16
        if (!cond) {
2784
0
            Py_DECREF(Set_annotations);
2785
0
            return 0;
2786
0
        }
2787
16
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2788
16
        Py_DECREF(type);
2789
16
        if (!cond) {
2790
0
            Py_DECREF(Set_annotations);
2791
0
            return 0;
2792
0
        }
2793
16
    }
2794
16
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2795
16
                                  Set_annotations) == 0;
2796
16
    if (!cond) {
2797
0
        Py_DECREF(Set_annotations);
2798
0
        return 0;
2799
0
    }
2800
16
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2801
16
                                  Set_annotations) == 0;
2802
16
    if (!cond) {
2803
0
        Py_DECREF(Set_annotations);
2804
0
        return 0;
2805
0
    }
2806
16
    Py_DECREF(Set_annotations);
2807
16
    PyObject *ListComp_annotations = PyDict_New();
2808
16
    if (!ListComp_annotations) return 0;
2809
16
    {
2810
16
        PyObject *type = state->expr_type;
2811
16
        Py_INCREF(type);
2812
16
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2813
16
        Py_DECREF(type);
2814
16
        if (!cond) {
2815
0
            Py_DECREF(ListComp_annotations);
2816
0
            return 0;
2817
0
        }
2818
16
    }
2819
16
    {
2820
16
        PyObject *type = state->comprehension_type;
2821
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2822
16
        cond = type != NULL;
2823
16
        if (!cond) {
2824
0
            Py_DECREF(ListComp_annotations);
2825
0
            return 0;
2826
0
        }
2827
16
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2828
16
                                    == 0;
2829
16
        Py_DECREF(type);
2830
16
        if (!cond) {
2831
0
            Py_DECREF(ListComp_annotations);
2832
0
            return 0;
2833
0
        }
2834
16
    }
2835
16
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2836
16
                                  ListComp_annotations) == 0;
2837
16
    if (!cond) {
2838
0
        Py_DECREF(ListComp_annotations);
2839
0
        return 0;
2840
0
    }
2841
16
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2842
16
                                  ListComp_annotations) == 0;
2843
16
    if (!cond) {
2844
0
        Py_DECREF(ListComp_annotations);
2845
0
        return 0;
2846
0
    }
2847
16
    Py_DECREF(ListComp_annotations);
2848
16
    PyObject *SetComp_annotations = PyDict_New();
2849
16
    if (!SetComp_annotations) return 0;
2850
16
    {
2851
16
        PyObject *type = state->expr_type;
2852
16
        Py_INCREF(type);
2853
16
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2854
16
        Py_DECREF(type);
2855
16
        if (!cond) {
2856
0
            Py_DECREF(SetComp_annotations);
2857
0
            return 0;
2858
0
        }
2859
16
    }
2860
16
    {
2861
16
        PyObject *type = state->comprehension_type;
2862
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2863
16
        cond = type != NULL;
2864
16
        if (!cond) {
2865
0
            Py_DECREF(SetComp_annotations);
2866
0
            return 0;
2867
0
        }
2868
16
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2869
16
                                    0;
2870
16
        Py_DECREF(type);
2871
16
        if (!cond) {
2872
0
            Py_DECREF(SetComp_annotations);
2873
0
            return 0;
2874
0
        }
2875
16
    }
2876
16
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2877
16
                                  SetComp_annotations) == 0;
2878
16
    if (!cond) {
2879
0
        Py_DECREF(SetComp_annotations);
2880
0
        return 0;
2881
0
    }
2882
16
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2883
16
                                  SetComp_annotations) == 0;
2884
16
    if (!cond) {
2885
0
        Py_DECREF(SetComp_annotations);
2886
0
        return 0;
2887
0
    }
2888
16
    Py_DECREF(SetComp_annotations);
2889
16
    PyObject *DictComp_annotations = PyDict_New();
2890
16
    if (!DictComp_annotations) return 0;
2891
16
    {
2892
16
        PyObject *type = state->expr_type;
2893
16
        Py_INCREF(type);
2894
16
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2895
16
        Py_DECREF(type);
2896
16
        if (!cond) {
2897
0
            Py_DECREF(DictComp_annotations);
2898
0
            return 0;
2899
0
        }
2900
16
    }
2901
16
    {
2902
16
        PyObject *type = state->expr_type;
2903
16
        type = _Py_union_type_or(type, Py_None);
2904
16
        cond = type != NULL;
2905
16
        if (!cond) {
2906
0
            Py_DECREF(DictComp_annotations);
2907
0
            return 0;
2908
0
        }
2909
16
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2910
16
        Py_DECREF(type);
2911
16
        if (!cond) {
2912
0
            Py_DECREF(DictComp_annotations);
2913
0
            return 0;
2914
0
        }
2915
16
    }
2916
16
    {
2917
16
        PyObject *type = state->comprehension_type;
2918
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2919
16
        cond = type != NULL;
2920
16
        if (!cond) {
2921
0
            Py_DECREF(DictComp_annotations);
2922
0
            return 0;
2923
0
        }
2924
16
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2925
16
                                    == 0;
2926
16
        Py_DECREF(type);
2927
16
        if (!cond) {
2928
0
            Py_DECREF(DictComp_annotations);
2929
0
            return 0;
2930
0
        }
2931
16
    }
2932
16
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2933
16
                                  DictComp_annotations) == 0;
2934
16
    if (!cond) {
2935
0
        Py_DECREF(DictComp_annotations);
2936
0
        return 0;
2937
0
    }
2938
16
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2939
16
                                  DictComp_annotations) == 0;
2940
16
    if (!cond) {
2941
0
        Py_DECREF(DictComp_annotations);
2942
0
        return 0;
2943
0
    }
2944
16
    Py_DECREF(DictComp_annotations);
2945
16
    PyObject *GeneratorExp_annotations = PyDict_New();
2946
16
    if (!GeneratorExp_annotations) return 0;
2947
16
    {
2948
16
        PyObject *type = state->expr_type;
2949
16
        Py_INCREF(type);
2950
16
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2951
16
        Py_DECREF(type);
2952
16
        if (!cond) {
2953
0
            Py_DECREF(GeneratorExp_annotations);
2954
0
            return 0;
2955
0
        }
2956
16
    }
2957
16
    {
2958
16
        PyObject *type = state->comprehension_type;
2959
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2960
16
        cond = type != NULL;
2961
16
        if (!cond) {
2962
0
            Py_DECREF(GeneratorExp_annotations);
2963
0
            return 0;
2964
0
        }
2965
16
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2966
16
                                    type) == 0;
2967
16
        Py_DECREF(type);
2968
16
        if (!cond) {
2969
0
            Py_DECREF(GeneratorExp_annotations);
2970
0
            return 0;
2971
0
        }
2972
16
    }
2973
16
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2974
16
                                  GeneratorExp_annotations) == 0;
2975
16
    if (!cond) {
2976
0
        Py_DECREF(GeneratorExp_annotations);
2977
0
        return 0;
2978
0
    }
2979
16
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2980
16
                                  GeneratorExp_annotations) == 0;
2981
16
    if (!cond) {
2982
0
        Py_DECREF(GeneratorExp_annotations);
2983
0
        return 0;
2984
0
    }
2985
16
    Py_DECREF(GeneratorExp_annotations);
2986
16
    PyObject *Await_annotations = PyDict_New();
2987
16
    if (!Await_annotations) return 0;
2988
16
    {
2989
16
        PyObject *type = state->expr_type;
2990
16
        Py_INCREF(type);
2991
16
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2992
16
        Py_DECREF(type);
2993
16
        if (!cond) {
2994
0
            Py_DECREF(Await_annotations);
2995
0
            return 0;
2996
0
        }
2997
16
    }
2998
16
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2999
16
                                  Await_annotations) == 0;
3000
16
    if (!cond) {
3001
0
        Py_DECREF(Await_annotations);
3002
0
        return 0;
3003
0
    }
3004
16
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
3005
16
                                  Await_annotations) == 0;
3006
16
    if (!cond) {
3007
0
        Py_DECREF(Await_annotations);
3008
0
        return 0;
3009
0
    }
3010
16
    Py_DECREF(Await_annotations);
3011
16
    PyObject *Yield_annotations = PyDict_New();
3012
16
    if (!Yield_annotations) return 0;
3013
16
    {
3014
16
        PyObject *type = state->expr_type;
3015
16
        type = _Py_union_type_or(type, Py_None);
3016
16
        cond = type != NULL;
3017
16
        if (!cond) {
3018
0
            Py_DECREF(Yield_annotations);
3019
0
            return 0;
3020
0
        }
3021
16
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
3022
16
        Py_DECREF(type);
3023
16
        if (!cond) {
3024
0
            Py_DECREF(Yield_annotations);
3025
0
            return 0;
3026
0
        }
3027
16
    }
3028
16
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
3029
16
                                  Yield_annotations) == 0;
3030
16
    if (!cond) {
3031
0
        Py_DECREF(Yield_annotations);
3032
0
        return 0;
3033
0
    }
3034
16
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
3035
16
                                  Yield_annotations) == 0;
3036
16
    if (!cond) {
3037
0
        Py_DECREF(Yield_annotations);
3038
0
        return 0;
3039
0
    }
3040
16
    Py_DECREF(Yield_annotations);
3041
16
    PyObject *YieldFrom_annotations = PyDict_New();
3042
16
    if (!YieldFrom_annotations) return 0;
3043
16
    {
3044
16
        PyObject *type = state->expr_type;
3045
16
        Py_INCREF(type);
3046
16
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3047
16
        Py_DECREF(type);
3048
16
        if (!cond) {
3049
0
            Py_DECREF(YieldFrom_annotations);
3050
0
            return 0;
3051
0
        }
3052
16
    }
3053
16
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3054
16
                                  YieldFrom_annotations) == 0;
3055
16
    if (!cond) {
3056
0
        Py_DECREF(YieldFrom_annotations);
3057
0
        return 0;
3058
0
    }
3059
16
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3060
16
                                  YieldFrom_annotations) == 0;
3061
16
    if (!cond) {
3062
0
        Py_DECREF(YieldFrom_annotations);
3063
0
        return 0;
3064
0
    }
3065
16
    Py_DECREF(YieldFrom_annotations);
3066
16
    PyObject *Compare_annotations = PyDict_New();
3067
16
    if (!Compare_annotations) return 0;
3068
16
    {
3069
16
        PyObject *type = state->expr_type;
3070
16
        Py_INCREF(type);
3071
16
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3072
16
        Py_DECREF(type);
3073
16
        if (!cond) {
3074
0
            Py_DECREF(Compare_annotations);
3075
0
            return 0;
3076
0
        }
3077
16
    }
3078
16
    {
3079
16
        PyObject *type = state->cmpop_type;
3080
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3081
16
        cond = type != NULL;
3082
16
        if (!cond) {
3083
0
            Py_DECREF(Compare_annotations);
3084
0
            return 0;
3085
0
        }
3086
16
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3087
16
        Py_DECREF(type);
3088
16
        if (!cond) {
3089
0
            Py_DECREF(Compare_annotations);
3090
0
            return 0;
3091
0
        }
3092
16
    }
3093
16
    {
3094
16
        PyObject *type = state->expr_type;
3095
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3096
16
        cond = type != NULL;
3097
16
        if (!cond) {
3098
0
            Py_DECREF(Compare_annotations);
3099
0
            return 0;
3100
0
        }
3101
16
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3102
16
                                    == 0;
3103
16
        Py_DECREF(type);
3104
16
        if (!cond) {
3105
0
            Py_DECREF(Compare_annotations);
3106
0
            return 0;
3107
0
        }
3108
16
    }
3109
16
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3110
16
                                  Compare_annotations) == 0;
3111
16
    if (!cond) {
3112
0
        Py_DECREF(Compare_annotations);
3113
0
        return 0;
3114
0
    }
3115
16
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3116
16
                                  Compare_annotations) == 0;
3117
16
    if (!cond) {
3118
0
        Py_DECREF(Compare_annotations);
3119
0
        return 0;
3120
0
    }
3121
16
    Py_DECREF(Compare_annotations);
3122
16
    PyObject *Call_annotations = PyDict_New();
3123
16
    if (!Call_annotations) return 0;
3124
16
    {
3125
16
        PyObject *type = state->expr_type;
3126
16
        Py_INCREF(type);
3127
16
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3128
16
        Py_DECREF(type);
3129
16
        if (!cond) {
3130
0
            Py_DECREF(Call_annotations);
3131
0
            return 0;
3132
0
        }
3133
16
    }
3134
16
    {
3135
16
        PyObject *type = state->expr_type;
3136
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3137
16
        cond = type != NULL;
3138
16
        if (!cond) {
3139
0
            Py_DECREF(Call_annotations);
3140
0
            return 0;
3141
0
        }
3142
16
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3143
16
        Py_DECREF(type);
3144
16
        if (!cond) {
3145
0
            Py_DECREF(Call_annotations);
3146
0
            return 0;
3147
0
        }
3148
16
    }
3149
16
    {
3150
16
        PyObject *type = state->keyword_type;
3151
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3152
16
        cond = type != NULL;
3153
16
        if (!cond) {
3154
0
            Py_DECREF(Call_annotations);
3155
0
            return 0;
3156
0
        }
3157
16
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3158
16
        Py_DECREF(type);
3159
16
        if (!cond) {
3160
0
            Py_DECREF(Call_annotations);
3161
0
            return 0;
3162
0
        }
3163
16
    }
3164
16
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3165
16
                                  Call_annotations) == 0;
3166
16
    if (!cond) {
3167
0
        Py_DECREF(Call_annotations);
3168
0
        return 0;
3169
0
    }
3170
16
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3171
16
                                  Call_annotations) == 0;
3172
16
    if (!cond) {
3173
0
        Py_DECREF(Call_annotations);
3174
0
        return 0;
3175
0
    }
3176
16
    Py_DECREF(Call_annotations);
3177
16
    PyObject *FormattedValue_annotations = PyDict_New();
3178
16
    if (!FormattedValue_annotations) return 0;
3179
16
    {
3180
16
        PyObject *type = state->expr_type;
3181
16
        Py_INCREF(type);
3182
16
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3183
16
                                    == 0;
3184
16
        Py_DECREF(type);
3185
16
        if (!cond) {
3186
0
            Py_DECREF(FormattedValue_annotations);
3187
0
            return 0;
3188
0
        }
3189
16
    }
3190
16
    {
3191
16
        PyObject *type = (PyObject *)&PyLong_Type;
3192
16
        Py_INCREF(type);
3193
16
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3194
16
                                    type) == 0;
3195
16
        Py_DECREF(type);
3196
16
        if (!cond) {
3197
0
            Py_DECREF(FormattedValue_annotations);
3198
0
            return 0;
3199
0
        }
3200
16
    }
3201
16
    {
3202
16
        PyObject *type = state->expr_type;
3203
16
        type = _Py_union_type_or(type, Py_None);
3204
16
        cond = type != NULL;
3205
16
        if (!cond) {
3206
0
            Py_DECREF(FormattedValue_annotations);
3207
0
            return 0;
3208
0
        }
3209
16
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3210
16
                                    type) == 0;
3211
16
        Py_DECREF(type);
3212
16
        if (!cond) {
3213
0
            Py_DECREF(FormattedValue_annotations);
3214
0
            return 0;
3215
0
        }
3216
16
    }
3217
16
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3218
16
                                  FormattedValue_annotations) == 0;
3219
16
    if (!cond) {
3220
0
        Py_DECREF(FormattedValue_annotations);
3221
0
        return 0;
3222
0
    }
3223
16
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3224
16
                                  "__annotations__",
3225
16
                                  FormattedValue_annotations) == 0;
3226
16
    if (!cond) {
3227
0
        Py_DECREF(FormattedValue_annotations);
3228
0
        return 0;
3229
0
    }
3230
16
    Py_DECREF(FormattedValue_annotations);
3231
16
    PyObject *Interpolation_annotations = PyDict_New();
3232
16
    if (!Interpolation_annotations) return 0;
3233
16
    {
3234
16
        PyObject *type = state->expr_type;
3235
16
        Py_INCREF(type);
3236
16
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3237
16
                                    == 0;
3238
16
        Py_DECREF(type);
3239
16
        if (!cond) {
3240
0
            Py_DECREF(Interpolation_annotations);
3241
0
            return 0;
3242
0
        }
3243
16
    }
3244
16
    {
3245
16
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3246
16
        Py_INCREF(type);
3247
16
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3248
16
                                    0;
3249
16
        Py_DECREF(type);
3250
16
        if (!cond) {
3251
0
            Py_DECREF(Interpolation_annotations);
3252
0
            return 0;
3253
0
        }
3254
16
    }
3255
16
    {
3256
16
        PyObject *type = (PyObject *)&PyLong_Type;
3257
16
        Py_INCREF(type);
3258
16
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3259
16
                                    type) == 0;
3260
16
        Py_DECREF(type);
3261
16
        if (!cond) {
3262
0
            Py_DECREF(Interpolation_annotations);
3263
0
            return 0;
3264
0
        }
3265
16
    }
3266
16
    {
3267
16
        PyObject *type = state->expr_type;
3268
16
        type = _Py_union_type_or(type, Py_None);
3269
16
        cond = type != NULL;
3270
16
        if (!cond) {
3271
0
            Py_DECREF(Interpolation_annotations);
3272
0
            return 0;
3273
0
        }
3274
16
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3275
16
                                    type) == 0;
3276
16
        Py_DECREF(type);
3277
16
        if (!cond) {
3278
0
            Py_DECREF(Interpolation_annotations);
3279
0
            return 0;
3280
0
        }
3281
16
    }
3282
16
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3283
16
                                  Interpolation_annotations) == 0;
3284
16
    if (!cond) {
3285
0
        Py_DECREF(Interpolation_annotations);
3286
0
        return 0;
3287
0
    }
3288
16
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3289
16
                                  Interpolation_annotations) == 0;
3290
16
    if (!cond) {
3291
0
        Py_DECREF(Interpolation_annotations);
3292
0
        return 0;
3293
0
    }
3294
16
    Py_DECREF(Interpolation_annotations);
3295
16
    PyObject *JoinedStr_annotations = PyDict_New();
3296
16
    if (!JoinedStr_annotations) return 0;
3297
16
    {
3298
16
        PyObject *type = state->expr_type;
3299
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3300
16
        cond = type != NULL;
3301
16
        if (!cond) {
3302
0
            Py_DECREF(JoinedStr_annotations);
3303
0
            return 0;
3304
0
        }
3305
16
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3306
16
        Py_DECREF(type);
3307
16
        if (!cond) {
3308
0
            Py_DECREF(JoinedStr_annotations);
3309
0
            return 0;
3310
0
        }
3311
16
    }
3312
16
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3313
16
                                  JoinedStr_annotations) == 0;
3314
16
    if (!cond) {
3315
0
        Py_DECREF(JoinedStr_annotations);
3316
0
        return 0;
3317
0
    }
3318
16
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3319
16
                                  JoinedStr_annotations) == 0;
3320
16
    if (!cond) {
3321
0
        Py_DECREF(JoinedStr_annotations);
3322
0
        return 0;
3323
0
    }
3324
16
    Py_DECREF(JoinedStr_annotations);
3325
16
    PyObject *TemplateStr_annotations = PyDict_New();
3326
16
    if (!TemplateStr_annotations) return 0;
3327
16
    {
3328
16
        PyObject *type = state->expr_type;
3329
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3330
16
        cond = type != NULL;
3331
16
        if (!cond) {
3332
0
            Py_DECREF(TemplateStr_annotations);
3333
0
            return 0;
3334
0
        }
3335
16
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3336
16
                                    0;
3337
16
        Py_DECREF(type);
3338
16
        if (!cond) {
3339
0
            Py_DECREF(TemplateStr_annotations);
3340
0
            return 0;
3341
0
        }
3342
16
    }
3343
16
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3344
16
                                  TemplateStr_annotations) == 0;
3345
16
    if (!cond) {
3346
0
        Py_DECREF(TemplateStr_annotations);
3347
0
        return 0;
3348
0
    }
3349
16
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3350
16
                                  TemplateStr_annotations) == 0;
3351
16
    if (!cond) {
3352
0
        Py_DECREF(TemplateStr_annotations);
3353
0
        return 0;
3354
0
    }
3355
16
    Py_DECREF(TemplateStr_annotations);
3356
16
    PyObject *Constant_annotations = PyDict_New();
3357
16
    if (!Constant_annotations) return 0;
3358
16
    {
3359
16
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3360
16
        Py_INCREF(type);
3361
16
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3362
16
        Py_DECREF(type);
3363
16
        if (!cond) {
3364
0
            Py_DECREF(Constant_annotations);
3365
0
            return 0;
3366
0
        }
3367
16
    }
3368
16
    {
3369
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
3370
16
        type = _Py_union_type_or(type, Py_None);
3371
16
        cond = type != NULL;
3372
16
        if (!cond) {
3373
0
            Py_DECREF(Constant_annotations);
3374
0
            return 0;
3375
0
        }
3376
16
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3377
16
        Py_DECREF(type);
3378
16
        if (!cond) {
3379
0
            Py_DECREF(Constant_annotations);
3380
0
            return 0;
3381
0
        }
3382
16
    }
3383
16
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3384
16
                                  Constant_annotations) == 0;
3385
16
    if (!cond) {
3386
0
        Py_DECREF(Constant_annotations);
3387
0
        return 0;
3388
0
    }
3389
16
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3390
16
                                  Constant_annotations) == 0;
3391
16
    if (!cond) {
3392
0
        Py_DECREF(Constant_annotations);
3393
0
        return 0;
3394
0
    }
3395
16
    Py_DECREF(Constant_annotations);
3396
16
    PyObject *Attribute_annotations = PyDict_New();
3397
16
    if (!Attribute_annotations) return 0;
3398
16
    {
3399
16
        PyObject *type = state->expr_type;
3400
16
        Py_INCREF(type);
3401
16
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3402
16
        Py_DECREF(type);
3403
16
        if (!cond) {
3404
0
            Py_DECREF(Attribute_annotations);
3405
0
            return 0;
3406
0
        }
3407
16
    }
3408
16
    {
3409
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
3410
16
        Py_INCREF(type);
3411
16
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3412
16
        Py_DECREF(type);
3413
16
        if (!cond) {
3414
0
            Py_DECREF(Attribute_annotations);
3415
0
            return 0;
3416
0
        }
3417
16
    }
3418
16
    {
3419
16
        PyObject *type = state->expr_context_type;
3420
16
        Py_INCREF(type);
3421
16
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3422
16
        Py_DECREF(type);
3423
16
        if (!cond) {
3424
0
            Py_DECREF(Attribute_annotations);
3425
0
            return 0;
3426
0
        }
3427
16
    }
3428
16
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3429
16
                                  Attribute_annotations) == 0;
3430
16
    if (!cond) {
3431
0
        Py_DECREF(Attribute_annotations);
3432
0
        return 0;
3433
0
    }
3434
16
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3435
16
                                  Attribute_annotations) == 0;
3436
16
    if (!cond) {
3437
0
        Py_DECREF(Attribute_annotations);
3438
0
        return 0;
3439
0
    }
3440
16
    Py_DECREF(Attribute_annotations);
3441
16
    PyObject *Subscript_annotations = PyDict_New();
3442
16
    if (!Subscript_annotations) return 0;
3443
16
    {
3444
16
        PyObject *type = state->expr_type;
3445
16
        Py_INCREF(type);
3446
16
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3447
16
        Py_DECREF(type);
3448
16
        if (!cond) {
3449
0
            Py_DECREF(Subscript_annotations);
3450
0
            return 0;
3451
0
        }
3452
16
    }
3453
16
    {
3454
16
        PyObject *type = state->expr_type;
3455
16
        Py_INCREF(type);
3456
16
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3457
16
        Py_DECREF(type);
3458
16
        if (!cond) {
3459
0
            Py_DECREF(Subscript_annotations);
3460
0
            return 0;
3461
0
        }
3462
16
    }
3463
16
    {
3464
16
        PyObject *type = state->expr_context_type;
3465
16
        Py_INCREF(type);
3466
16
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3467
16
        Py_DECREF(type);
3468
16
        if (!cond) {
3469
0
            Py_DECREF(Subscript_annotations);
3470
0
            return 0;
3471
0
        }
3472
16
    }
3473
16
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3474
16
                                  Subscript_annotations) == 0;
3475
16
    if (!cond) {
3476
0
        Py_DECREF(Subscript_annotations);
3477
0
        return 0;
3478
0
    }
3479
16
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3480
16
                                  Subscript_annotations) == 0;
3481
16
    if (!cond) {
3482
0
        Py_DECREF(Subscript_annotations);
3483
0
        return 0;
3484
0
    }
3485
16
    Py_DECREF(Subscript_annotations);
3486
16
    PyObject *Starred_annotations = PyDict_New();
3487
16
    if (!Starred_annotations) return 0;
3488
16
    {
3489
16
        PyObject *type = state->expr_type;
3490
16
        Py_INCREF(type);
3491
16
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3492
16
        Py_DECREF(type);
3493
16
        if (!cond) {
3494
0
            Py_DECREF(Starred_annotations);
3495
0
            return 0;
3496
0
        }
3497
16
    }
3498
16
    {
3499
16
        PyObject *type = state->expr_context_type;
3500
16
        Py_INCREF(type);
3501
16
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3502
16
        Py_DECREF(type);
3503
16
        if (!cond) {
3504
0
            Py_DECREF(Starred_annotations);
3505
0
            return 0;
3506
0
        }
3507
16
    }
3508
16
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3509
16
                                  Starred_annotations) == 0;
3510
16
    if (!cond) {
3511
0
        Py_DECREF(Starred_annotations);
3512
0
        return 0;
3513
0
    }
3514
16
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3515
16
                                  Starred_annotations) == 0;
3516
16
    if (!cond) {
3517
0
        Py_DECREF(Starred_annotations);
3518
0
        return 0;
3519
0
    }
3520
16
    Py_DECREF(Starred_annotations);
3521
16
    PyObject *Name_annotations = PyDict_New();
3522
16
    if (!Name_annotations) return 0;
3523
16
    {
3524
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
3525
16
        Py_INCREF(type);
3526
16
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3527
16
        Py_DECREF(type);
3528
16
        if (!cond) {
3529
0
            Py_DECREF(Name_annotations);
3530
0
            return 0;
3531
0
        }
3532
16
    }
3533
16
    {
3534
16
        PyObject *type = state->expr_context_type;
3535
16
        Py_INCREF(type);
3536
16
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3537
16
        Py_DECREF(type);
3538
16
        if (!cond) {
3539
0
            Py_DECREF(Name_annotations);
3540
0
            return 0;
3541
0
        }
3542
16
    }
3543
16
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3544
16
                                  Name_annotations) == 0;
3545
16
    if (!cond) {
3546
0
        Py_DECREF(Name_annotations);
3547
0
        return 0;
3548
0
    }
3549
16
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3550
16
                                  Name_annotations) == 0;
3551
16
    if (!cond) {
3552
0
        Py_DECREF(Name_annotations);
3553
0
        return 0;
3554
0
    }
3555
16
    Py_DECREF(Name_annotations);
3556
16
    PyObject *List_annotations = PyDict_New();
3557
16
    if (!List_annotations) return 0;
3558
16
    {
3559
16
        PyObject *type = state->expr_type;
3560
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3561
16
        cond = type != NULL;
3562
16
        if (!cond) {
3563
0
            Py_DECREF(List_annotations);
3564
0
            return 0;
3565
0
        }
3566
16
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3567
16
        Py_DECREF(type);
3568
16
        if (!cond) {
3569
0
            Py_DECREF(List_annotations);
3570
0
            return 0;
3571
0
        }
3572
16
    }
3573
16
    {
3574
16
        PyObject *type = state->expr_context_type;
3575
16
        Py_INCREF(type);
3576
16
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3577
16
        Py_DECREF(type);
3578
16
        if (!cond) {
3579
0
            Py_DECREF(List_annotations);
3580
0
            return 0;
3581
0
        }
3582
16
    }
3583
16
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3584
16
                                  List_annotations) == 0;
3585
16
    if (!cond) {
3586
0
        Py_DECREF(List_annotations);
3587
0
        return 0;
3588
0
    }
3589
16
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3590
16
                                  List_annotations) == 0;
3591
16
    if (!cond) {
3592
0
        Py_DECREF(List_annotations);
3593
0
        return 0;
3594
0
    }
3595
16
    Py_DECREF(List_annotations);
3596
16
    PyObject *Tuple_annotations = PyDict_New();
3597
16
    if (!Tuple_annotations) return 0;
3598
16
    {
3599
16
        PyObject *type = state->expr_type;
3600
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3601
16
        cond = type != NULL;
3602
16
        if (!cond) {
3603
0
            Py_DECREF(Tuple_annotations);
3604
0
            return 0;
3605
0
        }
3606
16
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3607
16
        Py_DECREF(type);
3608
16
        if (!cond) {
3609
0
            Py_DECREF(Tuple_annotations);
3610
0
            return 0;
3611
0
        }
3612
16
    }
3613
16
    {
3614
16
        PyObject *type = state->expr_context_type;
3615
16
        Py_INCREF(type);
3616
16
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3617
16
        Py_DECREF(type);
3618
16
        if (!cond) {
3619
0
            Py_DECREF(Tuple_annotations);
3620
0
            return 0;
3621
0
        }
3622
16
    }
3623
16
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3624
16
                                  Tuple_annotations) == 0;
3625
16
    if (!cond) {
3626
0
        Py_DECREF(Tuple_annotations);
3627
0
        return 0;
3628
0
    }
3629
16
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3630
16
                                  Tuple_annotations) == 0;
3631
16
    if (!cond) {
3632
0
        Py_DECREF(Tuple_annotations);
3633
0
        return 0;
3634
0
    }
3635
16
    Py_DECREF(Tuple_annotations);
3636
16
    PyObject *Slice_annotations = PyDict_New();
3637
16
    if (!Slice_annotations) return 0;
3638
16
    {
3639
16
        PyObject *type = state->expr_type;
3640
16
        type = _Py_union_type_or(type, Py_None);
3641
16
        cond = type != NULL;
3642
16
        if (!cond) {
3643
0
            Py_DECREF(Slice_annotations);
3644
0
            return 0;
3645
0
        }
3646
16
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3647
16
        Py_DECREF(type);
3648
16
        if (!cond) {
3649
0
            Py_DECREF(Slice_annotations);
3650
0
            return 0;
3651
0
        }
3652
16
    }
3653
16
    {
3654
16
        PyObject *type = state->expr_type;
3655
16
        type = _Py_union_type_or(type, Py_None);
3656
16
        cond = type != NULL;
3657
16
        if (!cond) {
3658
0
            Py_DECREF(Slice_annotations);
3659
0
            return 0;
3660
0
        }
3661
16
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3662
16
        Py_DECREF(type);
3663
16
        if (!cond) {
3664
0
            Py_DECREF(Slice_annotations);
3665
0
            return 0;
3666
0
        }
3667
16
    }
3668
16
    {
3669
16
        PyObject *type = state->expr_type;
3670
16
        type = _Py_union_type_or(type, Py_None);
3671
16
        cond = type != NULL;
3672
16
        if (!cond) {
3673
0
            Py_DECREF(Slice_annotations);
3674
0
            return 0;
3675
0
        }
3676
16
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3677
16
        Py_DECREF(type);
3678
16
        if (!cond) {
3679
0
            Py_DECREF(Slice_annotations);
3680
0
            return 0;
3681
0
        }
3682
16
    }
3683
16
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3684
16
                                  Slice_annotations) == 0;
3685
16
    if (!cond) {
3686
0
        Py_DECREF(Slice_annotations);
3687
0
        return 0;
3688
0
    }
3689
16
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3690
16
                                  Slice_annotations) == 0;
3691
16
    if (!cond) {
3692
0
        Py_DECREF(Slice_annotations);
3693
0
        return 0;
3694
0
    }
3695
16
    Py_DECREF(Slice_annotations);
3696
16
    PyObject *Load_annotations = PyDict_New();
3697
16
    if (!Load_annotations) return 0;
3698
16
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3699
16
                                  Load_annotations) == 0;
3700
16
    if (!cond) {
3701
0
        Py_DECREF(Load_annotations);
3702
0
        return 0;
3703
0
    }
3704
16
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3705
16
                                  Load_annotations) == 0;
3706
16
    if (!cond) {
3707
0
        Py_DECREF(Load_annotations);
3708
0
        return 0;
3709
0
    }
3710
16
    Py_DECREF(Load_annotations);
3711
16
    PyObject *Store_annotations = PyDict_New();
3712
16
    if (!Store_annotations) return 0;
3713
16
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3714
16
                                  Store_annotations) == 0;
3715
16
    if (!cond) {
3716
0
        Py_DECREF(Store_annotations);
3717
0
        return 0;
3718
0
    }
3719
16
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3720
16
                                  Store_annotations) == 0;
3721
16
    if (!cond) {
3722
0
        Py_DECREF(Store_annotations);
3723
0
        return 0;
3724
0
    }
3725
16
    Py_DECREF(Store_annotations);
3726
16
    PyObject *Del_annotations = PyDict_New();
3727
16
    if (!Del_annotations) return 0;
3728
16
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3729
16
                                  Del_annotations) == 0;
3730
16
    if (!cond) {
3731
0
        Py_DECREF(Del_annotations);
3732
0
        return 0;
3733
0
    }
3734
16
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3735
16
                                  Del_annotations) == 0;
3736
16
    if (!cond) {
3737
0
        Py_DECREF(Del_annotations);
3738
0
        return 0;
3739
0
    }
3740
16
    Py_DECREF(Del_annotations);
3741
16
    PyObject *And_annotations = PyDict_New();
3742
16
    if (!And_annotations) return 0;
3743
16
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3744
16
                                  And_annotations) == 0;
3745
16
    if (!cond) {
3746
0
        Py_DECREF(And_annotations);
3747
0
        return 0;
3748
0
    }
3749
16
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3750
16
                                  And_annotations) == 0;
3751
16
    if (!cond) {
3752
0
        Py_DECREF(And_annotations);
3753
0
        return 0;
3754
0
    }
3755
16
    Py_DECREF(And_annotations);
3756
16
    PyObject *Or_annotations = PyDict_New();
3757
16
    if (!Or_annotations) return 0;
3758
16
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3759
16
                                  Or_annotations) == 0;
3760
16
    if (!cond) {
3761
0
        Py_DECREF(Or_annotations);
3762
0
        return 0;
3763
0
    }
3764
16
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3765
16
                                  Or_annotations) == 0;
3766
16
    if (!cond) {
3767
0
        Py_DECREF(Or_annotations);
3768
0
        return 0;
3769
0
    }
3770
16
    Py_DECREF(Or_annotations);
3771
16
    PyObject *Add_annotations = PyDict_New();
3772
16
    if (!Add_annotations) return 0;
3773
16
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3774
16
                                  Add_annotations) == 0;
3775
16
    if (!cond) {
3776
0
        Py_DECREF(Add_annotations);
3777
0
        return 0;
3778
0
    }
3779
16
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3780
16
                                  Add_annotations) == 0;
3781
16
    if (!cond) {
3782
0
        Py_DECREF(Add_annotations);
3783
0
        return 0;
3784
0
    }
3785
16
    Py_DECREF(Add_annotations);
3786
16
    PyObject *Sub_annotations = PyDict_New();
3787
16
    if (!Sub_annotations) return 0;
3788
16
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3789
16
                                  Sub_annotations) == 0;
3790
16
    if (!cond) {
3791
0
        Py_DECREF(Sub_annotations);
3792
0
        return 0;
3793
0
    }
3794
16
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3795
16
                                  Sub_annotations) == 0;
3796
16
    if (!cond) {
3797
0
        Py_DECREF(Sub_annotations);
3798
0
        return 0;
3799
0
    }
3800
16
    Py_DECREF(Sub_annotations);
3801
16
    PyObject *Mult_annotations = PyDict_New();
3802
16
    if (!Mult_annotations) return 0;
3803
16
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3804
16
                                  Mult_annotations) == 0;
3805
16
    if (!cond) {
3806
0
        Py_DECREF(Mult_annotations);
3807
0
        return 0;
3808
0
    }
3809
16
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3810
16
                                  Mult_annotations) == 0;
3811
16
    if (!cond) {
3812
0
        Py_DECREF(Mult_annotations);
3813
0
        return 0;
3814
0
    }
3815
16
    Py_DECREF(Mult_annotations);
3816
16
    PyObject *MatMult_annotations = PyDict_New();
3817
16
    if (!MatMult_annotations) return 0;
3818
16
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3819
16
                                  MatMult_annotations) == 0;
3820
16
    if (!cond) {
3821
0
        Py_DECREF(MatMult_annotations);
3822
0
        return 0;
3823
0
    }
3824
16
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3825
16
                                  MatMult_annotations) == 0;
3826
16
    if (!cond) {
3827
0
        Py_DECREF(MatMult_annotations);
3828
0
        return 0;
3829
0
    }
3830
16
    Py_DECREF(MatMult_annotations);
3831
16
    PyObject *Div_annotations = PyDict_New();
3832
16
    if (!Div_annotations) return 0;
3833
16
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3834
16
                                  Div_annotations) == 0;
3835
16
    if (!cond) {
3836
0
        Py_DECREF(Div_annotations);
3837
0
        return 0;
3838
0
    }
3839
16
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3840
16
                                  Div_annotations) == 0;
3841
16
    if (!cond) {
3842
0
        Py_DECREF(Div_annotations);
3843
0
        return 0;
3844
0
    }
3845
16
    Py_DECREF(Div_annotations);
3846
16
    PyObject *Mod_annotations = PyDict_New();
3847
16
    if (!Mod_annotations) return 0;
3848
16
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3849
16
                                  Mod_annotations) == 0;
3850
16
    if (!cond) {
3851
0
        Py_DECREF(Mod_annotations);
3852
0
        return 0;
3853
0
    }
3854
16
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3855
16
                                  Mod_annotations) == 0;
3856
16
    if (!cond) {
3857
0
        Py_DECREF(Mod_annotations);
3858
0
        return 0;
3859
0
    }
3860
16
    Py_DECREF(Mod_annotations);
3861
16
    PyObject *Pow_annotations = PyDict_New();
3862
16
    if (!Pow_annotations) return 0;
3863
16
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3864
16
                                  Pow_annotations) == 0;
3865
16
    if (!cond) {
3866
0
        Py_DECREF(Pow_annotations);
3867
0
        return 0;
3868
0
    }
3869
16
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3870
16
                                  Pow_annotations) == 0;
3871
16
    if (!cond) {
3872
0
        Py_DECREF(Pow_annotations);
3873
0
        return 0;
3874
0
    }
3875
16
    Py_DECREF(Pow_annotations);
3876
16
    PyObject *LShift_annotations = PyDict_New();
3877
16
    if (!LShift_annotations) return 0;
3878
16
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3879
16
                                  LShift_annotations) == 0;
3880
16
    if (!cond) {
3881
0
        Py_DECREF(LShift_annotations);
3882
0
        return 0;
3883
0
    }
3884
16
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3885
16
                                  LShift_annotations) == 0;
3886
16
    if (!cond) {
3887
0
        Py_DECREF(LShift_annotations);
3888
0
        return 0;
3889
0
    }
3890
16
    Py_DECREF(LShift_annotations);
3891
16
    PyObject *RShift_annotations = PyDict_New();
3892
16
    if (!RShift_annotations) return 0;
3893
16
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3894
16
                                  RShift_annotations) == 0;
3895
16
    if (!cond) {
3896
0
        Py_DECREF(RShift_annotations);
3897
0
        return 0;
3898
0
    }
3899
16
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3900
16
                                  RShift_annotations) == 0;
3901
16
    if (!cond) {
3902
0
        Py_DECREF(RShift_annotations);
3903
0
        return 0;
3904
0
    }
3905
16
    Py_DECREF(RShift_annotations);
3906
16
    PyObject *BitOr_annotations = PyDict_New();
3907
16
    if (!BitOr_annotations) return 0;
3908
16
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3909
16
                                  BitOr_annotations) == 0;
3910
16
    if (!cond) {
3911
0
        Py_DECREF(BitOr_annotations);
3912
0
        return 0;
3913
0
    }
3914
16
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3915
16
                                  BitOr_annotations) == 0;
3916
16
    if (!cond) {
3917
0
        Py_DECREF(BitOr_annotations);
3918
0
        return 0;
3919
0
    }
3920
16
    Py_DECREF(BitOr_annotations);
3921
16
    PyObject *BitXor_annotations = PyDict_New();
3922
16
    if (!BitXor_annotations) return 0;
3923
16
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3924
16
                                  BitXor_annotations) == 0;
3925
16
    if (!cond) {
3926
0
        Py_DECREF(BitXor_annotations);
3927
0
        return 0;
3928
0
    }
3929
16
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3930
16
                                  BitXor_annotations) == 0;
3931
16
    if (!cond) {
3932
0
        Py_DECREF(BitXor_annotations);
3933
0
        return 0;
3934
0
    }
3935
16
    Py_DECREF(BitXor_annotations);
3936
16
    PyObject *BitAnd_annotations = PyDict_New();
3937
16
    if (!BitAnd_annotations) return 0;
3938
16
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3939
16
                                  BitAnd_annotations) == 0;
3940
16
    if (!cond) {
3941
0
        Py_DECREF(BitAnd_annotations);
3942
0
        return 0;
3943
0
    }
3944
16
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3945
16
                                  BitAnd_annotations) == 0;
3946
16
    if (!cond) {
3947
0
        Py_DECREF(BitAnd_annotations);
3948
0
        return 0;
3949
0
    }
3950
16
    Py_DECREF(BitAnd_annotations);
3951
16
    PyObject *FloorDiv_annotations = PyDict_New();
3952
16
    if (!FloorDiv_annotations) return 0;
3953
16
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3954
16
                                  FloorDiv_annotations) == 0;
3955
16
    if (!cond) {
3956
0
        Py_DECREF(FloorDiv_annotations);
3957
0
        return 0;
3958
0
    }
3959
16
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3960
16
                                  FloorDiv_annotations) == 0;
3961
16
    if (!cond) {
3962
0
        Py_DECREF(FloorDiv_annotations);
3963
0
        return 0;
3964
0
    }
3965
16
    Py_DECREF(FloorDiv_annotations);
3966
16
    PyObject *Invert_annotations = PyDict_New();
3967
16
    if (!Invert_annotations) return 0;
3968
16
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3969
16
                                  Invert_annotations) == 0;
3970
16
    if (!cond) {
3971
0
        Py_DECREF(Invert_annotations);
3972
0
        return 0;
3973
0
    }
3974
16
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3975
16
                                  Invert_annotations) == 0;
3976
16
    if (!cond) {
3977
0
        Py_DECREF(Invert_annotations);
3978
0
        return 0;
3979
0
    }
3980
16
    Py_DECREF(Invert_annotations);
3981
16
    PyObject *Not_annotations = PyDict_New();
3982
16
    if (!Not_annotations) return 0;
3983
16
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3984
16
                                  Not_annotations) == 0;
3985
16
    if (!cond) {
3986
0
        Py_DECREF(Not_annotations);
3987
0
        return 0;
3988
0
    }
3989
16
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3990
16
                                  Not_annotations) == 0;
3991
16
    if (!cond) {
3992
0
        Py_DECREF(Not_annotations);
3993
0
        return 0;
3994
0
    }
3995
16
    Py_DECREF(Not_annotations);
3996
16
    PyObject *UAdd_annotations = PyDict_New();
3997
16
    if (!UAdd_annotations) return 0;
3998
16
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3999
16
                                  UAdd_annotations) == 0;
4000
16
    if (!cond) {
4001
0
        Py_DECREF(UAdd_annotations);
4002
0
        return 0;
4003
0
    }
4004
16
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
4005
16
                                  UAdd_annotations) == 0;
4006
16
    if (!cond) {
4007
0
        Py_DECREF(UAdd_annotations);
4008
0
        return 0;
4009
0
    }
4010
16
    Py_DECREF(UAdd_annotations);
4011
16
    PyObject *USub_annotations = PyDict_New();
4012
16
    if (!USub_annotations) return 0;
4013
16
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
4014
16
                                  USub_annotations) == 0;
4015
16
    if (!cond) {
4016
0
        Py_DECREF(USub_annotations);
4017
0
        return 0;
4018
0
    }
4019
16
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
4020
16
                                  USub_annotations) == 0;
4021
16
    if (!cond) {
4022
0
        Py_DECREF(USub_annotations);
4023
0
        return 0;
4024
0
    }
4025
16
    Py_DECREF(USub_annotations);
4026
16
    PyObject *Eq_annotations = PyDict_New();
4027
16
    if (!Eq_annotations) return 0;
4028
16
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
4029
16
                                  Eq_annotations) == 0;
4030
16
    if (!cond) {
4031
0
        Py_DECREF(Eq_annotations);
4032
0
        return 0;
4033
0
    }
4034
16
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
4035
16
                                  Eq_annotations) == 0;
4036
16
    if (!cond) {
4037
0
        Py_DECREF(Eq_annotations);
4038
0
        return 0;
4039
0
    }
4040
16
    Py_DECREF(Eq_annotations);
4041
16
    PyObject *NotEq_annotations = PyDict_New();
4042
16
    if (!NotEq_annotations) return 0;
4043
16
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4044
16
                                  NotEq_annotations) == 0;
4045
16
    if (!cond) {
4046
0
        Py_DECREF(NotEq_annotations);
4047
0
        return 0;
4048
0
    }
4049
16
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4050
16
                                  NotEq_annotations) == 0;
4051
16
    if (!cond) {
4052
0
        Py_DECREF(NotEq_annotations);
4053
0
        return 0;
4054
0
    }
4055
16
    Py_DECREF(NotEq_annotations);
4056
16
    PyObject *Lt_annotations = PyDict_New();
4057
16
    if (!Lt_annotations) return 0;
4058
16
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4059
16
                                  Lt_annotations) == 0;
4060
16
    if (!cond) {
4061
0
        Py_DECREF(Lt_annotations);
4062
0
        return 0;
4063
0
    }
4064
16
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4065
16
                                  Lt_annotations) == 0;
4066
16
    if (!cond) {
4067
0
        Py_DECREF(Lt_annotations);
4068
0
        return 0;
4069
0
    }
4070
16
    Py_DECREF(Lt_annotations);
4071
16
    PyObject *LtE_annotations = PyDict_New();
4072
16
    if (!LtE_annotations) return 0;
4073
16
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4074
16
                                  LtE_annotations) == 0;
4075
16
    if (!cond) {
4076
0
        Py_DECREF(LtE_annotations);
4077
0
        return 0;
4078
0
    }
4079
16
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4080
16
                                  LtE_annotations) == 0;
4081
16
    if (!cond) {
4082
0
        Py_DECREF(LtE_annotations);
4083
0
        return 0;
4084
0
    }
4085
16
    Py_DECREF(LtE_annotations);
4086
16
    PyObject *Gt_annotations = PyDict_New();
4087
16
    if (!Gt_annotations) return 0;
4088
16
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4089
16
                                  Gt_annotations) == 0;
4090
16
    if (!cond) {
4091
0
        Py_DECREF(Gt_annotations);
4092
0
        return 0;
4093
0
    }
4094
16
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4095
16
                                  Gt_annotations) == 0;
4096
16
    if (!cond) {
4097
0
        Py_DECREF(Gt_annotations);
4098
0
        return 0;
4099
0
    }
4100
16
    Py_DECREF(Gt_annotations);
4101
16
    PyObject *GtE_annotations = PyDict_New();
4102
16
    if (!GtE_annotations) return 0;
4103
16
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4104
16
                                  GtE_annotations) == 0;
4105
16
    if (!cond) {
4106
0
        Py_DECREF(GtE_annotations);
4107
0
        return 0;
4108
0
    }
4109
16
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4110
16
                                  GtE_annotations) == 0;
4111
16
    if (!cond) {
4112
0
        Py_DECREF(GtE_annotations);
4113
0
        return 0;
4114
0
    }
4115
16
    Py_DECREF(GtE_annotations);
4116
16
    PyObject *Is_annotations = PyDict_New();
4117
16
    if (!Is_annotations) return 0;
4118
16
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4119
16
                                  Is_annotations) == 0;
4120
16
    if (!cond) {
4121
0
        Py_DECREF(Is_annotations);
4122
0
        return 0;
4123
0
    }
4124
16
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4125
16
                                  Is_annotations) == 0;
4126
16
    if (!cond) {
4127
0
        Py_DECREF(Is_annotations);
4128
0
        return 0;
4129
0
    }
4130
16
    Py_DECREF(Is_annotations);
4131
16
    PyObject *IsNot_annotations = PyDict_New();
4132
16
    if (!IsNot_annotations) return 0;
4133
16
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4134
16
                                  IsNot_annotations) == 0;
4135
16
    if (!cond) {
4136
0
        Py_DECREF(IsNot_annotations);
4137
0
        return 0;
4138
0
    }
4139
16
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4140
16
                                  IsNot_annotations) == 0;
4141
16
    if (!cond) {
4142
0
        Py_DECREF(IsNot_annotations);
4143
0
        return 0;
4144
0
    }
4145
16
    Py_DECREF(IsNot_annotations);
4146
16
    PyObject *In_annotations = PyDict_New();
4147
16
    if (!In_annotations) return 0;
4148
16
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4149
16
                                  In_annotations) == 0;
4150
16
    if (!cond) {
4151
0
        Py_DECREF(In_annotations);
4152
0
        return 0;
4153
0
    }
4154
16
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4155
16
                                  In_annotations) == 0;
4156
16
    if (!cond) {
4157
0
        Py_DECREF(In_annotations);
4158
0
        return 0;
4159
0
    }
4160
16
    Py_DECREF(In_annotations);
4161
16
    PyObject *NotIn_annotations = PyDict_New();
4162
16
    if (!NotIn_annotations) return 0;
4163
16
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4164
16
                                  NotIn_annotations) == 0;
4165
16
    if (!cond) {
4166
0
        Py_DECREF(NotIn_annotations);
4167
0
        return 0;
4168
0
    }
4169
16
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4170
16
                                  NotIn_annotations) == 0;
4171
16
    if (!cond) {
4172
0
        Py_DECREF(NotIn_annotations);
4173
0
        return 0;
4174
0
    }
4175
16
    Py_DECREF(NotIn_annotations);
4176
16
    PyObject *comprehension_annotations = PyDict_New();
4177
16
    if (!comprehension_annotations) return 0;
4178
16
    {
4179
16
        PyObject *type = state->expr_type;
4180
16
        Py_INCREF(type);
4181
16
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4182
16
                                    == 0;
4183
16
        Py_DECREF(type);
4184
16
        if (!cond) {
4185
0
            Py_DECREF(comprehension_annotations);
4186
0
            return 0;
4187
0
        }
4188
16
    }
4189
16
    {
4190
16
        PyObject *type = state->expr_type;
4191
16
        Py_INCREF(type);
4192
16
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4193
16
                                    0;
4194
16
        Py_DECREF(type);
4195
16
        if (!cond) {
4196
0
            Py_DECREF(comprehension_annotations);
4197
0
            return 0;
4198
0
        }
4199
16
    }
4200
16
    {
4201
16
        PyObject *type = state->expr_type;
4202
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4203
16
        cond = type != NULL;
4204
16
        if (!cond) {
4205
0
            Py_DECREF(comprehension_annotations);
4206
0
            return 0;
4207
0
        }
4208
16
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4209
16
                                    0;
4210
16
        Py_DECREF(type);
4211
16
        if (!cond) {
4212
0
            Py_DECREF(comprehension_annotations);
4213
0
            return 0;
4214
0
        }
4215
16
    }
4216
16
    {
4217
16
        PyObject *type = (PyObject *)&PyLong_Type;
4218
16
        Py_INCREF(type);
4219
16
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4220
16
                                    type) == 0;
4221
16
        Py_DECREF(type);
4222
16
        if (!cond) {
4223
0
            Py_DECREF(comprehension_annotations);
4224
0
            return 0;
4225
0
        }
4226
16
    }
4227
16
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4228
16
                                  comprehension_annotations) == 0;
4229
16
    if (!cond) {
4230
0
        Py_DECREF(comprehension_annotations);
4231
0
        return 0;
4232
0
    }
4233
16
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4234
16
                                  comprehension_annotations) == 0;
4235
16
    if (!cond) {
4236
0
        Py_DECREF(comprehension_annotations);
4237
0
        return 0;
4238
0
    }
4239
16
    Py_DECREF(comprehension_annotations);
4240
16
    PyObject *ExceptHandler_annotations = PyDict_New();
4241
16
    if (!ExceptHandler_annotations) return 0;
4242
16
    {
4243
16
        PyObject *type = state->expr_type;
4244
16
        type = _Py_union_type_or(type, Py_None);
4245
16
        cond = type != NULL;
4246
16
        if (!cond) {
4247
0
            Py_DECREF(ExceptHandler_annotations);
4248
0
            return 0;
4249
0
        }
4250
16
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4251
16
                                    0;
4252
16
        Py_DECREF(type);
4253
16
        if (!cond) {
4254
0
            Py_DECREF(ExceptHandler_annotations);
4255
0
            return 0;
4256
0
        }
4257
16
    }
4258
16
    {
4259
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4260
16
        type = _Py_union_type_or(type, Py_None);
4261
16
        cond = type != NULL;
4262
16
        if (!cond) {
4263
0
            Py_DECREF(ExceptHandler_annotations);
4264
0
            return 0;
4265
0
        }
4266
16
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4267
16
                                    0;
4268
16
        Py_DECREF(type);
4269
16
        if (!cond) {
4270
0
            Py_DECREF(ExceptHandler_annotations);
4271
0
            return 0;
4272
0
        }
4273
16
    }
4274
16
    {
4275
16
        PyObject *type = state->stmt_type;
4276
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4277
16
        cond = type != NULL;
4278
16
        if (!cond) {
4279
0
            Py_DECREF(ExceptHandler_annotations);
4280
0
            return 0;
4281
0
        }
4282
16
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4283
16
                                    0;
4284
16
        Py_DECREF(type);
4285
16
        if (!cond) {
4286
0
            Py_DECREF(ExceptHandler_annotations);
4287
0
            return 0;
4288
0
        }
4289
16
    }
4290
16
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4291
16
                                  ExceptHandler_annotations) == 0;
4292
16
    if (!cond) {
4293
0
        Py_DECREF(ExceptHandler_annotations);
4294
0
        return 0;
4295
0
    }
4296
16
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4297
16
                                  ExceptHandler_annotations) == 0;
4298
16
    if (!cond) {
4299
0
        Py_DECREF(ExceptHandler_annotations);
4300
0
        return 0;
4301
0
    }
4302
16
    Py_DECREF(ExceptHandler_annotations);
4303
16
    PyObject *arguments_annotations = PyDict_New();
4304
16
    if (!arguments_annotations) return 0;
4305
16
    {
4306
16
        PyObject *type = state->arg_type;
4307
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4308
16
        cond = type != NULL;
4309
16
        if (!cond) {
4310
0
            Py_DECREF(arguments_annotations);
4311
0
            return 0;
4312
0
        }
4313
16
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4314
16
                                    == 0;
4315
16
        Py_DECREF(type);
4316
16
        if (!cond) {
4317
0
            Py_DECREF(arguments_annotations);
4318
0
            return 0;
4319
0
        }
4320
16
    }
4321
16
    {
4322
16
        PyObject *type = state->arg_type;
4323
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4324
16
        cond = type != NULL;
4325
16
        if (!cond) {
4326
0
            Py_DECREF(arguments_annotations);
4327
0
            return 0;
4328
0
        }
4329
16
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4330
16
        Py_DECREF(type);
4331
16
        if (!cond) {
4332
0
            Py_DECREF(arguments_annotations);
4333
0
            return 0;
4334
0
        }
4335
16
    }
4336
16
    {
4337
16
        PyObject *type = state->arg_type;
4338
16
        type = _Py_union_type_or(type, Py_None);
4339
16
        cond = type != NULL;
4340
16
        if (!cond) {
4341
0
            Py_DECREF(arguments_annotations);
4342
0
            return 0;
4343
0
        }
4344
16
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4345
16
        Py_DECREF(type);
4346
16
        if (!cond) {
4347
0
            Py_DECREF(arguments_annotations);
4348
0
            return 0;
4349
0
        }
4350
16
    }
4351
16
    {
4352
16
        PyObject *type = state->arg_type;
4353
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4354
16
        cond = type != NULL;
4355
16
        if (!cond) {
4356
0
            Py_DECREF(arguments_annotations);
4357
0
            return 0;
4358
0
        }
4359
16
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4360
16
                                    == 0;
4361
16
        Py_DECREF(type);
4362
16
        if (!cond) {
4363
0
            Py_DECREF(arguments_annotations);
4364
0
            return 0;
4365
0
        }
4366
16
    }
4367
16
    {
4368
16
        PyObject *type = state->expr_type;
4369
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4370
16
        cond = type != NULL;
4371
16
        if (!cond) {
4372
0
            Py_DECREF(arguments_annotations);
4373
0
            return 0;
4374
0
        }
4375
16
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4376
16
                                    == 0;
4377
16
        Py_DECREF(type);
4378
16
        if (!cond) {
4379
0
            Py_DECREF(arguments_annotations);
4380
0
            return 0;
4381
0
        }
4382
16
    }
4383
16
    {
4384
16
        PyObject *type = state->arg_type;
4385
16
        type = _Py_union_type_or(type, Py_None);
4386
16
        cond = type != NULL;
4387
16
        if (!cond) {
4388
0
            Py_DECREF(arguments_annotations);
4389
0
            return 0;
4390
0
        }
4391
16
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4392
16
        Py_DECREF(type);
4393
16
        if (!cond) {
4394
0
            Py_DECREF(arguments_annotations);
4395
0
            return 0;
4396
0
        }
4397
16
    }
4398
16
    {
4399
16
        PyObject *type = state->expr_type;
4400
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4401
16
        cond = type != NULL;
4402
16
        if (!cond) {
4403
0
            Py_DECREF(arguments_annotations);
4404
0
            return 0;
4405
0
        }
4406
16
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4407
16
                                    0;
4408
16
        Py_DECREF(type);
4409
16
        if (!cond) {
4410
0
            Py_DECREF(arguments_annotations);
4411
0
            return 0;
4412
0
        }
4413
16
    }
4414
16
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4415
16
                                  arguments_annotations) == 0;
4416
16
    if (!cond) {
4417
0
        Py_DECREF(arguments_annotations);
4418
0
        return 0;
4419
0
    }
4420
16
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4421
16
                                  arguments_annotations) == 0;
4422
16
    if (!cond) {
4423
0
        Py_DECREF(arguments_annotations);
4424
0
        return 0;
4425
0
    }
4426
16
    Py_DECREF(arguments_annotations);
4427
16
    PyObject *arg_annotations = PyDict_New();
4428
16
    if (!arg_annotations) return 0;
4429
16
    {
4430
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4431
16
        Py_INCREF(type);
4432
16
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4433
16
        Py_DECREF(type);
4434
16
        if (!cond) {
4435
0
            Py_DECREF(arg_annotations);
4436
0
            return 0;
4437
0
        }
4438
16
    }
4439
16
    {
4440
16
        PyObject *type = state->expr_type;
4441
16
        type = _Py_union_type_or(type, Py_None);
4442
16
        cond = type != NULL;
4443
16
        if (!cond) {
4444
0
            Py_DECREF(arg_annotations);
4445
0
            return 0;
4446
0
        }
4447
16
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4448
16
        Py_DECREF(type);
4449
16
        if (!cond) {
4450
0
            Py_DECREF(arg_annotations);
4451
0
            return 0;
4452
0
        }
4453
16
    }
4454
16
    {
4455
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4456
16
        type = _Py_union_type_or(type, Py_None);
4457
16
        cond = type != NULL;
4458
16
        if (!cond) {
4459
0
            Py_DECREF(arg_annotations);
4460
0
            return 0;
4461
0
        }
4462
16
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4463
16
        Py_DECREF(type);
4464
16
        if (!cond) {
4465
0
            Py_DECREF(arg_annotations);
4466
0
            return 0;
4467
0
        }
4468
16
    }
4469
16
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4470
16
                                  arg_annotations) == 0;
4471
16
    if (!cond) {
4472
0
        Py_DECREF(arg_annotations);
4473
0
        return 0;
4474
0
    }
4475
16
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4476
16
                                  arg_annotations) == 0;
4477
16
    if (!cond) {
4478
0
        Py_DECREF(arg_annotations);
4479
0
        return 0;
4480
0
    }
4481
16
    Py_DECREF(arg_annotations);
4482
16
    PyObject *keyword_annotations = PyDict_New();
4483
16
    if (!keyword_annotations) return 0;
4484
16
    {
4485
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4486
16
        type = _Py_union_type_or(type, Py_None);
4487
16
        cond = type != NULL;
4488
16
        if (!cond) {
4489
0
            Py_DECREF(keyword_annotations);
4490
0
            return 0;
4491
0
        }
4492
16
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4493
16
        Py_DECREF(type);
4494
16
        if (!cond) {
4495
0
            Py_DECREF(keyword_annotations);
4496
0
            return 0;
4497
0
        }
4498
16
    }
4499
16
    {
4500
16
        PyObject *type = state->expr_type;
4501
16
        Py_INCREF(type);
4502
16
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4503
16
        Py_DECREF(type);
4504
16
        if (!cond) {
4505
0
            Py_DECREF(keyword_annotations);
4506
0
            return 0;
4507
0
        }
4508
16
    }
4509
16
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4510
16
                                  keyword_annotations) == 0;
4511
16
    if (!cond) {
4512
0
        Py_DECREF(keyword_annotations);
4513
0
        return 0;
4514
0
    }
4515
16
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4516
16
                                  keyword_annotations) == 0;
4517
16
    if (!cond) {
4518
0
        Py_DECREF(keyword_annotations);
4519
0
        return 0;
4520
0
    }
4521
16
    Py_DECREF(keyword_annotations);
4522
16
    PyObject *alias_annotations = PyDict_New();
4523
16
    if (!alias_annotations) return 0;
4524
16
    {
4525
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4526
16
        Py_INCREF(type);
4527
16
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4528
16
        Py_DECREF(type);
4529
16
        if (!cond) {
4530
0
            Py_DECREF(alias_annotations);
4531
0
            return 0;
4532
0
        }
4533
16
    }
4534
16
    {
4535
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4536
16
        type = _Py_union_type_or(type, Py_None);
4537
16
        cond = type != NULL;
4538
16
        if (!cond) {
4539
0
            Py_DECREF(alias_annotations);
4540
0
            return 0;
4541
0
        }
4542
16
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4543
16
        Py_DECREF(type);
4544
16
        if (!cond) {
4545
0
            Py_DECREF(alias_annotations);
4546
0
            return 0;
4547
0
        }
4548
16
    }
4549
16
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4550
16
                                  alias_annotations) == 0;
4551
16
    if (!cond) {
4552
0
        Py_DECREF(alias_annotations);
4553
0
        return 0;
4554
0
    }
4555
16
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4556
16
                                  alias_annotations) == 0;
4557
16
    if (!cond) {
4558
0
        Py_DECREF(alias_annotations);
4559
0
        return 0;
4560
0
    }
4561
16
    Py_DECREF(alias_annotations);
4562
16
    PyObject *withitem_annotations = PyDict_New();
4563
16
    if (!withitem_annotations) return 0;
4564
16
    {
4565
16
        PyObject *type = state->expr_type;
4566
16
        Py_INCREF(type);
4567
16
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4568
16
                                    == 0;
4569
16
        Py_DECREF(type);
4570
16
        if (!cond) {
4571
0
            Py_DECREF(withitem_annotations);
4572
0
            return 0;
4573
0
        }
4574
16
    }
4575
16
    {
4576
16
        PyObject *type = state->expr_type;
4577
16
        type = _Py_union_type_or(type, Py_None);
4578
16
        cond = type != NULL;
4579
16
        if (!cond) {
4580
0
            Py_DECREF(withitem_annotations);
4581
0
            return 0;
4582
0
        }
4583
16
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4584
16
                                    type) == 0;
4585
16
        Py_DECREF(type);
4586
16
        if (!cond) {
4587
0
            Py_DECREF(withitem_annotations);
4588
0
            return 0;
4589
0
        }
4590
16
    }
4591
16
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4592
16
                                  withitem_annotations) == 0;
4593
16
    if (!cond) {
4594
0
        Py_DECREF(withitem_annotations);
4595
0
        return 0;
4596
0
    }
4597
16
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4598
16
                                  withitem_annotations) == 0;
4599
16
    if (!cond) {
4600
0
        Py_DECREF(withitem_annotations);
4601
0
        return 0;
4602
0
    }
4603
16
    Py_DECREF(withitem_annotations);
4604
16
    PyObject *match_case_annotations = PyDict_New();
4605
16
    if (!match_case_annotations) return 0;
4606
16
    {
4607
16
        PyObject *type = state->pattern_type;
4608
16
        Py_INCREF(type);
4609
16
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4610
16
                                    0;
4611
16
        Py_DECREF(type);
4612
16
        if (!cond) {
4613
0
            Py_DECREF(match_case_annotations);
4614
0
            return 0;
4615
0
        }
4616
16
    }
4617
16
    {
4618
16
        PyObject *type = state->expr_type;
4619
16
        type = _Py_union_type_or(type, Py_None);
4620
16
        cond = type != NULL;
4621
16
        if (!cond) {
4622
0
            Py_DECREF(match_case_annotations);
4623
0
            return 0;
4624
0
        }
4625
16
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4626
16
        Py_DECREF(type);
4627
16
        if (!cond) {
4628
0
            Py_DECREF(match_case_annotations);
4629
0
            return 0;
4630
0
        }
4631
16
    }
4632
16
    {
4633
16
        PyObject *type = state->stmt_type;
4634
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4635
16
        cond = type != NULL;
4636
16
        if (!cond) {
4637
0
            Py_DECREF(match_case_annotations);
4638
0
            return 0;
4639
0
        }
4640
16
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4641
16
        Py_DECREF(type);
4642
16
        if (!cond) {
4643
0
            Py_DECREF(match_case_annotations);
4644
0
            return 0;
4645
0
        }
4646
16
    }
4647
16
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4648
16
                                  match_case_annotations) == 0;
4649
16
    if (!cond) {
4650
0
        Py_DECREF(match_case_annotations);
4651
0
        return 0;
4652
0
    }
4653
16
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4654
16
                                  match_case_annotations) == 0;
4655
16
    if (!cond) {
4656
0
        Py_DECREF(match_case_annotations);
4657
0
        return 0;
4658
0
    }
4659
16
    Py_DECREF(match_case_annotations);
4660
16
    PyObject *MatchValue_annotations = PyDict_New();
4661
16
    if (!MatchValue_annotations) return 0;
4662
16
    {
4663
16
        PyObject *type = state->expr_type;
4664
16
        Py_INCREF(type);
4665
16
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4666
16
        Py_DECREF(type);
4667
16
        if (!cond) {
4668
0
            Py_DECREF(MatchValue_annotations);
4669
0
            return 0;
4670
0
        }
4671
16
    }
4672
16
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4673
16
                                  MatchValue_annotations) == 0;
4674
16
    if (!cond) {
4675
0
        Py_DECREF(MatchValue_annotations);
4676
0
        return 0;
4677
0
    }
4678
16
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4679
16
                                  MatchValue_annotations) == 0;
4680
16
    if (!cond) {
4681
0
        Py_DECREF(MatchValue_annotations);
4682
0
        return 0;
4683
0
    }
4684
16
    Py_DECREF(MatchValue_annotations);
4685
16
    PyObject *MatchSingleton_annotations = PyDict_New();
4686
16
    if (!MatchSingleton_annotations) return 0;
4687
16
    {
4688
16
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4689
16
        Py_INCREF(type);
4690
16
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4691
16
                                    == 0;
4692
16
        Py_DECREF(type);
4693
16
        if (!cond) {
4694
0
            Py_DECREF(MatchSingleton_annotations);
4695
0
            return 0;
4696
0
        }
4697
16
    }
4698
16
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4699
16
                                  MatchSingleton_annotations) == 0;
4700
16
    if (!cond) {
4701
0
        Py_DECREF(MatchSingleton_annotations);
4702
0
        return 0;
4703
0
    }
4704
16
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4705
16
                                  "__annotations__",
4706
16
                                  MatchSingleton_annotations) == 0;
4707
16
    if (!cond) {
4708
0
        Py_DECREF(MatchSingleton_annotations);
4709
0
        return 0;
4710
0
    }
4711
16
    Py_DECREF(MatchSingleton_annotations);
4712
16
    PyObject *MatchSequence_annotations = PyDict_New();
4713
16
    if (!MatchSequence_annotations) return 0;
4714
16
    {
4715
16
        PyObject *type = state->pattern_type;
4716
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4717
16
        cond = type != NULL;
4718
16
        if (!cond) {
4719
0
            Py_DECREF(MatchSequence_annotations);
4720
0
            return 0;
4721
0
        }
4722
16
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4723
16
                                    type) == 0;
4724
16
        Py_DECREF(type);
4725
16
        if (!cond) {
4726
0
            Py_DECREF(MatchSequence_annotations);
4727
0
            return 0;
4728
0
        }
4729
16
    }
4730
16
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4731
16
                                  MatchSequence_annotations) == 0;
4732
16
    if (!cond) {
4733
0
        Py_DECREF(MatchSequence_annotations);
4734
0
        return 0;
4735
0
    }
4736
16
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4737
16
                                  MatchSequence_annotations) == 0;
4738
16
    if (!cond) {
4739
0
        Py_DECREF(MatchSequence_annotations);
4740
0
        return 0;
4741
0
    }
4742
16
    Py_DECREF(MatchSequence_annotations);
4743
16
    PyObject *MatchMapping_annotations = PyDict_New();
4744
16
    if (!MatchMapping_annotations) return 0;
4745
16
    {
4746
16
        PyObject *type = state->expr_type;
4747
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4748
16
        cond = type != NULL;
4749
16
        if (!cond) {
4750
0
            Py_DECREF(MatchMapping_annotations);
4751
0
            return 0;
4752
0
        }
4753
16
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4754
16
                                    0;
4755
16
        Py_DECREF(type);
4756
16
        if (!cond) {
4757
0
            Py_DECREF(MatchMapping_annotations);
4758
0
            return 0;
4759
0
        }
4760
16
    }
4761
16
    {
4762
16
        PyObject *type = state->pattern_type;
4763
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4764
16
        cond = type != NULL;
4765
16
        if (!cond) {
4766
0
            Py_DECREF(MatchMapping_annotations);
4767
0
            return 0;
4768
0
        }
4769
16
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4770
16
                                    == 0;
4771
16
        Py_DECREF(type);
4772
16
        if (!cond) {
4773
0
            Py_DECREF(MatchMapping_annotations);
4774
0
            return 0;
4775
0
        }
4776
16
    }
4777
16
    {
4778
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4779
16
        type = _Py_union_type_or(type, Py_None);
4780
16
        cond = type != NULL;
4781
16
        if (!cond) {
4782
0
            Py_DECREF(MatchMapping_annotations);
4783
0
            return 0;
4784
0
        }
4785
16
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4786
16
                                    0;
4787
16
        Py_DECREF(type);
4788
16
        if (!cond) {
4789
0
            Py_DECREF(MatchMapping_annotations);
4790
0
            return 0;
4791
0
        }
4792
16
    }
4793
16
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4794
16
                                  MatchMapping_annotations) == 0;
4795
16
    if (!cond) {
4796
0
        Py_DECREF(MatchMapping_annotations);
4797
0
        return 0;
4798
0
    }
4799
16
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4800
16
                                  MatchMapping_annotations) == 0;
4801
16
    if (!cond) {
4802
0
        Py_DECREF(MatchMapping_annotations);
4803
0
        return 0;
4804
0
    }
4805
16
    Py_DECREF(MatchMapping_annotations);
4806
16
    PyObject *MatchClass_annotations = PyDict_New();
4807
16
    if (!MatchClass_annotations) return 0;
4808
16
    {
4809
16
        PyObject *type = state->expr_type;
4810
16
        Py_INCREF(type);
4811
16
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4812
16
        Py_DECREF(type);
4813
16
        if (!cond) {
4814
0
            Py_DECREF(MatchClass_annotations);
4815
0
            return 0;
4816
0
        }
4817
16
    }
4818
16
    {
4819
16
        PyObject *type = state->pattern_type;
4820
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4821
16
        cond = type != NULL;
4822
16
        if (!cond) {
4823
0
            Py_DECREF(MatchClass_annotations);
4824
0
            return 0;
4825
0
        }
4826
16
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4827
16
                                    == 0;
4828
16
        Py_DECREF(type);
4829
16
        if (!cond) {
4830
0
            Py_DECREF(MatchClass_annotations);
4831
0
            return 0;
4832
0
        }
4833
16
    }
4834
16
    {
4835
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4836
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4837
16
        cond = type != NULL;
4838
16
        if (!cond) {
4839
0
            Py_DECREF(MatchClass_annotations);
4840
0
            return 0;
4841
0
        }
4842
16
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4843
16
                                    == 0;
4844
16
        Py_DECREF(type);
4845
16
        if (!cond) {
4846
0
            Py_DECREF(MatchClass_annotations);
4847
0
            return 0;
4848
0
        }
4849
16
    }
4850
16
    {
4851
16
        PyObject *type = state->pattern_type;
4852
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4853
16
        cond = type != NULL;
4854
16
        if (!cond) {
4855
0
            Py_DECREF(MatchClass_annotations);
4856
0
            return 0;
4857
0
        }
4858
16
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4859
16
                                    type) == 0;
4860
16
        Py_DECREF(type);
4861
16
        if (!cond) {
4862
0
            Py_DECREF(MatchClass_annotations);
4863
0
            return 0;
4864
0
        }
4865
16
    }
4866
16
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4867
16
                                  MatchClass_annotations) == 0;
4868
16
    if (!cond) {
4869
0
        Py_DECREF(MatchClass_annotations);
4870
0
        return 0;
4871
0
    }
4872
16
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4873
16
                                  MatchClass_annotations) == 0;
4874
16
    if (!cond) {
4875
0
        Py_DECREF(MatchClass_annotations);
4876
0
        return 0;
4877
0
    }
4878
16
    Py_DECREF(MatchClass_annotations);
4879
16
    PyObject *MatchStar_annotations = PyDict_New();
4880
16
    if (!MatchStar_annotations) return 0;
4881
16
    {
4882
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4883
16
        type = _Py_union_type_or(type, Py_None);
4884
16
        cond = type != NULL;
4885
16
        if (!cond) {
4886
0
            Py_DECREF(MatchStar_annotations);
4887
0
            return 0;
4888
0
        }
4889
16
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4890
16
        Py_DECREF(type);
4891
16
        if (!cond) {
4892
0
            Py_DECREF(MatchStar_annotations);
4893
0
            return 0;
4894
0
        }
4895
16
    }
4896
16
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4897
16
                                  MatchStar_annotations) == 0;
4898
16
    if (!cond) {
4899
0
        Py_DECREF(MatchStar_annotations);
4900
0
        return 0;
4901
0
    }
4902
16
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4903
16
                                  MatchStar_annotations) == 0;
4904
16
    if (!cond) {
4905
0
        Py_DECREF(MatchStar_annotations);
4906
0
        return 0;
4907
0
    }
4908
16
    Py_DECREF(MatchStar_annotations);
4909
16
    PyObject *MatchAs_annotations = PyDict_New();
4910
16
    if (!MatchAs_annotations) return 0;
4911
16
    {
4912
16
        PyObject *type = state->pattern_type;
4913
16
        type = _Py_union_type_or(type, Py_None);
4914
16
        cond = type != NULL;
4915
16
        if (!cond) {
4916
0
            Py_DECREF(MatchAs_annotations);
4917
0
            return 0;
4918
0
        }
4919
16
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4920
16
        Py_DECREF(type);
4921
16
        if (!cond) {
4922
0
            Py_DECREF(MatchAs_annotations);
4923
0
            return 0;
4924
0
        }
4925
16
    }
4926
16
    {
4927
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4928
16
        type = _Py_union_type_or(type, Py_None);
4929
16
        cond = type != NULL;
4930
16
        if (!cond) {
4931
0
            Py_DECREF(MatchAs_annotations);
4932
0
            return 0;
4933
0
        }
4934
16
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4935
16
        Py_DECREF(type);
4936
16
        if (!cond) {
4937
0
            Py_DECREF(MatchAs_annotations);
4938
0
            return 0;
4939
0
        }
4940
16
    }
4941
16
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4942
16
                                  MatchAs_annotations) == 0;
4943
16
    if (!cond) {
4944
0
        Py_DECREF(MatchAs_annotations);
4945
0
        return 0;
4946
0
    }
4947
16
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4948
16
                                  MatchAs_annotations) == 0;
4949
16
    if (!cond) {
4950
0
        Py_DECREF(MatchAs_annotations);
4951
0
        return 0;
4952
0
    }
4953
16
    Py_DECREF(MatchAs_annotations);
4954
16
    PyObject *MatchOr_annotations = PyDict_New();
4955
16
    if (!MatchOr_annotations) return 0;
4956
16
    {
4957
16
        PyObject *type = state->pattern_type;
4958
16
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4959
16
        cond = type != NULL;
4960
16
        if (!cond) {
4961
0
            Py_DECREF(MatchOr_annotations);
4962
0
            return 0;
4963
0
        }
4964
16
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4965
16
        Py_DECREF(type);
4966
16
        if (!cond) {
4967
0
            Py_DECREF(MatchOr_annotations);
4968
0
            return 0;
4969
0
        }
4970
16
    }
4971
16
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4972
16
                                  MatchOr_annotations) == 0;
4973
16
    if (!cond) {
4974
0
        Py_DECREF(MatchOr_annotations);
4975
0
        return 0;
4976
0
    }
4977
16
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4978
16
                                  MatchOr_annotations) == 0;
4979
16
    if (!cond) {
4980
0
        Py_DECREF(MatchOr_annotations);
4981
0
        return 0;
4982
0
    }
4983
16
    Py_DECREF(MatchOr_annotations);
4984
16
    PyObject *TypeIgnore_annotations = PyDict_New();
4985
16
    if (!TypeIgnore_annotations) return 0;
4986
16
    {
4987
16
        PyObject *type = (PyObject *)&PyLong_Type;
4988
16
        Py_INCREF(type);
4989
16
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4990
16
                                    0;
4991
16
        Py_DECREF(type);
4992
16
        if (!cond) {
4993
0
            Py_DECREF(TypeIgnore_annotations);
4994
0
            return 0;
4995
0
        }
4996
16
    }
4997
16
    {
4998
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
4999
16
        Py_INCREF(type);
5000
16
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
5001
16
        Py_DECREF(type);
5002
16
        if (!cond) {
5003
0
            Py_DECREF(TypeIgnore_annotations);
5004
0
            return 0;
5005
0
        }
5006
16
    }
5007
16
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
5008
16
                                  TypeIgnore_annotations) == 0;
5009
16
    if (!cond) {
5010
0
        Py_DECREF(TypeIgnore_annotations);
5011
0
        return 0;
5012
0
    }
5013
16
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
5014
16
                                  TypeIgnore_annotations) == 0;
5015
16
    if (!cond) {
5016
0
        Py_DECREF(TypeIgnore_annotations);
5017
0
        return 0;
5018
0
    }
5019
16
    Py_DECREF(TypeIgnore_annotations);
5020
16
    PyObject *TypeVar_annotations = PyDict_New();
5021
16
    if (!TypeVar_annotations) return 0;
5022
16
    {
5023
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
5024
16
        Py_INCREF(type);
5025
16
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
5026
16
        Py_DECREF(type);
5027
16
        if (!cond) {
5028
0
            Py_DECREF(TypeVar_annotations);
5029
0
            return 0;
5030
0
        }
5031
16
    }
5032
16
    {
5033
16
        PyObject *type = state->expr_type;
5034
16
        type = _Py_union_type_or(type, Py_None);
5035
16
        cond = type != NULL;
5036
16
        if (!cond) {
5037
0
            Py_DECREF(TypeVar_annotations);
5038
0
            return 0;
5039
0
        }
5040
16
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5041
16
        Py_DECREF(type);
5042
16
        if (!cond) {
5043
0
            Py_DECREF(TypeVar_annotations);
5044
0
            return 0;
5045
0
        }
5046
16
    }
5047
16
    {
5048
16
        PyObject *type = state->expr_type;
5049
16
        type = _Py_union_type_or(type, Py_None);
5050
16
        cond = type != NULL;
5051
16
        if (!cond) {
5052
0
            Py_DECREF(TypeVar_annotations);
5053
0
            return 0;
5054
0
        }
5055
16
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5056
16
                                    == 0;
5057
16
        Py_DECREF(type);
5058
16
        if (!cond) {
5059
0
            Py_DECREF(TypeVar_annotations);
5060
0
            return 0;
5061
0
        }
5062
16
    }
5063
16
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5064
16
                                  TypeVar_annotations) == 0;
5065
16
    if (!cond) {
5066
0
        Py_DECREF(TypeVar_annotations);
5067
0
        return 0;
5068
0
    }
5069
16
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5070
16
                                  TypeVar_annotations) == 0;
5071
16
    if (!cond) {
5072
0
        Py_DECREF(TypeVar_annotations);
5073
0
        return 0;
5074
0
    }
5075
16
    Py_DECREF(TypeVar_annotations);
5076
16
    PyObject *ParamSpec_annotations = PyDict_New();
5077
16
    if (!ParamSpec_annotations) return 0;
5078
16
    {
5079
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
5080
16
        Py_INCREF(type);
5081
16
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5082
16
        Py_DECREF(type);
5083
16
        if (!cond) {
5084
0
            Py_DECREF(ParamSpec_annotations);
5085
0
            return 0;
5086
0
        }
5087
16
    }
5088
16
    {
5089
16
        PyObject *type = state->expr_type;
5090
16
        type = _Py_union_type_or(type, Py_None);
5091
16
        cond = type != NULL;
5092
16
        if (!cond) {
5093
0
            Py_DECREF(ParamSpec_annotations);
5094
0
            return 0;
5095
0
        }
5096
16
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5097
16
                                    type) == 0;
5098
16
        Py_DECREF(type);
5099
16
        if (!cond) {
5100
0
            Py_DECREF(ParamSpec_annotations);
5101
0
            return 0;
5102
0
        }
5103
16
    }
5104
16
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5105
16
                                  ParamSpec_annotations) == 0;
5106
16
    if (!cond) {
5107
0
        Py_DECREF(ParamSpec_annotations);
5108
0
        return 0;
5109
0
    }
5110
16
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5111
16
                                  ParamSpec_annotations) == 0;
5112
16
    if (!cond) {
5113
0
        Py_DECREF(ParamSpec_annotations);
5114
0
        return 0;
5115
0
    }
5116
16
    Py_DECREF(ParamSpec_annotations);
5117
16
    PyObject *TypeVarTuple_annotations = PyDict_New();
5118
16
    if (!TypeVarTuple_annotations) return 0;
5119
16
    {
5120
16
        PyObject *type = (PyObject *)&PyUnicode_Type;
5121
16
        Py_INCREF(type);
5122
16
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5123
16
                                    0;
5124
16
        Py_DECREF(type);
5125
16
        if (!cond) {
5126
0
            Py_DECREF(TypeVarTuple_annotations);
5127
0
            return 0;
5128
0
        }
5129
16
    }
5130
16
    {
5131
16
        PyObject *type = state->expr_type;
5132
16
        type = _Py_union_type_or(type, Py_None);
5133
16
        cond = type != NULL;
5134
16
        if (!cond) {
5135
0
            Py_DECREF(TypeVarTuple_annotations);
5136
0
            return 0;
5137
0
        }
5138
16
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5139
16
                                    type) == 0;
5140
16
        Py_DECREF(type);
5141
16
        if (!cond) {
5142
0
            Py_DECREF(TypeVarTuple_annotations);
5143
0
            return 0;
5144
0
        }
5145
16
    }
5146
16
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5147
16
                                  TypeVarTuple_annotations) == 0;
5148
16
    if (!cond) {
5149
0
        Py_DECREF(TypeVarTuple_annotations);
5150
0
        return 0;
5151
0
    }
5152
16
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5153
16
                                  TypeVarTuple_annotations) == 0;
5154
16
    if (!cond) {
5155
0
        Py_DECREF(TypeVarTuple_annotations);
5156
0
        return 0;
5157
0
    }
5158
16
    Py_DECREF(TypeVarTuple_annotations);
5159
5160
16
    return 1;
5161
16
}
5162
5163
5164
5165
typedef struct {
5166
    PyObject_HEAD
5167
    PyObject *dict;
5168
} AST_object;
5169
5170
static void
5171
ast_dealloc(PyObject *op)
5172
450k
{
5173
450k
    AST_object *self = (AST_object*)op;
5174
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5175
450k
    PyTypeObject *tp = Py_TYPE(self);
5176
450k
    PyObject_GC_UnTrack(self);
5177
450k
    Py_CLEAR(self->dict);
5178
450k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5179
450k
    assert(free_func != NULL);
5180
450k
    free_func(self);
5181
450k
    Py_DECREF(tp);
5182
450k
}
5183
5184
static int
5185
ast_traverse(PyObject *op, visitproc visit, void *arg)
5186
431k
{
5187
431k
    AST_object *self = (AST_object*)op;
5188
431k
    Py_VISIT(Py_TYPE(self));
5189
431k
    Py_VISIT(self->dict);
5190
431k
    return 0;
5191
431k
}
5192
5193
static int
5194
ast_clear(PyObject *op)
5195
0
{
5196
0
    AST_object *self = (AST_object*)op;
5197
0
    Py_CLEAR(self->dict);
5198
0
    return 0;
5199
0
}
5200
5201
/*
5202
 * Format the names in the set 'missing' into a natural language list,
5203
 * sorted in the order in which they appear in 'fields'.
5204
 *
5205
 * Similar to format_missing() from 'Python/ceval.c'.
5206
 *
5207
 * Parameters
5208
 *
5209
 *      missing     Set of missing field names to render.
5210
 *      fields      Sequence of AST node field names (self._fields).
5211
 */
5212
static PyObject *
5213
format_missing(PyObject *missing, PyObject *fields)
5214
0
{
5215
0
    Py_ssize_t num_fields, num_total, num_left;
5216
0
    num_fields = PySequence_Size(fields);
5217
0
    if (num_fields == -1) {
5218
0
        return NULL;
5219
0
    }
5220
0
    num_total = num_left = PySet_GET_SIZE(missing);
5221
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5222
0
    if (writer == NULL) {
5223
0
        goto error;
5224
0
    }
5225
    // Iterate all AST node fields in order so that the missing positional
5226
    // arguments are rendered in the order in which __init__ expects them.
5227
0
    for (Py_ssize_t i = 0; i < num_fields; i++) {
5228
0
        PyObject *name = PySequence_GetItem(fields, i);
5229
0
        if (name == NULL) {
5230
0
            goto error;
5231
0
        }
5232
0
        int contains = PySet_Contains(missing, name);
5233
0
        if (contains == -1) {
5234
0
            Py_DECREF(name);
5235
0
            goto error;
5236
0
        }
5237
0
        else if (contains == 1) {
5238
0
            const char* fmt = NULL;
5239
0
            if (num_left == 1) {
5240
0
                fmt = "'%U'";
5241
0
            }
5242
0
            else if (num_total == 2) {
5243
0
                fmt = "'%U' and ";
5244
0
            }
5245
0
            else if (num_left == 2) {
5246
0
                fmt = "'%U', and ";
5247
0
            }
5248
0
            else {
5249
0
                fmt = "'%U', ";
5250
0
            }
5251
0
            num_left--;
5252
0
            if (PyUnicodeWriter_Format(writer, fmt, name) < 0) {
5253
0
                Py_DECREF(name);
5254
0
                goto error;
5255
0
            }
5256
0
        }
5257
0
        Py_DECREF(name);
5258
0
    }
5259
0
    return PyUnicodeWriter_Finish(writer);
5260
0
error:
5261
0
    PyUnicodeWriter_Discard(writer);
5262
0
    return NULL;
5263
0
}
5264
5265
static int
5266
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
5267
250
{
5268
250
    struct ast_state *state = get_ast_state();
5269
250
    if (state == NULL) {
5270
0
        return -1;
5271
0
    }
5272
5273
250
    int contains = PySet_Contains(state->abstract_types, (PyObject *)Py_TYPE(self));
5274
250
    if (contains == -1) {
5275
0
        return -1;
5276
0
    }
5277
250
    else if (contains == 1) {
5278
0
        if (PyErr_WarnFormat(
5279
0
                PyExc_DeprecationWarning, 1,
5280
0
                "Instantiating abstract AST node class %T is deprecated. "
5281
0
                "This will become an error in Python 3.20", self) < 0) {
5282
0
            return -1;
5283
0
        }
5284
0
    }
5285
5286
250
    Py_ssize_t i, numfields = 0;
5287
250
    int res = -1;
5288
250
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5289
5290
250
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5291
250
    if (fields == NULL) {
5292
0
        goto cleanup;
5293
0
    }
5294
5295
250
    numfields = PySequence_Size(fields);
5296
250
    if (numfields == -1) {
5297
0
        goto cleanup;
5298
0
    }
5299
250
    remaining_fields = PySet_New(fields);
5300
250
    if (remaining_fields == NULL) {
5301
0
        goto cleanup;
5302
0
    }
5303
5304
250
    res = 0; /* if no error occurs, this stays 0 to the end */
5305
250
    if (numfields < PyTuple_GET_SIZE(args)) {
5306
0
        PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
5307
0
                     "%zd positional argument%s",
5308
0
                     _PyType_Name(Py_TYPE(self)),
5309
0
                     numfields, numfields == 1 ? "" : "s");
5310
0
        res = -1;
5311
0
        goto cleanup;
5312
0
    }
5313
253
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5314
        /* cannot be reached when fields is NULL */
5315
3
        PyObject *name = PySequence_GetItem(fields, i);
5316
3
        if (!name) {
5317
0
            res = -1;
5318
0
            goto cleanup;
5319
0
        }
5320
3
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5321
3
        if (PySet_Discard(remaining_fields, name) < 0) {
5322
0
            res = -1;
5323
0
            Py_DECREF(name);
5324
0
            goto cleanup;
5325
0
        }
5326
3
        Py_DECREF(name);
5327
3
        if (res < 0) {
5328
0
            goto cleanup;
5329
0
        }
5330
3
    }
5331
250
    if (kw) {
5332
3
        i = 0;  /* needed by PyDict_Next */
5333
6
        while (PyDict_Next(kw, &i, &key, &value)) {
5334
3
            int contains = PySequence_Contains(fields, key);
5335
3
            if (contains == -1) {
5336
0
                res = -1;
5337
0
                goto cleanup;
5338
0
            }
5339
3
            else if (contains == 1) {
5340
3
                int p = PySet_Discard(remaining_fields, key);
5341
3
                if (p == -1) {
5342
0
                    res = -1;
5343
0
                    goto cleanup;
5344
0
                }
5345
3
                if (p == 0) {
5346
0
                    PyErr_Format(PyExc_TypeError,
5347
0
                        "%T got multiple values for argument %R",
5348
0
                        self, key);
5349
0
                    res = -1;
5350
0
                    goto cleanup;
5351
0
                }
5352
3
            }
5353
0
            else {
5354
                // Lazily initialize "attributes"
5355
0
                if (attributes == NULL) {
5356
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5357
0
                    if (attributes == NULL) {
5358
0
                        res = -1;
5359
0
                        goto cleanup;
5360
0
                    }
5361
0
                }
5362
0
                int contains = PySequence_Contains(attributes, key);
5363
0
                if (contains == -1) {
5364
0
                    res = -1;
5365
0
                    goto cleanup;
5366
0
                }
5367
0
                else if (contains == 0) {
5368
0
                    PyErr_Format(PyExc_TypeError,
5369
0
                        "%T.__init__ got an unexpected keyword argument %R",
5370
0
                        self, key);
5371
0
                    res = -1;
5372
0
                    goto cleanup;
5373
0
                }
5374
0
            }
5375
3
            res = PyObject_SetAttr(self, key, value);
5376
3
            if (res < 0) {
5377
0
                goto cleanup;
5378
0
            }
5379
3
        }
5380
3
    }
5381
250
    Py_ssize_t size = PySet_Size(remaining_fields);
5382
250
    PyObject *field_types = NULL, *remaining_list = NULL, *missing_names = NULL;
5383
250
    if (size > 0) {
5384
5
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5385
5
                                     &field_types) < 0) {
5386
0
            res = -1;
5387
0
            goto cleanup;
5388
0
        }
5389
5
        if (field_types == NULL) {
5390
            // Probably a user-defined subclass of AST that lacks _field_types.
5391
            // This will continue to work as it did before 3.13; i.e., attributes
5392
            // that are not passed in simply do not exist on the instance.
5393
0
            goto cleanup;
5394
0
        }
5395
5
        remaining_list = PySequence_List(remaining_fields);
5396
5
        if (!remaining_list) {
5397
0
            goto set_remaining_cleanup;
5398
0
        }
5399
5
        missing_names = PySet_New(NULL);
5400
5
        if (!missing_names) {
5401
0
            goto set_remaining_cleanup;
5402
0
        }
5403
10
        for (Py_ssize_t i = 0; i < size; i++) {
5404
5
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5405
5
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5406
5
            if (!type) {
5407
0
                if (PyErr_Occurred()) {
5408
0
                    goto set_remaining_cleanup;
5409
0
                }
5410
0
                else {
5411
0
                    PyErr_Format(PyExc_TypeError,
5412
0
                        "Field %R is missing from %T._field_types",
5413
0
                        name, self);
5414
0
                    goto set_remaining_cleanup;
5415
0
                }
5416
0
            }
5417
5
            else if (_PyUnion_Check(type)) {
5418
                // optional field
5419
                // do nothing, we'll have set a None default on the class
5420
2
            }
5421
3
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5422
                // list field
5423
0
                PyObject *empty = PyList_New(0);
5424
0
                if (!empty) {
5425
0
                    goto set_remaining_cleanup;
5426
0
                }
5427
0
                res = PyObject_SetAttr(self, name, empty);
5428
0
                Py_DECREF(empty);
5429
0
                if (res < 0) {
5430
0
                    goto set_remaining_cleanup;
5431
0
                }
5432
0
            }
5433
3
            else if (type == state->expr_context_type) {
5434
                // special case for expr_context: default to Load()
5435
3
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5436
3
                if (res < 0) {
5437
0
                    goto set_remaining_cleanup;
5438
0
                }
5439
3
            }
5440
0
            else {
5441
                // simple field (e.g., identifier)
5442
0
                res = PySet_Add(missing_names, name);
5443
0
                if (res < 0) {
5444
0
                    goto set_remaining_cleanup;
5445
0
                }
5446
0
            }
5447
5
        }
5448
5
        Py_ssize_t num_missing = PySet_GET_SIZE(missing_names);
5449
5
        if (num_missing > 0) {
5450
0
            PyObject *name_str = format_missing(missing_names, fields);
5451
0
            if (!name_str) {
5452
0
                goto set_remaining_cleanup;
5453
0
            }
5454
0
            PyErr_Format(PyExc_TypeError,
5455
0
                "%T.__init__ missing %d required positional argument%s: %U",
5456
0
                self, num_missing, num_missing == 1 ? "" : "s", name_str);
5457
0
            Py_DECREF(name_str);
5458
0
            goto set_remaining_cleanup;
5459
0
        }
5460
5
        Py_DECREF(missing_names);
5461
5
        Py_DECREF(remaining_list);
5462
5
        Py_DECREF(field_types);
5463
5
    }
5464
250
  cleanup:
5465
250
    Py_XDECREF(attributes);
5466
250
    Py_XDECREF(fields);
5467
250
    Py_XDECREF(remaining_fields);
5468
250
    return res;
5469
0
  set_remaining_cleanup:
5470
0
    Py_XDECREF(missing_names);
5471
0
    Py_XDECREF(remaining_list);
5472
0
    Py_XDECREF(field_types);
5473
0
    res = -1;
5474
0
    goto cleanup;
5475
250
}
5476
5477
/* Pickling support */
5478
static PyObject *
5479
ast_type_reduce(PyObject *self, PyObject *unused)
5480
0
{
5481
0
    struct ast_state *state = get_ast_state();
5482
0
    if (state == NULL) {
5483
0
        return NULL;
5484
0
    }
5485
5486
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5487
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5488
0
        return NULL;
5489
0
    }
5490
0
    PyObject *result = NULL;
5491
0
    if (dict) {
5492
        // Unpickling (or copying) works as follows:
5493
        // - Construct the object with only positional arguments
5494
        // - Set the fields from the dict
5495
        // We have two constraints:
5496
        // - We must set all the required fields in the initial constructor call,
5497
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5498
        // - We must not include child nodes in the positional args, because
5499
        //   that may trigger runaway recursion during copying (gh-120108).
5500
        // To satisfy both constraints, we set all the fields to None in the
5501
        // initial list of positional args, and then set the fields from the dict.
5502
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5503
0
            goto cleanup;
5504
0
        }
5505
0
        if (fields) {
5506
0
            Py_ssize_t numfields = PySequence_Size(fields);
5507
0
            if (numfields == -1) {
5508
0
                Py_DECREF(dict);
5509
0
                goto cleanup;
5510
0
            }
5511
0
            positional_args = PyList_New(0);
5512
0
            if (!positional_args) {
5513
0
                goto cleanup;
5514
0
            }
5515
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5516
0
                PyObject *name = PySequence_GetItem(fields, i);
5517
0
                if (!name) {
5518
0
                    goto cleanup;
5519
0
                }
5520
0
                PyObject *value;
5521
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5522
0
                Py_DECREF(name);
5523
0
                if (rc < 0) {
5524
0
                    goto cleanup;
5525
0
                }
5526
0
                if (!value) {
5527
0
                    break;
5528
0
                }
5529
0
                rc = PyList_Append(positional_args, Py_None);
5530
0
                Py_DECREF(value);
5531
0
                if (rc < 0) {
5532
0
                    goto cleanup;
5533
0
                }
5534
0
            }
5535
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5536
0
            if (!args_tuple) {
5537
0
                goto cleanup;
5538
0
            }
5539
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5540
0
        }
5541
0
        else {
5542
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5543
0
        }
5544
0
    }
5545
0
    else {
5546
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5547
0
    }
5548
0
cleanup:
5549
0
    Py_XDECREF(fields);
5550
0
    Py_XDECREF(positional_args);
5551
0
    return result;
5552
0
}
5553
5554
/*
5555
 * Python equivalent:
5556
 *
5557
 *   for key in keys:
5558
 *       if hasattr(self, key):
5559
 *           payload[key] = getattr(self, key)
5560
 *
5561
 * The 'keys' argument is a sequence corresponding to
5562
 * the '_fields' or the '_attributes' of an AST node.
5563
 *
5564
 * This returns -1 if an error occurs and 0 otherwise.
5565
 *
5566
 * Parameters
5567
 *
5568
 *      payload   A dictionary to fill.
5569
 *      keys      A sequence of keys or NULL for an empty sequence.
5570
 *      dict      The AST node instance dictionary (must not be NULL).
5571
 */
5572
static inline int
5573
ast_type_replace_update_payload(PyObject *payload,
5574
                                PyObject *keys,
5575
                                PyObject *dict)
5576
0
{
5577
0
    assert(dict != NULL);
5578
0
    if (keys == NULL) {
5579
0
        return 0;
5580
0
    }
5581
0
    Py_ssize_t n = PySequence_Size(keys);
5582
0
    if (n == -1) {
5583
0
        return -1;
5584
0
    }
5585
0
    for (Py_ssize_t i = 0; i < n; i++) {
5586
0
        PyObject *key = PySequence_GetItem(keys, i);
5587
0
        if (key == NULL) {
5588
0
            return -1;
5589
0
        }
5590
0
        PyObject *value;
5591
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5592
0
            Py_DECREF(key);
5593
0
            return -1;
5594
0
        }
5595
0
        if (value == NULL) {
5596
0
            Py_DECREF(key);
5597
            // If a field or attribute is not present at runtime, it should
5598
            // be explicitly given in 'kwargs'. If not, the constructor will
5599
            // issue a warning (which becomes an error in 3.15).
5600
0
            continue;
5601
0
        }
5602
0
        int rc = PyDict_SetItem(payload, key, value);
5603
0
        Py_DECREF(key);
5604
0
        Py_DECREF(value);
5605
0
        if (rc < 0) {
5606
0
            return -1;
5607
0
        }
5608
0
    }
5609
0
    return 0;
5610
0
}
5611
5612
/* copy.replace() support (shallow copy) */
5613
static PyObject *
5614
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5615
0
{
5616
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5617
0
        return NULL;
5618
0
    }
5619
5620
0
    struct ast_state *state = get_ast_state();
5621
0
    if (state == NULL) {
5622
0
        return NULL;
5623
0
    }
5624
5625
0
    PyObject *result = NULL;
5626
    // known AST class fields and attributes
5627
0
    PyObject *fields = NULL, *attributes = NULL;
5628
    // current instance dictionary
5629
0
    PyObject *dict = NULL;
5630
    // constructor positional and keyword arguments
5631
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5632
5633
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5634
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5635
0
        goto cleanup;
5636
0
    }
5637
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5638
0
        goto cleanup;
5639
0
    }
5640
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5641
0
        goto cleanup;
5642
0
    }
5643
0
    empty_tuple = PyTuple_New(0);
5644
0
    if (empty_tuple == NULL) {
5645
0
        goto cleanup;
5646
0
    }
5647
0
    payload = PyDict_New();
5648
0
    if (payload == NULL) {
5649
0
        goto cleanup;
5650
0
    }
5651
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5652
        // copy the instance's fields (possibly NULL)
5653
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5654
0
            goto cleanup;
5655
0
        }
5656
        // copy the instance's attributes (possibly NULL)
5657
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5658
0
            goto cleanup;
5659
0
        }
5660
0
    }
5661
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5662
0
        goto cleanup;
5663
0
    }
5664
0
    result = PyObject_Call(type, empty_tuple, payload);
5665
0
cleanup:
5666
0
    Py_XDECREF(payload);
5667
0
    Py_XDECREF(empty_tuple);
5668
0
    Py_XDECREF(dict);
5669
0
    Py_XDECREF(attributes);
5670
0
    Py_XDECREF(fields);
5671
0
    return result;
5672
0
}
5673
5674
static PyMemberDef ast_type_members[] = {
5675
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5676
    {NULL}  /* Sentinel */
5677
};
5678
5679
static PyMethodDef ast_type_methods[] = {
5680
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5681
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5682
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5683
               "Return a copy of the AST node with new values "
5684
               "for the specified fields.")},
5685
    {NULL}
5686
};
5687
5688
static PyGetSetDef ast_type_getsets[] = {
5689
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5690
    {NULL}
5691
};
5692
5693
static PyObject *
5694
ast_repr_max_depth(AST_object *self, int depth);
5695
5696
/* Format list and tuple properties of AST nodes.
5697
   Note that, only the first and last elements are shown.
5698
   Anything in between is represented with an ellipsis ('...').
5699
   For example, the list [1, 2, 3] is formatted as
5700
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5701
static PyObject *
5702
ast_repr_list(PyObject *list, int depth)
5703
0
{
5704
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5705
5706
0
    struct ast_state *state = get_ast_state();
5707
0
    if (state == NULL) {
5708
0
        return NULL;
5709
0
    }
5710
5711
0
    Py_ssize_t length = PySequence_Size(list);
5712
0
    if (length < 0) {
5713
0
        return NULL;
5714
0
    }
5715
0
    else if (length == 0) {
5716
0
        return PyObject_Repr(list);
5717
0
    }
5718
5719
0
    PyObject *items[2] = {NULL, NULL};
5720
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5721
0
    if (writer == NULL) {
5722
0
        goto error;
5723
0
    }
5724
5725
0
    items[0] = PySequence_GetItem(list, 0);
5726
0
    if (!items[0]) {
5727
0
        goto error;
5728
0
    }
5729
0
    if (length > 1) {
5730
0
        items[1] = PySequence_GetItem(list, length - 1);
5731
0
        if (!items[1]) {
5732
0
            goto error;
5733
0
        }
5734
0
    }
5735
5736
0
    bool is_list = PyList_Check(list);
5737
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5738
0
        goto error;
5739
0
    }
5740
5741
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5742
0
        if (i > 0) {
5743
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5744
0
                goto error;
5745
0
            }
5746
0
        }
5747
5748
0
        PyObject *item = items[i];
5749
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5750
0
            PyObject *item_repr;
5751
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5752
0
            if (!item_repr) {
5753
0
                goto error;
5754
0
            }
5755
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5756
0
                Py_DECREF(item_repr);
5757
0
                goto error;
5758
0
            }
5759
0
            Py_DECREF(item_repr);
5760
0
        } else {
5761
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5762
0
                goto error;
5763
0
            }
5764
0
        }
5765
5766
0
        if (i == 0 && length > 2) {
5767
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5768
0
                goto error;
5769
0
            }
5770
0
        }
5771
0
    }
5772
5773
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5774
0
        goto error;
5775
0
    }
5776
5777
0
    Py_XDECREF(items[0]);
5778
0
    Py_XDECREF(items[1]);
5779
0
    return PyUnicodeWriter_Finish(writer);
5780
5781
0
error:
5782
0
    Py_XDECREF(items[0]);
5783
0
    Py_XDECREF(items[1]);
5784
0
    PyUnicodeWriter_Discard(writer);
5785
0
    return NULL;
5786
0
}
5787
5788
static PyObject *
5789
ast_repr_max_depth(AST_object *self, int depth)
5790
0
{
5791
0
    struct ast_state *state = get_ast_state();
5792
0
    if (state == NULL) {
5793
0
        return NULL;
5794
0
    }
5795
5796
0
    if (depth <= 0) {
5797
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5798
0
    }
5799
5800
0
    int status = Py_ReprEnter((PyObject *)self);
5801
0
    if (status != 0) {
5802
0
        if (status < 0) {
5803
0
            return NULL;
5804
0
        }
5805
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5806
0
    }
5807
5808
0
    PyObject *fields;
5809
0
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5810
0
        Py_ReprLeave((PyObject *)self);
5811
0
        return NULL;
5812
0
    }
5813
5814
0
    Py_ssize_t numfields = PySequence_Size(fields);
5815
0
    if (numfields < 0) {
5816
0
        Py_ReprLeave((PyObject *)self);
5817
0
        Py_DECREF(fields);
5818
0
        return NULL;
5819
0
    }
5820
5821
0
    if (numfields == 0) {
5822
0
        Py_ReprLeave((PyObject *)self);
5823
0
        Py_DECREF(fields);
5824
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5825
0
    }
5826
5827
0
    const char* tp_name = Py_TYPE(self)->tp_name;
5828
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5829
0
    if (writer == NULL) {
5830
0
        goto error;
5831
0
    }
5832
5833
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5834
0
        goto error;
5835
0
    }
5836
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5837
0
        goto error;
5838
0
    }
5839
5840
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
5841
0
        PyObject *name = PySequence_GetItem(fields, i);
5842
0
        if (!name) {
5843
0
            goto error;
5844
0
        }
5845
5846
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5847
0
        if (!value) {
5848
0
            Py_DECREF(name);
5849
0
            goto error;
5850
0
        }
5851
5852
0
        PyObject *value_repr;
5853
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
5854
0
            value_repr = ast_repr_list(value, depth);
5855
0
        }
5856
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5857
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5858
0
        }
5859
0
        else {
5860
0
            value_repr = PyObject_Repr(value);
5861
0
        }
5862
5863
0
        Py_DECREF(value);
5864
5865
0
        if (!value_repr) {
5866
0
            Py_DECREF(name);
5867
0
            goto error;
5868
0
        }
5869
5870
0
        if (i > 0) {
5871
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5872
0
                Py_DECREF(name);
5873
0
                Py_DECREF(value_repr);
5874
0
                goto error;
5875
0
            }
5876
0
        }
5877
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5878
0
            Py_DECREF(name);
5879
0
            Py_DECREF(value_repr);
5880
0
            goto error;
5881
0
        }
5882
5883
0
        Py_DECREF(name);
5884
5885
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5886
0
            Py_DECREF(value_repr);
5887
0
            goto error;
5888
0
        }
5889
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5890
0
            Py_DECREF(value_repr);
5891
0
            goto error;
5892
0
        }
5893
5894
0
        Py_DECREF(value_repr);
5895
0
    }
5896
5897
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5898
0
        goto error;
5899
0
    }
5900
0
    Py_ReprLeave((PyObject *)self);
5901
0
    Py_DECREF(fields);
5902
0
    return PyUnicodeWriter_Finish(writer);
5903
5904
0
error:
5905
0
    Py_ReprLeave((PyObject *)self);
5906
0
    Py_DECREF(fields);
5907
0
    PyUnicodeWriter_Discard(writer);
5908
0
    return NULL;
5909
0
}
5910
5911
static PyObject *
5912
ast_repr(PyObject *self)
5913
0
{
5914
0
    return ast_repr_max_depth((AST_object*)self, 3);
5915
0
}
5916
5917
static PyType_Slot AST_type_slots[] = {
5918
    {Py_tp_dealloc, ast_dealloc},
5919
    {Py_tp_repr, ast_repr},
5920
    {Py_tp_getattro, PyObject_GenericGetAttr},
5921
    {Py_tp_setattro, PyObject_GenericSetAttr},
5922
    {Py_tp_traverse, ast_traverse},
5923
    {Py_tp_clear, ast_clear},
5924
    {Py_tp_members, ast_type_members},
5925
    {Py_tp_methods, ast_type_methods},
5926
    {Py_tp_getset, ast_type_getsets},
5927
    {Py_tp_init, ast_type_init},
5928
    {Py_tp_alloc, PyType_GenericAlloc},
5929
    {Py_tp_new, PyType_GenericNew},
5930
    {Py_tp_free, PyObject_GC_Del},
5931
    {0, 0},
5932
};
5933
5934
static PyType_Spec AST_type_spec = {
5935
    "ast.AST",
5936
    sizeof(AST_object),
5937
    0,
5938
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
5939
    AST_type_slots
5940
};
5941
5942
static PyObject *
5943
make_type(struct ast_state *state, const char *type, PyObject* base,
5944
          const char* const* fields, int num_fields, const char *doc)
5945
2.00k
{
5946
2.00k
    PyObject *fnames, *result;
5947
2.00k
    int i;
5948
2.00k
    fnames = PyTuple_New(num_fields);
5949
2.00k
    if (!fnames) return NULL;
5950
5.16k
    for (i = 0; i < num_fields; i++) {
5951
3.16k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
5952
3.16k
        if (!field) {
5953
0
            Py_DECREF(fnames);
5954
0
            return NULL;
5955
0
        }
5956
3.16k
        PyTuple_SET_ITEM(fnames, i, field);
5957
3.16k
    }
5958
2.00k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
5959
2.00k
                    type, base,
5960
2.00k
                    state->_fields, fnames,
5961
2.00k
                    state->__match_args__, fnames,
5962
2.00k
                    state->__module__,
5963
2.00k
                    state->ast,
5964
2.00k
                    state->__doc__, doc);
5965
2.00k
    Py_DECREF(fnames);
5966
2.00k
    return result;
5967
2.00k
}
5968
5969
static int
5970
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
5971
304
{
5972
304
    int i, result;
5973
304
    PyObject *s, *l = PyTuple_New(num_fields);
5974
304
    if (!l)
5975
0
        return -1;
5976
816
    for (i = 0; i < num_fields; i++) {
5977
512
        s = PyUnicode_InternFromString(attrs[i]);
5978
512
        if (!s) {
5979
0
            Py_DECREF(l);
5980
0
            return -1;
5981
0
        }
5982
512
        PyTuple_SET_ITEM(l, i, s);
5983
512
    }
5984
304
    result = PyObject_SetAttr(type, state->_attributes, l);
5985
304
    Py_DECREF(l);
5986
304
    return result;
5987
304
}
5988
5989
/* Conversion AST -> Python */
5990
5991
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
5992
                              PyObject* (*func)(struct ast_state *state, void*))
5993
92.9k
{
5994
92.9k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
5995
92.9k
    PyObject *result = PyList_New(n);
5996
92.9k
    PyObject *value;
5997
92.9k
    if (!result)
5998
0
        return NULL;
5999
253k
    for (i = 0; i < n; i++) {
6000
160k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6001
160k
        if (!value) {
6002
0
            Py_DECREF(result);
6003
0
            return NULL;
6004
0
        }
6005
160k
        PyList_SET_ITEM(result, i, value);
6006
160k
    }
6007
92.9k
    return result;
6008
92.9k
}
6009
6010
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6011
247k
{
6012
247k
    PyObject *op = (PyObject*)o;
6013
247k
    if (!op) {
6014
84.5k
        op = Py_None;
6015
84.5k
    }
6016
247k
    return Py_NewRef(op);
6017
247k
}
6018
59.0k
#define ast2obj_constant ast2obj_object
6019
113k
#define ast2obj_identifier ast2obj_object
6020
75.0k
#define ast2obj_string ast2obj_object
6021
6022
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6023
1.77M
{
6024
1.77M
    return PyLong_FromLong(b);
6025
1.77M
}
6026
6027
/* Conversion Python -> AST */
6028
6029
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6030
0
{
6031
0
    if (obj == Py_None)
6032
0
        obj = NULL;
6033
0
    if (obj) {
6034
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6035
0
            *out = NULL;
6036
0
            return -1;
6037
0
        }
6038
0
        *out = Py_NewRef(obj);
6039
0
    }
6040
0
    else {
6041
0
        *out = NULL;
6042
0
    }
6043
0
    return 0;
6044
0
}
6045
6046
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6047
0
{
6048
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6049
0
        *out = NULL;
6050
0
        return -1;
6051
0
    }
6052
0
    *out = Py_NewRef(obj);
6053
0
    return 0;
6054
0
}
6055
6056
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6057
0
{
6058
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6059
0
        PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
6060
0
        return -1;
6061
0
    }
6062
0
    return obj2ast_object(state, obj, out, arena);
6063
0
}
6064
6065
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6066
0
{
6067
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6068
0
        PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
6069
0
        return -1;
6070
0
    }
6071
0
    return obj2ast_object(state, obj, out, arena);
6072
0
}
6073
6074
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
6075
0
{
6076
0
    int i;
6077
0
    if (!PyLong_Check(obj)) {
6078
0
        PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
6079
0
        return -1;
6080
0
    }
6081
6082
0
    i = PyLong_AsInt(obj);
6083
0
    if (i == -1 && PyErr_Occurred())
6084
0
        return -1;
6085
0
    *out = i;
6086
0
    return 0;
6087
0
}
6088
6089
static int add_ast_fields(struct ast_state *state)
6090
16
{
6091
16
    PyObject *empty_tuple;
6092
16
    empty_tuple = PyTuple_New(0);
6093
16
    if (!empty_tuple ||
6094
16
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6095
16
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6096
16
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6097
0
        Py_XDECREF(empty_tuple);
6098
0
        return -1;
6099
0
    }
6100
16
    Py_DECREF(empty_tuple);
6101
16
    return 0;
6102
16
}
6103
6104
6105
6106
static int
6107
init_types(void *arg)
6108
16
{
6109
16
    struct ast_state *state = arg;
6110
16
    if (init_identifiers(state) < 0) {
6111
0
        return -1;
6112
0
    }
6113
16
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6114
16
    if (!state->AST_type) {
6115
0
        return -1;
6116
0
    }
6117
16
    state->abstract_types = PySet_New(NULL);
6118
16
    if (!state->abstract_types) {
6119
0
        return -1;
6120
0
    }
6121
16
    if (PySet_Add(state->abstract_types, state->AST_type) < 0) {
6122
0
        return -1;
6123
0
    }
6124
16
    if (add_ast_fields(state) < 0) {
6125
0
        return -1;
6126
0
    }
6127
16
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6128
16
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6129
16
        "    | Interactive(stmt* body)\n"
6130
16
        "    | Expression(expr body)\n"
6131
16
        "    | FunctionType(expr* argtypes, expr returns)");
6132
16
    if (!state->mod_type) return -1;
6133
16
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6134
16
    if (PySet_Add(state->abstract_types, state->mod_type) < 0) return -1;
6135
16
    state->Module_type = make_type(state, "Module", state->mod_type,
6136
16
                                   Module_fields, 2,
6137
16
        "Module(stmt* body, type_ignore* type_ignores)");
6138
16
    if (!state->Module_type) return -1;
6139
16
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6140
16
                                        Interactive_fields, 1,
6141
16
        "Interactive(stmt* body)");
6142
16
    if (!state->Interactive_type) return -1;
6143
16
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6144
16
                                       Expression_fields, 1,
6145
16
        "Expression(expr body)");
6146
16
    if (!state->Expression_type) return -1;
6147
16
    state->FunctionType_type = make_type(state, "FunctionType",
6148
16
                                         state->mod_type, FunctionType_fields,
6149
16
                                         2,
6150
16
        "FunctionType(expr* argtypes, expr returns)");
6151
16
    if (!state->FunctionType_type) return -1;
6152
16
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6153
16
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6154
16
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6155
16
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6156
16
        "     | Return(expr? value)\n"
6157
16
        "     | Delete(expr* targets)\n"
6158
16
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6159
16
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6160
16
        "     | AugAssign(expr target, operator op, expr value)\n"
6161
16
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6162
16
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6163
16
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6164
16
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6165
16
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6166
16
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6167
16
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6168
16
        "     | Match(expr subject, match_case* cases)\n"
6169
16
        "     | Raise(expr? exc, expr? cause)\n"
6170
16
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6171
16
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6172
16
        "     | Assert(expr test, expr? msg)\n"
6173
16
        "     | Import(alias* names, int? is_lazy)\n"
6174
16
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
6175
16
        "     | Global(identifier* names)\n"
6176
16
        "     | Nonlocal(identifier* names)\n"
6177
16
        "     | Expr(expr value)\n"
6178
16
        "     | Pass\n"
6179
16
        "     | Break\n"
6180
16
        "     | Continue");
6181
16
    if (!state->stmt_type) return -1;
6182
16
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6183
0
        -1;
6184
16
    if (PySet_Add(state->abstract_types, state->stmt_type) < 0) return -1;
6185
16
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6186
0
        return -1;
6187
16
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6188
16
        -1)
6189
0
        return -1;
6190
16
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6191
16
                                        FunctionDef_fields, 7,
6192
16
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6193
16
    if (!state->FunctionDef_type) return -1;
6194
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6195
16
        -1)
6196
0
        return -1;
6197
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6198
16
        == -1)
6199
0
        return -1;
6200
16
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6201
16
                                             state->stmt_type,
6202
16
                                             AsyncFunctionDef_fields, 7,
6203
16
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6204
16
    if (!state->AsyncFunctionDef_type) return -1;
6205
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6206
16
        == -1)
6207
0
        return -1;
6208
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6209
16
        Py_None) == -1)
6210
0
        return -1;
6211
16
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6212
16
                                     ClassDef_fields, 6,
6213
16
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6214
16
    if (!state->ClassDef_type) return -1;
6215
16
    state->Return_type = make_type(state, "Return", state->stmt_type,
6216
16
                                   Return_fields, 1,
6217
16
        "Return(expr? value)");
6218
16
    if (!state->Return_type) return -1;
6219
16
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6220
0
        return -1;
6221
16
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6222
16
                                   Delete_fields, 1,
6223
16
        "Delete(expr* targets)");
6224
16
    if (!state->Delete_type) return -1;
6225
16
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6226
16
                                   Assign_fields, 3,
6227
16
        "Assign(expr* targets, expr value, string? type_comment)");
6228
16
    if (!state->Assign_type) return -1;
6229
16
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6230
16
        -1)
6231
0
        return -1;
6232
16
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6233
16
                                      TypeAlias_fields, 3,
6234
16
        "TypeAlias(expr name, type_param* type_params, expr value)");
6235
16
    if (!state->TypeAlias_type) return -1;
6236
16
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6237
16
                                      AugAssign_fields, 3,
6238
16
        "AugAssign(expr target, operator op, expr value)");
6239
16
    if (!state->AugAssign_type) return -1;
6240
16
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6241
16
                                      AnnAssign_fields, 4,
6242
16
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6243
16
    if (!state->AnnAssign_type) return -1;
6244
16
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6245
0
        return -1;
6246
16
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6247
16
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6248
16
    if (!state->For_type) return -1;
6249
16
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6250
0
        return -1;
6251
16
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6252
16
                                     AsyncFor_fields, 5,
6253
16
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6254
16
    if (!state->AsyncFor_type) return -1;
6255
16
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6256
16
        -1)
6257
0
        return -1;
6258
16
    state->While_type = make_type(state, "While", state->stmt_type,
6259
16
                                  While_fields, 3,
6260
16
        "While(expr test, stmt* body, stmt* orelse)");
6261
16
    if (!state->While_type) return -1;
6262
16
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6263
16
        "If(expr test, stmt* body, stmt* orelse)");
6264
16
    if (!state->If_type) return -1;
6265
16
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6266
16
                                 3,
6267
16
        "With(withitem* items, stmt* body, string? type_comment)");
6268
16
    if (!state->With_type) return -1;
6269
16
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6270
0
        return -1;
6271
16
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6272
16
                                      AsyncWith_fields, 3,
6273
16
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6274
16
    if (!state->AsyncWith_type) return -1;
6275
16
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6276
16
        == -1)
6277
0
        return -1;
6278
16
    state->Match_type = make_type(state, "Match", state->stmt_type,
6279
16
                                  Match_fields, 2,
6280
16
        "Match(expr subject, match_case* cases)");
6281
16
    if (!state->Match_type) return -1;
6282
16
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6283
16
                                  Raise_fields, 2,
6284
16
        "Raise(expr? exc, expr? cause)");
6285
16
    if (!state->Raise_type) return -1;
6286
16
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6287
0
        return -1;
6288
16
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6289
0
        return -1;
6290
16
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6291
16
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6292
16
    if (!state->Try_type) return -1;
6293
16
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6294
16
                                    TryStar_fields, 4,
6295
16
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6296
16
    if (!state->TryStar_type) return -1;
6297
16
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6298
16
                                   Assert_fields, 2,
6299
16
        "Assert(expr test, expr? msg)");
6300
16
    if (!state->Assert_type) return -1;
6301
16
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6302
0
        return -1;
6303
16
    state->Import_type = make_type(state, "Import", state->stmt_type,
6304
16
                                   Import_fields, 2,
6305
16
        "Import(alias* names, int? is_lazy)");
6306
16
    if (!state->Import_type) return -1;
6307
16
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
6308
0
        return -1;
6309
16
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6310
16
                                       ImportFrom_fields, 4,
6311
16
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
6312
16
    if (!state->ImportFrom_type) return -1;
6313
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6314
0
        return -1;
6315
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6316
0
        return -1;
6317
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
6318
0
        return -1;
6319
16
    state->Global_type = make_type(state, "Global", state->stmt_type,
6320
16
                                   Global_fields, 1,
6321
16
        "Global(identifier* names)");
6322
16
    if (!state->Global_type) return -1;
6323
16
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6324
16
                                     Nonlocal_fields, 1,
6325
16
        "Nonlocal(identifier* names)");
6326
16
    if (!state->Nonlocal_type) return -1;
6327
16
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6328
16
                                 1,
6329
16
        "Expr(expr value)");
6330
16
    if (!state->Expr_type) return -1;
6331
16
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6332
16
        "Pass");
6333
16
    if (!state->Pass_type) return -1;
6334
16
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6335
16
        "Break");
6336
16
    if (!state->Break_type) return -1;
6337
16
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6338
16
                                     0,
6339
16
        "Continue");
6340
16
    if (!state->Continue_type) return -1;
6341
16
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6342
16
        "expr = BoolOp(boolop op, expr* values)\n"
6343
16
        "     | NamedExpr(expr target, expr value)\n"
6344
16
        "     | BinOp(expr left, operator op, expr right)\n"
6345
16
        "     | UnaryOp(unaryop op, expr operand)\n"
6346
16
        "     | Lambda(arguments args, expr body)\n"
6347
16
        "     | IfExp(expr test, expr body, expr orelse)\n"
6348
16
        "     | Dict(expr?* keys, expr* values)\n"
6349
16
        "     | Set(expr* elts)\n"
6350
16
        "     | ListComp(expr elt, comprehension* generators)\n"
6351
16
        "     | SetComp(expr elt, comprehension* generators)\n"
6352
16
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6353
16
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6354
16
        "     | Await(expr value)\n"
6355
16
        "     | Yield(expr? value)\n"
6356
16
        "     | YieldFrom(expr value)\n"
6357
16
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6358
16
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6359
16
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6360
16
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6361
16
        "     | JoinedStr(expr* values)\n"
6362
16
        "     | TemplateStr(expr* values)\n"
6363
16
        "     | Constant(constant value, string? kind)\n"
6364
16
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6365
16
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6366
16
        "     | Starred(expr value, expr_context ctx)\n"
6367
16
        "     | Name(identifier id, expr_context ctx)\n"
6368
16
        "     | List(expr* elts, expr_context ctx)\n"
6369
16
        "     | Tuple(expr* elts, expr_context ctx)\n"
6370
16
        "     | Slice(expr? lower, expr? upper, expr? step)");
6371
16
    if (!state->expr_type) return -1;
6372
16
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6373
0
        -1;
6374
16
    if (PySet_Add(state->abstract_types, state->expr_type) < 0) return -1;
6375
16
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6376
0
        return -1;
6377
16
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6378
16
        -1)
6379
0
        return -1;
6380
16
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6381
16
                                   BoolOp_fields, 2,
6382
16
        "BoolOp(boolop op, expr* values)");
6383
16
    if (!state->BoolOp_type) return -1;
6384
16
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6385
16
                                      NamedExpr_fields, 2,
6386
16
        "NamedExpr(expr target, expr value)");
6387
16
    if (!state->NamedExpr_type) return -1;
6388
16
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6389
16
                                  BinOp_fields, 3,
6390
16
        "BinOp(expr left, operator op, expr right)");
6391
16
    if (!state->BinOp_type) return -1;
6392
16
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6393
16
                                    UnaryOp_fields, 2,
6394
16
        "UnaryOp(unaryop op, expr operand)");
6395
16
    if (!state->UnaryOp_type) return -1;
6396
16
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6397
16
                                   Lambda_fields, 2,
6398
16
        "Lambda(arguments args, expr body)");
6399
16
    if (!state->Lambda_type) return -1;
6400
16
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6401
16
                                  IfExp_fields, 3,
6402
16
        "IfExp(expr test, expr body, expr orelse)");
6403
16
    if (!state->IfExp_type) return -1;
6404
16
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6405
16
                                 2,
6406
16
        "Dict(expr?* keys, expr* values)");
6407
16
    if (!state->Dict_type) return -1;
6408
16
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6409
16
        "Set(expr* elts)");
6410
16
    if (!state->Set_type) return -1;
6411
16
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6412
16
                                     ListComp_fields, 2,
6413
16
        "ListComp(expr elt, comprehension* generators)");
6414
16
    if (!state->ListComp_type) return -1;
6415
16
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6416
16
                                    SetComp_fields, 2,
6417
16
        "SetComp(expr elt, comprehension* generators)");
6418
16
    if (!state->SetComp_type) return -1;
6419
16
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6420
16
                                     DictComp_fields, 3,
6421
16
        "DictComp(expr key, expr? value, comprehension* generators)");
6422
16
    if (!state->DictComp_type) return -1;
6423
16
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6424
0
        return -1;
6425
16
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6426
16
                                         state->expr_type, GeneratorExp_fields,
6427
16
                                         2,
6428
16
        "GeneratorExp(expr elt, comprehension* generators)");
6429
16
    if (!state->GeneratorExp_type) return -1;
6430
16
    state->Await_type = make_type(state, "Await", state->expr_type,
6431
16
                                  Await_fields, 1,
6432
16
        "Await(expr value)");
6433
16
    if (!state->Await_type) return -1;
6434
16
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6435
16
                                  Yield_fields, 1,
6436
16
        "Yield(expr? value)");
6437
16
    if (!state->Yield_type) return -1;
6438
16
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6439
0
        return -1;
6440
16
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6441
16
                                      YieldFrom_fields, 1,
6442
16
        "YieldFrom(expr value)");
6443
16
    if (!state->YieldFrom_type) return -1;
6444
16
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6445
16
                                    Compare_fields, 3,
6446
16
        "Compare(expr left, cmpop* ops, expr* comparators)");
6447
16
    if (!state->Compare_type) return -1;
6448
16
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6449
16
                                 3,
6450
16
        "Call(expr func, expr* args, keyword* keywords)");
6451
16
    if (!state->Call_type) return -1;
6452
16
    state->FormattedValue_type = make_type(state, "FormattedValue",
6453
16
                                           state->expr_type,
6454
16
                                           FormattedValue_fields, 3,
6455
16
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6456
16
    if (!state->FormattedValue_type) return -1;
6457
16
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6458
16
        Py_None) == -1)
6459
0
        return -1;
6460
16
    state->Interpolation_type = make_type(state, "Interpolation",
6461
16
                                          state->expr_type,
6462
16
                                          Interpolation_fields, 4,
6463
16
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6464
16
    if (!state->Interpolation_type) return -1;
6465
16
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6466
16
        Py_None) == -1)
6467
0
        return -1;
6468
16
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6469
16
                                      JoinedStr_fields, 1,
6470
16
        "JoinedStr(expr* values)");
6471
16
    if (!state->JoinedStr_type) return -1;
6472
16
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6473
16
                                        TemplateStr_fields, 1,
6474
16
        "TemplateStr(expr* values)");
6475
16
    if (!state->TemplateStr_type) return -1;
6476
16
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6477
16
                                     Constant_fields, 2,
6478
16
        "Constant(constant value, string? kind)");
6479
16
    if (!state->Constant_type) return -1;
6480
16
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6481
0
        return -1;
6482
16
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6483
16
                                      Attribute_fields, 3,
6484
16
        "Attribute(expr value, identifier attr, expr_context ctx)");
6485
16
    if (!state->Attribute_type) return -1;
6486
16
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6487
16
                                      Subscript_fields, 3,
6488
16
        "Subscript(expr value, expr slice, expr_context ctx)");
6489
16
    if (!state->Subscript_type) return -1;
6490
16
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6491
16
                                    Starred_fields, 2,
6492
16
        "Starred(expr value, expr_context ctx)");
6493
16
    if (!state->Starred_type) return -1;
6494
16
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6495
16
                                 2,
6496
16
        "Name(identifier id, expr_context ctx)");
6497
16
    if (!state->Name_type) return -1;
6498
16
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6499
16
                                 2,
6500
16
        "List(expr* elts, expr_context ctx)");
6501
16
    if (!state->List_type) return -1;
6502
16
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6503
16
                                  Tuple_fields, 2,
6504
16
        "Tuple(expr* elts, expr_context ctx)");
6505
16
    if (!state->Tuple_type) return -1;
6506
16
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6507
16
                                  Slice_fields, 3,
6508
16
        "Slice(expr? lower, expr? upper, expr? step)");
6509
16
    if (!state->Slice_type) return -1;
6510
16
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6511
0
        return -1;
6512
16
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6513
0
        return -1;
6514
16
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6515
0
        return -1;
6516
16
    state->expr_context_type = make_type(state, "expr_context",
6517
16
                                         state->AST_type, NULL, 0,
6518
16
        "expr_context = Load | Store | Del");
6519
16
    if (!state->expr_context_type) return -1;
6520
16
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6521
16
    if (PySet_Add(state->abstract_types, state->expr_context_type) < 0) return
6522
0
        -1;
6523
16
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6524
16
                                 0,
6525
16
        "Load");
6526
16
    if (!state->Load_type) return -1;
6527
16
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6528
16
                                              NULL, NULL);
6529
16
    if (!state->Load_singleton) return -1;
6530
16
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6531
16
                                  NULL, 0,
6532
16
        "Store");
6533
16
    if (!state->Store_type) return -1;
6534
16
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6535
16
                                               *)state->Store_type, NULL, NULL);
6536
16
    if (!state->Store_singleton) return -1;
6537
16
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6538
16
        "Del");
6539
16
    if (!state->Del_type) return -1;
6540
16
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6541
16
                                             NULL, NULL);
6542
16
    if (!state->Del_singleton) return -1;
6543
16
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6544
16
        "boolop = And | Or");
6545
16
    if (!state->boolop_type) return -1;
6546
16
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6547
16
    if (PySet_Add(state->abstract_types, state->boolop_type) < 0) return -1;
6548
16
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6549
16
        "And");
6550
16
    if (!state->And_type) return -1;
6551
16
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6552
16
                                             NULL, NULL);
6553
16
    if (!state->And_singleton) return -1;
6554
16
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6555
16
        "Or");
6556
16
    if (!state->Or_type) return -1;
6557
16
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6558
16
                                            NULL, NULL);
6559
16
    if (!state->Or_singleton) return -1;
6560
16
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6561
16
                                     0,
6562
16
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6563
16
    if (!state->operator_type) return -1;
6564
16
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6565
16
    if (PySet_Add(state->abstract_types, state->operator_type) < 0) return -1;
6566
16
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6567
16
        "Add");
6568
16
    if (!state->Add_type) return -1;
6569
16
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6570
16
                                             NULL, NULL);
6571
16
    if (!state->Add_singleton) return -1;
6572
16
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6573
16
        "Sub");
6574
16
    if (!state->Sub_type) return -1;
6575
16
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6576
16
                                             NULL, NULL);
6577
16
    if (!state->Sub_singleton) return -1;
6578
16
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6579
16
        "Mult");
6580
16
    if (!state->Mult_type) return -1;
6581
16
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6582
16
                                              NULL, NULL);
6583
16
    if (!state->Mult_singleton) return -1;
6584
16
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6585
16
                                    NULL, 0,
6586
16
        "MatMult");
6587
16
    if (!state->MatMult_type) return -1;
6588
16
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6589
16
                                                 *)state->MatMult_type, NULL,
6590
16
                                                 NULL);
6591
16
    if (!state->MatMult_singleton) return -1;
6592
16
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6593
16
        "Div");
6594
16
    if (!state->Div_type) return -1;
6595
16
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6596
16
                                             NULL, NULL);
6597
16
    if (!state->Div_singleton) return -1;
6598
16
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6599
16
        "Mod");
6600
16
    if (!state->Mod_type) return -1;
6601
16
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6602
16
                                             NULL, NULL);
6603
16
    if (!state->Mod_singleton) return -1;
6604
16
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6605
16
        "Pow");
6606
16
    if (!state->Pow_type) return -1;
6607
16
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6608
16
                                             NULL, NULL);
6609
16
    if (!state->Pow_singleton) return -1;
6610
16
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6611
16
                                   0,
6612
16
        "LShift");
6613
16
    if (!state->LShift_type) return -1;
6614
16
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6615
16
                                                *)state->LShift_type, NULL,
6616
16
                                                NULL);
6617
16
    if (!state->LShift_singleton) return -1;
6618
16
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6619
16
                                   0,
6620
16
        "RShift");
6621
16
    if (!state->RShift_type) return -1;
6622
16
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6623
16
                                                *)state->RShift_type, NULL,
6624
16
                                                NULL);
6625
16
    if (!state->RShift_singleton) return -1;
6626
16
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6627
16
        "BitOr");
6628
16
    if (!state->BitOr_type) return -1;
6629
16
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6630
16
                                               *)state->BitOr_type, NULL, NULL);
6631
16
    if (!state->BitOr_singleton) return -1;
6632
16
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6633
16
                                   0,
6634
16
        "BitXor");
6635
16
    if (!state->BitXor_type) return -1;
6636
16
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6637
16
                                                *)state->BitXor_type, NULL,
6638
16
                                                NULL);
6639
16
    if (!state->BitXor_singleton) return -1;
6640
16
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6641
16
                                   0,
6642
16
        "BitAnd");
6643
16
    if (!state->BitAnd_type) return -1;
6644
16
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6645
16
                                                *)state->BitAnd_type, NULL,
6646
16
                                                NULL);
6647
16
    if (!state->BitAnd_singleton) return -1;
6648
16
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6649
16
                                     NULL, 0,
6650
16
        "FloorDiv");
6651
16
    if (!state->FloorDiv_type) return -1;
6652
16
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6653
16
                                                  *)state->FloorDiv_type, NULL,
6654
16
                                                  NULL);
6655
16
    if (!state->FloorDiv_singleton) return -1;
6656
16
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6657
16
        "unaryop = Invert | Not | UAdd | USub");
6658
16
    if (!state->unaryop_type) return -1;
6659
16
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6660
16
    if (PySet_Add(state->abstract_types, state->unaryop_type) < 0) return -1;
6661
16
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6662
16
                                   0,
6663
16
        "Invert");
6664
16
    if (!state->Invert_type) return -1;
6665
16
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6666
16
                                                *)state->Invert_type, NULL,
6667
16
                                                NULL);
6668
16
    if (!state->Invert_singleton) return -1;
6669
16
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6670
16
        "Not");
6671
16
    if (!state->Not_type) return -1;
6672
16
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6673
16
                                             NULL, NULL);
6674
16
    if (!state->Not_singleton) return -1;
6675
16
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6676
16
        "UAdd");
6677
16
    if (!state->UAdd_type) return -1;
6678
16
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6679
16
                                              NULL, NULL);
6680
16
    if (!state->UAdd_singleton) return -1;
6681
16
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6682
16
        "USub");
6683
16
    if (!state->USub_type) return -1;
6684
16
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6685
16
                                              NULL, NULL);
6686
16
    if (!state->USub_singleton) return -1;
6687
16
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6688
16
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6689
16
    if (!state->cmpop_type) return -1;
6690
16
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6691
16
    if (PySet_Add(state->abstract_types, state->cmpop_type) < 0) return -1;
6692
16
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6693
16
        "Eq");
6694
16
    if (!state->Eq_type) return -1;
6695
16
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6696
16
                                            NULL, NULL);
6697
16
    if (!state->Eq_singleton) return -1;
6698
16
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6699
16
        "NotEq");
6700
16
    if (!state->NotEq_type) return -1;
6701
16
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6702
16
                                               *)state->NotEq_type, NULL, NULL);
6703
16
    if (!state->NotEq_singleton) return -1;
6704
16
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6705
16
        "Lt");
6706
16
    if (!state->Lt_type) return -1;
6707
16
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6708
16
                                            NULL, NULL);
6709
16
    if (!state->Lt_singleton) return -1;
6710
16
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6711
16
        "LtE");
6712
16
    if (!state->LtE_type) return -1;
6713
16
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6714
16
                                             NULL, NULL);
6715
16
    if (!state->LtE_singleton) return -1;
6716
16
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6717
16
        "Gt");
6718
16
    if (!state->Gt_type) return -1;
6719
16
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6720
16
                                            NULL, NULL);
6721
16
    if (!state->Gt_singleton) return -1;
6722
16
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6723
16
        "GtE");
6724
16
    if (!state->GtE_type) return -1;
6725
16
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6726
16
                                             NULL, NULL);
6727
16
    if (!state->GtE_singleton) return -1;
6728
16
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6729
16
        "Is");
6730
16
    if (!state->Is_type) return -1;
6731
16
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6732
16
                                            NULL, NULL);
6733
16
    if (!state->Is_singleton) return -1;
6734
16
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6735
16
        "IsNot");
6736
16
    if (!state->IsNot_type) return -1;
6737
16
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6738
16
                                               *)state->IsNot_type, NULL, NULL);
6739
16
    if (!state->IsNot_singleton) return -1;
6740
16
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6741
16
        "In");
6742
16
    if (!state->In_type) return -1;
6743
16
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6744
16
                                            NULL, NULL);
6745
16
    if (!state->In_singleton) return -1;
6746
16
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6747
16
        "NotIn");
6748
16
    if (!state->NotIn_type) return -1;
6749
16
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6750
16
                                               *)state->NotIn_type, NULL, NULL);
6751
16
    if (!state->NotIn_singleton) return -1;
6752
16
    state->comprehension_type = make_type(state, "comprehension",
6753
16
                                          state->AST_type,
6754
16
                                          comprehension_fields, 4,
6755
16
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6756
16
    if (!state->comprehension_type) return -1;
6757
16
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6758
0
        -1;
6759
16
    state->excepthandler_type = make_type(state, "excepthandler",
6760
16
                                          state->AST_type, NULL, 0,
6761
16
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6762
16
    if (!state->excepthandler_type) return -1;
6763
16
    if (add_attributes(state, state->excepthandler_type,
6764
16
        excepthandler_attributes, 4) < 0) return -1;
6765
16
    if (PySet_Add(state->abstract_types, state->excepthandler_type) < 0) return
6766
0
        -1;
6767
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6768
16
        == -1)
6769
0
        return -1;
6770
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6771
16
        Py_None) == -1)
6772
0
        return -1;
6773
16
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6774
16
                                          state->excepthandler_type,
6775
16
                                          ExceptHandler_fields, 3,
6776
16
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6777
16
    if (!state->ExceptHandler_type) return -1;
6778
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6779
0
        return -1;
6780
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6781
0
        return -1;
6782
16
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6783
16
                                      arguments_fields, 7,
6784
16
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6785
16
    if (!state->arguments_type) return -1;
6786
16
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6787
16
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6788
0
        return -1;
6789
16
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6790
0
        return -1;
6791
16
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6792
16
        "arg(identifier arg, expr? annotation, string? type_comment)");
6793
16
    if (!state->arg_type) return -1;
6794
16
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6795
0
        -1;
6796
16
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6797
0
        return -1;
6798
16
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6799
0
        return -1;
6800
16
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6801
0
        return -1;
6802
16
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6803
0
        return -1;
6804
16
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6805
16
                                    keyword_fields, 2,
6806
16
        "keyword(identifier? arg, expr value)");
6807
16
    if (!state->keyword_type) return -1;
6808
16
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6809
0
        return -1;
6810
16
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6811
0
        return -1;
6812
16
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6813
0
        return -1;
6814
16
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6815
16
        == -1)
6816
0
        return -1;
6817
16
    state->alias_type = make_type(state, "alias", state->AST_type,
6818
16
                                  alias_fields, 2,
6819
16
        "alias(identifier name, identifier? asname)");
6820
16
    if (!state->alias_type) return -1;
6821
16
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6822
0
        return -1;
6823
16
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6824
0
        return -1;
6825
16
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6826
0
        return -1;
6827
16
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6828
16
        -1)
6829
0
        return -1;
6830
16
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6831
16
                                     withitem_fields, 2,
6832
16
        "withitem(expr context_expr, expr? optional_vars)");
6833
16
    if (!state->withitem_type) return -1;
6834
16
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6835
16
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6836
16
        == -1)
6837
0
        return -1;
6838
16
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6839
16
                                       match_case_fields, 3,
6840
16
        "match_case(pattern pattern, expr? guard, stmt* body)");
6841
16
    if (!state->match_case_type) return -1;
6842
16
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6843
16
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6844
0
        return -1;
6845
16
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6846
16
        "pattern = MatchValue(expr value)\n"
6847
16
        "        | MatchSingleton(constant value)\n"
6848
16
        "        | MatchSequence(pattern* patterns)\n"
6849
16
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6850
16
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6851
16
        "        | MatchStar(identifier? name)\n"
6852
16
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6853
16
        "        | MatchOr(pattern* patterns)");
6854
16
    if (!state->pattern_type) return -1;
6855
16
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6856
0
        return -1;
6857
16
    if (PySet_Add(state->abstract_types, state->pattern_type) < 0) return -1;
6858
16
    state->MatchValue_type = make_type(state, "MatchValue",
6859
16
                                       state->pattern_type, MatchValue_fields,
6860
16
                                       1,
6861
16
        "MatchValue(expr value)");
6862
16
    if (!state->MatchValue_type) return -1;
6863
16
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6864
16
                                           state->pattern_type,
6865
16
                                           MatchSingleton_fields, 1,
6866
16
        "MatchSingleton(constant value)");
6867
16
    if (!state->MatchSingleton_type) return -1;
6868
16
    state->MatchSequence_type = make_type(state, "MatchSequence",
6869
16
                                          state->pattern_type,
6870
16
                                          MatchSequence_fields, 1,
6871
16
        "MatchSequence(pattern* patterns)");
6872
16
    if (!state->MatchSequence_type) return -1;
6873
16
    state->MatchMapping_type = make_type(state, "MatchMapping",
6874
16
                                         state->pattern_type,
6875
16
                                         MatchMapping_fields, 3,
6876
16
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6877
16
    if (!state->MatchMapping_type) return -1;
6878
16
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6879
0
        return -1;
6880
16
    state->MatchClass_type = make_type(state, "MatchClass",
6881
16
                                       state->pattern_type, MatchClass_fields,
6882
16
                                       4,
6883
16
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6884
16
    if (!state->MatchClass_type) return -1;
6885
16
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6886
16
                                      MatchStar_fields, 1,
6887
16
        "MatchStar(identifier? name)");
6888
16
    if (!state->MatchStar_type) return -1;
6889
16
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6890
0
        return -1;
6891
16
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6892
16
                                    MatchAs_fields, 2,
6893
16
        "MatchAs(pattern? pattern, identifier? name)");
6894
16
    if (!state->MatchAs_type) return -1;
6895
16
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6896
0
        return -1;
6897
16
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6898
0
        return -1;
6899
16
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6900
16
                                    MatchOr_fields, 1,
6901
16
        "MatchOr(pattern* patterns)");
6902
16
    if (!state->MatchOr_type) return -1;
6903
16
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6904
16
                                        NULL, 0,
6905
16
        "type_ignore = TypeIgnore(int lineno, string tag)");
6906
16
    if (!state->type_ignore_type) return -1;
6907
16
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6908
16
    if (PySet_Add(state->abstract_types, state->type_ignore_type) < 0) return
6909
0
        -1;
6910
16
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6911
16
                                       state->type_ignore_type,
6912
16
                                       TypeIgnore_fields, 2,
6913
16
        "TypeIgnore(int lineno, string tag)");
6914
16
    if (!state->TypeIgnore_type) return -1;
6915
16
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6916
16
                                       NULL, 0,
6917
16
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6918
16
        "           | ParamSpec(identifier name, expr? default_value)\n"
6919
16
        "           | TypeVarTuple(identifier name, expr? default_value)");
6920
16
    if (!state->type_param_type) return -1;
6921
16
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6922
16
        < 0) return -1;
6923
16
    if (PySet_Add(state->abstract_types, state->type_param_type) < 0) return -1;
6924
16
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6925
16
                                    TypeVar_fields, 3,
6926
16
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6927
16
    if (!state->TypeVar_type) return -1;
6928
16
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6929
0
        return -1;
6930
16
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6931
16
        -1)
6932
0
        return -1;
6933
16
    state->ParamSpec_type = make_type(state, "ParamSpec",
6934
16
                                      state->type_param_type, ParamSpec_fields,
6935
16
                                      2,
6936
16
        "ParamSpec(identifier name, expr? default_value)");
6937
16
    if (!state->ParamSpec_type) return -1;
6938
16
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6939
16
        == -1)
6940
0
        return -1;
6941
16
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6942
16
                                         state->type_param_type,
6943
16
                                         TypeVarTuple_fields, 2,
6944
16
        "TypeVarTuple(identifier name, expr? default_value)");
6945
16
    if (!state->TypeVarTuple_type) return -1;
6946
16
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6947
16
        Py_None) == -1)
6948
0
        return -1;
6949
6950
16
    if (!add_ast_annotations(state)) {
6951
0
        return -1;
6952
0
    }
6953
16
    return 0;
6954
16
}
6955
6956
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6957
                       PyArena* arena);
6958
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6959
                        PyArena* arena);
6960
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6961
                        PyArena* arena);
6962
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6963
                                expr_context_ty* out, PyArena* arena);
6964
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
6965
                          out, PyArena* arena);
6966
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
6967
                            operator_ty* out, PyArena* arena);
6968
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
6969
                           out, PyArena* arena);
6970
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
6971
                         PyArena* arena);
6972
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
6973
                                 comprehension_ty* out, PyArena* arena);
6974
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
6975
                                 excepthandler_ty* out, PyArena* arena);
6976
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
6977
                             arguments_ty* out, PyArena* arena);
6978
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
6979
                       PyArena* arena);
6980
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
6981
                           out, PyArena* arena);
6982
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
6983
                         PyArena* arena);
6984
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
6985
                            withitem_ty* out, PyArena* arena);
6986
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
6987
                              match_case_ty* out, PyArena* arena);
6988
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
6989
                           out, PyArena* arena);
6990
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
6991
                               type_ignore_ty* out, PyArena* arena);
6992
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
6993
                              type_param_ty* out, PyArena* arena);
6994
6995
mod_ty
6996
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
6997
              PyArena *arena)
6998
6.86k
{
6999
6.86k
    mod_ty p;
7000
6.86k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7001
6.86k
    if (!p)
7002
0
        return NULL;
7003
6.86k
    p->kind = Module_kind;
7004
6.86k
    p->v.Module.body = body;
7005
6.86k
    p->v.Module.type_ignores = type_ignores;
7006
6.86k
    return p;
7007
6.86k
}
7008
7009
mod_ty
7010
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7011
0
{
7012
0
    mod_ty p;
7013
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7014
0
    if (!p)
7015
0
        return NULL;
7016
0
    p->kind = Interactive_kind;
7017
0
    p->v.Interactive.body = body;
7018
0
    return p;
7019
0
}
7020
7021
mod_ty
7022
_PyAST_Expression(expr_ty body, PyArena *arena)
7023
229
{
7024
229
    mod_ty p;
7025
229
    if (!body) {
7026
0
        PyErr_SetString(PyExc_ValueError,
7027
0
                        "field 'body' is required for Expression");
7028
0
        return NULL;
7029
0
    }
7030
229
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7031
229
    if (!p)
7032
0
        return NULL;
7033
229
    p->kind = Expression_kind;
7034
229
    p->v.Expression.body = body;
7035
229
    return p;
7036
229
}
7037
7038
mod_ty
7039
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7040
0
{
7041
0
    mod_ty p;
7042
0
    if (!returns) {
7043
0
        PyErr_SetString(PyExc_ValueError,
7044
0
                        "field 'returns' is required for FunctionType");
7045
0
        return NULL;
7046
0
    }
7047
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7048
0
    if (!p)
7049
0
        return NULL;
7050
0
    p->kind = FunctionType_kind;
7051
0
    p->v.FunctionType.argtypes = argtypes;
7052
0
    p->v.FunctionType.returns = returns;
7053
0
    return p;
7054
0
}
7055
7056
stmt_ty
7057
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7058
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7059
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7060
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7061
                   *arena)
7062
6.29k
{
7063
6.29k
    stmt_ty p;
7064
6.29k
    if (!name) {
7065
0
        PyErr_SetString(PyExc_ValueError,
7066
0
                        "field 'name' is required for FunctionDef");
7067
0
        return NULL;
7068
0
    }
7069
6.29k
    if (!args) {
7070
0
        PyErr_SetString(PyExc_ValueError,
7071
0
                        "field 'args' is required for FunctionDef");
7072
0
        return NULL;
7073
0
    }
7074
6.29k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7075
6.29k
    if (!p)
7076
0
        return NULL;
7077
6.29k
    p->kind = FunctionDef_kind;
7078
6.29k
    p->v.FunctionDef.name = name;
7079
6.29k
    p->v.FunctionDef.args = args;
7080
6.29k
    p->v.FunctionDef.body = body;
7081
6.29k
    p->v.FunctionDef.decorator_list = decorator_list;
7082
6.29k
    p->v.FunctionDef.returns = returns;
7083
6.29k
    p->v.FunctionDef.type_comment = type_comment;
7084
6.29k
    p->v.FunctionDef.type_params = type_params;
7085
6.29k
    p->lineno = lineno;
7086
6.29k
    p->col_offset = col_offset;
7087
6.29k
    p->end_lineno = end_lineno;
7088
6.29k
    p->end_col_offset = end_col_offset;
7089
6.29k
    return p;
7090
6.29k
}
7091
7092
stmt_ty
7093
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7094
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7095
                        string type_comment, asdl_type_param_seq * type_params,
7096
                        int lineno, int col_offset, int end_lineno, int
7097
                        end_col_offset, PyArena *arena)
7098
698
{
7099
698
    stmt_ty p;
7100
698
    if (!name) {
7101
0
        PyErr_SetString(PyExc_ValueError,
7102
0
                        "field 'name' is required for AsyncFunctionDef");
7103
0
        return NULL;
7104
0
    }
7105
698
    if (!args) {
7106
0
        PyErr_SetString(PyExc_ValueError,
7107
0
                        "field 'args' is required for AsyncFunctionDef");
7108
0
        return NULL;
7109
0
    }
7110
698
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7111
698
    if (!p)
7112
0
        return NULL;
7113
698
    p->kind = AsyncFunctionDef_kind;
7114
698
    p->v.AsyncFunctionDef.name = name;
7115
698
    p->v.AsyncFunctionDef.args = args;
7116
698
    p->v.AsyncFunctionDef.body = body;
7117
698
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7118
698
    p->v.AsyncFunctionDef.returns = returns;
7119
698
    p->v.AsyncFunctionDef.type_comment = type_comment;
7120
698
    p->v.AsyncFunctionDef.type_params = type_params;
7121
698
    p->lineno = lineno;
7122
698
    p->col_offset = col_offset;
7123
698
    p->end_lineno = end_lineno;
7124
698
    p->end_col_offset = end_col_offset;
7125
698
    return p;
7126
698
}
7127
7128
stmt_ty
7129
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7130
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7131
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7132
                int end_lineno, int end_col_offset, PyArena *arena)
7133
2.69k
{
7134
2.69k
    stmt_ty p;
7135
2.69k
    if (!name) {
7136
0
        PyErr_SetString(PyExc_ValueError,
7137
0
                        "field 'name' is required for ClassDef");
7138
0
        return NULL;
7139
0
    }
7140
2.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7141
2.69k
    if (!p)
7142
0
        return NULL;
7143
2.69k
    p->kind = ClassDef_kind;
7144
2.69k
    p->v.ClassDef.name = name;
7145
2.69k
    p->v.ClassDef.bases = bases;
7146
2.69k
    p->v.ClassDef.keywords = keywords;
7147
2.69k
    p->v.ClassDef.body = body;
7148
2.69k
    p->v.ClassDef.decorator_list = decorator_list;
7149
2.69k
    p->v.ClassDef.type_params = type_params;
7150
2.69k
    p->lineno = lineno;
7151
2.69k
    p->col_offset = col_offset;
7152
2.69k
    p->end_lineno = end_lineno;
7153
2.69k
    p->end_col_offset = end_col_offset;
7154
2.69k
    return p;
7155
2.69k
}
7156
7157
stmt_ty
7158
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7159
              end_col_offset, PyArena *arena)
7160
3.34k
{
7161
3.34k
    stmt_ty p;
7162
3.34k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7163
3.34k
    if (!p)
7164
0
        return NULL;
7165
3.34k
    p->kind = Return_kind;
7166
3.34k
    p->v.Return.value = value;
7167
3.34k
    p->lineno = lineno;
7168
3.34k
    p->col_offset = col_offset;
7169
3.34k
    p->end_lineno = end_lineno;
7170
3.34k
    p->end_col_offset = end_col_offset;
7171
3.34k
    return p;
7172
3.34k
}
7173
7174
stmt_ty
7175
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7176
              end_lineno, int end_col_offset, PyArena *arena)
7177
521
{
7178
521
    stmt_ty p;
7179
521
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7180
521
    if (!p)
7181
0
        return NULL;
7182
521
    p->kind = Delete_kind;
7183
521
    p->v.Delete.targets = targets;
7184
521
    p->lineno = lineno;
7185
521
    p->col_offset = col_offset;
7186
521
    p->end_lineno = end_lineno;
7187
521
    p->end_col_offset = end_col_offset;
7188
521
    return p;
7189
521
}
7190
7191
stmt_ty
7192
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7193
              lineno, int col_offset, int end_lineno, int end_col_offset,
7194
              PyArena *arena)
7195
6.29k
{
7196
6.29k
    stmt_ty p;
7197
6.29k
    if (!value) {
7198
0
        PyErr_SetString(PyExc_ValueError,
7199
0
                        "field 'value' is required for Assign");
7200
0
        return NULL;
7201
0
    }
7202
6.29k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7203
6.29k
    if (!p)
7204
0
        return NULL;
7205
6.29k
    p->kind = Assign_kind;
7206
6.29k
    p->v.Assign.targets = targets;
7207
6.29k
    p->v.Assign.value = value;
7208
6.29k
    p->v.Assign.type_comment = type_comment;
7209
6.29k
    p->lineno = lineno;
7210
6.29k
    p->col_offset = col_offset;
7211
6.29k
    p->end_lineno = end_lineno;
7212
6.29k
    p->end_col_offset = end_col_offset;
7213
6.29k
    return p;
7214
6.29k
}
7215
7216
stmt_ty
7217
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7218
                 value, int lineno, int col_offset, int end_lineno, int
7219
                 end_col_offset, PyArena *arena)
7220
285
{
7221
285
    stmt_ty p;
7222
285
    if (!name) {
7223
0
        PyErr_SetString(PyExc_ValueError,
7224
0
                        "field 'name' is required for TypeAlias");
7225
0
        return NULL;
7226
0
    }
7227
285
    if (!value) {
7228
0
        PyErr_SetString(PyExc_ValueError,
7229
0
                        "field 'value' is required for TypeAlias");
7230
0
        return NULL;
7231
0
    }
7232
285
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7233
285
    if (!p)
7234
0
        return NULL;
7235
285
    p->kind = TypeAlias_kind;
7236
285
    p->v.TypeAlias.name = name;
7237
285
    p->v.TypeAlias.type_params = type_params;
7238
285
    p->v.TypeAlias.value = value;
7239
285
    p->lineno = lineno;
7240
285
    p->col_offset = col_offset;
7241
285
    p->end_lineno = end_lineno;
7242
285
    p->end_col_offset = end_col_offset;
7243
285
    return p;
7244
285
}
7245
7246
stmt_ty
7247
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7248
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7249
2.63k
{
7250
2.63k
    stmt_ty p;
7251
2.63k
    if (!target) {
7252
0
        PyErr_SetString(PyExc_ValueError,
7253
0
                        "field 'target' is required for AugAssign");
7254
0
        return NULL;
7255
0
    }
7256
2.63k
    if (!op) {
7257
0
        PyErr_SetString(PyExc_ValueError,
7258
0
                        "field 'op' is required for AugAssign");
7259
0
        return NULL;
7260
0
    }
7261
2.63k
    if (!value) {
7262
0
        PyErr_SetString(PyExc_ValueError,
7263
0
                        "field 'value' is required for AugAssign");
7264
0
        return NULL;
7265
0
    }
7266
2.63k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7267
2.63k
    if (!p)
7268
0
        return NULL;
7269
2.63k
    p->kind = AugAssign_kind;
7270
2.63k
    p->v.AugAssign.target = target;
7271
2.63k
    p->v.AugAssign.op = op;
7272
2.63k
    p->v.AugAssign.value = value;
7273
2.63k
    p->lineno = lineno;
7274
2.63k
    p->col_offset = col_offset;
7275
2.63k
    p->end_lineno = end_lineno;
7276
2.63k
    p->end_col_offset = end_col_offset;
7277
2.63k
    return p;
7278
2.63k
}
7279
7280
stmt_ty
7281
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7282
                 int lineno, int col_offset, int end_lineno, int
7283
                 end_col_offset, PyArena *arena)
7284
2.24k
{
7285
2.24k
    stmt_ty p;
7286
2.24k
    if (!target) {
7287
0
        PyErr_SetString(PyExc_ValueError,
7288
0
                        "field 'target' is required for AnnAssign");
7289
0
        return NULL;
7290
0
    }
7291
2.24k
    if (!annotation) {
7292
0
        PyErr_SetString(PyExc_ValueError,
7293
0
                        "field 'annotation' is required for AnnAssign");
7294
0
        return NULL;
7295
0
    }
7296
2.24k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7297
2.24k
    if (!p)
7298
0
        return NULL;
7299
2.24k
    p->kind = AnnAssign_kind;
7300
2.24k
    p->v.AnnAssign.target = target;
7301
2.24k
    p->v.AnnAssign.annotation = annotation;
7302
2.24k
    p->v.AnnAssign.value = value;
7303
2.24k
    p->v.AnnAssign.simple = simple;
7304
2.24k
    p->lineno = lineno;
7305
2.24k
    p->col_offset = col_offset;
7306
2.24k
    p->end_lineno = end_lineno;
7307
2.24k
    p->end_col_offset = end_col_offset;
7308
2.24k
    return p;
7309
2.24k
}
7310
7311
stmt_ty
7312
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7313
           orelse, string type_comment, int lineno, int col_offset, int
7314
           end_lineno, int end_col_offset, PyArena *arena)
7315
1.03k
{
7316
1.03k
    stmt_ty p;
7317
1.03k
    if (!target) {
7318
0
        PyErr_SetString(PyExc_ValueError,
7319
0
                        "field 'target' is required for For");
7320
0
        return NULL;
7321
0
    }
7322
1.03k
    if (!iter) {
7323
0
        PyErr_SetString(PyExc_ValueError,
7324
0
                        "field 'iter' is required for For");
7325
0
        return NULL;
7326
0
    }
7327
1.03k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7328
1.03k
    if (!p)
7329
0
        return NULL;
7330
1.03k
    p->kind = For_kind;
7331
1.03k
    p->v.For.target = target;
7332
1.03k
    p->v.For.iter = iter;
7333
1.03k
    p->v.For.body = body;
7334
1.03k
    p->v.For.orelse = orelse;
7335
1.03k
    p->v.For.type_comment = type_comment;
7336
1.03k
    p->lineno = lineno;
7337
1.03k
    p->col_offset = col_offset;
7338
1.03k
    p->end_lineno = end_lineno;
7339
1.03k
    p->end_col_offset = end_col_offset;
7340
1.03k
    return p;
7341
1.03k
}
7342
7343
stmt_ty
7344
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7345
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7346
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7347
452
{
7348
452
    stmt_ty p;
7349
452
    if (!target) {
7350
0
        PyErr_SetString(PyExc_ValueError,
7351
0
                        "field 'target' is required for AsyncFor");
7352
0
        return NULL;
7353
0
    }
7354
452
    if (!iter) {
7355
0
        PyErr_SetString(PyExc_ValueError,
7356
0
                        "field 'iter' is required for AsyncFor");
7357
0
        return NULL;
7358
0
    }
7359
452
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7360
452
    if (!p)
7361
0
        return NULL;
7362
452
    p->kind = AsyncFor_kind;
7363
452
    p->v.AsyncFor.target = target;
7364
452
    p->v.AsyncFor.iter = iter;
7365
452
    p->v.AsyncFor.body = body;
7366
452
    p->v.AsyncFor.orelse = orelse;
7367
452
    p->v.AsyncFor.type_comment = type_comment;
7368
452
    p->lineno = lineno;
7369
452
    p->col_offset = col_offset;
7370
452
    p->end_lineno = end_lineno;
7371
452
    p->end_col_offset = end_col_offset;
7372
452
    return p;
7373
452
}
7374
7375
stmt_ty
7376
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7377
             lineno, int col_offset, int end_lineno, int end_col_offset,
7378
             PyArena *arena)
7379
818
{
7380
818
    stmt_ty p;
7381
818
    if (!test) {
7382
0
        PyErr_SetString(PyExc_ValueError,
7383
0
                        "field 'test' is required for While");
7384
0
        return NULL;
7385
0
    }
7386
818
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7387
818
    if (!p)
7388
0
        return NULL;
7389
818
    p->kind = While_kind;
7390
818
    p->v.While.test = test;
7391
818
    p->v.While.body = body;
7392
818
    p->v.While.orelse = orelse;
7393
818
    p->lineno = lineno;
7394
818
    p->col_offset = col_offset;
7395
818
    p->end_lineno = end_lineno;
7396
818
    p->end_col_offset = end_col_offset;
7397
818
    return p;
7398
818
}
7399
7400
stmt_ty
7401
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7402
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7403
          *arena)
7404
4.94k
{
7405
4.94k
    stmt_ty p;
7406
4.94k
    if (!test) {
7407
0
        PyErr_SetString(PyExc_ValueError,
7408
0
                        "field 'test' is required for If");
7409
0
        return NULL;
7410
0
    }
7411
4.94k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7412
4.94k
    if (!p)
7413
0
        return NULL;
7414
4.94k
    p->kind = If_kind;
7415
4.94k
    p->v.If.test = test;
7416
4.94k
    p->v.If.body = body;
7417
4.94k
    p->v.If.orelse = orelse;
7418
4.94k
    p->lineno = lineno;
7419
4.94k
    p->col_offset = col_offset;
7420
4.94k
    p->end_lineno = end_lineno;
7421
4.94k
    p->end_col_offset = end_col_offset;
7422
4.94k
    return p;
7423
4.94k
}
7424
7425
stmt_ty
7426
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7427
            type_comment, int lineno, int col_offset, int end_lineno, int
7428
            end_col_offset, PyArena *arena)
7429
1.69k
{
7430
1.69k
    stmt_ty p;
7431
1.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7432
1.69k
    if (!p)
7433
0
        return NULL;
7434
1.69k
    p->kind = With_kind;
7435
1.69k
    p->v.With.items = items;
7436
1.69k
    p->v.With.body = body;
7437
1.69k
    p->v.With.type_comment = type_comment;
7438
1.69k
    p->lineno = lineno;
7439
1.69k
    p->col_offset = col_offset;
7440
1.69k
    p->end_lineno = end_lineno;
7441
1.69k
    p->end_col_offset = end_col_offset;
7442
1.69k
    return p;
7443
1.69k
}
7444
7445
stmt_ty
7446
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7447
                 type_comment, int lineno, int col_offset, int end_lineno, int
7448
                 end_col_offset, PyArena *arena)
7449
1.11k
{
7450
1.11k
    stmt_ty p;
7451
1.11k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7452
1.11k
    if (!p)
7453
0
        return NULL;
7454
1.11k
    p->kind = AsyncWith_kind;
7455
1.11k
    p->v.AsyncWith.items = items;
7456
1.11k
    p->v.AsyncWith.body = body;
7457
1.11k
    p->v.AsyncWith.type_comment = type_comment;
7458
1.11k
    p->lineno = lineno;
7459
1.11k
    p->col_offset = col_offset;
7460
1.11k
    p->end_lineno = end_lineno;
7461
1.11k
    p->end_col_offset = end_col_offset;
7462
1.11k
    return p;
7463
1.11k
}
7464
7465
stmt_ty
7466
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7467
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7468
422
{
7469
422
    stmt_ty p;
7470
422
    if (!subject) {
7471
0
        PyErr_SetString(PyExc_ValueError,
7472
0
                        "field 'subject' is required for Match");
7473
0
        return NULL;
7474
0
    }
7475
422
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7476
422
    if (!p)
7477
0
        return NULL;
7478
422
    p->kind = Match_kind;
7479
422
    p->v.Match.subject = subject;
7480
422
    p->v.Match.cases = cases;
7481
422
    p->lineno = lineno;
7482
422
    p->col_offset = col_offset;
7483
422
    p->end_lineno = end_lineno;
7484
422
    p->end_col_offset = end_col_offset;
7485
422
    return p;
7486
422
}
7487
7488
stmt_ty
7489
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7490
             end_lineno, int end_col_offset, PyArena *arena)
7491
2.49k
{
7492
2.49k
    stmt_ty p;
7493
2.49k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7494
2.49k
    if (!p)
7495
0
        return NULL;
7496
2.49k
    p->kind = Raise_kind;
7497
2.49k
    p->v.Raise.exc = exc;
7498
2.49k
    p->v.Raise.cause = cause;
7499
2.49k
    p->lineno = lineno;
7500
2.49k
    p->col_offset = col_offset;
7501
2.49k
    p->end_lineno = end_lineno;
7502
2.49k
    p->end_col_offset = end_col_offset;
7503
2.49k
    return p;
7504
2.49k
}
7505
7506
stmt_ty
7507
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7508
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7509
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7510
2.71k
{
7511
2.71k
    stmt_ty p;
7512
2.71k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7513
2.71k
    if (!p)
7514
0
        return NULL;
7515
2.71k
    p->kind = Try_kind;
7516
2.71k
    p->v.Try.body = body;
7517
2.71k
    p->v.Try.handlers = handlers;
7518
2.71k
    p->v.Try.orelse = orelse;
7519
2.71k
    p->v.Try.finalbody = finalbody;
7520
2.71k
    p->lineno = lineno;
7521
2.71k
    p->col_offset = col_offset;
7522
2.71k
    p->end_lineno = end_lineno;
7523
2.71k
    p->end_col_offset = end_col_offset;
7524
2.71k
    return p;
7525
2.71k
}
7526
7527
stmt_ty
7528
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7529
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7530
               int col_offset, int end_lineno, int end_col_offset, PyArena
7531
               *arena)
7532
1.47k
{
7533
1.47k
    stmt_ty p;
7534
1.47k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7535
1.47k
    if (!p)
7536
0
        return NULL;
7537
1.47k
    p->kind = TryStar_kind;
7538
1.47k
    p->v.TryStar.body = body;
7539
1.47k
    p->v.TryStar.handlers = handlers;
7540
1.47k
    p->v.TryStar.orelse = orelse;
7541
1.47k
    p->v.TryStar.finalbody = finalbody;
7542
1.47k
    p->lineno = lineno;
7543
1.47k
    p->col_offset = col_offset;
7544
1.47k
    p->end_lineno = end_lineno;
7545
1.47k
    p->end_col_offset = end_col_offset;
7546
1.47k
    return p;
7547
1.47k
}
7548
7549
stmt_ty
7550
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7551
              end_lineno, int end_col_offset, PyArena *arena)
7552
954
{
7553
954
    stmt_ty p;
7554
954
    if (!test) {
7555
0
        PyErr_SetString(PyExc_ValueError,
7556
0
                        "field 'test' is required for Assert");
7557
0
        return NULL;
7558
0
    }
7559
954
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7560
954
    if (!p)
7561
0
        return NULL;
7562
954
    p->kind = Assert_kind;
7563
954
    p->v.Assert.test = test;
7564
954
    p->v.Assert.msg = msg;
7565
954
    p->lineno = lineno;
7566
954
    p->col_offset = col_offset;
7567
954
    p->end_lineno = end_lineno;
7568
954
    p->end_col_offset = end_col_offset;
7569
954
    return p;
7570
954
}
7571
7572
stmt_ty
7573
_PyAST_Import(asdl_alias_seq * names, int is_lazy, int lineno, int col_offset,
7574
              int end_lineno, int end_col_offset, PyArena *arena)
7575
2.25k
{
7576
2.25k
    stmt_ty p;
7577
2.25k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7578
2.25k
    if (!p)
7579
0
        return NULL;
7580
2.25k
    p->kind = Import_kind;
7581
2.25k
    p->v.Import.names = names;
7582
2.25k
    p->v.Import.is_lazy = is_lazy;
7583
2.25k
    p->lineno = lineno;
7584
2.25k
    p->col_offset = col_offset;
7585
2.25k
    p->end_lineno = end_lineno;
7586
2.25k
    p->end_col_offset = end_col_offset;
7587
2.25k
    return p;
7588
2.25k
}
7589
7590
stmt_ty
7591
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7592
                  is_lazy, int lineno, int col_offset, int end_lineno, int
7593
                  end_col_offset, PyArena *arena)
7594
2.63k
{
7595
2.63k
    stmt_ty p;
7596
2.63k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7597
2.63k
    if (!p)
7598
0
        return NULL;
7599
2.63k
    p->kind = ImportFrom_kind;
7600
2.63k
    p->v.ImportFrom.module = module;
7601
2.63k
    p->v.ImportFrom.names = names;
7602
2.63k
    p->v.ImportFrom.level = level;
7603
2.63k
    p->v.ImportFrom.is_lazy = is_lazy;
7604
2.63k
    p->lineno = lineno;
7605
2.63k
    p->col_offset = col_offset;
7606
2.63k
    p->end_lineno = end_lineno;
7607
2.63k
    p->end_col_offset = end_col_offset;
7608
2.63k
    return p;
7609
2.63k
}
7610
7611
stmt_ty
7612
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7613
              end_lineno, int end_col_offset, PyArena *arena)
7614
464
{
7615
464
    stmt_ty p;
7616
464
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7617
464
    if (!p)
7618
0
        return NULL;
7619
464
    p->kind = Global_kind;
7620
464
    p->v.Global.names = names;
7621
464
    p->lineno = lineno;
7622
464
    p->col_offset = col_offset;
7623
464
    p->end_lineno = end_lineno;
7624
464
    p->end_col_offset = end_col_offset;
7625
464
    return p;
7626
464
}
7627
7628
stmt_ty
7629
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7630
                end_lineno, int end_col_offset, PyArena *arena)
7631
99
{
7632
99
    stmt_ty p;
7633
99
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7634
99
    if (!p)
7635
0
        return NULL;
7636
99
    p->kind = Nonlocal_kind;
7637
99
    p->v.Nonlocal.names = names;
7638
99
    p->lineno = lineno;
7639
99
    p->col_offset = col_offset;
7640
99
    p->end_lineno = end_lineno;
7641
99
    p->end_col_offset = end_col_offset;
7642
99
    return p;
7643
99
}
7644
7645
stmt_ty
7646
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7647
            end_col_offset, PyArena *arena)
7648
87.8k
{
7649
87.8k
    stmt_ty p;
7650
87.8k
    if (!value) {
7651
0
        PyErr_SetString(PyExc_ValueError,
7652
0
                        "field 'value' is required for Expr");
7653
0
        return NULL;
7654
0
    }
7655
87.8k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7656
87.8k
    if (!p)
7657
0
        return NULL;
7658
87.8k
    p->kind = Expr_kind;
7659
87.8k
    p->v.Expr.value = value;
7660
87.8k
    p->lineno = lineno;
7661
87.8k
    p->col_offset = col_offset;
7662
87.8k
    p->end_lineno = end_lineno;
7663
87.8k
    p->end_col_offset = end_col_offset;
7664
87.8k
    return p;
7665
87.8k
}
7666
7667
stmt_ty
7668
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7669
            PyArena *arena)
7670
1.60k
{
7671
1.60k
    stmt_ty p;
7672
1.60k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7673
1.60k
    if (!p)
7674
0
        return NULL;
7675
1.60k
    p->kind = Pass_kind;
7676
1.60k
    p->lineno = lineno;
7677
1.60k
    p->col_offset = col_offset;
7678
1.60k
    p->end_lineno = end_lineno;
7679
1.60k
    p->end_col_offset = end_col_offset;
7680
1.60k
    return p;
7681
1.60k
}
7682
7683
stmt_ty
7684
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7685
             PyArena *arena)
7686
1.48k
{
7687
1.48k
    stmt_ty p;
7688
1.48k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7689
1.48k
    if (!p)
7690
0
        return NULL;
7691
1.48k
    p->kind = Break_kind;
7692
1.48k
    p->lineno = lineno;
7693
1.48k
    p->col_offset = col_offset;
7694
1.48k
    p->end_lineno = end_lineno;
7695
1.48k
    p->end_col_offset = end_col_offset;
7696
1.48k
    return p;
7697
1.48k
}
7698
7699
stmt_ty
7700
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7701
                PyArena *arena)
7702
2.81k
{
7703
2.81k
    stmt_ty p;
7704
2.81k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7705
2.81k
    if (!p)
7706
0
        return NULL;
7707
2.81k
    p->kind = Continue_kind;
7708
2.81k
    p->lineno = lineno;
7709
2.81k
    p->col_offset = col_offset;
7710
2.81k
    p->end_lineno = end_lineno;
7711
2.81k
    p->end_col_offset = end_col_offset;
7712
2.81k
    return p;
7713
2.81k
}
7714
7715
expr_ty
7716
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7717
              int end_lineno, int end_col_offset, PyArena *arena)
7718
2.33k
{
7719
2.33k
    expr_ty p;
7720
2.33k
    if (!op) {
7721
0
        PyErr_SetString(PyExc_ValueError,
7722
0
                        "field 'op' is required for BoolOp");
7723
0
        return NULL;
7724
0
    }
7725
2.33k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7726
2.33k
    if (!p)
7727
0
        return NULL;
7728
2.33k
    p->kind = BoolOp_kind;
7729
2.33k
    p->v.BoolOp.op = op;
7730
2.33k
    p->v.BoolOp.values = values;
7731
2.33k
    p->lineno = lineno;
7732
2.33k
    p->col_offset = col_offset;
7733
2.33k
    p->end_lineno = end_lineno;
7734
2.33k
    p->end_col_offset = end_col_offset;
7735
2.33k
    return p;
7736
2.33k
}
7737
7738
expr_ty
7739
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7740
                 end_lineno, int end_col_offset, PyArena *arena)
7741
1.48k
{
7742
1.48k
    expr_ty p;
7743
1.48k
    if (!target) {
7744
0
        PyErr_SetString(PyExc_ValueError,
7745
0
                        "field 'target' is required for NamedExpr");
7746
0
        return NULL;
7747
0
    }
7748
1.48k
    if (!value) {
7749
0
        PyErr_SetString(PyExc_ValueError,
7750
0
                        "field 'value' is required for NamedExpr");
7751
0
        return NULL;
7752
0
    }
7753
1.48k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7754
1.48k
    if (!p)
7755
0
        return NULL;
7756
1.48k
    p->kind = NamedExpr_kind;
7757
1.48k
    p->v.NamedExpr.target = target;
7758
1.48k
    p->v.NamedExpr.value = value;
7759
1.48k
    p->lineno = lineno;
7760
1.48k
    p->col_offset = col_offset;
7761
1.48k
    p->end_lineno = end_lineno;
7762
1.48k
    p->end_col_offset = end_col_offset;
7763
1.48k
    return p;
7764
1.48k
}
7765
7766
expr_ty
7767
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7768
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7769
37.9k
{
7770
37.9k
    expr_ty p;
7771
37.9k
    if (!left) {
7772
0
        PyErr_SetString(PyExc_ValueError,
7773
0
                        "field 'left' is required for BinOp");
7774
0
        return NULL;
7775
0
    }
7776
37.9k
    if (!op) {
7777
0
        PyErr_SetString(PyExc_ValueError,
7778
0
                        "field 'op' is required for BinOp");
7779
0
        return NULL;
7780
0
    }
7781
37.9k
    if (!right) {
7782
0
        PyErr_SetString(PyExc_ValueError,
7783
0
                        "field 'right' is required for BinOp");
7784
0
        return NULL;
7785
0
    }
7786
37.9k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7787
37.9k
    if (!p)
7788
0
        return NULL;
7789
37.9k
    p->kind = BinOp_kind;
7790
37.9k
    p->v.BinOp.left = left;
7791
37.9k
    p->v.BinOp.op = op;
7792
37.9k
    p->v.BinOp.right = right;
7793
37.9k
    p->lineno = lineno;
7794
37.9k
    p->col_offset = col_offset;
7795
37.9k
    p->end_lineno = end_lineno;
7796
37.9k
    p->end_col_offset = end_col_offset;
7797
37.9k
    return p;
7798
37.9k
}
7799
7800
expr_ty
7801
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7802
               end_lineno, int end_col_offset, PyArena *arena)
7803
169k
{
7804
169k
    expr_ty p;
7805
169k
    if (!op) {
7806
0
        PyErr_SetString(PyExc_ValueError,
7807
0
                        "field 'op' is required for UnaryOp");
7808
0
        return NULL;
7809
0
    }
7810
169k
    if (!operand) {
7811
0
        PyErr_SetString(PyExc_ValueError,
7812
0
                        "field 'operand' is required for UnaryOp");
7813
0
        return NULL;
7814
0
    }
7815
169k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7816
169k
    if (!p)
7817
0
        return NULL;
7818
169k
    p->kind = UnaryOp_kind;
7819
169k
    p->v.UnaryOp.op = op;
7820
169k
    p->v.UnaryOp.operand = operand;
7821
169k
    p->lineno = lineno;
7822
169k
    p->col_offset = col_offset;
7823
169k
    p->end_lineno = end_lineno;
7824
169k
    p->end_col_offset = end_col_offset;
7825
169k
    return p;
7826
169k
}
7827
7828
expr_ty
7829
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7830
              end_lineno, int end_col_offset, PyArena *arena)
7831
2.78k
{
7832
2.78k
    expr_ty p;
7833
2.78k
    if (!args) {
7834
0
        PyErr_SetString(PyExc_ValueError,
7835
0
                        "field 'args' is required for Lambda");
7836
0
        return NULL;
7837
0
    }
7838
2.78k
    if (!body) {
7839
0
        PyErr_SetString(PyExc_ValueError,
7840
0
                        "field 'body' is required for Lambda");
7841
0
        return NULL;
7842
0
    }
7843
2.78k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7844
2.78k
    if (!p)
7845
0
        return NULL;
7846
2.78k
    p->kind = Lambda_kind;
7847
2.78k
    p->v.Lambda.args = args;
7848
2.78k
    p->v.Lambda.body = body;
7849
2.78k
    p->lineno = lineno;
7850
2.78k
    p->col_offset = col_offset;
7851
2.78k
    p->end_lineno = end_lineno;
7852
2.78k
    p->end_col_offset = end_col_offset;
7853
2.78k
    return p;
7854
2.78k
}
7855
7856
expr_ty
7857
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7858
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7859
975
{
7860
975
    expr_ty p;
7861
975
    if (!test) {
7862
0
        PyErr_SetString(PyExc_ValueError,
7863
0
                        "field 'test' is required for IfExp");
7864
0
        return NULL;
7865
0
    }
7866
975
    if (!body) {
7867
0
        PyErr_SetString(PyExc_ValueError,
7868
0
                        "field 'body' is required for IfExp");
7869
0
        return NULL;
7870
0
    }
7871
975
    if (!orelse) {
7872
0
        PyErr_SetString(PyExc_ValueError,
7873
0
                        "field 'orelse' is required for IfExp");
7874
0
        return NULL;
7875
0
    }
7876
975
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7877
975
    if (!p)
7878
0
        return NULL;
7879
975
    p->kind = IfExp_kind;
7880
975
    p->v.IfExp.test = test;
7881
975
    p->v.IfExp.body = body;
7882
975
    p->v.IfExp.orelse = orelse;
7883
975
    p->lineno = lineno;
7884
975
    p->col_offset = col_offset;
7885
975
    p->end_lineno = end_lineno;
7886
975
    p->end_col_offset = end_col_offset;
7887
975
    return p;
7888
975
}
7889
7890
expr_ty
7891
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7892
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7893
4.69k
{
7894
4.69k
    expr_ty p;
7895
4.69k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7896
4.69k
    if (!p)
7897
0
        return NULL;
7898
4.69k
    p->kind = Dict_kind;
7899
4.69k
    p->v.Dict.keys = keys;
7900
4.69k
    p->v.Dict.values = values;
7901
4.69k
    p->lineno = lineno;
7902
4.69k
    p->col_offset = col_offset;
7903
4.69k
    p->end_lineno = end_lineno;
7904
4.69k
    p->end_col_offset = end_col_offset;
7905
4.69k
    return p;
7906
4.69k
}
7907
7908
expr_ty
7909
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7910
           int end_col_offset, PyArena *arena)
7911
1.04k
{
7912
1.04k
    expr_ty p;
7913
1.04k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7914
1.04k
    if (!p)
7915
0
        return NULL;
7916
1.04k
    p->kind = Set_kind;
7917
1.04k
    p->v.Set.elts = elts;
7918
1.04k
    p->lineno = lineno;
7919
1.04k
    p->col_offset = col_offset;
7920
1.04k
    p->end_lineno = end_lineno;
7921
1.04k
    p->end_col_offset = end_col_offset;
7922
1.04k
    return p;
7923
1.04k
}
7924
7925
expr_ty
7926
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7927
                int col_offset, int end_lineno, int end_col_offset, PyArena
7928
                *arena)
7929
750
{
7930
750
    expr_ty p;
7931
750
    if (!elt) {
7932
0
        PyErr_SetString(PyExc_ValueError,
7933
0
                        "field 'elt' is required for ListComp");
7934
0
        return NULL;
7935
0
    }
7936
750
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7937
750
    if (!p)
7938
0
        return NULL;
7939
750
    p->kind = ListComp_kind;
7940
750
    p->v.ListComp.elt = elt;
7941
750
    p->v.ListComp.generators = generators;
7942
750
    p->lineno = lineno;
7943
750
    p->col_offset = col_offset;
7944
750
    p->end_lineno = end_lineno;
7945
750
    p->end_col_offset = end_col_offset;
7946
750
    return p;
7947
750
}
7948
7949
expr_ty
7950
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7951
               int col_offset, int end_lineno, int end_col_offset, PyArena
7952
               *arena)
7953
844
{
7954
844
    expr_ty p;
7955
844
    if (!elt) {
7956
0
        PyErr_SetString(PyExc_ValueError,
7957
0
                        "field 'elt' is required for SetComp");
7958
0
        return NULL;
7959
0
    }
7960
844
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7961
844
    if (!p)
7962
0
        return NULL;
7963
844
    p->kind = SetComp_kind;
7964
844
    p->v.SetComp.elt = elt;
7965
844
    p->v.SetComp.generators = generators;
7966
844
    p->lineno = lineno;
7967
844
    p->col_offset = col_offset;
7968
844
    p->end_lineno = end_lineno;
7969
844
    p->end_col_offset = end_col_offset;
7970
844
    return p;
7971
844
}
7972
7973
expr_ty
7974
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
7975
                generators, int lineno, int col_offset, int end_lineno, int
7976
                end_col_offset, PyArena *arena)
7977
933
{
7978
933
    expr_ty p;
7979
933
    if (!key) {
7980
0
        PyErr_SetString(PyExc_ValueError,
7981
0
                        "field 'key' is required for DictComp");
7982
0
        return NULL;
7983
0
    }
7984
933
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7985
933
    if (!p)
7986
0
        return NULL;
7987
933
    p->kind = DictComp_kind;
7988
933
    p->v.DictComp.key = key;
7989
933
    p->v.DictComp.value = value;
7990
933
    p->v.DictComp.generators = generators;
7991
933
    p->lineno = lineno;
7992
933
    p->col_offset = col_offset;
7993
933
    p->end_lineno = end_lineno;
7994
933
    p->end_col_offset = end_col_offset;
7995
933
    return p;
7996
933
}
7997
7998
expr_ty
7999
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8000
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8001
                    PyArena *arena)
8002
3.96k
{
8003
3.96k
    expr_ty p;
8004
3.96k
    if (!elt) {
8005
0
        PyErr_SetString(PyExc_ValueError,
8006
0
                        "field 'elt' is required for GeneratorExp");
8007
0
        return NULL;
8008
0
    }
8009
3.96k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8010
3.96k
    if (!p)
8011
0
        return NULL;
8012
3.96k
    p->kind = GeneratorExp_kind;
8013
3.96k
    p->v.GeneratorExp.elt = elt;
8014
3.96k
    p->v.GeneratorExp.generators = generators;
8015
3.96k
    p->lineno = lineno;
8016
3.96k
    p->col_offset = col_offset;
8017
3.96k
    p->end_lineno = end_lineno;
8018
3.96k
    p->end_col_offset = end_col_offset;
8019
3.96k
    return p;
8020
3.96k
}
8021
8022
expr_ty
8023
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8024
             end_col_offset, PyArena *arena)
8025
378
{
8026
378
    expr_ty p;
8027
378
    if (!value) {
8028
0
        PyErr_SetString(PyExc_ValueError,
8029
0
                        "field 'value' is required for Await");
8030
0
        return NULL;
8031
0
    }
8032
378
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8033
378
    if (!p)
8034
0
        return NULL;
8035
378
    p->kind = Await_kind;
8036
378
    p->v.Await.value = value;
8037
378
    p->lineno = lineno;
8038
378
    p->col_offset = col_offset;
8039
378
    p->end_lineno = end_lineno;
8040
378
    p->end_col_offset = end_col_offset;
8041
378
    return p;
8042
378
}
8043
8044
expr_ty
8045
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8046
             end_col_offset, PyArena *arena)
8047
2.37k
{
8048
2.37k
    expr_ty p;
8049
2.37k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8050
2.37k
    if (!p)
8051
0
        return NULL;
8052
2.37k
    p->kind = Yield_kind;
8053
2.37k
    p->v.Yield.value = value;
8054
2.37k
    p->lineno = lineno;
8055
2.37k
    p->col_offset = col_offset;
8056
2.37k
    p->end_lineno = end_lineno;
8057
2.37k
    p->end_col_offset = end_col_offset;
8058
2.37k
    return p;
8059
2.37k
}
8060
8061
expr_ty
8062
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8063
                 end_col_offset, PyArena *arena)
8064
383
{
8065
383
    expr_ty p;
8066
383
    if (!value) {
8067
0
        PyErr_SetString(PyExc_ValueError,
8068
0
                        "field 'value' is required for YieldFrom");
8069
0
        return NULL;
8070
0
    }
8071
383
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8072
383
    if (!p)
8073
0
        return NULL;
8074
383
    p->kind = YieldFrom_kind;
8075
383
    p->v.YieldFrom.value = value;
8076
383
    p->lineno = lineno;
8077
383
    p->col_offset = col_offset;
8078
383
    p->end_lineno = end_lineno;
8079
383
    p->end_col_offset = end_col_offset;
8080
383
    return p;
8081
383
}
8082
8083
expr_ty
8084
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8085
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8086
               PyArena *arena)
8087
5.62k
{
8088
5.62k
    expr_ty p;
8089
5.62k
    if (!left) {
8090
0
        PyErr_SetString(PyExc_ValueError,
8091
0
                        "field 'left' is required for Compare");
8092
0
        return NULL;
8093
0
    }
8094
5.62k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8095
5.62k
    if (!p)
8096
0
        return NULL;
8097
5.62k
    p->kind = Compare_kind;
8098
5.62k
    p->v.Compare.left = left;
8099
5.62k
    p->v.Compare.ops = ops;
8100
5.62k
    p->v.Compare.comparators = comparators;
8101
5.62k
    p->lineno = lineno;
8102
5.62k
    p->col_offset = col_offset;
8103
5.62k
    p->end_lineno = end_lineno;
8104
5.62k
    p->end_col_offset = end_col_offset;
8105
5.62k
    return p;
8106
5.62k
}
8107
8108
expr_ty
8109
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8110
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8111
            PyArena *arena)
8112
59.8k
{
8113
59.8k
    expr_ty p;
8114
59.8k
    if (!func) {
8115
0
        PyErr_SetString(PyExc_ValueError,
8116
0
                        "field 'func' is required for Call");
8117
0
        return NULL;
8118
0
    }
8119
59.8k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8120
59.8k
    if (!p)
8121
0
        return NULL;
8122
59.8k
    p->kind = Call_kind;
8123
59.8k
    p->v.Call.func = func;
8124
59.8k
    p->v.Call.args = args;
8125
59.8k
    p->v.Call.keywords = keywords;
8126
59.8k
    p->lineno = lineno;
8127
59.8k
    p->col_offset = col_offset;
8128
59.8k
    p->end_lineno = end_lineno;
8129
59.8k
    p->end_col_offset = end_col_offset;
8130
59.8k
    return p;
8131
59.8k
}
8132
8133
expr_ty
8134
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8135
                      lineno, int col_offset, int end_lineno, int
8136
                      end_col_offset, PyArena *arena)
8137
22.4k
{
8138
22.4k
    expr_ty p;
8139
22.4k
    if (!value) {
8140
0
        PyErr_SetString(PyExc_ValueError,
8141
0
                        "field 'value' is required for FormattedValue");
8142
0
        return NULL;
8143
0
    }
8144
22.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8145
22.4k
    if (!p)
8146
0
        return NULL;
8147
22.4k
    p->kind = FormattedValue_kind;
8148
22.4k
    p->v.FormattedValue.value = value;
8149
22.4k
    p->v.FormattedValue.conversion = conversion;
8150
22.4k
    p->v.FormattedValue.format_spec = format_spec;
8151
22.4k
    p->lineno = lineno;
8152
22.4k
    p->col_offset = col_offset;
8153
22.4k
    p->end_lineno = end_lineno;
8154
22.4k
    p->end_col_offset = end_col_offset;
8155
22.4k
    return p;
8156
22.4k
}
8157
8158
expr_ty
8159
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8160
                     format_spec, int lineno, int col_offset, int end_lineno,
8161
                     int end_col_offset, PyArena *arena)
8162
5.19k
{
8163
5.19k
    expr_ty p;
8164
5.19k
    if (!value) {
8165
0
        PyErr_SetString(PyExc_ValueError,
8166
0
                        "field 'value' is required for Interpolation");
8167
0
        return NULL;
8168
0
    }
8169
5.19k
    if (!str) {
8170
0
        PyErr_SetString(PyExc_ValueError,
8171
0
                        "field 'str' is required for Interpolation");
8172
0
        return NULL;
8173
0
    }
8174
5.19k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8175
5.19k
    if (!p)
8176
0
        return NULL;
8177
5.19k
    p->kind = Interpolation_kind;
8178
5.19k
    p->v.Interpolation.value = value;
8179
5.19k
    p->v.Interpolation.str = str;
8180
5.19k
    p->v.Interpolation.conversion = conversion;
8181
5.19k
    p->v.Interpolation.format_spec = format_spec;
8182
5.19k
    p->lineno = lineno;
8183
5.19k
    p->col_offset = col_offset;
8184
5.19k
    p->end_lineno = end_lineno;
8185
5.19k
    p->end_col_offset = end_col_offset;
8186
5.19k
    return p;
8187
5.19k
}
8188
8189
expr_ty
8190
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8191
                 end_lineno, int end_col_offset, PyArena *arena)
8192
34.8k
{
8193
34.8k
    expr_ty p;
8194
34.8k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8195
34.8k
    if (!p)
8196
0
        return NULL;
8197
34.8k
    p->kind = JoinedStr_kind;
8198
34.8k
    p->v.JoinedStr.values = values;
8199
34.8k
    p->lineno = lineno;
8200
34.8k
    p->col_offset = col_offset;
8201
34.8k
    p->end_lineno = end_lineno;
8202
34.8k
    p->end_col_offset = end_col_offset;
8203
34.8k
    return p;
8204
34.8k
}
8205
8206
expr_ty
8207
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8208
                   end_lineno, int end_col_offset, PyArena *arena)
8209
8.17k
{
8210
8.17k
    expr_ty p;
8211
8.17k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8212
8.17k
    if (!p)
8213
0
        return NULL;
8214
8.17k
    p->kind = TemplateStr_kind;
8215
8.17k
    p->v.TemplateStr.values = values;
8216
8.17k
    p->lineno = lineno;
8217
8.17k
    p->col_offset = col_offset;
8218
8.17k
    p->end_lineno = end_lineno;
8219
8.17k
    p->end_col_offset = end_col_offset;
8220
8.17k
    return p;
8221
8.17k
}
8222
8223
expr_ty
8224
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8225
                end_lineno, int end_col_offset, PyArena *arena)
8226
347k
{
8227
347k
    expr_ty p;
8228
347k
    if (!value) {
8229
3
        PyErr_SetString(PyExc_ValueError,
8230
3
                        "field 'value' is required for Constant");
8231
3
        return NULL;
8232
3
    }
8233
347k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8234
347k
    if (!p)
8235
0
        return NULL;
8236
347k
    p->kind = Constant_kind;
8237
347k
    p->v.Constant.value = value;
8238
347k
    p->v.Constant.kind = kind;
8239
347k
    p->lineno = lineno;
8240
347k
    p->col_offset = col_offset;
8241
347k
    p->end_lineno = end_lineno;
8242
347k
    p->end_col_offset = end_col_offset;
8243
347k
    return p;
8244
347k
}
8245
8246
expr_ty
8247
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8248
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8249
                 PyArena *arena)
8250
33.2k
{
8251
33.2k
    expr_ty p;
8252
33.2k
    if (!value) {
8253
0
        PyErr_SetString(PyExc_ValueError,
8254
0
                        "field 'value' is required for Attribute");
8255
0
        return NULL;
8256
0
    }
8257
33.2k
    if (!attr) {
8258
0
        PyErr_SetString(PyExc_ValueError,
8259
0
                        "field 'attr' is required for Attribute");
8260
0
        return NULL;
8261
0
    }
8262
33.2k
    if (!ctx) {
8263
0
        PyErr_SetString(PyExc_ValueError,
8264
0
                        "field 'ctx' is required for Attribute");
8265
0
        return NULL;
8266
0
    }
8267
33.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8268
33.2k
    if (!p)
8269
0
        return NULL;
8270
33.2k
    p->kind = Attribute_kind;
8271
33.2k
    p->v.Attribute.value = value;
8272
33.2k
    p->v.Attribute.attr = attr;
8273
33.2k
    p->v.Attribute.ctx = ctx;
8274
33.2k
    p->lineno = lineno;
8275
33.2k
    p->col_offset = col_offset;
8276
33.2k
    p->end_lineno = end_lineno;
8277
33.2k
    p->end_col_offset = end_col_offset;
8278
33.2k
    return p;
8279
33.2k
}
8280
8281
expr_ty
8282
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8283
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8284
                 *arena)
8285
5.50k
{
8286
5.50k
    expr_ty p;
8287
5.50k
    if (!value) {
8288
0
        PyErr_SetString(PyExc_ValueError,
8289
0
                        "field 'value' is required for Subscript");
8290
0
        return NULL;
8291
0
    }
8292
5.50k
    if (!slice) {
8293
0
        PyErr_SetString(PyExc_ValueError,
8294
0
                        "field 'slice' is required for Subscript");
8295
0
        return NULL;
8296
0
    }
8297
5.50k
    if (!ctx) {
8298
0
        PyErr_SetString(PyExc_ValueError,
8299
0
                        "field 'ctx' is required for Subscript");
8300
0
        return NULL;
8301
0
    }
8302
5.50k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8303
5.50k
    if (!p)
8304
0
        return NULL;
8305
5.50k
    p->kind = Subscript_kind;
8306
5.50k
    p->v.Subscript.value = value;
8307
5.50k
    p->v.Subscript.slice = slice;
8308
5.50k
    p->v.Subscript.ctx = ctx;
8309
5.50k
    p->lineno = lineno;
8310
5.50k
    p->col_offset = col_offset;
8311
5.50k
    p->end_lineno = end_lineno;
8312
5.50k
    p->end_col_offset = end_col_offset;
8313
5.50k
    return p;
8314
5.50k
}
8315
8316
expr_ty
8317
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8318
               int end_lineno, int end_col_offset, PyArena *arena)
8319
19.1k
{
8320
19.1k
    expr_ty p;
8321
19.1k
    if (!value) {
8322
0
        PyErr_SetString(PyExc_ValueError,
8323
0
                        "field 'value' is required for Starred");
8324
0
        return NULL;
8325
0
    }
8326
19.1k
    if (!ctx) {
8327
0
        PyErr_SetString(PyExc_ValueError,
8328
0
                        "field 'ctx' is required for Starred");
8329
0
        return NULL;
8330
0
    }
8331
19.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8332
19.1k
    if (!p)
8333
0
        return NULL;
8334
19.1k
    p->kind = Starred_kind;
8335
19.1k
    p->v.Starred.value = value;
8336
19.1k
    p->v.Starred.ctx = ctx;
8337
19.1k
    p->lineno = lineno;
8338
19.1k
    p->col_offset = col_offset;
8339
19.1k
    p->end_lineno = end_lineno;
8340
19.1k
    p->end_col_offset = end_col_offset;
8341
19.1k
    return p;
8342
19.1k
}
8343
8344
expr_ty
8345
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8346
            end_lineno, int end_col_offset, PyArena *arena)
8347
12.3M
{
8348
12.3M
    expr_ty p;
8349
12.3M
    if (!id) {
8350
0
        PyErr_SetString(PyExc_ValueError,
8351
0
                        "field 'id' is required for Name");
8352
0
        return NULL;
8353
0
    }
8354
12.3M
    if (!ctx) {
8355
0
        PyErr_SetString(PyExc_ValueError,
8356
0
                        "field 'ctx' is required for Name");
8357
0
        return NULL;
8358
0
    }
8359
12.3M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8360
12.3M
    if (!p)
8361
0
        return NULL;
8362
12.3M
    p->kind = Name_kind;
8363
12.3M
    p->v.Name.id = id;
8364
12.3M
    p->v.Name.ctx = ctx;
8365
12.3M
    p->lineno = lineno;
8366
12.3M
    p->col_offset = col_offset;
8367
12.3M
    p->end_lineno = end_lineno;
8368
12.3M
    p->end_col_offset = end_col_offset;
8369
12.3M
    return p;
8370
12.3M
}
8371
8372
expr_ty
8373
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8374
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8375
18.3k
{
8376
18.3k
    expr_ty p;
8377
18.3k
    if (!ctx) {
8378
0
        PyErr_SetString(PyExc_ValueError,
8379
0
                        "field 'ctx' is required for List");
8380
0
        return NULL;
8381
0
    }
8382
18.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8383
18.3k
    if (!p)
8384
0
        return NULL;
8385
18.3k
    p->kind = List_kind;
8386
18.3k
    p->v.List.elts = elts;
8387
18.3k
    p->v.List.ctx = ctx;
8388
18.3k
    p->lineno = lineno;
8389
18.3k
    p->col_offset = col_offset;
8390
18.3k
    p->end_lineno = end_lineno;
8391
18.3k
    p->end_col_offset = end_col_offset;
8392
18.3k
    return p;
8393
18.3k
}
8394
8395
expr_ty
8396
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8397
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8398
82.3k
{
8399
82.3k
    expr_ty p;
8400
82.3k
    if (!ctx) {
8401
0
        PyErr_SetString(PyExc_ValueError,
8402
0
                        "field 'ctx' is required for Tuple");
8403
0
        return NULL;
8404
0
    }
8405
82.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8406
82.3k
    if (!p)
8407
0
        return NULL;
8408
82.3k
    p->kind = Tuple_kind;
8409
82.3k
    p->v.Tuple.elts = elts;
8410
82.3k
    p->v.Tuple.ctx = ctx;
8411
82.3k
    p->lineno = lineno;
8412
82.3k
    p->col_offset = col_offset;
8413
82.3k
    p->end_lineno = end_lineno;
8414
82.3k
    p->end_col_offset = end_col_offset;
8415
82.3k
    return p;
8416
82.3k
}
8417
8418
expr_ty
8419
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8420
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8421
16.1k
{
8422
16.1k
    expr_ty p;
8423
16.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8424
16.1k
    if (!p)
8425
0
        return NULL;
8426
16.1k
    p->kind = Slice_kind;
8427
16.1k
    p->v.Slice.lower = lower;
8428
16.1k
    p->v.Slice.upper = upper;
8429
16.1k
    p->v.Slice.step = step;
8430
16.1k
    p->lineno = lineno;
8431
16.1k
    p->col_offset = col_offset;
8432
16.1k
    p->end_lineno = end_lineno;
8433
16.1k
    p->end_col_offset = end_col_offset;
8434
16.1k
    return p;
8435
16.1k
}
8436
8437
comprehension_ty
8438
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8439
                     is_async, PyArena *arena)
8440
8.75k
{
8441
8.75k
    comprehension_ty p;
8442
8.75k
    if (!target) {
8443
0
        PyErr_SetString(PyExc_ValueError,
8444
0
                        "field 'target' is required for comprehension");
8445
0
        return NULL;
8446
0
    }
8447
8.75k
    if (!iter) {
8448
0
        PyErr_SetString(PyExc_ValueError,
8449
0
                        "field 'iter' is required for comprehension");
8450
0
        return NULL;
8451
0
    }
8452
8.75k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8453
8.75k
    if (!p)
8454
0
        return NULL;
8455
8.75k
    p->target = target;
8456
8.75k
    p->iter = iter;
8457
8.75k
    p->ifs = ifs;
8458
8.75k
    p->is_async = is_async;
8459
8.75k
    return p;
8460
8.75k
}
8461
8462
excepthandler_ty
8463
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8464
                     lineno, int col_offset, int end_lineno, int
8465
                     end_col_offset, PyArena *arena)
8466
7.43k
{
8467
7.43k
    excepthandler_ty p;
8468
7.43k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8469
7.43k
    if (!p)
8470
0
        return NULL;
8471
7.43k
    p->kind = ExceptHandler_kind;
8472
7.43k
    p->v.ExceptHandler.type = type;
8473
7.43k
    p->v.ExceptHandler.name = name;
8474
7.43k
    p->v.ExceptHandler.body = body;
8475
7.43k
    p->lineno = lineno;
8476
7.43k
    p->col_offset = col_offset;
8477
7.43k
    p->end_lineno = end_lineno;
8478
7.43k
    p->end_col_offset = end_col_offset;
8479
7.43k
    return p;
8480
7.43k
}
8481
8482
arguments_ty
8483
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8484
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8485
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8486
                 *arena)
8487
342k
{
8488
342k
    arguments_ty p;
8489
342k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8490
342k
    if (!p)
8491
0
        return NULL;
8492
342k
    p->posonlyargs = posonlyargs;
8493
342k
    p->args = args;
8494
342k
    p->vararg = vararg;
8495
342k
    p->kwonlyargs = kwonlyargs;
8496
342k
    p->kw_defaults = kw_defaults;
8497
342k
    p->kwarg = kwarg;
8498
342k
    p->defaults = defaults;
8499
342k
    return p;
8500
342k
}
8501
8502
arg_ty
8503
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8504
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8505
10.5M
{
8506
10.5M
    arg_ty p;
8507
10.5M
    if (!arg) {
8508
0
        PyErr_SetString(PyExc_ValueError,
8509
0
                        "field 'arg' is required for arg");
8510
0
        return NULL;
8511
0
    }
8512
10.5M
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8513
10.5M
    if (!p)
8514
0
        return NULL;
8515
10.5M
    p->arg = arg;
8516
10.5M
    p->annotation = annotation;
8517
10.5M
    p->type_comment = type_comment;
8518
10.5M
    p->lineno = lineno;
8519
10.5M
    p->col_offset = col_offset;
8520
10.5M
    p->end_lineno = end_lineno;
8521
10.5M
    p->end_col_offset = end_col_offset;
8522
10.5M
    return p;
8523
10.5M
}
8524
8525
keyword_ty
8526
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8527
               end_lineno, int end_col_offset, PyArena *arena)
8528
35.3k
{
8529
35.3k
    keyword_ty p;
8530
35.3k
    if (!value) {
8531
0
        PyErr_SetString(PyExc_ValueError,
8532
0
                        "field 'value' is required for keyword");
8533
0
        return NULL;
8534
0
    }
8535
35.3k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8536
35.3k
    if (!p)
8537
0
        return NULL;
8538
35.3k
    p->arg = arg;
8539
35.3k
    p->value = value;
8540
35.3k
    p->lineno = lineno;
8541
35.3k
    p->col_offset = col_offset;
8542
35.3k
    p->end_lineno = end_lineno;
8543
35.3k
    p->end_col_offset = end_col_offset;
8544
35.3k
    return p;
8545
35.3k
}
8546
8547
alias_ty
8548
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8549
             int end_lineno, int end_col_offset, PyArena *arena)
8550
12.0k
{
8551
12.0k
    alias_ty p;
8552
12.0k
    if (!name) {
8553
0
        PyErr_SetString(PyExc_ValueError,
8554
0
                        "field 'name' is required for alias");
8555
0
        return NULL;
8556
0
    }
8557
12.0k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8558
12.0k
    if (!p)
8559
0
        return NULL;
8560
12.0k
    p->name = name;
8561
12.0k
    p->asname = asname;
8562
12.0k
    p->lineno = lineno;
8563
12.0k
    p->col_offset = col_offset;
8564
12.0k
    p->end_lineno = end_lineno;
8565
12.0k
    p->end_col_offset = end_col_offset;
8566
12.0k
    return p;
8567
12.0k
}
8568
8569
withitem_ty
8570
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8571
7.12k
{
8572
7.12k
    withitem_ty p;
8573
7.12k
    if (!context_expr) {
8574
0
        PyErr_SetString(PyExc_ValueError,
8575
0
                        "field 'context_expr' is required for withitem");
8576
0
        return NULL;
8577
0
    }
8578
7.12k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8579
7.12k
    if (!p)
8580
0
        return NULL;
8581
7.12k
    p->context_expr = context_expr;
8582
7.12k
    p->optional_vars = optional_vars;
8583
7.12k
    return p;
8584
7.12k
}
8585
8586
match_case_ty
8587
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8588
                  PyArena *arena)
8589
2.73k
{
8590
2.73k
    match_case_ty p;
8591
2.73k
    if (!pattern) {
8592
0
        PyErr_SetString(PyExc_ValueError,
8593
0
                        "field 'pattern' is required for match_case");
8594
0
        return NULL;
8595
0
    }
8596
2.73k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8597
2.73k
    if (!p)
8598
0
        return NULL;
8599
2.73k
    p->pattern = pattern;
8600
2.73k
    p->guard = guard;
8601
2.73k
    p->body = body;
8602
2.73k
    return p;
8603
2.73k
}
8604
8605
pattern_ty
8606
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8607
                  int end_col_offset, PyArena *arena)
8608
4.79k
{
8609
4.79k
    pattern_ty p;
8610
4.79k
    if (!value) {
8611
0
        PyErr_SetString(PyExc_ValueError,
8612
0
                        "field 'value' is required for MatchValue");
8613
0
        return NULL;
8614
0
    }
8615
4.79k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8616
4.79k
    if (!p)
8617
0
        return NULL;
8618
4.79k
    p->kind = MatchValue_kind;
8619
4.79k
    p->v.MatchValue.value = value;
8620
4.79k
    p->lineno = lineno;
8621
4.79k
    p->col_offset = col_offset;
8622
4.79k
    p->end_lineno = end_lineno;
8623
4.79k
    p->end_col_offset = end_col_offset;
8624
4.79k
    return p;
8625
4.79k
}
8626
8627
pattern_ty
8628
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8629
                      end_lineno, int end_col_offset, PyArena *arena)
8630
923
{
8631
923
    pattern_ty p;
8632
923
    if (!value) {
8633
0
        PyErr_SetString(PyExc_ValueError,
8634
0
                        "field 'value' is required for MatchSingleton");
8635
0
        return NULL;
8636
0
    }
8637
923
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8638
923
    if (!p)
8639
0
        return NULL;
8640
923
    p->kind = MatchSingleton_kind;
8641
923
    p->v.MatchSingleton.value = value;
8642
923
    p->lineno = lineno;
8643
923
    p->col_offset = col_offset;
8644
923
    p->end_lineno = end_lineno;
8645
923
    p->end_col_offset = end_col_offset;
8646
923
    return p;
8647
923
}
8648
8649
pattern_ty
8650
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8651
                     int end_lineno, int end_col_offset, PyArena *arena)
8652
2.83k
{
8653
2.83k
    pattern_ty p;
8654
2.83k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8655
2.83k
    if (!p)
8656
0
        return NULL;
8657
2.83k
    p->kind = MatchSequence_kind;
8658
2.83k
    p->v.MatchSequence.patterns = patterns;
8659
2.83k
    p->lineno = lineno;
8660
2.83k
    p->col_offset = col_offset;
8661
2.83k
    p->end_lineno = end_lineno;
8662
2.83k
    p->end_col_offset = end_col_offset;
8663
2.83k
    return p;
8664
2.83k
}
8665
8666
pattern_ty
8667
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8668
                    identifier rest, int lineno, int col_offset, int
8669
                    end_lineno, int end_col_offset, PyArena *arena)
8670
1.14k
{
8671
1.14k
    pattern_ty p;
8672
1.14k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8673
1.14k
    if (!p)
8674
0
        return NULL;
8675
1.14k
    p->kind = MatchMapping_kind;
8676
1.14k
    p->v.MatchMapping.keys = keys;
8677
1.14k
    p->v.MatchMapping.patterns = patterns;
8678
1.14k
    p->v.MatchMapping.rest = rest;
8679
1.14k
    p->lineno = lineno;
8680
1.14k
    p->col_offset = col_offset;
8681
1.14k
    p->end_lineno = end_lineno;
8682
1.14k
    p->end_col_offset = end_col_offset;
8683
1.14k
    return p;
8684
1.14k
}
8685
8686
pattern_ty
8687
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8688
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8689
                  col_offset, int end_lineno, int end_col_offset, PyArena
8690
                  *arena)
8691
1.74k
{
8692
1.74k
    pattern_ty p;
8693
1.74k
    if (!cls) {
8694
0
        PyErr_SetString(PyExc_ValueError,
8695
0
                        "field 'cls' is required for MatchClass");
8696
0
        return NULL;
8697
0
    }
8698
1.74k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8699
1.74k
    if (!p)
8700
0
        return NULL;
8701
1.74k
    p->kind = MatchClass_kind;
8702
1.74k
    p->v.MatchClass.cls = cls;
8703
1.74k
    p->v.MatchClass.patterns = patterns;
8704
1.74k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8705
1.74k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8706
1.74k
    p->lineno = lineno;
8707
1.74k
    p->col_offset = col_offset;
8708
1.74k
    p->end_lineno = end_lineno;
8709
1.74k
    p->end_col_offset = end_col_offset;
8710
1.74k
    return p;
8711
1.74k
}
8712
8713
pattern_ty
8714
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8715
                 int end_col_offset, PyArena *arena)
8716
1.04k
{
8717
1.04k
    pattern_ty p;
8718
1.04k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8719
1.04k
    if (!p)
8720
0
        return NULL;
8721
1.04k
    p->kind = MatchStar_kind;
8722
1.04k
    p->v.MatchStar.name = name;
8723
1.04k
    p->lineno = lineno;
8724
1.04k
    p->col_offset = col_offset;
8725
1.04k
    p->end_lineno = end_lineno;
8726
1.04k
    p->end_col_offset = end_col_offset;
8727
1.04k
    return p;
8728
1.04k
}
8729
8730
pattern_ty
8731
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8732
               int end_lineno, int end_col_offset, PyArena *arena)
8733
21.8k
{
8734
21.8k
    pattern_ty p;
8735
21.8k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8736
21.8k
    if (!p)
8737
0
        return NULL;
8738
21.8k
    p->kind = MatchAs_kind;
8739
21.8k
    p->v.MatchAs.pattern = pattern;
8740
21.8k
    p->v.MatchAs.name = name;
8741
21.8k
    p->lineno = lineno;
8742
21.8k
    p->col_offset = col_offset;
8743
21.8k
    p->end_lineno = end_lineno;
8744
21.8k
    p->end_col_offset = end_col_offset;
8745
21.8k
    return p;
8746
21.8k
}
8747
8748
pattern_ty
8749
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8750
               end_lineno, int end_col_offset, PyArena *arena)
8751
8.89k
{
8752
8.89k
    pattern_ty p;
8753
8.89k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8754
8.89k
    if (!p)
8755
0
        return NULL;
8756
8.89k
    p->kind = MatchOr_kind;
8757
8.89k
    p->v.MatchOr.patterns = patterns;
8758
8.89k
    p->lineno = lineno;
8759
8.89k
    p->col_offset = col_offset;
8760
8.89k
    p->end_lineno = end_lineno;
8761
8.89k
    p->end_col_offset = end_col_offset;
8762
8.89k
    return p;
8763
8.89k
}
8764
8765
type_ignore_ty
8766
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8767
0
{
8768
0
    type_ignore_ty p;
8769
0
    if (!tag) {
8770
0
        PyErr_SetString(PyExc_ValueError,
8771
0
                        "field 'tag' is required for TypeIgnore");
8772
0
        return NULL;
8773
0
    }
8774
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8775
0
    if (!p)
8776
0
        return NULL;
8777
0
    p->kind = TypeIgnore_kind;
8778
0
    p->v.TypeIgnore.lineno = lineno;
8779
0
    p->v.TypeIgnore.tag = tag;
8780
0
    return p;
8781
0
}
8782
8783
type_param_ty
8784
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8785
               lineno, int col_offset, int end_lineno, int end_col_offset,
8786
               PyArena *arena)
8787
6.59k
{
8788
6.59k
    type_param_ty p;
8789
6.59k
    if (!name) {
8790
0
        PyErr_SetString(PyExc_ValueError,
8791
0
                        "field 'name' is required for TypeVar");
8792
0
        return NULL;
8793
0
    }
8794
6.59k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8795
6.59k
    if (!p)
8796
0
        return NULL;
8797
6.59k
    p->kind = TypeVar_kind;
8798
6.59k
    p->v.TypeVar.name = name;
8799
6.59k
    p->v.TypeVar.bound = bound;
8800
6.59k
    p->v.TypeVar.default_value = default_value;
8801
6.59k
    p->lineno = lineno;
8802
6.59k
    p->col_offset = col_offset;
8803
6.59k
    p->end_lineno = end_lineno;
8804
6.59k
    p->end_col_offset = end_col_offset;
8805
6.59k
    return p;
8806
6.59k
}
8807
8808
type_param_ty
8809
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8810
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8811
961
{
8812
961
    type_param_ty p;
8813
961
    if (!name) {
8814
0
        PyErr_SetString(PyExc_ValueError,
8815
0
                        "field 'name' is required for ParamSpec");
8816
0
        return NULL;
8817
0
    }
8818
961
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8819
961
    if (!p)
8820
0
        return NULL;
8821
961
    p->kind = ParamSpec_kind;
8822
961
    p->v.ParamSpec.name = name;
8823
961
    p->v.ParamSpec.default_value = default_value;
8824
961
    p->lineno = lineno;
8825
961
    p->col_offset = col_offset;
8826
961
    p->end_lineno = end_lineno;
8827
961
    p->end_col_offset = end_col_offset;
8828
961
    return p;
8829
961
}
8830
8831
type_param_ty
8832
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8833
                    col_offset, int end_lineno, int end_col_offset, PyArena
8834
                    *arena)
8835
1.81k
{
8836
1.81k
    type_param_ty p;
8837
1.81k
    if (!name) {
8838
0
        PyErr_SetString(PyExc_ValueError,
8839
0
                        "field 'name' is required for TypeVarTuple");
8840
0
        return NULL;
8841
0
    }
8842
1.81k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8843
1.81k
    if (!p)
8844
0
        return NULL;
8845
1.81k
    p->kind = TypeVarTuple_kind;
8846
1.81k
    p->v.TypeVarTuple.name = name;
8847
1.81k
    p->v.TypeVarTuple.default_value = default_value;
8848
1.81k
    p->lineno = lineno;
8849
1.81k
    p->col_offset = col_offset;
8850
1.81k
    p->end_lineno = end_lineno;
8851
1.81k
    p->end_col_offset = end_col_offset;
8852
1.81k
    return p;
8853
1.81k
}
8854
8855
8856
PyObject*
8857
ast2obj_mod(struct ast_state *state, void* _o)
8858
6.28k
{
8859
6.28k
    mod_ty o = (mod_ty)_o;
8860
6.28k
    PyObject *result = NULL, *value = NULL;
8861
6.28k
    PyTypeObject *tp;
8862
6.28k
    if (!o) {
8863
0
        Py_RETURN_NONE;
8864
0
    }
8865
6.28k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8866
0
        return NULL;
8867
0
    }
8868
6.28k
    switch (o->kind) {
8869
6.28k
    case Module_kind:
8870
6.28k
        tp = (PyTypeObject *)state->Module_type;
8871
6.28k
        result = PyType_GenericNew(tp, NULL, NULL);
8872
6.28k
        if (!result) goto failed;
8873
6.28k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8874
6.28k
        if (!value) goto failed;
8875
6.28k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8876
0
            goto failed;
8877
6.28k
        Py_DECREF(value);
8878
6.28k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8879
6.28k
                             ast2obj_type_ignore);
8880
6.28k
        if (!value) goto failed;
8881
6.28k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8882
0
            goto failed;
8883
6.28k
        Py_DECREF(value);
8884
6.28k
        break;
8885
0
    case Interactive_kind:
8886
0
        tp = (PyTypeObject *)state->Interactive_type;
8887
0
        result = PyType_GenericNew(tp, NULL, NULL);
8888
0
        if (!result) goto failed;
8889
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8890
0
                             ast2obj_stmt);
8891
0
        if (!value) goto failed;
8892
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8893
0
            goto failed;
8894
0
        Py_DECREF(value);
8895
0
        break;
8896
0
    case Expression_kind:
8897
0
        tp = (PyTypeObject *)state->Expression_type;
8898
0
        result = PyType_GenericNew(tp, NULL, NULL);
8899
0
        if (!result) goto failed;
8900
0
        value = ast2obj_expr(state, o->v.Expression.body);
8901
0
        if (!value) goto failed;
8902
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8903
0
            goto failed;
8904
0
        Py_DECREF(value);
8905
0
        break;
8906
0
    case FunctionType_kind:
8907
0
        tp = (PyTypeObject *)state->FunctionType_type;
8908
0
        result = PyType_GenericNew(tp, NULL, NULL);
8909
0
        if (!result) goto failed;
8910
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8911
0
                             ast2obj_expr);
8912
0
        if (!value) goto failed;
8913
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8914
0
            goto failed;
8915
0
        Py_DECREF(value);
8916
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8917
0
        if (!value) goto failed;
8918
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8919
0
            goto failed;
8920
0
        Py_DECREF(value);
8921
0
        break;
8922
6.28k
    }
8923
6.28k
    Py_LeaveRecursiveCall();
8924
6.28k
    return result;
8925
0
failed:
8926
0
    Py_LeaveRecursiveCall();
8927
0
    Py_XDECREF(value);
8928
0
    Py_XDECREF(result);
8929
0
    return NULL;
8930
6.28k
}
8931
8932
PyObject*
8933
ast2obj_stmt(struct ast_state *state, void* _o)
8934
43.9k
{
8935
43.9k
    stmt_ty o = (stmt_ty)_o;
8936
43.9k
    PyObject *result = NULL, *value = NULL;
8937
43.9k
    PyTypeObject *tp;
8938
43.9k
    if (!o) {
8939
0
        Py_RETURN_NONE;
8940
0
    }
8941
43.9k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8942
0
        return NULL;
8943
0
    }
8944
43.9k
    switch (o->kind) {
8945
1.35k
    case FunctionDef_kind:
8946
1.35k
        tp = (PyTypeObject *)state->FunctionDef_type;
8947
1.35k
        result = PyType_GenericNew(tp, NULL, NULL);
8948
1.35k
        if (!result) goto failed;
8949
1.35k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8950
1.35k
        if (!value) goto failed;
8951
1.35k
        if (PyObject_SetAttr(result, state->name, value) == -1)
8952
0
            goto failed;
8953
1.35k
        Py_DECREF(value);
8954
1.35k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8955
1.35k
        if (!value) goto failed;
8956
1.35k
        if (PyObject_SetAttr(result, state->args, value) == -1)
8957
0
            goto failed;
8958
1.35k
        Py_DECREF(value);
8959
1.35k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8960
1.35k
                             ast2obj_stmt);
8961
1.35k
        if (!value) goto failed;
8962
1.35k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8963
0
            goto failed;
8964
1.35k
        Py_DECREF(value);
8965
1.35k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8966
1.35k
                             ast2obj_expr);
8967
1.35k
        if (!value) goto failed;
8968
1.35k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
8969
0
            goto failed;
8970
1.35k
        Py_DECREF(value);
8971
1.35k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
8972
1.35k
        if (!value) goto failed;
8973
1.35k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8974
0
            goto failed;
8975
1.35k
        Py_DECREF(value);
8976
1.35k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
8977
1.35k
        if (!value) goto failed;
8978
1.35k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
8979
0
            goto failed;
8980
1.35k
        Py_DECREF(value);
8981
1.35k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
8982
1.35k
                             ast2obj_type_param);
8983
1.35k
        if (!value) goto failed;
8984
1.35k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
8985
0
            goto failed;
8986
1.35k
        Py_DECREF(value);
8987
1.35k
        break;
8988
301
    case AsyncFunctionDef_kind:
8989
301
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
8990
301
        result = PyType_GenericNew(tp, NULL, NULL);
8991
301
        if (!result) goto failed;
8992
301
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
8993
301
        if (!value) goto failed;
8994
301
        if (PyObject_SetAttr(result, state->name, value) == -1)
8995
0
            goto failed;
8996
301
        Py_DECREF(value);
8997
301
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
8998
301
        if (!value) goto failed;
8999
301
        if (PyObject_SetAttr(result, state->args, value) == -1)
9000
0
            goto failed;
9001
301
        Py_DECREF(value);
9002
301
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9003
301
                             ast2obj_stmt);
9004
301
        if (!value) goto failed;
9005
301
        if (PyObject_SetAttr(result, state->body, value) == -1)
9006
0
            goto failed;
9007
301
        Py_DECREF(value);
9008
301
        value = ast2obj_list(state,
9009
301
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9010
301
                             ast2obj_expr);
9011
301
        if (!value) goto failed;
9012
301
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9013
0
            goto failed;
9014
301
        Py_DECREF(value);
9015
301
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9016
301
        if (!value) goto failed;
9017
301
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9018
0
            goto failed;
9019
301
        Py_DECREF(value);
9020
301
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9021
301
        if (!value) goto failed;
9022
301
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9023
0
            goto failed;
9024
301
        Py_DECREF(value);
9025
301
        value = ast2obj_list(state,
9026
301
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9027
301
                             ast2obj_type_param);
9028
301
        if (!value) goto failed;
9029
301
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9030
0
            goto failed;
9031
301
        Py_DECREF(value);
9032
301
        break;
9033
355
    case ClassDef_kind:
9034
355
        tp = (PyTypeObject *)state->ClassDef_type;
9035
355
        result = PyType_GenericNew(tp, NULL, NULL);
9036
355
        if (!result) goto failed;
9037
355
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9038
355
        if (!value) goto failed;
9039
355
        if (PyObject_SetAttr(result, state->name, value) == -1)
9040
0
            goto failed;
9041
355
        Py_DECREF(value);
9042
355
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9043
355
                             ast2obj_expr);
9044
355
        if (!value) goto failed;
9045
355
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9046
0
            goto failed;
9047
355
        Py_DECREF(value);
9048
355
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9049
355
                             ast2obj_keyword);
9050
355
        if (!value) goto failed;
9051
355
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9052
0
            goto failed;
9053
355
        Py_DECREF(value);
9054
355
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9055
355
                             ast2obj_stmt);
9056
355
        if (!value) goto failed;
9057
355
        if (PyObject_SetAttr(result, state->body, value) == -1)
9058
0
            goto failed;
9059
355
        Py_DECREF(value);
9060
355
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9061
355
                             ast2obj_expr);
9062
355
        if (!value) goto failed;
9063
355
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9064
0
            goto failed;
9065
355
        Py_DECREF(value);
9066
355
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9067
355
                             ast2obj_type_param);
9068
355
        if (!value) goto failed;
9069
355
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9070
0
            goto failed;
9071
355
        Py_DECREF(value);
9072
355
        break;
9073
334
    case Return_kind:
9074
334
        tp = (PyTypeObject *)state->Return_type;
9075
334
        result = PyType_GenericNew(tp, NULL, NULL);
9076
334
        if (!result) goto failed;
9077
334
        value = ast2obj_expr(state, o->v.Return.value);
9078
334
        if (!value) goto failed;
9079
334
        if (PyObject_SetAttr(result, state->value, value) == -1)
9080
0
            goto failed;
9081
334
        Py_DECREF(value);
9082
334
        break;
9083
225
    case Delete_kind:
9084
225
        tp = (PyTypeObject *)state->Delete_type;
9085
225
        result = PyType_GenericNew(tp, NULL, NULL);
9086
225
        if (!result) goto failed;
9087
225
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9088
225
                             ast2obj_expr);
9089
225
        if (!value) goto failed;
9090
225
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9091
0
            goto failed;
9092
225
        Py_DECREF(value);
9093
225
        break;
9094
781
    case Assign_kind:
9095
781
        tp = (PyTypeObject *)state->Assign_type;
9096
781
        result = PyType_GenericNew(tp, NULL, NULL);
9097
781
        if (!result) goto failed;
9098
781
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9099
781
                             ast2obj_expr);
9100
781
        if (!value) goto failed;
9101
781
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9102
0
            goto failed;
9103
781
        Py_DECREF(value);
9104
781
        value = ast2obj_expr(state, o->v.Assign.value);
9105
781
        if (!value) goto failed;
9106
781
        if (PyObject_SetAttr(result, state->value, value) == -1)
9107
0
            goto failed;
9108
781
        Py_DECREF(value);
9109
781
        value = ast2obj_string(state, o->v.Assign.type_comment);
9110
781
        if (!value) goto failed;
9111
781
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9112
0
            goto failed;
9113
781
        Py_DECREF(value);
9114
781
        break;
9115
82
    case TypeAlias_kind:
9116
82
        tp = (PyTypeObject *)state->TypeAlias_type;
9117
82
        result = PyType_GenericNew(tp, NULL, NULL);
9118
82
        if (!result) goto failed;
9119
82
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9120
82
        if (!value) goto failed;
9121
82
        if (PyObject_SetAttr(result, state->name, value) == -1)
9122
0
            goto failed;
9123
82
        Py_DECREF(value);
9124
82
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9125
82
                             ast2obj_type_param);
9126
82
        if (!value) goto failed;
9127
82
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9128
0
            goto failed;
9129
82
        Py_DECREF(value);
9130
82
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9131
82
        if (!value) goto failed;
9132
82
        if (PyObject_SetAttr(result, state->value, value) == -1)
9133
0
            goto failed;
9134
82
        Py_DECREF(value);
9135
82
        break;
9136
497
    case AugAssign_kind:
9137
497
        tp = (PyTypeObject *)state->AugAssign_type;
9138
497
        result = PyType_GenericNew(tp, NULL, NULL);
9139
497
        if (!result) goto failed;
9140
497
        value = ast2obj_expr(state, o->v.AugAssign.target);
9141
497
        if (!value) goto failed;
9142
497
        if (PyObject_SetAttr(result, state->target, value) == -1)
9143
0
            goto failed;
9144
497
        Py_DECREF(value);
9145
497
        value = ast2obj_operator(state, o->v.AugAssign.op);
9146
497
        if (!value) goto failed;
9147
497
        if (PyObject_SetAttr(result, state->op, value) == -1)
9148
0
            goto failed;
9149
497
        Py_DECREF(value);
9150
497
        value = ast2obj_expr(state, o->v.AugAssign.value);
9151
497
        if (!value) goto failed;
9152
497
        if (PyObject_SetAttr(result, state->value, value) == -1)
9153
0
            goto failed;
9154
497
        Py_DECREF(value);
9155
497
        break;
9156
753
    case AnnAssign_kind:
9157
753
        tp = (PyTypeObject *)state->AnnAssign_type;
9158
753
        result = PyType_GenericNew(tp, NULL, NULL);
9159
753
        if (!result) goto failed;
9160
753
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9161
753
        if (!value) goto failed;
9162
753
        if (PyObject_SetAttr(result, state->target, value) == -1)
9163
0
            goto failed;
9164
753
        Py_DECREF(value);
9165
753
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9166
753
        if (!value) goto failed;
9167
753
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9168
0
            goto failed;
9169
753
        Py_DECREF(value);
9170
753
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9171
753
        if (!value) goto failed;
9172
753
        if (PyObject_SetAttr(result, state->value, value) == -1)
9173
0
            goto failed;
9174
753
        Py_DECREF(value);
9175
753
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9176
753
        if (!value) goto failed;
9177
753
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9178
0
            goto failed;
9179
753
        Py_DECREF(value);
9180
753
        break;
9181
316
    case For_kind:
9182
316
        tp = (PyTypeObject *)state->For_type;
9183
316
        result = PyType_GenericNew(tp, NULL, NULL);
9184
316
        if (!result) goto failed;
9185
316
        value = ast2obj_expr(state, o->v.For.target);
9186
316
        if (!value) goto failed;
9187
316
        if (PyObject_SetAttr(result, state->target, value) == -1)
9188
0
            goto failed;
9189
316
        Py_DECREF(value);
9190
316
        value = ast2obj_expr(state, o->v.For.iter);
9191
316
        if (!value) goto failed;
9192
316
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9193
0
            goto failed;
9194
316
        Py_DECREF(value);
9195
316
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9196
316
        if (!value) goto failed;
9197
316
        if (PyObject_SetAttr(result, state->body, value) == -1)
9198
0
            goto failed;
9199
316
        Py_DECREF(value);
9200
316
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9201
316
        if (!value) goto failed;
9202
316
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9203
0
            goto failed;
9204
316
        Py_DECREF(value);
9205
316
        value = ast2obj_string(state, o->v.For.type_comment);
9206
316
        if (!value) goto failed;
9207
316
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9208
0
            goto failed;
9209
316
        Py_DECREF(value);
9210
316
        break;
9211
148
    case AsyncFor_kind:
9212
148
        tp = (PyTypeObject *)state->AsyncFor_type;
9213
148
        result = PyType_GenericNew(tp, NULL, NULL);
9214
148
        if (!result) goto failed;
9215
148
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9216
148
        if (!value) goto failed;
9217
148
        if (PyObject_SetAttr(result, state->target, value) == -1)
9218
0
            goto failed;
9219
148
        Py_DECREF(value);
9220
148
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9221
148
        if (!value) goto failed;
9222
148
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9223
0
            goto failed;
9224
148
        Py_DECREF(value);
9225
148
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9226
148
                             ast2obj_stmt);
9227
148
        if (!value) goto failed;
9228
148
        if (PyObject_SetAttr(result, state->body, value) == -1)
9229
0
            goto failed;
9230
148
        Py_DECREF(value);
9231
148
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9232
148
                             ast2obj_stmt);
9233
148
        if (!value) goto failed;
9234
148
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9235
0
            goto failed;
9236
148
        Py_DECREF(value);
9237
148
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9238
148
        if (!value) goto failed;
9239
148
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9240
0
            goto failed;
9241
148
        Py_DECREF(value);
9242
148
        break;
9243
208
    case While_kind:
9244
208
        tp = (PyTypeObject *)state->While_type;
9245
208
        result = PyType_GenericNew(tp, NULL, NULL);
9246
208
        if (!result) goto failed;
9247
208
        value = ast2obj_expr(state, o->v.While.test);
9248
208
        if (!value) goto failed;
9249
208
        if (PyObject_SetAttr(result, state->test, value) == -1)
9250
0
            goto failed;
9251
208
        Py_DECREF(value);
9252
208
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9253
208
        if (!value) goto failed;
9254
208
        if (PyObject_SetAttr(result, state->body, value) == -1)
9255
0
            goto failed;
9256
208
        Py_DECREF(value);
9257
208
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9258
208
        if (!value) goto failed;
9259
208
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9260
0
            goto failed;
9261
208
        Py_DECREF(value);
9262
208
        break;
9263
338
    case If_kind:
9264
338
        tp = (PyTypeObject *)state->If_type;
9265
338
        result = PyType_GenericNew(tp, NULL, NULL);
9266
338
        if (!result) goto failed;
9267
338
        value = ast2obj_expr(state, o->v.If.test);
9268
338
        if (!value) goto failed;
9269
338
        if (PyObject_SetAttr(result, state->test, value) == -1)
9270
0
            goto failed;
9271
338
        Py_DECREF(value);
9272
338
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9273
338
        if (!value) goto failed;
9274
338
        if (PyObject_SetAttr(result, state->body, value) == -1)
9275
0
            goto failed;
9276
338
        Py_DECREF(value);
9277
338
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9278
338
        if (!value) goto failed;
9279
338
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9280
0
            goto failed;
9281
338
        Py_DECREF(value);
9282
338
        break;
9283
177
    case With_kind:
9284
177
        tp = (PyTypeObject *)state->With_type;
9285
177
        result = PyType_GenericNew(tp, NULL, NULL);
9286
177
        if (!result) goto failed;
9287
177
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9288
177
                             ast2obj_withitem);
9289
177
        if (!value) goto failed;
9290
177
        if (PyObject_SetAttr(result, state->items, value) == -1)
9291
0
            goto failed;
9292
177
        Py_DECREF(value);
9293
177
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9294
177
        if (!value) goto failed;
9295
177
        if (PyObject_SetAttr(result, state->body, value) == -1)
9296
0
            goto failed;
9297
177
        Py_DECREF(value);
9298
177
        value = ast2obj_string(state, o->v.With.type_comment);
9299
177
        if (!value) goto failed;
9300
177
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9301
0
            goto failed;
9302
177
        Py_DECREF(value);
9303
177
        break;
9304
293
    case AsyncWith_kind:
9305
293
        tp = (PyTypeObject *)state->AsyncWith_type;
9306
293
        result = PyType_GenericNew(tp, NULL, NULL);
9307
293
        if (!result) goto failed;
9308
293
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9309
293
                             ast2obj_withitem);
9310
293
        if (!value) goto failed;
9311
293
        if (PyObject_SetAttr(result, state->items, value) == -1)
9312
0
            goto failed;
9313
293
        Py_DECREF(value);
9314
293
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9315
293
                             ast2obj_stmt);
9316
293
        if (!value) goto failed;
9317
293
        if (PyObject_SetAttr(result, state->body, value) == -1)
9318
0
            goto failed;
9319
293
        Py_DECREF(value);
9320
293
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9321
293
        if (!value) goto failed;
9322
293
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9323
0
            goto failed;
9324
293
        Py_DECREF(value);
9325
293
        break;
9326
209
    case Match_kind:
9327
209
        tp = (PyTypeObject *)state->Match_type;
9328
209
        result = PyType_GenericNew(tp, NULL, NULL);
9329
209
        if (!result) goto failed;
9330
209
        value = ast2obj_expr(state, o->v.Match.subject);
9331
209
        if (!value) goto failed;
9332
209
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9333
0
            goto failed;
9334
209
        Py_DECREF(value);
9335
209
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9336
209
                             ast2obj_match_case);
9337
209
        if (!value) goto failed;
9338
209
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9339
0
            goto failed;
9340
209
        Py_DECREF(value);
9341
209
        break;
9342
482
    case Raise_kind:
9343
482
        tp = (PyTypeObject *)state->Raise_type;
9344
482
        result = PyType_GenericNew(tp, NULL, NULL);
9345
482
        if (!result) goto failed;
9346
482
        value = ast2obj_expr(state, o->v.Raise.exc);
9347
482
        if (!value) goto failed;
9348
482
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9349
0
            goto failed;
9350
482
        Py_DECREF(value);
9351
482
        value = ast2obj_expr(state, o->v.Raise.cause);
9352
482
        if (!value) goto failed;
9353
482
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9354
0
            goto failed;
9355
482
        Py_DECREF(value);
9356
482
        break;
9357
394
    case Try_kind:
9358
394
        tp = (PyTypeObject *)state->Try_type;
9359
394
        result = PyType_GenericNew(tp, NULL, NULL);
9360
394
        if (!result) goto failed;
9361
394
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9362
394
        if (!value) goto failed;
9363
394
        if (PyObject_SetAttr(result, state->body, value) == -1)
9364
0
            goto failed;
9365
394
        Py_DECREF(value);
9366
394
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9367
394
                             ast2obj_excepthandler);
9368
394
        if (!value) goto failed;
9369
394
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9370
0
            goto failed;
9371
394
        Py_DECREF(value);
9372
394
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9373
394
        if (!value) goto failed;
9374
394
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9375
0
            goto failed;
9376
394
        Py_DECREF(value);
9377
394
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9378
394
                             ast2obj_stmt);
9379
394
        if (!value) goto failed;
9380
394
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9381
0
            goto failed;
9382
394
        Py_DECREF(value);
9383
394
        break;
9384
505
    case TryStar_kind:
9385
505
        tp = (PyTypeObject *)state->TryStar_type;
9386
505
        result = PyType_GenericNew(tp, NULL, NULL);
9387
505
        if (!result) goto failed;
9388
505
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9389
505
        if (!value) goto failed;
9390
505
        if (PyObject_SetAttr(result, state->body, value) == -1)
9391
0
            goto failed;
9392
505
        Py_DECREF(value);
9393
505
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9394
505
                             ast2obj_excepthandler);
9395
505
        if (!value) goto failed;
9396
505
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9397
0
            goto failed;
9398
505
        Py_DECREF(value);
9399
505
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9400
505
                             ast2obj_stmt);
9401
505
        if (!value) goto failed;
9402
505
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9403
0
            goto failed;
9404
505
        Py_DECREF(value);
9405
505
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9406
505
                             ast2obj_stmt);
9407
505
        if (!value) goto failed;
9408
505
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9409
0
            goto failed;
9410
505
        Py_DECREF(value);
9411
505
        break;
9412
128
    case Assert_kind:
9413
128
        tp = (PyTypeObject *)state->Assert_type;
9414
128
        result = PyType_GenericNew(tp, NULL, NULL);
9415
128
        if (!result) goto failed;
9416
128
        value = ast2obj_expr(state, o->v.Assert.test);
9417
128
        if (!value) goto failed;
9418
128
        if (PyObject_SetAttr(result, state->test, value) == -1)
9419
0
            goto failed;
9420
128
        Py_DECREF(value);
9421
128
        value = ast2obj_expr(state, o->v.Assert.msg);
9422
128
        if (!value) goto failed;
9423
128
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9424
0
            goto failed;
9425
128
        Py_DECREF(value);
9426
128
        break;
9427
513
    case Import_kind:
9428
513
        tp = (PyTypeObject *)state->Import_type;
9429
513
        result = PyType_GenericNew(tp, NULL, NULL);
9430
513
        if (!result) goto failed;
9431
513
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9432
513
                             ast2obj_alias);
9433
513
        if (!value) goto failed;
9434
513
        if (PyObject_SetAttr(result, state->names, value) == -1)
9435
0
            goto failed;
9436
513
        Py_DECREF(value);
9437
513
        value = ast2obj_int(state, o->v.Import.is_lazy);
9438
513
        if (!value) goto failed;
9439
513
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9440
0
            goto failed;
9441
513
        Py_DECREF(value);
9442
513
        break;
9443
722
    case ImportFrom_kind:
9444
722
        tp = (PyTypeObject *)state->ImportFrom_type;
9445
722
        result = PyType_GenericNew(tp, NULL, NULL);
9446
722
        if (!result) goto failed;
9447
722
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9448
722
        if (!value) goto failed;
9449
722
        if (PyObject_SetAttr(result, state->module, value) == -1)
9450
0
            goto failed;
9451
722
        Py_DECREF(value);
9452
722
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9453
722
                             ast2obj_alias);
9454
722
        if (!value) goto failed;
9455
722
        if (PyObject_SetAttr(result, state->names, value) == -1)
9456
0
            goto failed;
9457
722
        Py_DECREF(value);
9458
722
        value = ast2obj_int(state, o->v.ImportFrom.level);
9459
722
        if (!value) goto failed;
9460
722
        if (PyObject_SetAttr(result, state->level, value) == -1)
9461
0
            goto failed;
9462
722
        Py_DECREF(value);
9463
722
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
9464
722
        if (!value) goto failed;
9465
722
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9466
0
            goto failed;
9467
722
        Py_DECREF(value);
9468
722
        break;
9469
114
    case Global_kind:
9470
114
        tp = (PyTypeObject *)state->Global_type;
9471
114
        result = PyType_GenericNew(tp, NULL, NULL);
9472
114
        if (!result) goto failed;
9473
114
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9474
114
                             ast2obj_identifier);
9475
114
        if (!value) goto failed;
9476
114
        if (PyObject_SetAttr(result, state->names, value) == -1)
9477
0
            goto failed;
9478
114
        Py_DECREF(value);
9479
114
        break;
9480
67
    case Nonlocal_kind:
9481
67
        tp = (PyTypeObject *)state->Nonlocal_type;
9482
67
        result = PyType_GenericNew(tp, NULL, NULL);
9483
67
        if (!result) goto failed;
9484
67
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9485
67
                             ast2obj_identifier);
9486
67
        if (!value) goto failed;
9487
67
        if (PyObject_SetAttr(result, state->names, value) == -1)
9488
0
            goto failed;
9489
67
        Py_DECREF(value);
9490
67
        break;
9491
33.8k
    case Expr_kind:
9492
33.8k
        tp = (PyTypeObject *)state->Expr_type;
9493
33.8k
        result = PyType_GenericNew(tp, NULL, NULL);
9494
33.8k
        if (!result) goto failed;
9495
33.8k
        value = ast2obj_expr(state, o->v.Expr.value);
9496
33.8k
        if (!value) goto failed;
9497
33.8k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9498
0
            goto failed;
9499
33.8k
        Py_DECREF(value);
9500
33.8k
        break;
9501
248
    case Pass_kind:
9502
248
        tp = (PyTypeObject *)state->Pass_type;
9503
248
        result = PyType_GenericNew(tp, NULL, NULL);
9504
248
        if (!result) goto failed;
9505
248
        break;
9506
289
    case Break_kind:
9507
289
        tp = (PyTypeObject *)state->Break_type;
9508
289
        result = PyType_GenericNew(tp, NULL, NULL);
9509
289
        if (!result) goto failed;
9510
289
        break;
9511
289
    case Continue_kind:
9512
209
        tp = (PyTypeObject *)state->Continue_type;
9513
209
        result = PyType_GenericNew(tp, NULL, NULL);
9514
209
        if (!result) goto failed;
9515
209
        break;
9516
43.9k
    }
9517
43.9k
    value = ast2obj_int(state, o->lineno);
9518
43.9k
    if (!value) goto failed;
9519
43.9k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9520
0
        goto failed;
9521
43.9k
    Py_DECREF(value);
9522
43.9k
    value = ast2obj_int(state, o->col_offset);
9523
43.9k
    if (!value) goto failed;
9524
43.9k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9525
0
        goto failed;
9526
43.9k
    Py_DECREF(value);
9527
43.9k
    value = ast2obj_int(state, o->end_lineno);
9528
43.9k
    if (!value) goto failed;
9529
43.9k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9530
0
        goto failed;
9531
43.9k
    Py_DECREF(value);
9532
43.9k
    value = ast2obj_int(state, o->end_col_offset);
9533
43.9k
    if (!value) goto failed;
9534
43.9k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9535
0
        goto failed;
9536
43.9k
    Py_DECREF(value);
9537
43.9k
    Py_LeaveRecursiveCall();
9538
43.9k
    return result;
9539
0
failed:
9540
0
    Py_LeaveRecursiveCall();
9541
0
    Py_XDECREF(value);
9542
0
    Py_XDECREF(result);
9543
0
    return NULL;
9544
43.9k
}
9545
9546
PyObject*
9547
ast2obj_expr(struct ast_state *state, void* _o)
9548
401k
{
9549
401k
    expr_ty o = (expr_ty)_o;
9550
401k
    PyObject *result = NULL, *value = NULL;
9551
401k
    PyTypeObject *tp;
9552
401k
    if (!o) {
9553
48.4k
        Py_RETURN_NONE;
9554
48.4k
    }
9555
353k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9556
0
        return NULL;
9557
0
    }
9558
353k
    switch (o->kind) {
9559
902
    case BoolOp_kind:
9560
902
        tp = (PyTypeObject *)state->BoolOp_type;
9561
902
        result = PyType_GenericNew(tp, NULL, NULL);
9562
902
        if (!result) goto failed;
9563
902
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9564
902
        if (!value) goto failed;
9565
902
        if (PyObject_SetAttr(result, state->op, value) == -1)
9566
0
            goto failed;
9567
902
        Py_DECREF(value);
9568
902
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9569
902
                             ast2obj_expr);
9570
902
        if (!value) goto failed;
9571
902
        if (PyObject_SetAttr(result, state->values, value) == -1)
9572
0
            goto failed;
9573
902
        Py_DECREF(value);
9574
902
        break;
9575
73
    case NamedExpr_kind:
9576
73
        tp = (PyTypeObject *)state->NamedExpr_type;
9577
73
        result = PyType_GenericNew(tp, NULL, NULL);
9578
73
        if (!result) goto failed;
9579
73
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9580
73
        if (!value) goto failed;
9581
73
        if (PyObject_SetAttr(result, state->target, value) == -1)
9582
0
            goto failed;
9583
73
        Py_DECREF(value);
9584
73
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9585
73
        if (!value) goto failed;
9586
73
        if (PyObject_SetAttr(result, state->value, value) == -1)
9587
0
            goto failed;
9588
73
        Py_DECREF(value);
9589
73
        break;
9590
21.5k
    case BinOp_kind:
9591
21.5k
        tp = (PyTypeObject *)state->BinOp_type;
9592
21.5k
        result = PyType_GenericNew(tp, NULL, NULL);
9593
21.5k
        if (!result) goto failed;
9594
21.5k
        value = ast2obj_expr(state, o->v.BinOp.left);
9595
21.5k
        if (!value) goto failed;
9596
21.5k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9597
0
            goto failed;
9598
21.5k
        Py_DECREF(value);
9599
21.5k
        value = ast2obj_operator(state, o->v.BinOp.op);
9600
21.5k
        if (!value) goto failed;
9601
21.5k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9602
0
            goto failed;
9603
21.5k
        Py_DECREF(value);
9604
21.5k
        value = ast2obj_expr(state, o->v.BinOp.right);
9605
21.5k
        if (!value) goto failed;
9606
21.5k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9607
0
            goto failed;
9608
21.5k
        Py_DECREF(value);
9609
21.5k
        break;
9610
149k
    case UnaryOp_kind:
9611
149k
        tp = (PyTypeObject *)state->UnaryOp_type;
9612
149k
        result = PyType_GenericNew(tp, NULL, NULL);
9613
149k
        if (!result) goto failed;
9614
149k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9615
149k
        if (!value) goto failed;
9616
149k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9617
0
            goto failed;
9618
149k
        Py_DECREF(value);
9619
149k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9620
149k
        if (!value) goto failed;
9621
149k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9622
0
            goto failed;
9623
149k
        Py_DECREF(value);
9624
149k
        break;
9625
902
    case Lambda_kind:
9626
902
        tp = (PyTypeObject *)state->Lambda_type;
9627
902
        result = PyType_GenericNew(tp, NULL, NULL);
9628
902
        if (!result) goto failed;
9629
902
        value = ast2obj_arguments(state, o->v.Lambda.args);
9630
902
        if (!value) goto failed;
9631
902
        if (PyObject_SetAttr(result, state->args, value) == -1)
9632
0
            goto failed;
9633
902
        Py_DECREF(value);
9634
902
        value = ast2obj_expr(state, o->v.Lambda.body);
9635
902
        if (!value) goto failed;
9636
902
        if (PyObject_SetAttr(result, state->body, value) == -1)
9637
0
            goto failed;
9638
902
        Py_DECREF(value);
9639
902
        break;
9640
213
    case IfExp_kind:
9641
213
        tp = (PyTypeObject *)state->IfExp_type;
9642
213
        result = PyType_GenericNew(tp, NULL, NULL);
9643
213
        if (!result) goto failed;
9644
213
        value = ast2obj_expr(state, o->v.IfExp.test);
9645
213
        if (!value) goto failed;
9646
213
        if (PyObject_SetAttr(result, state->test, value) == -1)
9647
0
            goto failed;
9648
213
        Py_DECREF(value);
9649
213
        value = ast2obj_expr(state, o->v.IfExp.body);
9650
213
        if (!value) goto failed;
9651
213
        if (PyObject_SetAttr(result, state->body, value) == -1)
9652
0
            goto failed;
9653
213
        Py_DECREF(value);
9654
213
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9655
213
        if (!value) goto failed;
9656
213
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9657
0
            goto failed;
9658
213
        Py_DECREF(value);
9659
213
        break;
9660
1.61k
    case Dict_kind:
9661
1.61k
        tp = (PyTypeObject *)state->Dict_type;
9662
1.61k
        result = PyType_GenericNew(tp, NULL, NULL);
9663
1.61k
        if (!result) goto failed;
9664
1.61k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9665
1.61k
        if (!value) goto failed;
9666
1.61k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9667
0
            goto failed;
9668
1.61k
        Py_DECREF(value);
9669
1.61k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9670
1.61k
        if (!value) goto failed;
9671
1.61k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9672
0
            goto failed;
9673
1.61k
        Py_DECREF(value);
9674
1.61k
        break;
9675
194
    case Set_kind:
9676
194
        tp = (PyTypeObject *)state->Set_type;
9677
194
        result = PyType_GenericNew(tp, NULL, NULL);
9678
194
        if (!result) goto failed;
9679
194
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9680
194
        if (!value) goto failed;
9681
194
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9682
0
            goto failed;
9683
194
        Py_DECREF(value);
9684
194
        break;
9685
189
    case ListComp_kind:
9686
189
        tp = (PyTypeObject *)state->ListComp_type;
9687
189
        result = PyType_GenericNew(tp, NULL, NULL);
9688
189
        if (!result) goto failed;
9689
189
        value = ast2obj_expr(state, o->v.ListComp.elt);
9690
189
        if (!value) goto failed;
9691
189
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9692
0
            goto failed;
9693
189
        Py_DECREF(value);
9694
189
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9695
189
                             ast2obj_comprehension);
9696
189
        if (!value) goto failed;
9697
189
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9698
0
            goto failed;
9699
189
        Py_DECREF(value);
9700
189
        break;
9701
308
    case SetComp_kind:
9702
308
        tp = (PyTypeObject *)state->SetComp_type;
9703
308
        result = PyType_GenericNew(tp, NULL, NULL);
9704
308
        if (!result) goto failed;
9705
308
        value = ast2obj_expr(state, o->v.SetComp.elt);
9706
308
        if (!value) goto failed;
9707
308
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9708
0
            goto failed;
9709
308
        Py_DECREF(value);
9710
308
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9711
308
                             ast2obj_comprehension);
9712
308
        if (!value) goto failed;
9713
308
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9714
0
            goto failed;
9715
308
        Py_DECREF(value);
9716
308
        break;
9717
324
    case DictComp_kind:
9718
324
        tp = (PyTypeObject *)state->DictComp_type;
9719
324
        result = PyType_GenericNew(tp, NULL, NULL);
9720
324
        if (!result) goto failed;
9721
324
        value = ast2obj_expr(state, o->v.DictComp.key);
9722
324
        if (!value) goto failed;
9723
324
        if (PyObject_SetAttr(result, state->key, value) == -1)
9724
0
            goto failed;
9725
324
        Py_DECREF(value);
9726
324
        value = ast2obj_expr(state, o->v.DictComp.value);
9727
324
        if (!value) goto failed;
9728
324
        if (PyObject_SetAttr(result, state->value, value) == -1)
9729
0
            goto failed;
9730
324
        Py_DECREF(value);
9731
324
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9732
324
                             ast2obj_comprehension);
9733
324
        if (!value) goto failed;
9734
324
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9735
0
            goto failed;
9736
324
        Py_DECREF(value);
9737
324
        break;
9738
353
    case GeneratorExp_kind:
9739
353
        tp = (PyTypeObject *)state->GeneratorExp_type;
9740
353
        result = PyType_GenericNew(tp, NULL, NULL);
9741
353
        if (!result) goto failed;
9742
353
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9743
353
        if (!value) goto failed;
9744
353
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9745
0
            goto failed;
9746
353
        Py_DECREF(value);
9747
353
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9748
353
                             ast2obj_comprehension);
9749
353
        if (!value) goto failed;
9750
353
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9751
0
            goto failed;
9752
353
        Py_DECREF(value);
9753
353
        break;
9754
70
    case Await_kind:
9755
70
        tp = (PyTypeObject *)state->Await_type;
9756
70
        result = PyType_GenericNew(tp, NULL, NULL);
9757
70
        if (!result) goto failed;
9758
70
        value = ast2obj_expr(state, o->v.Await.value);
9759
70
        if (!value) goto failed;
9760
70
        if (PyObject_SetAttr(result, state->value, value) == -1)
9761
0
            goto failed;
9762
70
        Py_DECREF(value);
9763
70
        break;
9764
563
    case Yield_kind:
9765
563
        tp = (PyTypeObject *)state->Yield_type;
9766
563
        result = PyType_GenericNew(tp, NULL, NULL);
9767
563
        if (!result) goto failed;
9768
563
        value = ast2obj_expr(state, o->v.Yield.value);
9769
563
        if (!value) goto failed;
9770
563
        if (PyObject_SetAttr(result, state->value, value) == -1)
9771
0
            goto failed;
9772
563
        Py_DECREF(value);
9773
563
        break;
9774
67
    case YieldFrom_kind:
9775
67
        tp = (PyTypeObject *)state->YieldFrom_type;
9776
67
        result = PyType_GenericNew(tp, NULL, NULL);
9777
67
        if (!result) goto failed;
9778
67
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9779
67
        if (!value) goto failed;
9780
67
        if (PyObject_SetAttr(result, state->value, value) == -1)
9781
0
            goto failed;
9782
67
        Py_DECREF(value);
9783
67
        break;
9784
1.41k
    case Compare_kind:
9785
1.41k
        tp = (PyTypeObject *)state->Compare_type;
9786
1.41k
        result = PyType_GenericNew(tp, NULL, NULL);
9787
1.41k
        if (!result) goto failed;
9788
1.41k
        value = ast2obj_expr(state, o->v.Compare.left);
9789
1.41k
        if (!value) goto failed;
9790
1.41k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9791
0
            goto failed;
9792
1.41k
        Py_DECREF(value);
9793
1.41k
        {
9794
1.41k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9795
1.41k
            value = PyList_New(n);
9796
1.41k
            if (!value) goto failed;
9797
8.64k
            for(i = 0; i < n; i++)
9798
7.23k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9799
1.41k
        }
9800
1.41k
        if (!value) goto failed;
9801
1.41k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9802
0
            goto failed;
9803
1.41k
        Py_DECREF(value);
9804
1.41k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9805
1.41k
                             ast2obj_expr);
9806
1.41k
        if (!value) goto failed;
9807
1.41k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9808
0
            goto failed;
9809
1.41k
        Py_DECREF(value);
9810
1.41k
        break;
9811
7.91k
    case Call_kind:
9812
7.91k
        tp = (PyTypeObject *)state->Call_type;
9813
7.91k
        result = PyType_GenericNew(tp, NULL, NULL);
9814
7.91k
        if (!result) goto failed;
9815
7.91k
        value = ast2obj_expr(state, o->v.Call.func);
9816
7.91k
        if (!value) goto failed;
9817
7.91k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9818
0
            goto failed;
9819
7.91k
        Py_DECREF(value);
9820
7.91k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9821
7.91k
        if (!value) goto failed;
9822
7.91k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9823
0
            goto failed;
9824
7.91k
        Py_DECREF(value);
9825
7.91k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9826
7.91k
                             ast2obj_keyword);
9827
7.91k
        if (!value) goto failed;
9828
7.91k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9829
0
            goto failed;
9830
7.91k
        Py_DECREF(value);
9831
7.91k
        break;
9832
14.7k
    case FormattedValue_kind:
9833
14.7k
        tp = (PyTypeObject *)state->FormattedValue_type;
9834
14.7k
        result = PyType_GenericNew(tp, NULL, NULL);
9835
14.7k
        if (!result) goto failed;
9836
14.7k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9837
14.7k
        if (!value) goto failed;
9838
14.7k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9839
0
            goto failed;
9840
14.7k
        Py_DECREF(value);
9841
14.7k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9842
14.7k
        if (!value) goto failed;
9843
14.7k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9844
0
            goto failed;
9845
14.7k
        Py_DECREF(value);
9846
14.7k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9847
14.7k
        if (!value) goto failed;
9848
14.7k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9849
0
            goto failed;
9850
14.7k
        Py_DECREF(value);
9851
14.7k
        break;
9852
1.27k
    case Interpolation_kind:
9853
1.27k
        tp = (PyTypeObject *)state->Interpolation_type;
9854
1.27k
        result = PyType_GenericNew(tp, NULL, NULL);
9855
1.27k
        if (!result) goto failed;
9856
1.27k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9857
1.27k
        if (!value) goto failed;
9858
1.27k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9859
0
            goto failed;
9860
1.27k
        Py_DECREF(value);
9861
1.27k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9862
1.27k
        if (!value) goto failed;
9863
1.27k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9864
0
            goto failed;
9865
1.27k
        Py_DECREF(value);
9866
1.27k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9867
1.27k
        if (!value) goto failed;
9868
1.27k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9869
0
            goto failed;
9870
1.27k
        Py_DECREF(value);
9871
1.27k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9872
1.27k
        if (!value) goto failed;
9873
1.27k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9874
0
            goto failed;
9875
1.27k
        Py_DECREF(value);
9876
1.27k
        break;
9877
7.12k
    case JoinedStr_kind:
9878
7.12k
        tp = (PyTypeObject *)state->JoinedStr_type;
9879
7.12k
        result = PyType_GenericNew(tp, NULL, NULL);
9880
7.12k
        if (!result) goto failed;
9881
7.12k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9882
7.12k
                             ast2obj_expr);
9883
7.12k
        if (!value) goto failed;
9884
7.12k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9885
0
            goto failed;
9886
7.12k
        Py_DECREF(value);
9887
7.12k
        break;
9888
548
    case TemplateStr_kind:
9889
548
        tp = (PyTypeObject *)state->TemplateStr_type;
9890
548
        result = PyType_GenericNew(tp, NULL, NULL);
9891
548
        if (!result) goto failed;
9892
548
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9893
548
                             ast2obj_expr);
9894
548
        if (!value) goto failed;
9895
548
        if (PyObject_SetAttr(result, state->values, value) == -1)
9896
0
            goto failed;
9897
548
        Py_DECREF(value);
9898
548
        break;
9899
57.4k
    case Constant_kind:
9900
57.4k
        tp = (PyTypeObject *)state->Constant_type;
9901
57.4k
        result = PyType_GenericNew(tp, NULL, NULL);
9902
57.4k
        if (!result) goto failed;
9903
57.4k
        value = ast2obj_constant(state, o->v.Constant.value);
9904
57.4k
        if (!value) goto failed;
9905
57.4k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9906
0
            goto failed;
9907
57.4k
        Py_DECREF(value);
9908
57.4k
        value = ast2obj_string(state, o->v.Constant.kind);
9909
57.4k
        if (!value) goto failed;
9910
57.4k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9911
0
            goto failed;
9912
57.4k
        Py_DECREF(value);
9913
57.4k
        break;
9914
1.60k
    case Attribute_kind:
9915
1.60k
        tp = (PyTypeObject *)state->Attribute_type;
9916
1.60k
        result = PyType_GenericNew(tp, NULL, NULL);
9917
1.60k
        if (!result) goto failed;
9918
1.60k
        value = ast2obj_expr(state, o->v.Attribute.value);
9919
1.60k
        if (!value) goto failed;
9920
1.60k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9921
0
            goto failed;
9922
1.60k
        Py_DECREF(value);
9923
1.60k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9924
1.60k
        if (!value) goto failed;
9925
1.60k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9926
0
            goto failed;
9927
1.60k
        Py_DECREF(value);
9928
1.60k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9929
1.60k
        if (!value) goto failed;
9930
1.60k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9931
0
            goto failed;
9932
1.60k
        Py_DECREF(value);
9933
1.60k
        break;
9934
537
    case Subscript_kind:
9935
537
        tp = (PyTypeObject *)state->Subscript_type;
9936
537
        result = PyType_GenericNew(tp, NULL, NULL);
9937
537
        if (!result) goto failed;
9938
537
        value = ast2obj_expr(state, o->v.Subscript.value);
9939
537
        if (!value) goto failed;
9940
537
        if (PyObject_SetAttr(result, state->value, value) == -1)
9941
0
            goto failed;
9942
537
        Py_DECREF(value);
9943
537
        value = ast2obj_expr(state, o->v.Subscript.slice);
9944
537
        if (!value) goto failed;
9945
537
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9946
0
            goto failed;
9947
537
        Py_DECREF(value);
9948
537
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9949
537
        if (!value) goto failed;
9950
537
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9951
0
            goto failed;
9952
537
        Py_DECREF(value);
9953
537
        break;
9954
421
    case Starred_kind:
9955
421
        tp = (PyTypeObject *)state->Starred_type;
9956
421
        result = PyType_GenericNew(tp, NULL, NULL);
9957
421
        if (!result) goto failed;
9958
421
        value = ast2obj_expr(state, o->v.Starred.value);
9959
421
        if (!value) goto failed;
9960
421
        if (PyObject_SetAttr(result, state->value, value) == -1)
9961
0
            goto failed;
9962
421
        Py_DECREF(value);
9963
421
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9964
421
        if (!value) goto failed;
9965
421
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9966
0
            goto failed;
9967
421
        Py_DECREF(value);
9968
421
        break;
9969
68.7k
    case Name_kind:
9970
68.7k
        tp = (PyTypeObject *)state->Name_type;
9971
68.7k
        result = PyType_GenericNew(tp, NULL, NULL);
9972
68.7k
        if (!result) goto failed;
9973
68.7k
        value = ast2obj_identifier(state, o->v.Name.id);
9974
68.7k
        if (!value) goto failed;
9975
68.7k
        if (PyObject_SetAttr(result, state->id, value) == -1)
9976
0
            goto failed;
9977
68.7k
        Py_DECREF(value);
9978
68.7k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
9979
68.7k
        if (!value) goto failed;
9980
68.7k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9981
0
            goto failed;
9982
68.7k
        Py_DECREF(value);
9983
68.7k
        break;
9984
2.02k
    case List_kind:
9985
2.02k
        tp = (PyTypeObject *)state->List_type;
9986
2.02k
        result = PyType_GenericNew(tp, NULL, NULL);
9987
2.02k
        if (!result) goto failed;
9988
2.02k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
9989
2.02k
        if (!value) goto failed;
9990
2.02k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9991
0
            goto failed;
9992
2.02k
        Py_DECREF(value);
9993
2.02k
        value = ast2obj_expr_context(state, o->v.List.ctx);
9994
2.02k
        if (!value) goto failed;
9995
2.02k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9996
0
            goto failed;
9997
2.02k
        Py_DECREF(value);
9998
2.02k
        break;
9999
9.77k
    case Tuple_kind:
10000
9.77k
        tp = (PyTypeObject *)state->Tuple_type;
10001
9.77k
        result = PyType_GenericNew(tp, NULL, NULL);
10002
9.77k
        if (!result) goto failed;
10003
9.77k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10004
9.77k
        if (!value) goto failed;
10005
9.77k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10006
0
            goto failed;
10007
9.77k
        Py_DECREF(value);
10008
9.77k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10009
9.77k
        if (!value) goto failed;
10010
9.77k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10011
0
            goto failed;
10012
9.77k
        Py_DECREF(value);
10013
9.77k
        break;
10014
2.97k
    case Slice_kind:
10015
2.97k
        tp = (PyTypeObject *)state->Slice_type;
10016
2.97k
        result = PyType_GenericNew(tp, NULL, NULL);
10017
2.97k
        if (!result) goto failed;
10018
2.97k
        value = ast2obj_expr(state, o->v.Slice.lower);
10019
2.97k
        if (!value) goto failed;
10020
2.97k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10021
0
            goto failed;
10022
2.97k
        Py_DECREF(value);
10023
2.97k
        value = ast2obj_expr(state, o->v.Slice.upper);
10024
2.97k
        if (!value) goto failed;
10025
2.97k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10026
0
            goto failed;
10027
2.97k
        Py_DECREF(value);
10028
2.97k
        value = ast2obj_expr(state, o->v.Slice.step);
10029
2.97k
        if (!value) goto failed;
10030
2.97k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10031
0
            goto failed;
10032
2.97k
        Py_DECREF(value);
10033
2.97k
        break;
10034
353k
    }
10035
353k
    value = ast2obj_int(state, o->lineno);
10036
353k
    if (!value) goto failed;
10037
353k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10038
0
        goto failed;
10039
353k
    Py_DECREF(value);
10040
353k
    value = ast2obj_int(state, o->col_offset);
10041
353k
    if (!value) goto failed;
10042
353k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10043
0
        goto failed;
10044
353k
    Py_DECREF(value);
10045
353k
    value = ast2obj_int(state, o->end_lineno);
10046
353k
    if (!value) goto failed;
10047
353k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10048
0
        goto failed;
10049
353k
    Py_DECREF(value);
10050
353k
    value = ast2obj_int(state, o->end_col_offset);
10051
353k
    if (!value) goto failed;
10052
353k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10053
0
        goto failed;
10054
353k
    Py_DECREF(value);
10055
353k
    Py_LeaveRecursiveCall();
10056
353k
    return result;
10057
0
failed:
10058
0
    Py_LeaveRecursiveCall();
10059
0
    Py_XDECREF(value);
10060
0
    Py_XDECREF(result);
10061
0
    return NULL;
10062
353k
}
10063
10064
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10065
83.0k
{
10066
83.0k
    switch(o) {
10067
76.6k
        case Load:
10068
76.6k
            return Py_NewRef(state->Load_singleton);
10069
5.95k
        case Store:
10070
5.95k
            return Py_NewRef(state->Store_singleton);
10071
466
        case Del:
10072
466
            return Py_NewRef(state->Del_singleton);
10073
83.0k
    }
10074
83.0k
    Py_UNREACHABLE();
10075
83.0k
}
10076
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10077
902
{
10078
902
    switch(o) {
10079
520
        case And:
10080
520
            return Py_NewRef(state->And_singleton);
10081
382
        case Or:
10082
382
            return Py_NewRef(state->Or_singleton);
10083
902
    }
10084
902
    Py_UNREACHABLE();
10085
902
}
10086
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10087
22.0k
{
10088
22.0k
    switch(o) {
10089
3.38k
        case Add:
10090
3.38k
            return Py_NewRef(state->Add_singleton);
10091
6.56k
        case Sub:
10092
6.56k
            return Py_NewRef(state->Sub_singleton);
10093
4.97k
        case Mult:
10094
4.97k
            return Py_NewRef(state->Mult_singleton);
10095
771
        case MatMult:
10096
771
            return Py_NewRef(state->MatMult_singleton);
10097
868
        case Div:
10098
868
            return Py_NewRef(state->Div_singleton);
10099
1.02k
        case Mod:
10100
1.02k
            return Py_NewRef(state->Mod_singleton);
10101
749
        case Pow:
10102
749
            return Py_NewRef(state->Pow_singleton);
10103
436
        case LShift:
10104
436
            return Py_NewRef(state->LShift_singleton);
10105
272
        case RShift:
10106
272
            return Py_NewRef(state->RShift_singleton);
10107
1.21k
        case BitOr:
10108
1.21k
            return Py_NewRef(state->BitOr_singleton);
10109
658
        case BitXor:
10110
658
            return Py_NewRef(state->BitXor_singleton);
10111
775
        case BitAnd:
10112
775
            return Py_NewRef(state->BitAnd_singleton);
10113
337
        case FloorDiv:
10114
337
            return Py_NewRef(state->FloorDiv_singleton);
10115
22.0k
    }
10116
22.0k
    Py_UNREACHABLE();
10117
22.0k
}
10118
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10119
149k
{
10120
149k
    switch(o) {
10121
29.5k
        case Invert:
10122
29.5k
            return Py_NewRef(state->Invert_singleton);
10123
73
        case Not:
10124
73
            return Py_NewRef(state->Not_singleton);
10125
56.7k
        case UAdd:
10126
56.7k
            return Py_NewRef(state->UAdd_singleton);
10127
62.7k
        case USub:
10128
62.7k
            return Py_NewRef(state->USub_singleton);
10129
149k
    }
10130
149k
    Py_UNREACHABLE();
10131
149k
}
10132
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10133
7.23k
{
10134
7.23k
    switch(o) {
10135
258
        case Eq:
10136
258
            return Py_NewRef(state->Eq_singleton);
10137
207
        case NotEq:
10138
207
            return Py_NewRef(state->NotEq_singleton);
10139
1.97k
        case Lt:
10140
1.97k
            return Py_NewRef(state->Lt_singleton);
10141
220
        case LtE:
10142
220
            return Py_NewRef(state->LtE_singleton);
10143
3.22k
        case Gt:
10144
3.22k
            return Py_NewRef(state->Gt_singleton);
10145
645
        case GtE:
10146
645
            return Py_NewRef(state->GtE_singleton);
10147
261
        case Is:
10148
261
            return Py_NewRef(state->Is_singleton);
10149
81
        case IsNot:
10150
81
            return Py_NewRef(state->IsNot_singleton);
10151
308
        case In:
10152
308
            return Py_NewRef(state->In_singleton);
10153
54
        case NotIn:
10154
54
            return Py_NewRef(state->NotIn_singleton);
10155
7.23k
    }
10156
7.23k
    Py_UNREACHABLE();
10157
7.23k
}
10158
PyObject*
10159
ast2obj_comprehension(struct ast_state *state, void* _o)
10160
1.20k
{
10161
1.20k
    comprehension_ty o = (comprehension_ty)_o;
10162
1.20k
    PyObject *result = NULL, *value = NULL;
10163
1.20k
    PyTypeObject *tp;
10164
1.20k
    if (!o) {
10165
0
        Py_RETURN_NONE;
10166
0
    }
10167
1.20k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10168
0
        return NULL;
10169
0
    }
10170
1.20k
    tp = (PyTypeObject *)state->comprehension_type;
10171
1.20k
    result = PyType_GenericNew(tp, NULL, NULL);
10172
1.20k
    if (!result) return NULL;
10173
1.20k
    value = ast2obj_expr(state, o->target);
10174
1.20k
    if (!value) goto failed;
10175
1.20k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10176
0
        goto failed;
10177
1.20k
    Py_DECREF(value);
10178
1.20k
    value = ast2obj_expr(state, o->iter);
10179
1.20k
    if (!value) goto failed;
10180
1.20k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10181
0
        goto failed;
10182
1.20k
    Py_DECREF(value);
10183
1.20k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10184
1.20k
    if (!value) goto failed;
10185
1.20k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10186
0
        goto failed;
10187
1.20k
    Py_DECREF(value);
10188
1.20k
    value = ast2obj_int(state, o->is_async);
10189
1.20k
    if (!value) goto failed;
10190
1.20k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10191
0
        goto failed;
10192
1.20k
    Py_DECREF(value);
10193
1.20k
    Py_LeaveRecursiveCall();
10194
1.20k
    return result;
10195
0
failed:
10196
0
    Py_LeaveRecursiveCall();
10197
0
    Py_XDECREF(value);
10198
0
    Py_XDECREF(result);
10199
0
    return NULL;
10200
1.20k
}
10201
10202
PyObject*
10203
ast2obj_excepthandler(struct ast_state *state, void* _o)
10204
1.22k
{
10205
1.22k
    excepthandler_ty o = (excepthandler_ty)_o;
10206
1.22k
    PyObject *result = NULL, *value = NULL;
10207
1.22k
    PyTypeObject *tp;
10208
1.22k
    if (!o) {
10209
0
        Py_RETURN_NONE;
10210
0
    }
10211
1.22k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10212
0
        return NULL;
10213
0
    }
10214
1.22k
    switch (o->kind) {
10215
1.22k
    case ExceptHandler_kind:
10216
1.22k
        tp = (PyTypeObject *)state->ExceptHandler_type;
10217
1.22k
        result = PyType_GenericNew(tp, NULL, NULL);
10218
1.22k
        if (!result) goto failed;
10219
1.22k
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10220
1.22k
        if (!value) goto failed;
10221
1.22k
        if (PyObject_SetAttr(result, state->type, value) == -1)
10222
0
            goto failed;
10223
1.22k
        Py_DECREF(value);
10224
1.22k
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10225
1.22k
        if (!value) goto failed;
10226
1.22k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10227
0
            goto failed;
10228
1.22k
        Py_DECREF(value);
10229
1.22k
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10230
1.22k
                             ast2obj_stmt);
10231
1.22k
        if (!value) goto failed;
10232
1.22k
        if (PyObject_SetAttr(result, state->body, value) == -1)
10233
0
            goto failed;
10234
1.22k
        Py_DECREF(value);
10235
1.22k
        break;
10236
1.22k
    }
10237
1.22k
    value = ast2obj_int(state, o->lineno);
10238
1.22k
    if (!value) goto failed;
10239
1.22k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10240
0
        goto failed;
10241
1.22k
    Py_DECREF(value);
10242
1.22k
    value = ast2obj_int(state, o->col_offset);
10243
1.22k
    if (!value) goto failed;
10244
1.22k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10245
0
        goto failed;
10246
1.22k
    Py_DECREF(value);
10247
1.22k
    value = ast2obj_int(state, o->end_lineno);
10248
1.22k
    if (!value) goto failed;
10249
1.22k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10250
0
        goto failed;
10251
1.22k
    Py_DECREF(value);
10252
1.22k
    value = ast2obj_int(state, o->end_col_offset);
10253
1.22k
    if (!value) goto failed;
10254
1.22k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10255
0
        goto failed;
10256
1.22k
    Py_DECREF(value);
10257
1.22k
    Py_LeaveRecursiveCall();
10258
1.22k
    return result;
10259
0
failed:
10260
0
    Py_LeaveRecursiveCall();
10261
0
    Py_XDECREF(value);
10262
0
    Py_XDECREF(result);
10263
0
    return NULL;
10264
1.22k
}
10265
10266
PyObject*
10267
ast2obj_arguments(struct ast_state *state, void* _o)
10268
2.55k
{
10269
2.55k
    arguments_ty o = (arguments_ty)_o;
10270
2.55k
    PyObject *result = NULL, *value = NULL;
10271
2.55k
    PyTypeObject *tp;
10272
2.55k
    if (!o) {
10273
0
        Py_RETURN_NONE;
10274
0
    }
10275
2.55k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10276
0
        return NULL;
10277
0
    }
10278
2.55k
    tp = (PyTypeObject *)state->arguments_type;
10279
2.55k
    result = PyType_GenericNew(tp, NULL, NULL);
10280
2.55k
    if (!result) return NULL;
10281
2.55k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10282
2.55k
    if (!value) goto failed;
10283
2.55k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10284
0
        goto failed;
10285
2.55k
    Py_DECREF(value);
10286
2.55k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10287
2.55k
    if (!value) goto failed;
10288
2.55k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10289
0
        goto failed;
10290
2.55k
    Py_DECREF(value);
10291
2.55k
    value = ast2obj_arg(state, o->vararg);
10292
2.55k
    if (!value) goto failed;
10293
2.55k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10294
0
        goto failed;
10295
2.55k
    Py_DECREF(value);
10296
2.55k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10297
2.55k
    if (!value) goto failed;
10298
2.55k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10299
0
        goto failed;
10300
2.55k
    Py_DECREF(value);
10301
2.55k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10302
2.55k
    if (!value) goto failed;
10303
2.55k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10304
0
        goto failed;
10305
2.55k
    Py_DECREF(value);
10306
2.55k
    value = ast2obj_arg(state, o->kwarg);
10307
2.55k
    if (!value) goto failed;
10308
2.55k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10309
0
        goto failed;
10310
2.55k
    Py_DECREF(value);
10311
2.55k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10312
2.55k
    if (!value) goto failed;
10313
2.55k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10314
0
        goto failed;
10315
2.55k
    Py_DECREF(value);
10316
2.55k
    Py_LeaveRecursiveCall();
10317
2.55k
    return result;
10318
0
failed:
10319
0
    Py_LeaveRecursiveCall();
10320
0
    Py_XDECREF(value);
10321
0
    Py_XDECREF(result);
10322
0
    return NULL;
10323
2.55k
}
10324
10325
PyObject*
10326
ast2obj_arg(struct ast_state *state, void* _o)
10327
18.6k
{
10328
18.6k
    arg_ty o = (arg_ty)_o;
10329
18.6k
    PyObject *result = NULL, *value = NULL;
10330
18.6k
    PyTypeObject *tp;
10331
18.6k
    if (!o) {
10332
4.39k
        Py_RETURN_NONE;
10333
4.39k
    }
10334
14.2k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10335
0
        return NULL;
10336
0
    }
10337
14.2k
    tp = (PyTypeObject *)state->arg_type;
10338
14.2k
    result = PyType_GenericNew(tp, NULL, NULL);
10339
14.2k
    if (!result) return NULL;
10340
14.2k
    value = ast2obj_identifier(state, o->arg);
10341
14.2k
    if (!value) goto failed;
10342
14.2k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10343
0
        goto failed;
10344
14.2k
    Py_DECREF(value);
10345
14.2k
    value = ast2obj_expr(state, o->annotation);
10346
14.2k
    if (!value) goto failed;
10347
14.2k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10348
0
        goto failed;
10349
14.2k
    Py_DECREF(value);
10350
14.2k
    value = ast2obj_string(state, o->type_comment);
10351
14.2k
    if (!value) goto failed;
10352
14.2k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10353
0
        goto failed;
10354
14.2k
    Py_DECREF(value);
10355
14.2k
    value = ast2obj_int(state, o->lineno);
10356
14.2k
    if (!value) goto failed;
10357
14.2k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10358
0
        goto failed;
10359
14.2k
    Py_DECREF(value);
10360
14.2k
    value = ast2obj_int(state, o->col_offset);
10361
14.2k
    if (!value) goto failed;
10362
14.2k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10363
0
        goto failed;
10364
14.2k
    Py_DECREF(value);
10365
14.2k
    value = ast2obj_int(state, o->end_lineno);
10366
14.2k
    if (!value) goto failed;
10367
14.2k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10368
0
        goto failed;
10369
14.2k
    Py_DECREF(value);
10370
14.2k
    value = ast2obj_int(state, o->end_col_offset);
10371
14.2k
    if (!value) goto failed;
10372
14.2k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10373
0
        goto failed;
10374
14.2k
    Py_DECREF(value);
10375
14.2k
    Py_LeaveRecursiveCall();
10376
14.2k
    return result;
10377
0
failed:
10378
0
    Py_LeaveRecursiveCall();
10379
0
    Py_XDECREF(value);
10380
0
    Py_XDECREF(result);
10381
0
    return NULL;
10382
14.2k
}
10383
10384
PyObject*
10385
ast2obj_keyword(struct ast_state *state, void* _o)
10386
1.80k
{
10387
1.80k
    keyword_ty o = (keyword_ty)_o;
10388
1.80k
    PyObject *result = NULL, *value = NULL;
10389
1.80k
    PyTypeObject *tp;
10390
1.80k
    if (!o) {
10391
0
        Py_RETURN_NONE;
10392
0
    }
10393
1.80k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10394
0
        return NULL;
10395
0
    }
10396
1.80k
    tp = (PyTypeObject *)state->keyword_type;
10397
1.80k
    result = PyType_GenericNew(tp, NULL, NULL);
10398
1.80k
    if (!result) return NULL;
10399
1.80k
    value = ast2obj_identifier(state, o->arg);
10400
1.80k
    if (!value) goto failed;
10401
1.80k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10402
0
        goto failed;
10403
1.80k
    Py_DECREF(value);
10404
1.80k
    value = ast2obj_expr(state, o->value);
10405
1.80k
    if (!value) goto failed;
10406
1.80k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10407
0
        goto failed;
10408
1.80k
    Py_DECREF(value);
10409
1.80k
    value = ast2obj_int(state, o->lineno);
10410
1.80k
    if (!value) goto failed;
10411
1.80k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10412
0
        goto failed;
10413
1.80k
    Py_DECREF(value);
10414
1.80k
    value = ast2obj_int(state, o->col_offset);
10415
1.80k
    if (!value) goto failed;
10416
1.80k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10417
0
        goto failed;
10418
1.80k
    Py_DECREF(value);
10419
1.80k
    value = ast2obj_int(state, o->end_lineno);
10420
1.80k
    if (!value) goto failed;
10421
1.80k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10422
0
        goto failed;
10423
1.80k
    Py_DECREF(value);
10424
1.80k
    value = ast2obj_int(state, o->end_col_offset);
10425
1.80k
    if (!value) goto failed;
10426
1.80k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10427
0
        goto failed;
10428
1.80k
    Py_DECREF(value);
10429
1.80k
    Py_LeaveRecursiveCall();
10430
1.80k
    return result;
10431
0
failed:
10432
0
    Py_LeaveRecursiveCall();
10433
0
    Py_XDECREF(value);
10434
0
    Py_XDECREF(result);
10435
0
    return NULL;
10436
1.80k
}
10437
10438
PyObject*
10439
ast2obj_alias(struct ast_state *state, void* _o)
10440
3.04k
{
10441
3.04k
    alias_ty o = (alias_ty)_o;
10442
3.04k
    PyObject *result = NULL, *value = NULL;
10443
3.04k
    PyTypeObject *tp;
10444
3.04k
    if (!o) {
10445
0
        Py_RETURN_NONE;
10446
0
    }
10447
3.04k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10448
0
        return NULL;
10449
0
    }
10450
3.04k
    tp = (PyTypeObject *)state->alias_type;
10451
3.04k
    result = PyType_GenericNew(tp, NULL, NULL);
10452
3.04k
    if (!result) return NULL;
10453
3.04k
    value = ast2obj_identifier(state, o->name);
10454
3.04k
    if (!value) goto failed;
10455
3.04k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10456
0
        goto failed;
10457
3.04k
    Py_DECREF(value);
10458
3.04k
    value = ast2obj_identifier(state, o->asname);
10459
3.04k
    if (!value) goto failed;
10460
3.04k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10461
0
        goto failed;
10462
3.04k
    Py_DECREF(value);
10463
3.04k
    value = ast2obj_int(state, o->lineno);
10464
3.04k
    if (!value) goto failed;
10465
3.04k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10466
0
        goto failed;
10467
3.04k
    Py_DECREF(value);
10468
3.04k
    value = ast2obj_int(state, o->col_offset);
10469
3.04k
    if (!value) goto failed;
10470
3.04k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10471
0
        goto failed;
10472
3.04k
    Py_DECREF(value);
10473
3.04k
    value = ast2obj_int(state, o->end_lineno);
10474
3.04k
    if (!value) goto failed;
10475
3.04k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10476
0
        goto failed;
10477
3.04k
    Py_DECREF(value);
10478
3.04k
    value = ast2obj_int(state, o->end_col_offset);
10479
3.04k
    if (!value) goto failed;
10480
3.04k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10481
0
        goto failed;
10482
3.04k
    Py_DECREF(value);
10483
3.04k
    Py_LeaveRecursiveCall();
10484
3.04k
    return result;
10485
0
failed:
10486
0
    Py_LeaveRecursiveCall();
10487
0
    Py_XDECREF(value);
10488
0
    Py_XDECREF(result);
10489
0
    return NULL;
10490
3.04k
}
10491
10492
PyObject*
10493
ast2obj_withitem(struct ast_state *state, void* _o)
10494
1.34k
{
10495
1.34k
    withitem_ty o = (withitem_ty)_o;
10496
1.34k
    PyObject *result = NULL, *value = NULL;
10497
1.34k
    PyTypeObject *tp;
10498
1.34k
    if (!o) {
10499
0
        Py_RETURN_NONE;
10500
0
    }
10501
1.34k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10502
0
        return NULL;
10503
0
    }
10504
1.34k
    tp = (PyTypeObject *)state->withitem_type;
10505
1.34k
    result = PyType_GenericNew(tp, NULL, NULL);
10506
1.34k
    if (!result) return NULL;
10507
1.34k
    value = ast2obj_expr(state, o->context_expr);
10508
1.34k
    if (!value) goto failed;
10509
1.34k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10510
0
        goto failed;
10511
1.34k
    Py_DECREF(value);
10512
1.34k
    value = ast2obj_expr(state, o->optional_vars);
10513
1.34k
    if (!value) goto failed;
10514
1.34k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10515
0
        goto failed;
10516
1.34k
    Py_DECREF(value);
10517
1.34k
    Py_LeaveRecursiveCall();
10518
1.34k
    return result;
10519
0
failed:
10520
0
    Py_LeaveRecursiveCall();
10521
0
    Py_XDECREF(value);
10522
0
    Py_XDECREF(result);
10523
0
    return NULL;
10524
1.34k
}
10525
10526
PyObject*
10527
ast2obj_match_case(struct ast_state *state, void* _o)
10528
689
{
10529
689
    match_case_ty o = (match_case_ty)_o;
10530
689
    PyObject *result = NULL, *value = NULL;
10531
689
    PyTypeObject *tp;
10532
689
    if (!o) {
10533
0
        Py_RETURN_NONE;
10534
0
    }
10535
689
    if (Py_EnterRecursiveCall("during  ast construction")) {
10536
0
        return NULL;
10537
0
    }
10538
689
    tp = (PyTypeObject *)state->match_case_type;
10539
689
    result = PyType_GenericNew(tp, NULL, NULL);
10540
689
    if (!result) return NULL;
10541
689
    value = ast2obj_pattern(state, o->pattern);
10542
689
    if (!value) goto failed;
10543
689
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10544
0
        goto failed;
10545
689
    Py_DECREF(value);
10546
689
    value = ast2obj_expr(state, o->guard);
10547
689
    if (!value) goto failed;
10548
689
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10549
0
        goto failed;
10550
689
    Py_DECREF(value);
10551
689
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10552
689
    if (!value) goto failed;
10553
689
    if (PyObject_SetAttr(result, state->body, value) == -1)
10554
0
        goto failed;
10555
689
    Py_DECREF(value);
10556
689
    Py_LeaveRecursiveCall();
10557
689
    return result;
10558
0
failed:
10559
0
    Py_LeaveRecursiveCall();
10560
0
    Py_XDECREF(value);
10561
0
    Py_XDECREF(result);
10562
0
    return NULL;
10563
689
}
10564
10565
PyObject*
10566
ast2obj_pattern(struct ast_state *state, void* _o)
10567
23.4k
{
10568
23.4k
    pattern_ty o = (pattern_ty)_o;
10569
23.4k
    PyObject *result = NULL, *value = NULL;
10570
23.4k
    PyTypeObject *tp;
10571
23.4k
    if (!o) {
10572
8.84k
        Py_RETURN_NONE;
10573
8.84k
    }
10574
14.5k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10575
0
        return NULL;
10576
0
    }
10577
14.5k
    switch (o->kind) {
10578
683
    case MatchValue_kind:
10579
683
        tp = (PyTypeObject *)state->MatchValue_type;
10580
683
        result = PyType_GenericNew(tp, NULL, NULL);
10581
683
        if (!result) goto failed;
10582
683
        value = ast2obj_expr(state, o->v.MatchValue.value);
10583
683
        if (!value) goto failed;
10584
683
        if (PyObject_SetAttr(result, state->value, value) == -1)
10585
0
            goto failed;
10586
683
        Py_DECREF(value);
10587
683
        break;
10588
269
    case MatchSingleton_kind:
10589
269
        tp = (PyTypeObject *)state->MatchSingleton_type;
10590
269
        result = PyType_GenericNew(tp, NULL, NULL);
10591
269
        if (!result) goto failed;
10592
269
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10593
269
        if (!value) goto failed;
10594
269
        if (PyObject_SetAttr(result, state->value, value) == -1)
10595
0
            goto failed;
10596
269
        Py_DECREF(value);
10597
269
        break;
10598
398
    case MatchSequence_kind:
10599
398
        tp = (PyTypeObject *)state->MatchSequence_type;
10600
398
        result = PyType_GenericNew(tp, NULL, NULL);
10601
398
        if (!result) goto failed;
10602
398
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10603
398
                             ast2obj_pattern);
10604
398
        if (!value) goto failed;
10605
398
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10606
0
            goto failed;
10607
398
        Py_DECREF(value);
10608
398
        break;
10609
307
    case MatchMapping_kind:
10610
307
        tp = (PyTypeObject *)state->MatchMapping_type;
10611
307
        result = PyType_GenericNew(tp, NULL, NULL);
10612
307
        if (!result) goto failed;
10613
307
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10614
307
                             ast2obj_expr);
10615
307
        if (!value) goto failed;
10616
307
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10617
0
            goto failed;
10618
307
        Py_DECREF(value);
10619
307
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10620
307
                             ast2obj_pattern);
10621
307
        if (!value) goto failed;
10622
307
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10623
0
            goto failed;
10624
307
        Py_DECREF(value);
10625
307
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10626
307
        if (!value) goto failed;
10627
307
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10628
0
            goto failed;
10629
307
        Py_DECREF(value);
10630
307
        break;
10631
763
    case MatchClass_kind:
10632
763
        tp = (PyTypeObject *)state->MatchClass_type;
10633
763
        result = PyType_GenericNew(tp, NULL, NULL);
10634
763
        if (!result) goto failed;
10635
763
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10636
763
        if (!value) goto failed;
10637
763
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10638
0
            goto failed;
10639
763
        Py_DECREF(value);
10640
763
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10641
763
                             ast2obj_pattern);
10642
763
        if (!value) goto failed;
10643
763
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10644
0
            goto failed;
10645
763
        Py_DECREF(value);
10646
763
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10647
763
                             ast2obj_identifier);
10648
763
        if (!value) goto failed;
10649
763
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10650
0
            goto failed;
10651
763
        Py_DECREF(value);
10652
763
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10653
763
                             ast2obj_pattern);
10654
763
        if (!value) goto failed;
10655
763
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10656
0
            goto failed;
10657
763
        Py_DECREF(value);
10658
763
        break;
10659
249
    case MatchStar_kind:
10660
249
        tp = (PyTypeObject *)state->MatchStar_type;
10661
249
        result = PyType_GenericNew(tp, NULL, NULL);
10662
249
        if (!result) goto failed;
10663
249
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10664
249
        if (!value) goto failed;
10665
249
        if (PyObject_SetAttr(result, state->name, value) == -1)
10666
0
            goto failed;
10667
249
        Py_DECREF(value);
10668
249
        break;
10669
8.93k
    case MatchAs_kind:
10670
8.93k
        tp = (PyTypeObject *)state->MatchAs_type;
10671
8.93k
        result = PyType_GenericNew(tp, NULL, NULL);
10672
8.93k
        if (!result) goto failed;
10673
8.93k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10674
8.93k
        if (!value) goto failed;
10675
8.93k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10676
0
            goto failed;
10677
8.93k
        Py_DECREF(value);
10678
8.93k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10679
8.93k
        if (!value) goto failed;
10680
8.93k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10681
0
            goto failed;
10682
8.93k
        Py_DECREF(value);
10683
8.93k
        break;
10684
2.99k
    case MatchOr_kind:
10685
2.99k
        tp = (PyTypeObject *)state->MatchOr_type;
10686
2.99k
        result = PyType_GenericNew(tp, NULL, NULL);
10687
2.99k
        if (!result) goto failed;
10688
2.99k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10689
2.99k
                             ast2obj_pattern);
10690
2.99k
        if (!value) goto failed;
10691
2.99k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10692
0
            goto failed;
10693
2.99k
        Py_DECREF(value);
10694
2.99k
        break;
10695
14.5k
    }
10696
14.5k
    value = ast2obj_int(state, o->lineno);
10697
14.5k
    if (!value) goto failed;
10698
14.5k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10699
0
        goto failed;
10700
14.5k
    Py_DECREF(value);
10701
14.5k
    value = ast2obj_int(state, o->col_offset);
10702
14.5k
    if (!value) goto failed;
10703
14.5k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10704
0
        goto failed;
10705
14.5k
    Py_DECREF(value);
10706
14.5k
    value = ast2obj_int(state, o->end_lineno);
10707
14.5k
    if (!value) goto failed;
10708
14.5k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10709
0
        goto failed;
10710
14.5k
    Py_DECREF(value);
10711
14.5k
    value = ast2obj_int(state, o->end_col_offset);
10712
14.5k
    if (!value) goto failed;
10713
14.5k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10714
0
        goto failed;
10715
14.5k
    Py_DECREF(value);
10716
14.5k
    Py_LeaveRecursiveCall();
10717
14.5k
    return result;
10718
0
failed:
10719
0
    Py_LeaveRecursiveCall();
10720
0
    Py_XDECREF(value);
10721
0
    Py_XDECREF(result);
10722
0
    return NULL;
10723
14.5k
}
10724
10725
PyObject*
10726
ast2obj_type_ignore(struct ast_state *state, void* _o)
10727
0
{
10728
0
    type_ignore_ty o = (type_ignore_ty)_o;
10729
0
    PyObject *result = NULL, *value = NULL;
10730
0
    PyTypeObject *tp;
10731
0
    if (!o) {
10732
0
        Py_RETURN_NONE;
10733
0
    }
10734
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10735
0
        return NULL;
10736
0
    }
10737
0
    switch (o->kind) {
10738
0
    case TypeIgnore_kind:
10739
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10740
0
        result = PyType_GenericNew(tp, NULL, NULL);
10741
0
        if (!result) goto failed;
10742
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10743
0
        if (!value) goto failed;
10744
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10745
0
            goto failed;
10746
0
        Py_DECREF(value);
10747
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10748
0
        if (!value) goto failed;
10749
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10750
0
            goto failed;
10751
0
        Py_DECREF(value);
10752
0
        break;
10753
0
    }
10754
0
    Py_LeaveRecursiveCall();
10755
0
    return result;
10756
0
failed:
10757
0
    Py_LeaveRecursiveCall();
10758
0
    Py_XDECREF(value);
10759
0
    Py_XDECREF(result);
10760
0
    return NULL;
10761
0
}
10762
10763
PyObject*
10764
ast2obj_type_param(struct ast_state *state, void* _o)
10765
6.92k
{
10766
6.92k
    type_param_ty o = (type_param_ty)_o;
10767
6.92k
    PyObject *result = NULL, *value = NULL;
10768
6.92k
    PyTypeObject *tp;
10769
6.92k
    if (!o) {
10770
0
        Py_RETURN_NONE;
10771
0
    }
10772
6.92k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10773
0
        return NULL;
10774
0
    }
10775
6.92k
    switch (o->kind) {
10776
5.19k
    case TypeVar_kind:
10777
5.19k
        tp = (PyTypeObject *)state->TypeVar_type;
10778
5.19k
        result = PyType_GenericNew(tp, NULL, NULL);
10779
5.19k
        if (!result) goto failed;
10780
5.19k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10781
5.19k
        if (!value) goto failed;
10782
5.19k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10783
0
            goto failed;
10784
5.19k
        Py_DECREF(value);
10785
5.19k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10786
5.19k
        if (!value) goto failed;
10787
5.19k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10788
0
            goto failed;
10789
5.19k
        Py_DECREF(value);
10790
5.19k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10791
5.19k
        if (!value) goto failed;
10792
5.19k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10793
0
            goto failed;
10794
5.19k
        Py_DECREF(value);
10795
5.19k
        break;
10796
427
    case ParamSpec_kind:
10797
427
        tp = (PyTypeObject *)state->ParamSpec_type;
10798
427
        result = PyType_GenericNew(tp, NULL, NULL);
10799
427
        if (!result) goto failed;
10800
427
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10801
427
        if (!value) goto failed;
10802
427
        if (PyObject_SetAttr(result, state->name, value) == -1)
10803
0
            goto failed;
10804
427
        Py_DECREF(value);
10805
427
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10806
427
        if (!value) goto failed;
10807
427
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10808
0
            goto failed;
10809
427
        Py_DECREF(value);
10810
427
        break;
10811
1.30k
    case TypeVarTuple_kind:
10812
1.30k
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10813
1.30k
        result = PyType_GenericNew(tp, NULL, NULL);
10814
1.30k
        if (!result) goto failed;
10815
1.30k
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10816
1.30k
        if (!value) goto failed;
10817
1.30k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10818
0
            goto failed;
10819
1.30k
        Py_DECREF(value);
10820
1.30k
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10821
1.30k
        if (!value) goto failed;
10822
1.30k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10823
0
            goto failed;
10824
1.30k
        Py_DECREF(value);
10825
1.30k
        break;
10826
6.92k
    }
10827
6.92k
    value = ast2obj_int(state, o->lineno);
10828
6.92k
    if (!value) goto failed;
10829
6.92k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10830
0
        goto failed;
10831
6.92k
    Py_DECREF(value);
10832
6.92k
    value = ast2obj_int(state, o->col_offset);
10833
6.92k
    if (!value) goto failed;
10834
6.92k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10835
0
        goto failed;
10836
6.92k
    Py_DECREF(value);
10837
6.92k
    value = ast2obj_int(state, o->end_lineno);
10838
6.92k
    if (!value) goto failed;
10839
6.92k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10840
0
        goto failed;
10841
6.92k
    Py_DECREF(value);
10842
6.92k
    value = ast2obj_int(state, o->end_col_offset);
10843
6.92k
    if (!value) goto failed;
10844
6.92k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10845
0
        goto failed;
10846
6.92k
    Py_DECREF(value);
10847
6.92k
    Py_LeaveRecursiveCall();
10848
6.92k
    return result;
10849
0
failed:
10850
0
    Py_LeaveRecursiveCall();
10851
0
    Py_XDECREF(value);
10852
0
    Py_XDECREF(result);
10853
0
    return NULL;
10854
6.92k
}
10855
10856
10857
int
10858
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
10859
0
{
10860
0
    int isinstance;
10861
10862
0
    PyObject *tmp = NULL;
10863
0
    PyObject *tp;
10864
10865
0
    if (obj == Py_None) {
10866
0
        *out = NULL;
10867
0
        return 0;
10868
0
    }
10869
0
    tp = state->Module_type;
10870
0
    isinstance = PyObject_IsInstance(obj, tp);
10871
0
    if (isinstance == -1) {
10872
0
        return -1;
10873
0
    }
10874
0
    if (isinstance) {
10875
0
        asdl_stmt_seq* body;
10876
0
        asdl_type_ignore_seq* type_ignores;
10877
10878
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10879
0
            return -1;
10880
0
        }
10881
0
        if (tmp == NULL) {
10882
0
            tmp = PyList_New(0);
10883
0
            if (tmp == NULL) {
10884
0
                return -1;
10885
0
            }
10886
0
        }
10887
0
        {
10888
0
            int res;
10889
0
            Py_ssize_t len;
10890
0
            Py_ssize_t i;
10891
0
            if (!PyList_Check(tmp)) {
10892
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10893
0
                goto failed;
10894
0
            }
10895
0
            len = PyList_GET_SIZE(tmp);
10896
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10897
0
            if (body == NULL) goto failed;
10898
0
            for (i = 0; i < len; i++) {
10899
0
                stmt_ty val;
10900
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10901
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10902
0
                    goto failed;
10903
0
                }
10904
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10905
0
                _Py_LeaveRecursiveCall();
10906
0
                Py_DECREF(tmp2);
10907
0
                if (res != 0) goto failed;
10908
0
                if (len != PyList_GET_SIZE(tmp)) {
10909
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10910
0
                    goto failed;
10911
0
                }
10912
0
                asdl_seq_SET(body, i, val);
10913
0
            }
10914
0
            Py_CLEAR(tmp);
10915
0
        }
10916
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10917
0
            return -1;
10918
0
        }
10919
0
        if (tmp == NULL) {
10920
0
            tmp = PyList_New(0);
10921
0
            if (tmp == NULL) {
10922
0
                return -1;
10923
0
            }
10924
0
        }
10925
0
        {
10926
0
            int res;
10927
0
            Py_ssize_t len;
10928
0
            Py_ssize_t i;
10929
0
            if (!PyList_Check(tmp)) {
10930
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10931
0
                goto failed;
10932
0
            }
10933
0
            len = PyList_GET_SIZE(tmp);
10934
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
10935
0
            if (type_ignores == NULL) goto failed;
10936
0
            for (i = 0; i < len; i++) {
10937
0
                type_ignore_ty val;
10938
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10939
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10940
0
                    goto failed;
10941
0
                }
10942
0
                res = obj2ast_type_ignore(state, tmp2, &val, arena);
10943
0
                _Py_LeaveRecursiveCall();
10944
0
                Py_DECREF(tmp2);
10945
0
                if (res != 0) goto failed;
10946
0
                if (len != PyList_GET_SIZE(tmp)) {
10947
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
10948
0
                    goto failed;
10949
0
                }
10950
0
                asdl_seq_SET(type_ignores, i, val);
10951
0
            }
10952
0
            Py_CLEAR(tmp);
10953
0
        }
10954
0
        *out = _PyAST_Module(body, type_ignores, arena);
10955
0
        if (*out == NULL) goto failed;
10956
0
        return 0;
10957
0
    }
10958
0
    tp = state->Interactive_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
        asdl_stmt_seq* body;
10965
10966
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10967
0
            return -1;
10968
0
        }
10969
0
        if (tmp == NULL) {
10970
0
            tmp = PyList_New(0);
10971
0
            if (tmp == NULL) {
10972
0
                return -1;
10973
0
            }
10974
0
        }
10975
0
        {
10976
0
            int res;
10977
0
            Py_ssize_t len;
10978
0
            Py_ssize_t i;
10979
0
            if (!PyList_Check(tmp)) {
10980
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10981
0
                goto failed;
10982
0
            }
10983
0
            len = PyList_GET_SIZE(tmp);
10984
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10985
0
            if (body == NULL) goto failed;
10986
0
            for (i = 0; i < len; i++) {
10987
0
                stmt_ty val;
10988
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10989
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
10990
0
                    goto failed;
10991
0
                }
10992
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10993
0
                _Py_LeaveRecursiveCall();
10994
0
                Py_DECREF(tmp2);
10995
0
                if (res != 0) goto failed;
10996
0
                if (len != PyList_GET_SIZE(tmp)) {
10997
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
10998
0
                    goto failed;
10999
0
                }
11000
0
                asdl_seq_SET(body, i, val);
11001
0
            }
11002
0
            Py_CLEAR(tmp);
11003
0
        }
11004
0
        *out = _PyAST_Interactive(body, arena);
11005
0
        if (*out == NULL) goto failed;
11006
0
        return 0;
11007
0
    }
11008
0
    tp = state->Expression_type;
11009
0
    isinstance = PyObject_IsInstance(obj, tp);
11010
0
    if (isinstance == -1) {
11011
0
        return -1;
11012
0
    }
11013
0
    if (isinstance) {
11014
0
        expr_ty body;
11015
11016
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11017
0
            return -1;
11018
0
        }
11019
0
        if (tmp == NULL) {
11020
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11021
0
            return -1;
11022
0
        }
11023
0
        else {
11024
0
            int res;
11025
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11026
0
                goto failed;
11027
0
            }
11028
0
            res = obj2ast_expr(state, tmp, &body, arena);
11029
0
            _Py_LeaveRecursiveCall();
11030
0
            if (res != 0) goto failed;
11031
0
            Py_CLEAR(tmp);
11032
0
        }
11033
0
        *out = _PyAST_Expression(body, arena);
11034
0
        if (*out == NULL) goto failed;
11035
0
        return 0;
11036
0
    }
11037
0
    tp = state->FunctionType_type;
11038
0
    isinstance = PyObject_IsInstance(obj, tp);
11039
0
    if (isinstance == -1) {
11040
0
        return -1;
11041
0
    }
11042
0
    if (isinstance) {
11043
0
        asdl_expr_seq* argtypes;
11044
0
        expr_ty returns;
11045
11046
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11047
0
            return -1;
11048
0
        }
11049
0
        if (tmp == NULL) {
11050
0
            tmp = PyList_New(0);
11051
0
            if (tmp == NULL) {
11052
0
                return -1;
11053
0
            }
11054
0
        }
11055
0
        {
11056
0
            int res;
11057
0
            Py_ssize_t len;
11058
0
            Py_ssize_t i;
11059
0
            if (!PyList_Check(tmp)) {
11060
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11061
0
                goto failed;
11062
0
            }
11063
0
            len = PyList_GET_SIZE(tmp);
11064
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11065
0
            if (argtypes == NULL) goto failed;
11066
0
            for (i = 0; i < len; i++) {
11067
0
                expr_ty val;
11068
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11069
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11070
0
                    goto failed;
11071
0
                }
11072
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11073
0
                _Py_LeaveRecursiveCall();
11074
0
                Py_DECREF(tmp2);
11075
0
                if (res != 0) goto failed;
11076
0
                if (len != PyList_GET_SIZE(tmp)) {
11077
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11078
0
                    goto failed;
11079
0
                }
11080
0
                asdl_seq_SET(argtypes, i, val);
11081
0
            }
11082
0
            Py_CLEAR(tmp);
11083
0
        }
11084
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11085
0
            return -1;
11086
0
        }
11087
0
        if (tmp == NULL) {
11088
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11089
0
            return -1;
11090
0
        }
11091
0
        else {
11092
0
            int res;
11093
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11094
0
                goto failed;
11095
0
            }
11096
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11097
0
            _Py_LeaveRecursiveCall();
11098
0
            if (res != 0) goto failed;
11099
0
            Py_CLEAR(tmp);
11100
0
        }
11101
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11102
0
        if (*out == NULL) goto failed;
11103
0
        return 0;
11104
0
    }
11105
11106
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11107
0
    failed:
11108
0
    Py_XDECREF(tmp);
11109
0
    return -1;
11110
0
}
11111
11112
int
11113
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
11114
             arena)
11115
0
{
11116
0
    int isinstance;
11117
11118
0
    PyObject *tmp = NULL;
11119
0
    PyObject *tp;
11120
0
    int lineno;
11121
0
    int col_offset;
11122
0
    int end_lineno;
11123
0
    int end_col_offset;
11124
11125
0
    if (obj == Py_None) {
11126
0
        *out = NULL;
11127
0
        return 0;
11128
0
    }
11129
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11130
0
        return -1;
11131
0
    }
11132
0
    if (tmp == NULL) {
11133
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11134
0
        return -1;
11135
0
    }
11136
0
    else {
11137
0
        int res;
11138
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11139
0
            goto failed;
11140
0
        }
11141
0
        res = obj2ast_int(state, tmp, &lineno, arena);
11142
0
        _Py_LeaveRecursiveCall();
11143
0
        if (res != 0) goto failed;
11144
0
        Py_CLEAR(tmp);
11145
0
    }
11146
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11147
0
        return -1;
11148
0
    }
11149
0
    if (tmp == NULL) {
11150
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11151
0
        return -1;
11152
0
    }
11153
0
    else {
11154
0
        int res;
11155
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11156
0
            goto failed;
11157
0
        }
11158
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
11159
0
        _Py_LeaveRecursiveCall();
11160
0
        if (res != 0) goto failed;
11161
0
        Py_CLEAR(tmp);
11162
0
    }
11163
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11164
0
        return -1;
11165
0
    }
11166
0
    if (tmp == NULL || tmp == Py_None) {
11167
0
        Py_CLEAR(tmp);
11168
0
        end_lineno = lineno;
11169
0
    }
11170
0
    else {
11171
0
        int res;
11172
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11173
0
            goto failed;
11174
0
        }
11175
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
11176
0
        _Py_LeaveRecursiveCall();
11177
0
        if (res != 0) goto failed;
11178
0
        Py_CLEAR(tmp);
11179
0
    }
11180
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11181
0
        return -1;
11182
0
    }
11183
0
    if (tmp == NULL || tmp == Py_None) {
11184
0
        Py_CLEAR(tmp);
11185
0
        end_col_offset = col_offset;
11186
0
    }
11187
0
    else {
11188
0
        int res;
11189
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11190
0
            goto failed;
11191
0
        }
11192
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
11193
0
        _Py_LeaveRecursiveCall();
11194
0
        if (res != 0) goto failed;
11195
0
        Py_CLEAR(tmp);
11196
0
    }
11197
0
    tp = state->FunctionDef_type;
11198
0
    isinstance = PyObject_IsInstance(obj, tp);
11199
0
    if (isinstance == -1) {
11200
0
        return -1;
11201
0
    }
11202
0
    if (isinstance) {
11203
0
        identifier name;
11204
0
        arguments_ty args;
11205
0
        asdl_stmt_seq* body;
11206
0
        asdl_expr_seq* decorator_list;
11207
0
        expr_ty returns;
11208
0
        string type_comment;
11209
0
        asdl_type_param_seq* type_params;
11210
11211
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11212
0
            return -1;
11213
0
        }
11214
0
        if (tmp == NULL) {
11215
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11216
0
            return -1;
11217
0
        }
11218
0
        else {
11219
0
            int res;
11220
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11221
0
                goto failed;
11222
0
            }
11223
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11224
0
            _Py_LeaveRecursiveCall();
11225
0
            if (res != 0) goto failed;
11226
0
            Py_CLEAR(tmp);
11227
0
        }
11228
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11229
0
            return -1;
11230
0
        }
11231
0
        if (tmp == NULL) {
11232
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11233
0
            return -1;
11234
0
        }
11235
0
        else {
11236
0
            int res;
11237
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11238
0
                goto failed;
11239
0
            }
11240
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11241
0
            _Py_LeaveRecursiveCall();
11242
0
            if (res != 0) goto failed;
11243
0
            Py_CLEAR(tmp);
11244
0
        }
11245
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11246
0
            return -1;
11247
0
        }
11248
0
        if (tmp == NULL) {
11249
0
            tmp = PyList_New(0);
11250
0
            if (tmp == NULL) {
11251
0
                return -1;
11252
0
            }
11253
0
        }
11254
0
        {
11255
0
            int res;
11256
0
            Py_ssize_t len;
11257
0
            Py_ssize_t i;
11258
0
            if (!PyList_Check(tmp)) {
11259
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11260
0
                goto failed;
11261
0
            }
11262
0
            len = PyList_GET_SIZE(tmp);
11263
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11264
0
            if (body == NULL) goto failed;
11265
0
            for (i = 0; i < len; i++) {
11266
0
                stmt_ty val;
11267
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11268
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11269
0
                    goto failed;
11270
0
                }
11271
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11272
0
                _Py_LeaveRecursiveCall();
11273
0
                Py_DECREF(tmp2);
11274
0
                if (res != 0) goto failed;
11275
0
                if (len != PyList_GET_SIZE(tmp)) {
11276
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11277
0
                    goto failed;
11278
0
                }
11279
0
                asdl_seq_SET(body, i, val);
11280
0
            }
11281
0
            Py_CLEAR(tmp);
11282
0
        }
11283
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11284
0
            return -1;
11285
0
        }
11286
0
        if (tmp == NULL) {
11287
0
            tmp = PyList_New(0);
11288
0
            if (tmp == NULL) {
11289
0
                return -1;
11290
0
            }
11291
0
        }
11292
0
        {
11293
0
            int res;
11294
0
            Py_ssize_t len;
11295
0
            Py_ssize_t i;
11296
0
            if (!PyList_Check(tmp)) {
11297
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11298
0
                goto failed;
11299
0
            }
11300
0
            len = PyList_GET_SIZE(tmp);
11301
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11302
0
            if (decorator_list == NULL) goto failed;
11303
0
            for (i = 0; i < len; i++) {
11304
0
                expr_ty val;
11305
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11306
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11307
0
                    goto failed;
11308
0
                }
11309
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11310
0
                _Py_LeaveRecursiveCall();
11311
0
                Py_DECREF(tmp2);
11312
0
                if (res != 0) goto failed;
11313
0
                if (len != PyList_GET_SIZE(tmp)) {
11314
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11315
0
                    goto failed;
11316
0
                }
11317
0
                asdl_seq_SET(decorator_list, i, val);
11318
0
            }
11319
0
            Py_CLEAR(tmp);
11320
0
        }
11321
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11322
0
            return -1;
11323
0
        }
11324
0
        if (tmp == NULL || tmp == Py_None) {
11325
0
            Py_CLEAR(tmp);
11326
0
            returns = NULL;
11327
0
        }
11328
0
        else {
11329
0
            int res;
11330
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11331
0
                goto failed;
11332
0
            }
11333
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11334
0
            _Py_LeaveRecursiveCall();
11335
0
            if (res != 0) goto failed;
11336
0
            Py_CLEAR(tmp);
11337
0
        }
11338
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11339
0
            return -1;
11340
0
        }
11341
0
        if (tmp == NULL || tmp == Py_None) {
11342
0
            Py_CLEAR(tmp);
11343
0
            type_comment = NULL;
11344
0
        }
11345
0
        else {
11346
0
            int res;
11347
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11348
0
                goto failed;
11349
0
            }
11350
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11351
0
            _Py_LeaveRecursiveCall();
11352
0
            if (res != 0) goto failed;
11353
0
            Py_CLEAR(tmp);
11354
0
        }
11355
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11356
0
            return -1;
11357
0
        }
11358
0
        if (tmp == NULL) {
11359
0
            tmp = PyList_New(0);
11360
0
            if (tmp == NULL) {
11361
0
                return -1;
11362
0
            }
11363
0
        }
11364
0
        {
11365
0
            int res;
11366
0
            Py_ssize_t len;
11367
0
            Py_ssize_t i;
11368
0
            if (!PyList_Check(tmp)) {
11369
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11370
0
                goto failed;
11371
0
            }
11372
0
            len = PyList_GET_SIZE(tmp);
11373
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11374
0
            if (type_params == NULL) goto failed;
11375
0
            for (i = 0; i < len; i++) {
11376
0
                type_param_ty val;
11377
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11378
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11379
0
                    goto failed;
11380
0
                }
11381
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11382
0
                _Py_LeaveRecursiveCall();
11383
0
                Py_DECREF(tmp2);
11384
0
                if (res != 0) goto failed;
11385
0
                if (len != PyList_GET_SIZE(tmp)) {
11386
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11387
0
                    goto failed;
11388
0
                }
11389
0
                asdl_seq_SET(type_params, i, val);
11390
0
            }
11391
0
            Py_CLEAR(tmp);
11392
0
        }
11393
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11394
0
                                  type_comment, type_params, lineno,
11395
0
                                  col_offset, end_lineno, end_col_offset,
11396
0
                                  arena);
11397
0
        if (*out == NULL) goto failed;
11398
0
        return 0;
11399
0
    }
11400
0
    tp = state->AsyncFunctionDef_type;
11401
0
    isinstance = PyObject_IsInstance(obj, tp);
11402
0
    if (isinstance == -1) {
11403
0
        return -1;
11404
0
    }
11405
0
    if (isinstance) {
11406
0
        identifier name;
11407
0
        arguments_ty args;
11408
0
        asdl_stmt_seq* body;
11409
0
        asdl_expr_seq* decorator_list;
11410
0
        expr_ty returns;
11411
0
        string type_comment;
11412
0
        asdl_type_param_seq* type_params;
11413
11414
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11415
0
            return -1;
11416
0
        }
11417
0
        if (tmp == NULL) {
11418
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11419
0
            return -1;
11420
0
        }
11421
0
        else {
11422
0
            int res;
11423
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11424
0
                goto failed;
11425
0
            }
11426
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11427
0
            _Py_LeaveRecursiveCall();
11428
0
            if (res != 0) goto failed;
11429
0
            Py_CLEAR(tmp);
11430
0
        }
11431
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11432
0
            return -1;
11433
0
        }
11434
0
        if (tmp == NULL) {
11435
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11436
0
            return -1;
11437
0
        }
11438
0
        else {
11439
0
            int res;
11440
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11441
0
                goto failed;
11442
0
            }
11443
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11444
0
            _Py_LeaveRecursiveCall();
11445
0
            if (res != 0) goto failed;
11446
0
            Py_CLEAR(tmp);
11447
0
        }
11448
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11449
0
            return -1;
11450
0
        }
11451
0
        if (tmp == NULL) {
11452
0
            tmp = PyList_New(0);
11453
0
            if (tmp == NULL) {
11454
0
                return -1;
11455
0
            }
11456
0
        }
11457
0
        {
11458
0
            int res;
11459
0
            Py_ssize_t len;
11460
0
            Py_ssize_t i;
11461
0
            if (!PyList_Check(tmp)) {
11462
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11463
0
                goto failed;
11464
0
            }
11465
0
            len = PyList_GET_SIZE(tmp);
11466
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11467
0
            if (body == NULL) goto failed;
11468
0
            for (i = 0; i < len; i++) {
11469
0
                stmt_ty val;
11470
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11471
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11472
0
                    goto failed;
11473
0
                }
11474
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11475
0
                _Py_LeaveRecursiveCall();
11476
0
                Py_DECREF(tmp2);
11477
0
                if (res != 0) goto failed;
11478
0
                if (len != PyList_GET_SIZE(tmp)) {
11479
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11480
0
                    goto failed;
11481
0
                }
11482
0
                asdl_seq_SET(body, i, val);
11483
0
            }
11484
0
            Py_CLEAR(tmp);
11485
0
        }
11486
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11487
0
            return -1;
11488
0
        }
11489
0
        if (tmp == NULL) {
11490
0
            tmp = PyList_New(0);
11491
0
            if (tmp == NULL) {
11492
0
                return -1;
11493
0
            }
11494
0
        }
11495
0
        {
11496
0
            int res;
11497
0
            Py_ssize_t len;
11498
0
            Py_ssize_t i;
11499
0
            if (!PyList_Check(tmp)) {
11500
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11501
0
                goto failed;
11502
0
            }
11503
0
            len = PyList_GET_SIZE(tmp);
11504
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11505
0
            if (decorator_list == NULL) goto failed;
11506
0
            for (i = 0; i < len; i++) {
11507
0
                expr_ty val;
11508
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11509
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11510
0
                    goto failed;
11511
0
                }
11512
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11513
0
                _Py_LeaveRecursiveCall();
11514
0
                Py_DECREF(tmp2);
11515
0
                if (res != 0) goto failed;
11516
0
                if (len != PyList_GET_SIZE(tmp)) {
11517
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11518
0
                    goto failed;
11519
0
                }
11520
0
                asdl_seq_SET(decorator_list, i, val);
11521
0
            }
11522
0
            Py_CLEAR(tmp);
11523
0
        }
11524
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11525
0
            return -1;
11526
0
        }
11527
0
        if (tmp == NULL || tmp == Py_None) {
11528
0
            Py_CLEAR(tmp);
11529
0
            returns = NULL;
11530
0
        }
11531
0
        else {
11532
0
            int res;
11533
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11534
0
                goto failed;
11535
0
            }
11536
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11537
0
            _Py_LeaveRecursiveCall();
11538
0
            if (res != 0) goto failed;
11539
0
            Py_CLEAR(tmp);
11540
0
        }
11541
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11542
0
            return -1;
11543
0
        }
11544
0
        if (tmp == NULL || tmp == Py_None) {
11545
0
            Py_CLEAR(tmp);
11546
0
            type_comment = NULL;
11547
0
        }
11548
0
        else {
11549
0
            int res;
11550
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11551
0
                goto failed;
11552
0
            }
11553
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11554
0
            _Py_LeaveRecursiveCall();
11555
0
            if (res != 0) goto failed;
11556
0
            Py_CLEAR(tmp);
11557
0
        }
11558
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11559
0
            return -1;
11560
0
        }
11561
0
        if (tmp == NULL) {
11562
0
            tmp = PyList_New(0);
11563
0
            if (tmp == NULL) {
11564
0
                return -1;
11565
0
            }
11566
0
        }
11567
0
        {
11568
0
            int res;
11569
0
            Py_ssize_t len;
11570
0
            Py_ssize_t i;
11571
0
            if (!PyList_Check(tmp)) {
11572
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11573
0
                goto failed;
11574
0
            }
11575
0
            len = PyList_GET_SIZE(tmp);
11576
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11577
0
            if (type_params == NULL) goto failed;
11578
0
            for (i = 0; i < len; i++) {
11579
0
                type_param_ty val;
11580
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11581
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11582
0
                    goto failed;
11583
0
                }
11584
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11585
0
                _Py_LeaveRecursiveCall();
11586
0
                Py_DECREF(tmp2);
11587
0
                if (res != 0) goto failed;
11588
0
                if (len != PyList_GET_SIZE(tmp)) {
11589
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11590
0
                    goto failed;
11591
0
                }
11592
0
                asdl_seq_SET(type_params, i, val);
11593
0
            }
11594
0
            Py_CLEAR(tmp);
11595
0
        }
11596
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11597
0
                                       returns, type_comment, type_params,
11598
0
                                       lineno, col_offset, end_lineno,
11599
0
                                       end_col_offset, arena);
11600
0
        if (*out == NULL) goto failed;
11601
0
        return 0;
11602
0
    }
11603
0
    tp = state->ClassDef_type;
11604
0
    isinstance = PyObject_IsInstance(obj, tp);
11605
0
    if (isinstance == -1) {
11606
0
        return -1;
11607
0
    }
11608
0
    if (isinstance) {
11609
0
        identifier name;
11610
0
        asdl_expr_seq* bases;
11611
0
        asdl_keyword_seq* keywords;
11612
0
        asdl_stmt_seq* body;
11613
0
        asdl_expr_seq* decorator_list;
11614
0
        asdl_type_param_seq* type_params;
11615
11616
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11617
0
            return -1;
11618
0
        }
11619
0
        if (tmp == NULL) {
11620
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11621
0
            return -1;
11622
0
        }
11623
0
        else {
11624
0
            int res;
11625
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11626
0
                goto failed;
11627
0
            }
11628
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11629
0
            _Py_LeaveRecursiveCall();
11630
0
            if (res != 0) goto failed;
11631
0
            Py_CLEAR(tmp);
11632
0
        }
11633
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11634
0
            return -1;
11635
0
        }
11636
0
        if (tmp == NULL) {
11637
0
            tmp = PyList_New(0);
11638
0
            if (tmp == NULL) {
11639
0
                return -1;
11640
0
            }
11641
0
        }
11642
0
        {
11643
0
            int res;
11644
0
            Py_ssize_t len;
11645
0
            Py_ssize_t i;
11646
0
            if (!PyList_Check(tmp)) {
11647
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11648
0
                goto failed;
11649
0
            }
11650
0
            len = PyList_GET_SIZE(tmp);
11651
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11652
0
            if (bases == NULL) goto failed;
11653
0
            for (i = 0; i < len; i++) {
11654
0
                expr_ty val;
11655
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11656
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11657
0
                    goto failed;
11658
0
                }
11659
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11660
0
                _Py_LeaveRecursiveCall();
11661
0
                Py_DECREF(tmp2);
11662
0
                if (res != 0) goto failed;
11663
0
                if (len != PyList_GET_SIZE(tmp)) {
11664
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11665
0
                    goto failed;
11666
0
                }
11667
0
                asdl_seq_SET(bases, i, val);
11668
0
            }
11669
0
            Py_CLEAR(tmp);
11670
0
        }
11671
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11672
0
            return -1;
11673
0
        }
11674
0
        if (tmp == NULL) {
11675
0
            tmp = PyList_New(0);
11676
0
            if (tmp == NULL) {
11677
0
                return -1;
11678
0
            }
11679
0
        }
11680
0
        {
11681
0
            int res;
11682
0
            Py_ssize_t len;
11683
0
            Py_ssize_t i;
11684
0
            if (!PyList_Check(tmp)) {
11685
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11686
0
                goto failed;
11687
0
            }
11688
0
            len = PyList_GET_SIZE(tmp);
11689
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11690
0
            if (keywords == NULL) goto failed;
11691
0
            for (i = 0; i < len; i++) {
11692
0
                keyword_ty val;
11693
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11694
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11695
0
                    goto failed;
11696
0
                }
11697
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
11698
0
                _Py_LeaveRecursiveCall();
11699
0
                Py_DECREF(tmp2);
11700
0
                if (res != 0) goto failed;
11701
0
                if (len != PyList_GET_SIZE(tmp)) {
11702
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11703
0
                    goto failed;
11704
0
                }
11705
0
                asdl_seq_SET(keywords, i, val);
11706
0
            }
11707
0
            Py_CLEAR(tmp);
11708
0
        }
11709
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11710
0
            return -1;
11711
0
        }
11712
0
        if (tmp == NULL) {
11713
0
            tmp = PyList_New(0);
11714
0
            if (tmp == NULL) {
11715
0
                return -1;
11716
0
            }
11717
0
        }
11718
0
        {
11719
0
            int res;
11720
0
            Py_ssize_t len;
11721
0
            Py_ssize_t i;
11722
0
            if (!PyList_Check(tmp)) {
11723
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11724
0
                goto failed;
11725
0
            }
11726
0
            len = PyList_GET_SIZE(tmp);
11727
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11728
0
            if (body == NULL) goto failed;
11729
0
            for (i = 0; i < len; i++) {
11730
0
                stmt_ty val;
11731
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11732
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11733
0
                    goto failed;
11734
0
                }
11735
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11736
0
                _Py_LeaveRecursiveCall();
11737
0
                Py_DECREF(tmp2);
11738
0
                if (res != 0) goto failed;
11739
0
                if (len != PyList_GET_SIZE(tmp)) {
11740
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11741
0
                    goto failed;
11742
0
                }
11743
0
                asdl_seq_SET(body, i, val);
11744
0
            }
11745
0
            Py_CLEAR(tmp);
11746
0
        }
11747
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11748
0
            return -1;
11749
0
        }
11750
0
        if (tmp == NULL) {
11751
0
            tmp = PyList_New(0);
11752
0
            if (tmp == NULL) {
11753
0
                return -1;
11754
0
            }
11755
0
        }
11756
0
        {
11757
0
            int res;
11758
0
            Py_ssize_t len;
11759
0
            Py_ssize_t i;
11760
0
            if (!PyList_Check(tmp)) {
11761
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11762
0
                goto failed;
11763
0
            }
11764
0
            len = PyList_GET_SIZE(tmp);
11765
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11766
0
            if (decorator_list == NULL) goto failed;
11767
0
            for (i = 0; i < len; i++) {
11768
0
                expr_ty val;
11769
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11770
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11771
0
                    goto failed;
11772
0
                }
11773
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11774
0
                _Py_LeaveRecursiveCall();
11775
0
                Py_DECREF(tmp2);
11776
0
                if (res != 0) goto failed;
11777
0
                if (len != PyList_GET_SIZE(tmp)) {
11778
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11779
0
                    goto failed;
11780
0
                }
11781
0
                asdl_seq_SET(decorator_list, i, val);
11782
0
            }
11783
0
            Py_CLEAR(tmp);
11784
0
        }
11785
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11786
0
            return -1;
11787
0
        }
11788
0
        if (tmp == NULL) {
11789
0
            tmp = PyList_New(0);
11790
0
            if (tmp == NULL) {
11791
0
                return -1;
11792
0
            }
11793
0
        }
11794
0
        {
11795
0
            int res;
11796
0
            Py_ssize_t len;
11797
0
            Py_ssize_t i;
11798
0
            if (!PyList_Check(tmp)) {
11799
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11800
0
                goto failed;
11801
0
            }
11802
0
            len = PyList_GET_SIZE(tmp);
11803
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11804
0
            if (type_params == NULL) goto failed;
11805
0
            for (i = 0; i < len; i++) {
11806
0
                type_param_ty val;
11807
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11808
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11809
0
                    goto failed;
11810
0
                }
11811
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11812
0
                _Py_LeaveRecursiveCall();
11813
0
                Py_DECREF(tmp2);
11814
0
                if (res != 0) goto failed;
11815
0
                if (len != PyList_GET_SIZE(tmp)) {
11816
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11817
0
                    goto failed;
11818
0
                }
11819
0
                asdl_seq_SET(type_params, i, val);
11820
0
            }
11821
0
            Py_CLEAR(tmp);
11822
0
        }
11823
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11824
0
                               type_params, lineno, col_offset, end_lineno,
11825
0
                               end_col_offset, arena);
11826
0
        if (*out == NULL) goto failed;
11827
0
        return 0;
11828
0
    }
11829
0
    tp = state->Return_type;
11830
0
    isinstance = PyObject_IsInstance(obj, tp);
11831
0
    if (isinstance == -1) {
11832
0
        return -1;
11833
0
    }
11834
0
    if (isinstance) {
11835
0
        expr_ty value;
11836
11837
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11838
0
            return -1;
11839
0
        }
11840
0
        if (tmp == NULL || tmp == Py_None) {
11841
0
            Py_CLEAR(tmp);
11842
0
            value = NULL;
11843
0
        }
11844
0
        else {
11845
0
            int res;
11846
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11847
0
                goto failed;
11848
0
            }
11849
0
            res = obj2ast_expr(state, tmp, &value, arena);
11850
0
            _Py_LeaveRecursiveCall();
11851
0
            if (res != 0) goto failed;
11852
0
            Py_CLEAR(tmp);
11853
0
        }
11854
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11855
0
                             end_col_offset, arena);
11856
0
        if (*out == NULL) goto failed;
11857
0
        return 0;
11858
0
    }
11859
0
    tp = state->Delete_type;
11860
0
    isinstance = PyObject_IsInstance(obj, tp);
11861
0
    if (isinstance == -1) {
11862
0
        return -1;
11863
0
    }
11864
0
    if (isinstance) {
11865
0
        asdl_expr_seq* targets;
11866
11867
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11868
0
            return -1;
11869
0
        }
11870
0
        if (tmp == NULL) {
11871
0
            tmp = PyList_New(0);
11872
0
            if (tmp == NULL) {
11873
0
                return -1;
11874
0
            }
11875
0
        }
11876
0
        {
11877
0
            int res;
11878
0
            Py_ssize_t len;
11879
0
            Py_ssize_t i;
11880
0
            if (!PyList_Check(tmp)) {
11881
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11882
0
                goto failed;
11883
0
            }
11884
0
            len = PyList_GET_SIZE(tmp);
11885
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11886
0
            if (targets == NULL) goto failed;
11887
0
            for (i = 0; i < len; i++) {
11888
0
                expr_ty val;
11889
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11890
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11891
0
                    goto failed;
11892
0
                }
11893
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11894
0
                _Py_LeaveRecursiveCall();
11895
0
                Py_DECREF(tmp2);
11896
0
                if (res != 0) goto failed;
11897
0
                if (len != PyList_GET_SIZE(tmp)) {
11898
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11899
0
                    goto failed;
11900
0
                }
11901
0
                asdl_seq_SET(targets, i, val);
11902
0
            }
11903
0
            Py_CLEAR(tmp);
11904
0
        }
11905
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11906
0
                             end_col_offset, arena);
11907
0
        if (*out == NULL) goto failed;
11908
0
        return 0;
11909
0
    }
11910
0
    tp = state->Assign_type;
11911
0
    isinstance = PyObject_IsInstance(obj, tp);
11912
0
    if (isinstance == -1) {
11913
0
        return -1;
11914
0
    }
11915
0
    if (isinstance) {
11916
0
        asdl_expr_seq* targets;
11917
0
        expr_ty value;
11918
0
        string type_comment;
11919
11920
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11921
0
            return -1;
11922
0
        }
11923
0
        if (tmp == NULL) {
11924
0
            tmp = PyList_New(0);
11925
0
            if (tmp == NULL) {
11926
0
                return -1;
11927
0
            }
11928
0
        }
11929
0
        {
11930
0
            int res;
11931
0
            Py_ssize_t len;
11932
0
            Py_ssize_t i;
11933
0
            if (!PyList_Check(tmp)) {
11934
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11935
0
                goto failed;
11936
0
            }
11937
0
            len = PyList_GET_SIZE(tmp);
11938
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11939
0
            if (targets == NULL) goto failed;
11940
0
            for (i = 0; i < len; i++) {
11941
0
                expr_ty val;
11942
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11943
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11944
0
                    goto failed;
11945
0
                }
11946
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11947
0
                _Py_LeaveRecursiveCall();
11948
0
                Py_DECREF(tmp2);
11949
0
                if (res != 0) goto failed;
11950
0
                if (len != PyList_GET_SIZE(tmp)) {
11951
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
11952
0
                    goto failed;
11953
0
                }
11954
0
                asdl_seq_SET(targets, i, val);
11955
0
            }
11956
0
            Py_CLEAR(tmp);
11957
0
        }
11958
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11959
0
            return -1;
11960
0
        }
11961
0
        if (tmp == NULL) {
11962
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11963
0
            return -1;
11964
0
        }
11965
0
        else {
11966
0
            int res;
11967
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11968
0
                goto failed;
11969
0
            }
11970
0
            res = obj2ast_expr(state, tmp, &value, arena);
11971
0
            _Py_LeaveRecursiveCall();
11972
0
            if (res != 0) goto failed;
11973
0
            Py_CLEAR(tmp);
11974
0
        }
11975
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11976
0
            return -1;
11977
0
        }
11978
0
        if (tmp == NULL || tmp == Py_None) {
11979
0
            Py_CLEAR(tmp);
11980
0
            type_comment = NULL;
11981
0
        }
11982
0
        else {
11983
0
            int res;
11984
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11985
0
                goto failed;
11986
0
            }
11987
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11988
0
            _Py_LeaveRecursiveCall();
11989
0
            if (res != 0) goto failed;
11990
0
            Py_CLEAR(tmp);
11991
0
        }
11992
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
11993
0
                             end_lineno, end_col_offset, arena);
11994
0
        if (*out == NULL) goto failed;
11995
0
        return 0;
11996
0
    }
11997
0
    tp = state->TypeAlias_type;
11998
0
    isinstance = PyObject_IsInstance(obj, tp);
11999
0
    if (isinstance == -1) {
12000
0
        return -1;
12001
0
    }
12002
0
    if (isinstance) {
12003
0
        expr_ty name;
12004
0
        asdl_type_param_seq* type_params;
12005
0
        expr_ty value;
12006
12007
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12008
0
            return -1;
12009
0
        }
12010
0
        if (tmp == NULL) {
12011
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12012
0
            return -1;
12013
0
        }
12014
0
        else {
12015
0
            int res;
12016
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12017
0
                goto failed;
12018
0
            }
12019
0
            res = obj2ast_expr(state, tmp, &name, arena);
12020
0
            _Py_LeaveRecursiveCall();
12021
0
            if (res != 0) goto failed;
12022
0
            Py_CLEAR(tmp);
12023
0
        }
12024
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12025
0
            return -1;
12026
0
        }
12027
0
        if (tmp == NULL) {
12028
0
            tmp = PyList_New(0);
12029
0
            if (tmp == NULL) {
12030
0
                return -1;
12031
0
            }
12032
0
        }
12033
0
        {
12034
0
            int res;
12035
0
            Py_ssize_t len;
12036
0
            Py_ssize_t i;
12037
0
            if (!PyList_Check(tmp)) {
12038
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12039
0
                goto failed;
12040
0
            }
12041
0
            len = PyList_GET_SIZE(tmp);
12042
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12043
0
            if (type_params == NULL) goto failed;
12044
0
            for (i = 0; i < len; i++) {
12045
0
                type_param_ty val;
12046
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12047
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12048
0
                    goto failed;
12049
0
                }
12050
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
12051
0
                _Py_LeaveRecursiveCall();
12052
0
                Py_DECREF(tmp2);
12053
0
                if (res != 0) goto failed;
12054
0
                if (len != PyList_GET_SIZE(tmp)) {
12055
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12056
0
                    goto failed;
12057
0
                }
12058
0
                asdl_seq_SET(type_params, i, val);
12059
0
            }
12060
0
            Py_CLEAR(tmp);
12061
0
        }
12062
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12063
0
            return -1;
12064
0
        }
12065
0
        if (tmp == NULL) {
12066
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12067
0
            return -1;
12068
0
        }
12069
0
        else {
12070
0
            int res;
12071
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12072
0
                goto failed;
12073
0
            }
12074
0
            res = obj2ast_expr(state, tmp, &value, arena);
12075
0
            _Py_LeaveRecursiveCall();
12076
0
            if (res != 0) goto failed;
12077
0
            Py_CLEAR(tmp);
12078
0
        }
12079
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12080
0
                                end_lineno, end_col_offset, arena);
12081
0
        if (*out == NULL) goto failed;
12082
0
        return 0;
12083
0
    }
12084
0
    tp = state->AugAssign_type;
12085
0
    isinstance = PyObject_IsInstance(obj, tp);
12086
0
    if (isinstance == -1) {
12087
0
        return -1;
12088
0
    }
12089
0
    if (isinstance) {
12090
0
        expr_ty target;
12091
0
        operator_ty op;
12092
0
        expr_ty value;
12093
12094
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12095
0
            return -1;
12096
0
        }
12097
0
        if (tmp == NULL) {
12098
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12099
0
            return -1;
12100
0
        }
12101
0
        else {
12102
0
            int res;
12103
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12104
0
                goto failed;
12105
0
            }
12106
0
            res = obj2ast_expr(state, tmp, &target, arena);
12107
0
            _Py_LeaveRecursiveCall();
12108
0
            if (res != 0) goto failed;
12109
0
            Py_CLEAR(tmp);
12110
0
        }
12111
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12112
0
            return -1;
12113
0
        }
12114
0
        if (tmp == NULL) {
12115
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12116
0
            return -1;
12117
0
        }
12118
0
        else {
12119
0
            int res;
12120
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12121
0
                goto failed;
12122
0
            }
12123
0
            res = obj2ast_operator(state, tmp, &op, arena);
12124
0
            _Py_LeaveRecursiveCall();
12125
0
            if (res != 0) goto failed;
12126
0
            Py_CLEAR(tmp);
12127
0
        }
12128
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12129
0
            return -1;
12130
0
        }
12131
0
        if (tmp == NULL) {
12132
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12133
0
            return -1;
12134
0
        }
12135
0
        else {
12136
0
            int res;
12137
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12138
0
                goto failed;
12139
0
            }
12140
0
            res = obj2ast_expr(state, tmp, &value, arena);
12141
0
            _Py_LeaveRecursiveCall();
12142
0
            if (res != 0) goto failed;
12143
0
            Py_CLEAR(tmp);
12144
0
        }
12145
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12146
0
                                end_lineno, end_col_offset, arena);
12147
0
        if (*out == NULL) goto failed;
12148
0
        return 0;
12149
0
    }
12150
0
    tp = state->AnnAssign_type;
12151
0
    isinstance = PyObject_IsInstance(obj, tp);
12152
0
    if (isinstance == -1) {
12153
0
        return -1;
12154
0
    }
12155
0
    if (isinstance) {
12156
0
        expr_ty target;
12157
0
        expr_ty annotation;
12158
0
        expr_ty value;
12159
0
        int simple;
12160
12161
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12162
0
            return -1;
12163
0
        }
12164
0
        if (tmp == NULL) {
12165
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12166
0
            return -1;
12167
0
        }
12168
0
        else {
12169
0
            int res;
12170
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12171
0
                goto failed;
12172
0
            }
12173
0
            res = obj2ast_expr(state, tmp, &target, arena);
12174
0
            _Py_LeaveRecursiveCall();
12175
0
            if (res != 0) goto failed;
12176
0
            Py_CLEAR(tmp);
12177
0
        }
12178
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12179
0
            return -1;
12180
0
        }
12181
0
        if (tmp == NULL) {
12182
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12183
0
            return -1;
12184
0
        }
12185
0
        else {
12186
0
            int res;
12187
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12188
0
                goto failed;
12189
0
            }
12190
0
            res = obj2ast_expr(state, tmp, &annotation, arena);
12191
0
            _Py_LeaveRecursiveCall();
12192
0
            if (res != 0) goto failed;
12193
0
            Py_CLEAR(tmp);
12194
0
        }
12195
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12196
0
            return -1;
12197
0
        }
12198
0
        if (tmp == NULL || tmp == Py_None) {
12199
0
            Py_CLEAR(tmp);
12200
0
            value = NULL;
12201
0
        }
12202
0
        else {
12203
0
            int res;
12204
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12205
0
                goto failed;
12206
0
            }
12207
0
            res = obj2ast_expr(state, tmp, &value, arena);
12208
0
            _Py_LeaveRecursiveCall();
12209
0
            if (res != 0) goto failed;
12210
0
            Py_CLEAR(tmp);
12211
0
        }
12212
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
12213
0
            return -1;
12214
0
        }
12215
0
        if (tmp == NULL) {
12216
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12217
0
            return -1;
12218
0
        }
12219
0
        else {
12220
0
            int res;
12221
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12222
0
                goto failed;
12223
0
            }
12224
0
            res = obj2ast_int(state, tmp, &simple, arena);
12225
0
            _Py_LeaveRecursiveCall();
12226
0
            if (res != 0) goto failed;
12227
0
            Py_CLEAR(tmp);
12228
0
        }
12229
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12230
0
                                col_offset, end_lineno, end_col_offset, arena);
12231
0
        if (*out == NULL) goto failed;
12232
0
        return 0;
12233
0
    }
12234
0
    tp = state->For_type;
12235
0
    isinstance = PyObject_IsInstance(obj, tp);
12236
0
    if (isinstance == -1) {
12237
0
        return -1;
12238
0
    }
12239
0
    if (isinstance) {
12240
0
        expr_ty target;
12241
0
        expr_ty iter;
12242
0
        asdl_stmt_seq* body;
12243
0
        asdl_stmt_seq* orelse;
12244
0
        string type_comment;
12245
12246
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12247
0
            return -1;
12248
0
        }
12249
0
        if (tmp == NULL) {
12250
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12251
0
            return -1;
12252
0
        }
12253
0
        else {
12254
0
            int res;
12255
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12256
0
                goto failed;
12257
0
            }
12258
0
            res = obj2ast_expr(state, tmp, &target, arena);
12259
0
            _Py_LeaveRecursiveCall();
12260
0
            if (res != 0) goto failed;
12261
0
            Py_CLEAR(tmp);
12262
0
        }
12263
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12264
0
            return -1;
12265
0
        }
12266
0
        if (tmp == NULL) {
12267
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12268
0
            return -1;
12269
0
        }
12270
0
        else {
12271
0
            int res;
12272
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12273
0
                goto failed;
12274
0
            }
12275
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12276
0
            _Py_LeaveRecursiveCall();
12277
0
            if (res != 0) goto failed;
12278
0
            Py_CLEAR(tmp);
12279
0
        }
12280
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12281
0
            return -1;
12282
0
        }
12283
0
        if (tmp == NULL) {
12284
0
            tmp = PyList_New(0);
12285
0
            if (tmp == NULL) {
12286
0
                return -1;
12287
0
            }
12288
0
        }
12289
0
        {
12290
0
            int res;
12291
0
            Py_ssize_t len;
12292
0
            Py_ssize_t i;
12293
0
            if (!PyList_Check(tmp)) {
12294
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12295
0
                goto failed;
12296
0
            }
12297
0
            len = PyList_GET_SIZE(tmp);
12298
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12299
0
            if (body == NULL) goto failed;
12300
0
            for (i = 0; i < len; i++) {
12301
0
                stmt_ty val;
12302
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12303
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12304
0
                    goto failed;
12305
0
                }
12306
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12307
0
                _Py_LeaveRecursiveCall();
12308
0
                Py_DECREF(tmp2);
12309
0
                if (res != 0) goto failed;
12310
0
                if (len != PyList_GET_SIZE(tmp)) {
12311
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12312
0
                    goto failed;
12313
0
                }
12314
0
                asdl_seq_SET(body, i, val);
12315
0
            }
12316
0
            Py_CLEAR(tmp);
12317
0
        }
12318
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12319
0
            return -1;
12320
0
        }
12321
0
        if (tmp == NULL) {
12322
0
            tmp = PyList_New(0);
12323
0
            if (tmp == NULL) {
12324
0
                return -1;
12325
0
            }
12326
0
        }
12327
0
        {
12328
0
            int res;
12329
0
            Py_ssize_t len;
12330
0
            Py_ssize_t i;
12331
0
            if (!PyList_Check(tmp)) {
12332
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12333
0
                goto failed;
12334
0
            }
12335
0
            len = PyList_GET_SIZE(tmp);
12336
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12337
0
            if (orelse == NULL) goto failed;
12338
0
            for (i = 0; i < len; i++) {
12339
0
                stmt_ty val;
12340
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12341
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12342
0
                    goto failed;
12343
0
                }
12344
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12345
0
                _Py_LeaveRecursiveCall();
12346
0
                Py_DECREF(tmp2);
12347
0
                if (res != 0) goto failed;
12348
0
                if (len != PyList_GET_SIZE(tmp)) {
12349
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12350
0
                    goto failed;
12351
0
                }
12352
0
                asdl_seq_SET(orelse, i, val);
12353
0
            }
12354
0
            Py_CLEAR(tmp);
12355
0
        }
12356
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12357
0
            return -1;
12358
0
        }
12359
0
        if (tmp == NULL || tmp == Py_None) {
12360
0
            Py_CLEAR(tmp);
12361
0
            type_comment = NULL;
12362
0
        }
12363
0
        else {
12364
0
            int res;
12365
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12366
0
                goto failed;
12367
0
            }
12368
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12369
0
            _Py_LeaveRecursiveCall();
12370
0
            if (res != 0) goto failed;
12371
0
            Py_CLEAR(tmp);
12372
0
        }
12373
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12374
0
                          col_offset, end_lineno, end_col_offset, arena);
12375
0
        if (*out == NULL) goto failed;
12376
0
        return 0;
12377
0
    }
12378
0
    tp = state->AsyncFor_type;
12379
0
    isinstance = PyObject_IsInstance(obj, tp);
12380
0
    if (isinstance == -1) {
12381
0
        return -1;
12382
0
    }
12383
0
    if (isinstance) {
12384
0
        expr_ty target;
12385
0
        expr_ty iter;
12386
0
        asdl_stmt_seq* body;
12387
0
        asdl_stmt_seq* orelse;
12388
0
        string type_comment;
12389
12390
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12391
0
            return -1;
12392
0
        }
12393
0
        if (tmp == NULL) {
12394
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12395
0
            return -1;
12396
0
        }
12397
0
        else {
12398
0
            int res;
12399
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12400
0
                goto failed;
12401
0
            }
12402
0
            res = obj2ast_expr(state, tmp, &target, arena);
12403
0
            _Py_LeaveRecursiveCall();
12404
0
            if (res != 0) goto failed;
12405
0
            Py_CLEAR(tmp);
12406
0
        }
12407
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12408
0
            return -1;
12409
0
        }
12410
0
        if (tmp == NULL) {
12411
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12412
0
            return -1;
12413
0
        }
12414
0
        else {
12415
0
            int res;
12416
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12417
0
                goto failed;
12418
0
            }
12419
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12420
0
            _Py_LeaveRecursiveCall();
12421
0
            if (res != 0) goto failed;
12422
0
            Py_CLEAR(tmp);
12423
0
        }
12424
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12425
0
            return -1;
12426
0
        }
12427
0
        if (tmp == NULL) {
12428
0
            tmp = PyList_New(0);
12429
0
            if (tmp == NULL) {
12430
0
                return -1;
12431
0
            }
12432
0
        }
12433
0
        {
12434
0
            int res;
12435
0
            Py_ssize_t len;
12436
0
            Py_ssize_t i;
12437
0
            if (!PyList_Check(tmp)) {
12438
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12439
0
                goto failed;
12440
0
            }
12441
0
            len = PyList_GET_SIZE(tmp);
12442
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12443
0
            if (body == NULL) goto failed;
12444
0
            for (i = 0; i < len; i++) {
12445
0
                stmt_ty val;
12446
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12447
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12448
0
                    goto failed;
12449
0
                }
12450
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12451
0
                _Py_LeaveRecursiveCall();
12452
0
                Py_DECREF(tmp2);
12453
0
                if (res != 0) goto failed;
12454
0
                if (len != PyList_GET_SIZE(tmp)) {
12455
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12456
0
                    goto failed;
12457
0
                }
12458
0
                asdl_seq_SET(body, i, val);
12459
0
            }
12460
0
            Py_CLEAR(tmp);
12461
0
        }
12462
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12463
0
            return -1;
12464
0
        }
12465
0
        if (tmp == NULL) {
12466
0
            tmp = PyList_New(0);
12467
0
            if (tmp == NULL) {
12468
0
                return -1;
12469
0
            }
12470
0
        }
12471
0
        {
12472
0
            int res;
12473
0
            Py_ssize_t len;
12474
0
            Py_ssize_t i;
12475
0
            if (!PyList_Check(tmp)) {
12476
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12477
0
                goto failed;
12478
0
            }
12479
0
            len = PyList_GET_SIZE(tmp);
12480
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12481
0
            if (orelse == NULL) goto failed;
12482
0
            for (i = 0; i < len; i++) {
12483
0
                stmt_ty val;
12484
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12485
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12486
0
                    goto failed;
12487
0
                }
12488
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12489
0
                _Py_LeaveRecursiveCall();
12490
0
                Py_DECREF(tmp2);
12491
0
                if (res != 0) goto failed;
12492
0
                if (len != PyList_GET_SIZE(tmp)) {
12493
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12494
0
                    goto failed;
12495
0
                }
12496
0
                asdl_seq_SET(orelse, i, val);
12497
0
            }
12498
0
            Py_CLEAR(tmp);
12499
0
        }
12500
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12501
0
            return -1;
12502
0
        }
12503
0
        if (tmp == NULL || tmp == Py_None) {
12504
0
            Py_CLEAR(tmp);
12505
0
            type_comment = NULL;
12506
0
        }
12507
0
        else {
12508
0
            int res;
12509
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12510
0
                goto failed;
12511
0
            }
12512
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12513
0
            _Py_LeaveRecursiveCall();
12514
0
            if (res != 0) goto failed;
12515
0
            Py_CLEAR(tmp);
12516
0
        }
12517
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12518
0
                               lineno, col_offset, end_lineno, end_col_offset,
12519
0
                               arena);
12520
0
        if (*out == NULL) goto failed;
12521
0
        return 0;
12522
0
    }
12523
0
    tp = state->While_type;
12524
0
    isinstance = PyObject_IsInstance(obj, tp);
12525
0
    if (isinstance == -1) {
12526
0
        return -1;
12527
0
    }
12528
0
    if (isinstance) {
12529
0
        expr_ty test;
12530
0
        asdl_stmt_seq* body;
12531
0
        asdl_stmt_seq* orelse;
12532
12533
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12534
0
            return -1;
12535
0
        }
12536
0
        if (tmp == NULL) {
12537
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12538
0
            return -1;
12539
0
        }
12540
0
        else {
12541
0
            int res;
12542
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12543
0
                goto failed;
12544
0
            }
12545
0
            res = obj2ast_expr(state, tmp, &test, arena);
12546
0
            _Py_LeaveRecursiveCall();
12547
0
            if (res != 0) goto failed;
12548
0
            Py_CLEAR(tmp);
12549
0
        }
12550
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12551
0
            return -1;
12552
0
        }
12553
0
        if (tmp == NULL) {
12554
0
            tmp = PyList_New(0);
12555
0
            if (tmp == NULL) {
12556
0
                return -1;
12557
0
            }
12558
0
        }
12559
0
        {
12560
0
            int res;
12561
0
            Py_ssize_t len;
12562
0
            Py_ssize_t i;
12563
0
            if (!PyList_Check(tmp)) {
12564
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12565
0
                goto failed;
12566
0
            }
12567
0
            len = PyList_GET_SIZE(tmp);
12568
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12569
0
            if (body == NULL) goto failed;
12570
0
            for (i = 0; i < len; i++) {
12571
0
                stmt_ty val;
12572
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12573
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12574
0
                    goto failed;
12575
0
                }
12576
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12577
0
                _Py_LeaveRecursiveCall();
12578
0
                Py_DECREF(tmp2);
12579
0
                if (res != 0) goto failed;
12580
0
                if (len != PyList_GET_SIZE(tmp)) {
12581
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12582
0
                    goto failed;
12583
0
                }
12584
0
                asdl_seq_SET(body, i, val);
12585
0
            }
12586
0
            Py_CLEAR(tmp);
12587
0
        }
12588
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12589
0
            return -1;
12590
0
        }
12591
0
        if (tmp == NULL) {
12592
0
            tmp = PyList_New(0);
12593
0
            if (tmp == NULL) {
12594
0
                return -1;
12595
0
            }
12596
0
        }
12597
0
        {
12598
0
            int res;
12599
0
            Py_ssize_t len;
12600
0
            Py_ssize_t i;
12601
0
            if (!PyList_Check(tmp)) {
12602
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12603
0
                goto failed;
12604
0
            }
12605
0
            len = PyList_GET_SIZE(tmp);
12606
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12607
0
            if (orelse == NULL) goto failed;
12608
0
            for (i = 0; i < len; i++) {
12609
0
                stmt_ty val;
12610
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12611
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12612
0
                    goto failed;
12613
0
                }
12614
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12615
0
                _Py_LeaveRecursiveCall();
12616
0
                Py_DECREF(tmp2);
12617
0
                if (res != 0) goto failed;
12618
0
                if (len != PyList_GET_SIZE(tmp)) {
12619
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12620
0
                    goto failed;
12621
0
                }
12622
0
                asdl_seq_SET(orelse, i, val);
12623
0
            }
12624
0
            Py_CLEAR(tmp);
12625
0
        }
12626
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12627
0
                            end_col_offset, arena);
12628
0
        if (*out == NULL) goto failed;
12629
0
        return 0;
12630
0
    }
12631
0
    tp = state->If_type;
12632
0
    isinstance = PyObject_IsInstance(obj, tp);
12633
0
    if (isinstance == -1) {
12634
0
        return -1;
12635
0
    }
12636
0
    if (isinstance) {
12637
0
        expr_ty test;
12638
0
        asdl_stmt_seq* body;
12639
0
        asdl_stmt_seq* orelse;
12640
12641
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12642
0
            return -1;
12643
0
        }
12644
0
        if (tmp == NULL) {
12645
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12646
0
            return -1;
12647
0
        }
12648
0
        else {
12649
0
            int res;
12650
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12651
0
                goto failed;
12652
0
            }
12653
0
            res = obj2ast_expr(state, tmp, &test, arena);
12654
0
            _Py_LeaveRecursiveCall();
12655
0
            if (res != 0) goto failed;
12656
0
            Py_CLEAR(tmp);
12657
0
        }
12658
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12659
0
            return -1;
12660
0
        }
12661
0
        if (tmp == NULL) {
12662
0
            tmp = PyList_New(0);
12663
0
            if (tmp == NULL) {
12664
0
                return -1;
12665
0
            }
12666
0
        }
12667
0
        {
12668
0
            int res;
12669
0
            Py_ssize_t len;
12670
0
            Py_ssize_t i;
12671
0
            if (!PyList_Check(tmp)) {
12672
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12673
0
                goto failed;
12674
0
            }
12675
0
            len = PyList_GET_SIZE(tmp);
12676
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12677
0
            if (body == NULL) goto failed;
12678
0
            for (i = 0; i < len; i++) {
12679
0
                stmt_ty val;
12680
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12681
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12682
0
                    goto failed;
12683
0
                }
12684
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12685
0
                _Py_LeaveRecursiveCall();
12686
0
                Py_DECREF(tmp2);
12687
0
                if (res != 0) goto failed;
12688
0
                if (len != PyList_GET_SIZE(tmp)) {
12689
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12690
0
                    goto failed;
12691
0
                }
12692
0
                asdl_seq_SET(body, i, val);
12693
0
            }
12694
0
            Py_CLEAR(tmp);
12695
0
        }
12696
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12697
0
            return -1;
12698
0
        }
12699
0
        if (tmp == NULL) {
12700
0
            tmp = PyList_New(0);
12701
0
            if (tmp == NULL) {
12702
0
                return -1;
12703
0
            }
12704
0
        }
12705
0
        {
12706
0
            int res;
12707
0
            Py_ssize_t len;
12708
0
            Py_ssize_t i;
12709
0
            if (!PyList_Check(tmp)) {
12710
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12711
0
                goto failed;
12712
0
            }
12713
0
            len = PyList_GET_SIZE(tmp);
12714
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12715
0
            if (orelse == NULL) goto failed;
12716
0
            for (i = 0; i < len; i++) {
12717
0
                stmt_ty val;
12718
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12719
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12720
0
                    goto failed;
12721
0
                }
12722
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12723
0
                _Py_LeaveRecursiveCall();
12724
0
                Py_DECREF(tmp2);
12725
0
                if (res != 0) goto failed;
12726
0
                if (len != PyList_GET_SIZE(tmp)) {
12727
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12728
0
                    goto failed;
12729
0
                }
12730
0
                asdl_seq_SET(orelse, i, val);
12731
0
            }
12732
0
            Py_CLEAR(tmp);
12733
0
        }
12734
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12735
0
                         end_col_offset, arena);
12736
0
        if (*out == NULL) goto failed;
12737
0
        return 0;
12738
0
    }
12739
0
    tp = state->With_type;
12740
0
    isinstance = PyObject_IsInstance(obj, tp);
12741
0
    if (isinstance == -1) {
12742
0
        return -1;
12743
0
    }
12744
0
    if (isinstance) {
12745
0
        asdl_withitem_seq* items;
12746
0
        asdl_stmt_seq* body;
12747
0
        string type_comment;
12748
12749
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12750
0
            return -1;
12751
0
        }
12752
0
        if (tmp == NULL) {
12753
0
            tmp = PyList_New(0);
12754
0
            if (tmp == NULL) {
12755
0
                return -1;
12756
0
            }
12757
0
        }
12758
0
        {
12759
0
            int res;
12760
0
            Py_ssize_t len;
12761
0
            Py_ssize_t i;
12762
0
            if (!PyList_Check(tmp)) {
12763
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12764
0
                goto failed;
12765
0
            }
12766
0
            len = PyList_GET_SIZE(tmp);
12767
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12768
0
            if (items == NULL) goto failed;
12769
0
            for (i = 0; i < len; i++) {
12770
0
                withitem_ty val;
12771
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12772
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12773
0
                    goto failed;
12774
0
                }
12775
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12776
0
                _Py_LeaveRecursiveCall();
12777
0
                Py_DECREF(tmp2);
12778
0
                if (res != 0) goto failed;
12779
0
                if (len != PyList_GET_SIZE(tmp)) {
12780
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12781
0
                    goto failed;
12782
0
                }
12783
0
                asdl_seq_SET(items, i, val);
12784
0
            }
12785
0
            Py_CLEAR(tmp);
12786
0
        }
12787
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12788
0
            return -1;
12789
0
        }
12790
0
        if (tmp == NULL) {
12791
0
            tmp = PyList_New(0);
12792
0
            if (tmp == NULL) {
12793
0
                return -1;
12794
0
            }
12795
0
        }
12796
0
        {
12797
0
            int res;
12798
0
            Py_ssize_t len;
12799
0
            Py_ssize_t i;
12800
0
            if (!PyList_Check(tmp)) {
12801
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12802
0
                goto failed;
12803
0
            }
12804
0
            len = PyList_GET_SIZE(tmp);
12805
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12806
0
            if (body == NULL) goto failed;
12807
0
            for (i = 0; i < len; i++) {
12808
0
                stmt_ty val;
12809
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12810
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12811
0
                    goto failed;
12812
0
                }
12813
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12814
0
                _Py_LeaveRecursiveCall();
12815
0
                Py_DECREF(tmp2);
12816
0
                if (res != 0) goto failed;
12817
0
                if (len != PyList_GET_SIZE(tmp)) {
12818
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12819
0
                    goto failed;
12820
0
                }
12821
0
                asdl_seq_SET(body, i, val);
12822
0
            }
12823
0
            Py_CLEAR(tmp);
12824
0
        }
12825
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12826
0
            return -1;
12827
0
        }
12828
0
        if (tmp == NULL || tmp == Py_None) {
12829
0
            Py_CLEAR(tmp);
12830
0
            type_comment = NULL;
12831
0
        }
12832
0
        else {
12833
0
            int res;
12834
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12835
0
                goto failed;
12836
0
            }
12837
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12838
0
            _Py_LeaveRecursiveCall();
12839
0
            if (res != 0) goto failed;
12840
0
            Py_CLEAR(tmp);
12841
0
        }
12842
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12843
0
                           end_lineno, end_col_offset, arena);
12844
0
        if (*out == NULL) goto failed;
12845
0
        return 0;
12846
0
    }
12847
0
    tp = state->AsyncWith_type;
12848
0
    isinstance = PyObject_IsInstance(obj, tp);
12849
0
    if (isinstance == -1) {
12850
0
        return -1;
12851
0
    }
12852
0
    if (isinstance) {
12853
0
        asdl_withitem_seq* items;
12854
0
        asdl_stmt_seq* body;
12855
0
        string type_comment;
12856
12857
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12858
0
            return -1;
12859
0
        }
12860
0
        if (tmp == NULL) {
12861
0
            tmp = PyList_New(0);
12862
0
            if (tmp == NULL) {
12863
0
                return -1;
12864
0
            }
12865
0
        }
12866
0
        {
12867
0
            int res;
12868
0
            Py_ssize_t len;
12869
0
            Py_ssize_t i;
12870
0
            if (!PyList_Check(tmp)) {
12871
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12872
0
                goto failed;
12873
0
            }
12874
0
            len = PyList_GET_SIZE(tmp);
12875
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12876
0
            if (items == NULL) goto failed;
12877
0
            for (i = 0; i < len; i++) {
12878
0
                withitem_ty val;
12879
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12880
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12881
0
                    goto failed;
12882
0
                }
12883
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12884
0
                _Py_LeaveRecursiveCall();
12885
0
                Py_DECREF(tmp2);
12886
0
                if (res != 0) goto failed;
12887
0
                if (len != PyList_GET_SIZE(tmp)) {
12888
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12889
0
                    goto failed;
12890
0
                }
12891
0
                asdl_seq_SET(items, i, val);
12892
0
            }
12893
0
            Py_CLEAR(tmp);
12894
0
        }
12895
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12896
0
            return -1;
12897
0
        }
12898
0
        if (tmp == NULL) {
12899
0
            tmp = PyList_New(0);
12900
0
            if (tmp == NULL) {
12901
0
                return -1;
12902
0
            }
12903
0
        }
12904
0
        {
12905
0
            int res;
12906
0
            Py_ssize_t len;
12907
0
            Py_ssize_t i;
12908
0
            if (!PyList_Check(tmp)) {
12909
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12910
0
                goto failed;
12911
0
            }
12912
0
            len = PyList_GET_SIZE(tmp);
12913
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12914
0
            if (body == NULL) goto failed;
12915
0
            for (i = 0; i < len; i++) {
12916
0
                stmt_ty val;
12917
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12918
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12919
0
                    goto failed;
12920
0
                }
12921
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12922
0
                _Py_LeaveRecursiveCall();
12923
0
                Py_DECREF(tmp2);
12924
0
                if (res != 0) goto failed;
12925
0
                if (len != PyList_GET_SIZE(tmp)) {
12926
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12927
0
                    goto failed;
12928
0
                }
12929
0
                asdl_seq_SET(body, i, val);
12930
0
            }
12931
0
            Py_CLEAR(tmp);
12932
0
        }
12933
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12934
0
            return -1;
12935
0
        }
12936
0
        if (tmp == NULL || tmp == Py_None) {
12937
0
            Py_CLEAR(tmp);
12938
0
            type_comment = NULL;
12939
0
        }
12940
0
        else {
12941
0
            int res;
12942
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12943
0
                goto failed;
12944
0
            }
12945
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12946
0
            _Py_LeaveRecursiveCall();
12947
0
            if (res != 0) goto failed;
12948
0
            Py_CLEAR(tmp);
12949
0
        }
12950
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12951
0
                                end_lineno, end_col_offset, arena);
12952
0
        if (*out == NULL) goto failed;
12953
0
        return 0;
12954
0
    }
12955
0
    tp = state->Match_type;
12956
0
    isinstance = PyObject_IsInstance(obj, tp);
12957
0
    if (isinstance == -1) {
12958
0
        return -1;
12959
0
    }
12960
0
    if (isinstance) {
12961
0
        expr_ty subject;
12962
0
        asdl_match_case_seq* cases;
12963
12964
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
12965
0
            return -1;
12966
0
        }
12967
0
        if (tmp == NULL) {
12968
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
12969
0
            return -1;
12970
0
        }
12971
0
        else {
12972
0
            int res;
12973
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
12974
0
                goto failed;
12975
0
            }
12976
0
            res = obj2ast_expr(state, tmp, &subject, arena);
12977
0
            _Py_LeaveRecursiveCall();
12978
0
            if (res != 0) goto failed;
12979
0
            Py_CLEAR(tmp);
12980
0
        }
12981
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
12982
0
            return -1;
12983
0
        }
12984
0
        if (tmp == NULL) {
12985
0
            tmp = PyList_New(0);
12986
0
            if (tmp == NULL) {
12987
0
                return -1;
12988
0
            }
12989
0
        }
12990
0
        {
12991
0
            int res;
12992
0
            Py_ssize_t len;
12993
0
            Py_ssize_t i;
12994
0
            if (!PyList_Check(tmp)) {
12995
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12996
0
                goto failed;
12997
0
            }
12998
0
            len = PyList_GET_SIZE(tmp);
12999
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13000
0
            if (cases == NULL) goto failed;
13001
0
            for (i = 0; i < len; i++) {
13002
0
                match_case_ty val;
13003
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13004
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13005
0
                    goto failed;
13006
0
                }
13007
0
                res = obj2ast_match_case(state, tmp2, &val, arena);
13008
0
                _Py_LeaveRecursiveCall();
13009
0
                Py_DECREF(tmp2);
13010
0
                if (res != 0) goto failed;
13011
0
                if (len != PyList_GET_SIZE(tmp)) {
13012
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13013
0
                    goto failed;
13014
0
                }
13015
0
                asdl_seq_SET(cases, i, val);
13016
0
            }
13017
0
            Py_CLEAR(tmp);
13018
0
        }
13019
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13020
0
                            end_col_offset, arena);
13021
0
        if (*out == NULL) goto failed;
13022
0
        return 0;
13023
0
    }
13024
0
    tp = state->Raise_type;
13025
0
    isinstance = PyObject_IsInstance(obj, tp);
13026
0
    if (isinstance == -1) {
13027
0
        return -1;
13028
0
    }
13029
0
    if (isinstance) {
13030
0
        expr_ty exc;
13031
0
        expr_ty cause;
13032
13033
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13034
0
            return -1;
13035
0
        }
13036
0
        if (tmp == NULL || tmp == Py_None) {
13037
0
            Py_CLEAR(tmp);
13038
0
            exc = NULL;
13039
0
        }
13040
0
        else {
13041
0
            int res;
13042
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13043
0
                goto failed;
13044
0
            }
13045
0
            res = obj2ast_expr(state, tmp, &exc, arena);
13046
0
            _Py_LeaveRecursiveCall();
13047
0
            if (res != 0) goto failed;
13048
0
            Py_CLEAR(tmp);
13049
0
        }
13050
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13051
0
            return -1;
13052
0
        }
13053
0
        if (tmp == NULL || tmp == Py_None) {
13054
0
            Py_CLEAR(tmp);
13055
0
            cause = NULL;
13056
0
        }
13057
0
        else {
13058
0
            int res;
13059
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13060
0
                goto failed;
13061
0
            }
13062
0
            res = obj2ast_expr(state, tmp, &cause, arena);
13063
0
            _Py_LeaveRecursiveCall();
13064
0
            if (res != 0) goto failed;
13065
0
            Py_CLEAR(tmp);
13066
0
        }
13067
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13068
0
                            end_col_offset, arena);
13069
0
        if (*out == NULL) goto failed;
13070
0
        return 0;
13071
0
    }
13072
0
    tp = state->Try_type;
13073
0
    isinstance = PyObject_IsInstance(obj, tp);
13074
0
    if (isinstance == -1) {
13075
0
        return -1;
13076
0
    }
13077
0
    if (isinstance) {
13078
0
        asdl_stmt_seq* body;
13079
0
        asdl_excepthandler_seq* handlers;
13080
0
        asdl_stmt_seq* orelse;
13081
0
        asdl_stmt_seq* finalbody;
13082
13083
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13084
0
            return -1;
13085
0
        }
13086
0
        if (tmp == NULL) {
13087
0
            tmp = PyList_New(0);
13088
0
            if (tmp == NULL) {
13089
0
                return -1;
13090
0
            }
13091
0
        }
13092
0
        {
13093
0
            int res;
13094
0
            Py_ssize_t len;
13095
0
            Py_ssize_t i;
13096
0
            if (!PyList_Check(tmp)) {
13097
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13098
0
                goto failed;
13099
0
            }
13100
0
            len = PyList_GET_SIZE(tmp);
13101
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13102
0
            if (body == NULL) goto failed;
13103
0
            for (i = 0; i < len; i++) {
13104
0
                stmt_ty val;
13105
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13106
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13107
0
                    goto failed;
13108
0
                }
13109
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13110
0
                _Py_LeaveRecursiveCall();
13111
0
                Py_DECREF(tmp2);
13112
0
                if (res != 0) goto failed;
13113
0
                if (len != PyList_GET_SIZE(tmp)) {
13114
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13115
0
                    goto failed;
13116
0
                }
13117
0
                asdl_seq_SET(body, i, val);
13118
0
            }
13119
0
            Py_CLEAR(tmp);
13120
0
        }
13121
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13122
0
            return -1;
13123
0
        }
13124
0
        if (tmp == NULL) {
13125
0
            tmp = PyList_New(0);
13126
0
            if (tmp == NULL) {
13127
0
                return -1;
13128
0
            }
13129
0
        }
13130
0
        {
13131
0
            int res;
13132
0
            Py_ssize_t len;
13133
0
            Py_ssize_t i;
13134
0
            if (!PyList_Check(tmp)) {
13135
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13136
0
                goto failed;
13137
0
            }
13138
0
            len = PyList_GET_SIZE(tmp);
13139
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13140
0
            if (handlers == NULL) goto failed;
13141
0
            for (i = 0; i < len; i++) {
13142
0
                excepthandler_ty val;
13143
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13144
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13145
0
                    goto failed;
13146
0
                }
13147
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13148
0
                _Py_LeaveRecursiveCall();
13149
0
                Py_DECREF(tmp2);
13150
0
                if (res != 0) goto failed;
13151
0
                if (len != PyList_GET_SIZE(tmp)) {
13152
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13153
0
                    goto failed;
13154
0
                }
13155
0
                asdl_seq_SET(handlers, i, val);
13156
0
            }
13157
0
            Py_CLEAR(tmp);
13158
0
        }
13159
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13160
0
            return -1;
13161
0
        }
13162
0
        if (tmp == NULL) {
13163
0
            tmp = PyList_New(0);
13164
0
            if (tmp == NULL) {
13165
0
                return -1;
13166
0
            }
13167
0
        }
13168
0
        {
13169
0
            int res;
13170
0
            Py_ssize_t len;
13171
0
            Py_ssize_t i;
13172
0
            if (!PyList_Check(tmp)) {
13173
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13174
0
                goto failed;
13175
0
            }
13176
0
            len = PyList_GET_SIZE(tmp);
13177
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13178
0
            if (orelse == NULL) goto failed;
13179
0
            for (i = 0; i < len; i++) {
13180
0
                stmt_ty val;
13181
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13182
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13183
0
                    goto failed;
13184
0
                }
13185
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13186
0
                _Py_LeaveRecursiveCall();
13187
0
                Py_DECREF(tmp2);
13188
0
                if (res != 0) goto failed;
13189
0
                if (len != PyList_GET_SIZE(tmp)) {
13190
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13191
0
                    goto failed;
13192
0
                }
13193
0
                asdl_seq_SET(orelse, i, val);
13194
0
            }
13195
0
            Py_CLEAR(tmp);
13196
0
        }
13197
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13198
0
            return -1;
13199
0
        }
13200
0
        if (tmp == NULL) {
13201
0
            tmp = PyList_New(0);
13202
0
            if (tmp == NULL) {
13203
0
                return -1;
13204
0
            }
13205
0
        }
13206
0
        {
13207
0
            int res;
13208
0
            Py_ssize_t len;
13209
0
            Py_ssize_t i;
13210
0
            if (!PyList_Check(tmp)) {
13211
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13212
0
                goto failed;
13213
0
            }
13214
0
            len = PyList_GET_SIZE(tmp);
13215
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13216
0
            if (finalbody == NULL) goto failed;
13217
0
            for (i = 0; i < len; i++) {
13218
0
                stmt_ty val;
13219
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13220
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13221
0
                    goto failed;
13222
0
                }
13223
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13224
0
                _Py_LeaveRecursiveCall();
13225
0
                Py_DECREF(tmp2);
13226
0
                if (res != 0) goto failed;
13227
0
                if (len != PyList_GET_SIZE(tmp)) {
13228
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13229
0
                    goto failed;
13230
0
                }
13231
0
                asdl_seq_SET(finalbody, i, val);
13232
0
            }
13233
0
            Py_CLEAR(tmp);
13234
0
        }
13235
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13236
0
                          col_offset, end_lineno, end_col_offset, arena);
13237
0
        if (*out == NULL) goto failed;
13238
0
        return 0;
13239
0
    }
13240
0
    tp = state->TryStar_type;
13241
0
    isinstance = PyObject_IsInstance(obj, tp);
13242
0
    if (isinstance == -1) {
13243
0
        return -1;
13244
0
    }
13245
0
    if (isinstance) {
13246
0
        asdl_stmt_seq* body;
13247
0
        asdl_excepthandler_seq* handlers;
13248
0
        asdl_stmt_seq* orelse;
13249
0
        asdl_stmt_seq* finalbody;
13250
13251
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13252
0
            return -1;
13253
0
        }
13254
0
        if (tmp == NULL) {
13255
0
            tmp = PyList_New(0);
13256
0
            if (tmp == NULL) {
13257
0
                return -1;
13258
0
            }
13259
0
        }
13260
0
        {
13261
0
            int res;
13262
0
            Py_ssize_t len;
13263
0
            Py_ssize_t i;
13264
0
            if (!PyList_Check(tmp)) {
13265
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13266
0
                goto failed;
13267
0
            }
13268
0
            len = PyList_GET_SIZE(tmp);
13269
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13270
0
            if (body == NULL) goto failed;
13271
0
            for (i = 0; i < len; i++) {
13272
0
                stmt_ty val;
13273
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13274
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13275
0
                    goto failed;
13276
0
                }
13277
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13278
0
                _Py_LeaveRecursiveCall();
13279
0
                Py_DECREF(tmp2);
13280
0
                if (res != 0) goto failed;
13281
0
                if (len != PyList_GET_SIZE(tmp)) {
13282
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13283
0
                    goto failed;
13284
0
                }
13285
0
                asdl_seq_SET(body, i, val);
13286
0
            }
13287
0
            Py_CLEAR(tmp);
13288
0
        }
13289
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13290
0
            return -1;
13291
0
        }
13292
0
        if (tmp == NULL) {
13293
0
            tmp = PyList_New(0);
13294
0
            if (tmp == NULL) {
13295
0
                return -1;
13296
0
            }
13297
0
        }
13298
0
        {
13299
0
            int res;
13300
0
            Py_ssize_t len;
13301
0
            Py_ssize_t i;
13302
0
            if (!PyList_Check(tmp)) {
13303
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13304
0
                goto failed;
13305
0
            }
13306
0
            len = PyList_GET_SIZE(tmp);
13307
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13308
0
            if (handlers == NULL) goto failed;
13309
0
            for (i = 0; i < len; i++) {
13310
0
                excepthandler_ty val;
13311
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13312
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13313
0
                    goto failed;
13314
0
                }
13315
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13316
0
                _Py_LeaveRecursiveCall();
13317
0
                Py_DECREF(tmp2);
13318
0
                if (res != 0) goto failed;
13319
0
                if (len != PyList_GET_SIZE(tmp)) {
13320
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13321
0
                    goto failed;
13322
0
                }
13323
0
                asdl_seq_SET(handlers, i, val);
13324
0
            }
13325
0
            Py_CLEAR(tmp);
13326
0
        }
13327
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13328
0
            return -1;
13329
0
        }
13330
0
        if (tmp == NULL) {
13331
0
            tmp = PyList_New(0);
13332
0
            if (tmp == NULL) {
13333
0
                return -1;
13334
0
            }
13335
0
        }
13336
0
        {
13337
0
            int res;
13338
0
            Py_ssize_t len;
13339
0
            Py_ssize_t i;
13340
0
            if (!PyList_Check(tmp)) {
13341
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13342
0
                goto failed;
13343
0
            }
13344
0
            len = PyList_GET_SIZE(tmp);
13345
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13346
0
            if (orelse == NULL) goto failed;
13347
0
            for (i = 0; i < len; i++) {
13348
0
                stmt_ty val;
13349
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13350
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13351
0
                    goto failed;
13352
0
                }
13353
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13354
0
                _Py_LeaveRecursiveCall();
13355
0
                Py_DECREF(tmp2);
13356
0
                if (res != 0) goto failed;
13357
0
                if (len != PyList_GET_SIZE(tmp)) {
13358
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13359
0
                    goto failed;
13360
0
                }
13361
0
                asdl_seq_SET(orelse, i, val);
13362
0
            }
13363
0
            Py_CLEAR(tmp);
13364
0
        }
13365
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13366
0
            return -1;
13367
0
        }
13368
0
        if (tmp == NULL) {
13369
0
            tmp = PyList_New(0);
13370
0
            if (tmp == NULL) {
13371
0
                return -1;
13372
0
            }
13373
0
        }
13374
0
        {
13375
0
            int res;
13376
0
            Py_ssize_t len;
13377
0
            Py_ssize_t i;
13378
0
            if (!PyList_Check(tmp)) {
13379
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13380
0
                goto failed;
13381
0
            }
13382
0
            len = PyList_GET_SIZE(tmp);
13383
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13384
0
            if (finalbody == NULL) goto failed;
13385
0
            for (i = 0; i < len; i++) {
13386
0
                stmt_ty val;
13387
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13388
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13389
0
                    goto failed;
13390
0
                }
13391
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13392
0
                _Py_LeaveRecursiveCall();
13393
0
                Py_DECREF(tmp2);
13394
0
                if (res != 0) goto failed;
13395
0
                if (len != PyList_GET_SIZE(tmp)) {
13396
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13397
0
                    goto failed;
13398
0
                }
13399
0
                asdl_seq_SET(finalbody, i, val);
13400
0
            }
13401
0
            Py_CLEAR(tmp);
13402
0
        }
13403
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13404
0
                              col_offset, end_lineno, end_col_offset, arena);
13405
0
        if (*out == NULL) goto failed;
13406
0
        return 0;
13407
0
    }
13408
0
    tp = state->Assert_type;
13409
0
    isinstance = PyObject_IsInstance(obj, tp);
13410
0
    if (isinstance == -1) {
13411
0
        return -1;
13412
0
    }
13413
0
    if (isinstance) {
13414
0
        expr_ty test;
13415
0
        expr_ty msg;
13416
13417
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13418
0
            return -1;
13419
0
        }
13420
0
        if (tmp == NULL) {
13421
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13422
0
            return -1;
13423
0
        }
13424
0
        else {
13425
0
            int res;
13426
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13427
0
                goto failed;
13428
0
            }
13429
0
            res = obj2ast_expr(state, tmp, &test, arena);
13430
0
            _Py_LeaveRecursiveCall();
13431
0
            if (res != 0) goto failed;
13432
0
            Py_CLEAR(tmp);
13433
0
        }
13434
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13435
0
            return -1;
13436
0
        }
13437
0
        if (tmp == NULL || tmp == Py_None) {
13438
0
            Py_CLEAR(tmp);
13439
0
            msg = NULL;
13440
0
        }
13441
0
        else {
13442
0
            int res;
13443
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13444
0
                goto failed;
13445
0
            }
13446
0
            res = obj2ast_expr(state, tmp, &msg, arena);
13447
0
            _Py_LeaveRecursiveCall();
13448
0
            if (res != 0) goto failed;
13449
0
            Py_CLEAR(tmp);
13450
0
        }
13451
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13452
0
                             end_col_offset, arena);
13453
0
        if (*out == NULL) goto failed;
13454
0
        return 0;
13455
0
    }
13456
0
    tp = state->Import_type;
13457
0
    isinstance = PyObject_IsInstance(obj, tp);
13458
0
    if (isinstance == -1) {
13459
0
        return -1;
13460
0
    }
13461
0
    if (isinstance) {
13462
0
        asdl_alias_seq* names;
13463
0
        int is_lazy;
13464
13465
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13466
0
            return -1;
13467
0
        }
13468
0
        if (tmp == NULL) {
13469
0
            tmp = PyList_New(0);
13470
0
            if (tmp == NULL) {
13471
0
                return -1;
13472
0
            }
13473
0
        }
13474
0
        {
13475
0
            int res;
13476
0
            Py_ssize_t len;
13477
0
            Py_ssize_t i;
13478
0
            if (!PyList_Check(tmp)) {
13479
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13480
0
                goto failed;
13481
0
            }
13482
0
            len = PyList_GET_SIZE(tmp);
13483
0
            names = _Py_asdl_alias_seq_new(len, arena);
13484
0
            if (names == NULL) goto failed;
13485
0
            for (i = 0; i < len; i++) {
13486
0
                alias_ty val;
13487
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13488
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13489
0
                    goto failed;
13490
0
                }
13491
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13492
0
                _Py_LeaveRecursiveCall();
13493
0
                Py_DECREF(tmp2);
13494
0
                if (res != 0) goto failed;
13495
0
                if (len != PyList_GET_SIZE(tmp)) {
13496
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13497
0
                    goto failed;
13498
0
                }
13499
0
                asdl_seq_SET(names, i, val);
13500
0
            }
13501
0
            Py_CLEAR(tmp);
13502
0
        }
13503
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13504
0
            return -1;
13505
0
        }
13506
0
        if (tmp == NULL || tmp == Py_None) {
13507
0
            Py_CLEAR(tmp);
13508
0
            is_lazy = 0;
13509
0
        }
13510
0
        else {
13511
0
            int res;
13512
0
            if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13513
0
                goto failed;
13514
0
            }
13515
0
            res = obj2ast_int(state, tmp, &is_lazy, arena);
13516
0
            _Py_LeaveRecursiveCall();
13517
0
            if (res != 0) goto failed;
13518
0
            Py_CLEAR(tmp);
13519
0
        }
13520
0
        *out = _PyAST_Import(names, is_lazy, lineno, col_offset, end_lineno,
13521
0
                             end_col_offset, arena);
13522
0
        if (*out == NULL) goto failed;
13523
0
        return 0;
13524
0
    }
13525
0
    tp = state->ImportFrom_type;
13526
0
    isinstance = PyObject_IsInstance(obj, tp);
13527
0
    if (isinstance == -1) {
13528
0
        return -1;
13529
0
    }
13530
0
    if (isinstance) {
13531
0
        identifier module;
13532
0
        asdl_alias_seq* names;
13533
0
        int level;
13534
0
        int is_lazy;
13535
13536
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13537
0
            return -1;
13538
0
        }
13539
0
        if (tmp == NULL || tmp == Py_None) {
13540
0
            Py_CLEAR(tmp);
13541
0
            module = NULL;
13542
0
        }
13543
0
        else {
13544
0
            int res;
13545
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13546
0
                goto failed;
13547
0
            }
13548
0
            res = obj2ast_identifier(state, tmp, &module, arena);
13549
0
            _Py_LeaveRecursiveCall();
13550
0
            if (res != 0) goto failed;
13551
0
            Py_CLEAR(tmp);
13552
0
        }
13553
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13554
0
            return -1;
13555
0
        }
13556
0
        if (tmp == NULL) {
13557
0
            tmp = PyList_New(0);
13558
0
            if (tmp == NULL) {
13559
0
                return -1;
13560
0
            }
13561
0
        }
13562
0
        {
13563
0
            int res;
13564
0
            Py_ssize_t len;
13565
0
            Py_ssize_t i;
13566
0
            if (!PyList_Check(tmp)) {
13567
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13568
0
                goto failed;
13569
0
            }
13570
0
            len = PyList_GET_SIZE(tmp);
13571
0
            names = _Py_asdl_alias_seq_new(len, arena);
13572
0
            if (names == NULL) goto failed;
13573
0
            for (i = 0; i < len; i++) {
13574
0
                alias_ty val;
13575
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13576
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13577
0
                    goto failed;
13578
0
                }
13579
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13580
0
                _Py_LeaveRecursiveCall();
13581
0
                Py_DECREF(tmp2);
13582
0
                if (res != 0) goto failed;
13583
0
                if (len != PyList_GET_SIZE(tmp)) {
13584
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13585
0
                    goto failed;
13586
0
                }
13587
0
                asdl_seq_SET(names, i, val);
13588
0
            }
13589
0
            Py_CLEAR(tmp);
13590
0
        }
13591
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13592
0
            return -1;
13593
0
        }
13594
0
        if (tmp == NULL || tmp == Py_None) {
13595
0
            Py_CLEAR(tmp);
13596
0
            level = 0;
13597
0
        }
13598
0
        else {
13599
0
            int res;
13600
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13601
0
                goto failed;
13602
0
            }
13603
0
            res = obj2ast_int(state, tmp, &level, arena);
13604
0
            _Py_LeaveRecursiveCall();
13605
0
            if (res != 0) goto failed;
13606
0
            Py_CLEAR(tmp);
13607
0
        }
13608
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13609
0
            return -1;
13610
0
        }
13611
0
        if (tmp == NULL || tmp == Py_None) {
13612
0
            Py_CLEAR(tmp);
13613
0
            is_lazy = 0;
13614
0
        }
13615
0
        else {
13616
0
            int res;
13617
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13618
0
                goto failed;
13619
0
            }
13620
0
            res = obj2ast_int(state, tmp, &is_lazy, arena);
13621
0
            _Py_LeaveRecursiveCall();
13622
0
            if (res != 0) goto failed;
13623
0
            Py_CLEAR(tmp);
13624
0
        }
13625
0
        *out = _PyAST_ImportFrom(module, names, level, is_lazy, lineno,
13626
0
                                 col_offset, end_lineno, end_col_offset, arena);
13627
0
        if (*out == NULL) goto failed;
13628
0
        return 0;
13629
0
    }
13630
0
    tp = state->Global_type;
13631
0
    isinstance = PyObject_IsInstance(obj, tp);
13632
0
    if (isinstance == -1) {
13633
0
        return -1;
13634
0
    }
13635
0
    if (isinstance) {
13636
0
        asdl_identifier_seq* names;
13637
13638
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13639
0
            return -1;
13640
0
        }
13641
0
        if (tmp == NULL) {
13642
0
            tmp = PyList_New(0);
13643
0
            if (tmp == NULL) {
13644
0
                return -1;
13645
0
            }
13646
0
        }
13647
0
        {
13648
0
            int res;
13649
0
            Py_ssize_t len;
13650
0
            Py_ssize_t i;
13651
0
            if (!PyList_Check(tmp)) {
13652
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13653
0
                goto failed;
13654
0
            }
13655
0
            len = PyList_GET_SIZE(tmp);
13656
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13657
0
            if (names == NULL) goto failed;
13658
0
            for (i = 0; i < len; i++) {
13659
0
                identifier val;
13660
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13661
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13662
0
                    goto failed;
13663
0
                }
13664
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13665
0
                _Py_LeaveRecursiveCall();
13666
0
                Py_DECREF(tmp2);
13667
0
                if (res != 0) goto failed;
13668
0
                if (len != PyList_GET_SIZE(tmp)) {
13669
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13670
0
                    goto failed;
13671
0
                }
13672
0
                asdl_seq_SET(names, i, val);
13673
0
            }
13674
0
            Py_CLEAR(tmp);
13675
0
        }
13676
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13677
0
                             end_col_offset, arena);
13678
0
        if (*out == NULL) goto failed;
13679
0
        return 0;
13680
0
    }
13681
0
    tp = state->Nonlocal_type;
13682
0
    isinstance = PyObject_IsInstance(obj, tp);
13683
0
    if (isinstance == -1) {
13684
0
        return -1;
13685
0
    }
13686
0
    if (isinstance) {
13687
0
        asdl_identifier_seq* names;
13688
13689
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13690
0
            return -1;
13691
0
        }
13692
0
        if (tmp == NULL) {
13693
0
            tmp = PyList_New(0);
13694
0
            if (tmp == NULL) {
13695
0
                return -1;
13696
0
            }
13697
0
        }
13698
0
        {
13699
0
            int res;
13700
0
            Py_ssize_t len;
13701
0
            Py_ssize_t i;
13702
0
            if (!PyList_Check(tmp)) {
13703
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13704
0
                goto failed;
13705
0
            }
13706
0
            len = PyList_GET_SIZE(tmp);
13707
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13708
0
            if (names == NULL) goto failed;
13709
0
            for (i = 0; i < len; i++) {
13710
0
                identifier val;
13711
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13712
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13713
0
                    goto failed;
13714
0
                }
13715
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13716
0
                _Py_LeaveRecursiveCall();
13717
0
                Py_DECREF(tmp2);
13718
0
                if (res != 0) goto failed;
13719
0
                if (len != PyList_GET_SIZE(tmp)) {
13720
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13721
0
                    goto failed;
13722
0
                }
13723
0
                asdl_seq_SET(names, i, val);
13724
0
            }
13725
0
            Py_CLEAR(tmp);
13726
0
        }
13727
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13728
0
                               end_col_offset, arena);
13729
0
        if (*out == NULL) goto failed;
13730
0
        return 0;
13731
0
    }
13732
0
    tp = state->Expr_type;
13733
0
    isinstance = PyObject_IsInstance(obj, tp);
13734
0
    if (isinstance == -1) {
13735
0
        return -1;
13736
0
    }
13737
0
    if (isinstance) {
13738
0
        expr_ty value;
13739
13740
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13741
0
            return -1;
13742
0
        }
13743
0
        if (tmp == NULL) {
13744
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13745
0
            return -1;
13746
0
        }
13747
0
        else {
13748
0
            int res;
13749
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13750
0
                goto failed;
13751
0
            }
13752
0
            res = obj2ast_expr(state, tmp, &value, arena);
13753
0
            _Py_LeaveRecursiveCall();
13754
0
            if (res != 0) goto failed;
13755
0
            Py_CLEAR(tmp);
13756
0
        }
13757
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13758
0
                           end_col_offset, arena);
13759
0
        if (*out == NULL) goto failed;
13760
0
        return 0;
13761
0
    }
13762
0
    tp = state->Pass_type;
13763
0
    isinstance = PyObject_IsInstance(obj, tp);
13764
0
    if (isinstance == -1) {
13765
0
        return -1;
13766
0
    }
13767
0
    if (isinstance) {
13768
13769
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13770
0
                           arena);
13771
0
        if (*out == NULL) goto failed;
13772
0
        return 0;
13773
0
    }
13774
0
    tp = state->Break_type;
13775
0
    isinstance = PyObject_IsInstance(obj, tp);
13776
0
    if (isinstance == -1) {
13777
0
        return -1;
13778
0
    }
13779
0
    if (isinstance) {
13780
13781
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13782
0
                            arena);
13783
0
        if (*out == NULL) goto failed;
13784
0
        return 0;
13785
0
    }
13786
0
    tp = state->Continue_type;
13787
0
    isinstance = PyObject_IsInstance(obj, tp);
13788
0
    if (isinstance == -1) {
13789
0
        return -1;
13790
0
    }
13791
0
    if (isinstance) {
13792
13793
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13794
0
                               arena);
13795
0
        if (*out == NULL) goto failed;
13796
0
        return 0;
13797
0
    }
13798
13799
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13800
0
    failed:
13801
0
    Py_XDECREF(tmp);
13802
0
    return -1;
13803
0
}
13804
13805
int
13806
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
13807
             arena)
13808
0
{
13809
0
    int isinstance;
13810
13811
0
    PyObject *tmp = NULL;
13812
0
    PyObject *tp;
13813
0
    int lineno;
13814
0
    int col_offset;
13815
0
    int end_lineno;
13816
0
    int end_col_offset;
13817
13818
0
    if (obj == Py_None) {
13819
0
        *out = NULL;
13820
0
        return 0;
13821
0
    }
13822
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13823
0
        return -1;
13824
0
    }
13825
0
    if (tmp == NULL) {
13826
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13827
0
        return -1;
13828
0
    }
13829
0
    else {
13830
0
        int res;
13831
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13832
0
            goto failed;
13833
0
        }
13834
0
        res = obj2ast_int(state, tmp, &lineno, arena);
13835
0
        _Py_LeaveRecursiveCall();
13836
0
        if (res != 0) goto failed;
13837
0
        Py_CLEAR(tmp);
13838
0
    }
13839
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13840
0
        return -1;
13841
0
    }
13842
0
    if (tmp == NULL) {
13843
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13844
0
        return -1;
13845
0
    }
13846
0
    else {
13847
0
        int res;
13848
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13849
0
            goto failed;
13850
0
        }
13851
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
13852
0
        _Py_LeaveRecursiveCall();
13853
0
        if (res != 0) goto failed;
13854
0
        Py_CLEAR(tmp);
13855
0
    }
13856
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13857
0
        return -1;
13858
0
    }
13859
0
    if (tmp == NULL || tmp == Py_None) {
13860
0
        Py_CLEAR(tmp);
13861
0
        end_lineno = lineno;
13862
0
    }
13863
0
    else {
13864
0
        int res;
13865
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13866
0
            goto failed;
13867
0
        }
13868
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
13869
0
        _Py_LeaveRecursiveCall();
13870
0
        if (res != 0) goto failed;
13871
0
        Py_CLEAR(tmp);
13872
0
    }
13873
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13874
0
        return -1;
13875
0
    }
13876
0
    if (tmp == NULL || tmp == Py_None) {
13877
0
        Py_CLEAR(tmp);
13878
0
        end_col_offset = col_offset;
13879
0
    }
13880
0
    else {
13881
0
        int res;
13882
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13883
0
            goto failed;
13884
0
        }
13885
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
13886
0
        _Py_LeaveRecursiveCall();
13887
0
        if (res != 0) goto failed;
13888
0
        Py_CLEAR(tmp);
13889
0
    }
13890
0
    tp = state->BoolOp_type;
13891
0
    isinstance = PyObject_IsInstance(obj, tp);
13892
0
    if (isinstance == -1) {
13893
0
        return -1;
13894
0
    }
13895
0
    if (isinstance) {
13896
0
        boolop_ty op;
13897
0
        asdl_expr_seq* values;
13898
13899
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13900
0
            return -1;
13901
0
        }
13902
0
        if (tmp == NULL) {
13903
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13904
0
            return -1;
13905
0
        }
13906
0
        else {
13907
0
            int res;
13908
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13909
0
                goto failed;
13910
0
            }
13911
0
            res = obj2ast_boolop(state, tmp, &op, arena);
13912
0
            _Py_LeaveRecursiveCall();
13913
0
            if (res != 0) goto failed;
13914
0
            Py_CLEAR(tmp);
13915
0
        }
13916
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13917
0
            return -1;
13918
0
        }
13919
0
        if (tmp == NULL) {
13920
0
            tmp = PyList_New(0);
13921
0
            if (tmp == NULL) {
13922
0
                return -1;
13923
0
            }
13924
0
        }
13925
0
        {
13926
0
            int res;
13927
0
            Py_ssize_t len;
13928
0
            Py_ssize_t i;
13929
0
            if (!PyList_Check(tmp)) {
13930
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13931
0
                goto failed;
13932
0
            }
13933
0
            len = PyList_GET_SIZE(tmp);
13934
0
            values = _Py_asdl_expr_seq_new(len, arena);
13935
0
            if (values == NULL) goto failed;
13936
0
            for (i = 0; i < len; i++) {
13937
0
                expr_ty val;
13938
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13939
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13940
0
                    goto failed;
13941
0
                }
13942
0
                res = obj2ast_expr(state, tmp2, &val, arena);
13943
0
                _Py_LeaveRecursiveCall();
13944
0
                Py_DECREF(tmp2);
13945
0
                if (res != 0) goto failed;
13946
0
                if (len != PyList_GET_SIZE(tmp)) {
13947
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13948
0
                    goto failed;
13949
0
                }
13950
0
                asdl_seq_SET(values, i, val);
13951
0
            }
13952
0
            Py_CLEAR(tmp);
13953
0
        }
13954
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
13955
0
                             end_col_offset, arena);
13956
0
        if (*out == NULL) goto failed;
13957
0
        return 0;
13958
0
    }
13959
0
    tp = state->NamedExpr_type;
13960
0
    isinstance = PyObject_IsInstance(obj, tp);
13961
0
    if (isinstance == -1) {
13962
0
        return -1;
13963
0
    }
13964
0
    if (isinstance) {
13965
0
        expr_ty target;
13966
0
        expr_ty value;
13967
13968
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
13969
0
            return -1;
13970
0
        }
13971
0
        if (tmp == NULL) {
13972
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
13973
0
            return -1;
13974
0
        }
13975
0
        else {
13976
0
            int res;
13977
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13978
0
                goto failed;
13979
0
            }
13980
0
            res = obj2ast_expr(state, tmp, &target, arena);
13981
0
            _Py_LeaveRecursiveCall();
13982
0
            if (res != 0) goto failed;
13983
0
            Py_CLEAR(tmp);
13984
0
        }
13985
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13986
0
            return -1;
13987
0
        }
13988
0
        if (tmp == NULL) {
13989
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
13990
0
            return -1;
13991
0
        }
13992
0
        else {
13993
0
            int res;
13994
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13995
0
                goto failed;
13996
0
            }
13997
0
            res = obj2ast_expr(state, tmp, &value, arena);
13998
0
            _Py_LeaveRecursiveCall();
13999
0
            if (res != 0) goto failed;
14000
0
            Py_CLEAR(tmp);
14001
0
        }
14002
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
14003
0
                                end_col_offset, arena);
14004
0
        if (*out == NULL) goto failed;
14005
0
        return 0;
14006
0
    }
14007
0
    tp = state->BinOp_type;
14008
0
    isinstance = PyObject_IsInstance(obj, tp);
14009
0
    if (isinstance == -1) {
14010
0
        return -1;
14011
0
    }
14012
0
    if (isinstance) {
14013
0
        expr_ty left;
14014
0
        operator_ty op;
14015
0
        expr_ty right;
14016
14017
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14018
0
            return -1;
14019
0
        }
14020
0
        if (tmp == NULL) {
14021
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14022
0
            return -1;
14023
0
        }
14024
0
        else {
14025
0
            int res;
14026
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14027
0
                goto failed;
14028
0
            }
14029
0
            res = obj2ast_expr(state, tmp, &left, arena);
14030
0
            _Py_LeaveRecursiveCall();
14031
0
            if (res != 0) goto failed;
14032
0
            Py_CLEAR(tmp);
14033
0
        }
14034
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14035
0
            return -1;
14036
0
        }
14037
0
        if (tmp == NULL) {
14038
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14039
0
            return -1;
14040
0
        }
14041
0
        else {
14042
0
            int res;
14043
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14044
0
                goto failed;
14045
0
            }
14046
0
            res = obj2ast_operator(state, tmp, &op, arena);
14047
0
            _Py_LeaveRecursiveCall();
14048
0
            if (res != 0) goto failed;
14049
0
            Py_CLEAR(tmp);
14050
0
        }
14051
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14052
0
            return -1;
14053
0
        }
14054
0
        if (tmp == NULL) {
14055
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14056
0
            return -1;
14057
0
        }
14058
0
        else {
14059
0
            int res;
14060
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14061
0
                goto failed;
14062
0
            }
14063
0
            res = obj2ast_expr(state, tmp, &right, arena);
14064
0
            _Py_LeaveRecursiveCall();
14065
0
            if (res != 0) goto failed;
14066
0
            Py_CLEAR(tmp);
14067
0
        }
14068
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14069
0
                            end_col_offset, arena);
14070
0
        if (*out == NULL) goto failed;
14071
0
        return 0;
14072
0
    }
14073
0
    tp = state->UnaryOp_type;
14074
0
    isinstance = PyObject_IsInstance(obj, tp);
14075
0
    if (isinstance == -1) {
14076
0
        return -1;
14077
0
    }
14078
0
    if (isinstance) {
14079
0
        unaryop_ty op;
14080
0
        expr_ty operand;
14081
14082
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14083
0
            return -1;
14084
0
        }
14085
0
        if (tmp == NULL) {
14086
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14087
0
            return -1;
14088
0
        }
14089
0
        else {
14090
0
            int res;
14091
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14092
0
                goto failed;
14093
0
            }
14094
0
            res = obj2ast_unaryop(state, tmp, &op, 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->operand, &tmp) < 0) {
14100
0
            return -1;
14101
0
        }
14102
0
        if (tmp == NULL) {
14103
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14104
0
            return -1;
14105
0
        }
14106
0
        else {
14107
0
            int res;
14108
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14109
0
                goto failed;
14110
0
            }
14111
0
            res = obj2ast_expr(state, tmp, &operand, arena);
14112
0
            _Py_LeaveRecursiveCall();
14113
0
            if (res != 0) goto failed;
14114
0
            Py_CLEAR(tmp);
14115
0
        }
14116
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14117
0
                              end_col_offset, arena);
14118
0
        if (*out == NULL) goto failed;
14119
0
        return 0;
14120
0
    }
14121
0
    tp = state->Lambda_type;
14122
0
    isinstance = PyObject_IsInstance(obj, tp);
14123
0
    if (isinstance == -1) {
14124
0
        return -1;
14125
0
    }
14126
0
    if (isinstance) {
14127
0
        arguments_ty args;
14128
0
        expr_ty body;
14129
14130
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14131
0
            return -1;
14132
0
        }
14133
0
        if (tmp == NULL) {
14134
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14135
0
            return -1;
14136
0
        }
14137
0
        else {
14138
0
            int res;
14139
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14140
0
                goto failed;
14141
0
            }
14142
0
            res = obj2ast_arguments(state, tmp, &args, arena);
14143
0
            _Py_LeaveRecursiveCall();
14144
0
            if (res != 0) goto failed;
14145
0
            Py_CLEAR(tmp);
14146
0
        }
14147
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14148
0
            return -1;
14149
0
        }
14150
0
        if (tmp == NULL) {
14151
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14152
0
            return -1;
14153
0
        }
14154
0
        else {
14155
0
            int res;
14156
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14157
0
                goto failed;
14158
0
            }
14159
0
            res = obj2ast_expr(state, tmp, &body, arena);
14160
0
            _Py_LeaveRecursiveCall();
14161
0
            if (res != 0) goto failed;
14162
0
            Py_CLEAR(tmp);
14163
0
        }
14164
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14165
0
                             end_col_offset, arena);
14166
0
        if (*out == NULL) goto failed;
14167
0
        return 0;
14168
0
    }
14169
0
    tp = state->IfExp_type;
14170
0
    isinstance = PyObject_IsInstance(obj, tp);
14171
0
    if (isinstance == -1) {
14172
0
        return -1;
14173
0
    }
14174
0
    if (isinstance) {
14175
0
        expr_ty test;
14176
0
        expr_ty body;
14177
0
        expr_ty orelse;
14178
14179
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14180
0
            return -1;
14181
0
        }
14182
0
        if (tmp == NULL) {
14183
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14184
0
            return -1;
14185
0
        }
14186
0
        else {
14187
0
            int res;
14188
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14189
0
                goto failed;
14190
0
            }
14191
0
            res = obj2ast_expr(state, tmp, &test, arena);
14192
0
            _Py_LeaveRecursiveCall();
14193
0
            if (res != 0) goto failed;
14194
0
            Py_CLEAR(tmp);
14195
0
        }
14196
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14197
0
            return -1;
14198
0
        }
14199
0
        if (tmp == NULL) {
14200
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14201
0
            return -1;
14202
0
        }
14203
0
        else {
14204
0
            int res;
14205
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14206
0
                goto failed;
14207
0
            }
14208
0
            res = obj2ast_expr(state, tmp, &body, arena);
14209
0
            _Py_LeaveRecursiveCall();
14210
0
            if (res != 0) goto failed;
14211
0
            Py_CLEAR(tmp);
14212
0
        }
14213
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14214
0
            return -1;
14215
0
        }
14216
0
        if (tmp == NULL) {
14217
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14218
0
            return -1;
14219
0
        }
14220
0
        else {
14221
0
            int res;
14222
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14223
0
                goto failed;
14224
0
            }
14225
0
            res = obj2ast_expr(state, tmp, &orelse, arena);
14226
0
            _Py_LeaveRecursiveCall();
14227
0
            if (res != 0) goto failed;
14228
0
            Py_CLEAR(tmp);
14229
0
        }
14230
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14231
0
                            end_col_offset, arena);
14232
0
        if (*out == NULL) goto failed;
14233
0
        return 0;
14234
0
    }
14235
0
    tp = state->Dict_type;
14236
0
    isinstance = PyObject_IsInstance(obj, tp);
14237
0
    if (isinstance == -1) {
14238
0
        return -1;
14239
0
    }
14240
0
    if (isinstance) {
14241
0
        asdl_expr_seq* keys;
14242
0
        asdl_expr_seq* values;
14243
14244
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14245
0
            return -1;
14246
0
        }
14247
0
        if (tmp == NULL) {
14248
0
            tmp = PyList_New(0);
14249
0
            if (tmp == NULL) {
14250
0
                return -1;
14251
0
            }
14252
0
        }
14253
0
        {
14254
0
            int res;
14255
0
            Py_ssize_t len;
14256
0
            Py_ssize_t i;
14257
0
            if (!PyList_Check(tmp)) {
14258
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14259
0
                goto failed;
14260
0
            }
14261
0
            len = PyList_GET_SIZE(tmp);
14262
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14263
0
            if (keys == NULL) goto failed;
14264
0
            for (i = 0; i < len; i++) {
14265
0
                expr_ty val;
14266
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14267
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14268
0
                    goto failed;
14269
0
                }
14270
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14271
0
                _Py_LeaveRecursiveCall();
14272
0
                Py_DECREF(tmp2);
14273
0
                if (res != 0) goto failed;
14274
0
                if (len != PyList_GET_SIZE(tmp)) {
14275
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14276
0
                    goto failed;
14277
0
                }
14278
0
                asdl_seq_SET(keys, i, val);
14279
0
            }
14280
0
            Py_CLEAR(tmp);
14281
0
        }
14282
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14283
0
            return -1;
14284
0
        }
14285
0
        if (tmp == NULL) {
14286
0
            tmp = PyList_New(0);
14287
0
            if (tmp == NULL) {
14288
0
                return -1;
14289
0
            }
14290
0
        }
14291
0
        {
14292
0
            int res;
14293
0
            Py_ssize_t len;
14294
0
            Py_ssize_t i;
14295
0
            if (!PyList_Check(tmp)) {
14296
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14297
0
                goto failed;
14298
0
            }
14299
0
            len = PyList_GET_SIZE(tmp);
14300
0
            values = _Py_asdl_expr_seq_new(len, arena);
14301
0
            if (values == NULL) goto failed;
14302
0
            for (i = 0; i < len; i++) {
14303
0
                expr_ty val;
14304
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14305
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14306
0
                    goto failed;
14307
0
                }
14308
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14309
0
                _Py_LeaveRecursiveCall();
14310
0
                Py_DECREF(tmp2);
14311
0
                if (res != 0) goto failed;
14312
0
                if (len != PyList_GET_SIZE(tmp)) {
14313
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14314
0
                    goto failed;
14315
0
                }
14316
0
                asdl_seq_SET(values, i, val);
14317
0
            }
14318
0
            Py_CLEAR(tmp);
14319
0
        }
14320
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14321
0
                           end_col_offset, arena);
14322
0
        if (*out == NULL) goto failed;
14323
0
        return 0;
14324
0
    }
14325
0
    tp = state->Set_type;
14326
0
    isinstance = PyObject_IsInstance(obj, tp);
14327
0
    if (isinstance == -1) {
14328
0
        return -1;
14329
0
    }
14330
0
    if (isinstance) {
14331
0
        asdl_expr_seq* elts;
14332
14333
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14334
0
            return -1;
14335
0
        }
14336
0
        if (tmp == NULL) {
14337
0
            tmp = PyList_New(0);
14338
0
            if (tmp == NULL) {
14339
0
                return -1;
14340
0
            }
14341
0
        }
14342
0
        {
14343
0
            int res;
14344
0
            Py_ssize_t len;
14345
0
            Py_ssize_t i;
14346
0
            if (!PyList_Check(tmp)) {
14347
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14348
0
                goto failed;
14349
0
            }
14350
0
            len = PyList_GET_SIZE(tmp);
14351
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14352
0
            if (elts == NULL) goto failed;
14353
0
            for (i = 0; i < len; i++) {
14354
0
                expr_ty val;
14355
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14356
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14357
0
                    goto failed;
14358
0
                }
14359
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14360
0
                _Py_LeaveRecursiveCall();
14361
0
                Py_DECREF(tmp2);
14362
0
                if (res != 0) goto failed;
14363
0
                if (len != PyList_GET_SIZE(tmp)) {
14364
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14365
0
                    goto failed;
14366
0
                }
14367
0
                asdl_seq_SET(elts, i, val);
14368
0
            }
14369
0
            Py_CLEAR(tmp);
14370
0
        }
14371
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14372
0
                          arena);
14373
0
        if (*out == NULL) goto failed;
14374
0
        return 0;
14375
0
    }
14376
0
    tp = state->ListComp_type;
14377
0
    isinstance = PyObject_IsInstance(obj, tp);
14378
0
    if (isinstance == -1) {
14379
0
        return -1;
14380
0
    }
14381
0
    if (isinstance) {
14382
0
        expr_ty elt;
14383
0
        asdl_comprehension_seq* generators;
14384
14385
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14386
0
            return -1;
14387
0
        }
14388
0
        if (tmp == NULL) {
14389
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14390
0
            return -1;
14391
0
        }
14392
0
        else {
14393
0
            int res;
14394
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14395
0
                goto failed;
14396
0
            }
14397
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14398
0
            _Py_LeaveRecursiveCall();
14399
0
            if (res != 0) goto failed;
14400
0
            Py_CLEAR(tmp);
14401
0
        }
14402
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14403
0
            return -1;
14404
0
        }
14405
0
        if (tmp == NULL) {
14406
0
            tmp = PyList_New(0);
14407
0
            if (tmp == NULL) {
14408
0
                return -1;
14409
0
            }
14410
0
        }
14411
0
        {
14412
0
            int res;
14413
0
            Py_ssize_t len;
14414
0
            Py_ssize_t i;
14415
0
            if (!PyList_Check(tmp)) {
14416
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14417
0
                goto failed;
14418
0
            }
14419
0
            len = PyList_GET_SIZE(tmp);
14420
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14421
0
            if (generators == NULL) goto failed;
14422
0
            for (i = 0; i < len; i++) {
14423
0
                comprehension_ty val;
14424
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14425
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14426
0
                    goto failed;
14427
0
                }
14428
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14429
0
                _Py_LeaveRecursiveCall();
14430
0
                Py_DECREF(tmp2);
14431
0
                if (res != 0) goto failed;
14432
0
                if (len != PyList_GET_SIZE(tmp)) {
14433
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14434
0
                    goto failed;
14435
0
                }
14436
0
                asdl_seq_SET(generators, i, val);
14437
0
            }
14438
0
            Py_CLEAR(tmp);
14439
0
        }
14440
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14441
0
                               end_col_offset, arena);
14442
0
        if (*out == NULL) goto failed;
14443
0
        return 0;
14444
0
    }
14445
0
    tp = state->SetComp_type;
14446
0
    isinstance = PyObject_IsInstance(obj, tp);
14447
0
    if (isinstance == -1) {
14448
0
        return -1;
14449
0
    }
14450
0
    if (isinstance) {
14451
0
        expr_ty elt;
14452
0
        asdl_comprehension_seq* generators;
14453
14454
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14455
0
            return -1;
14456
0
        }
14457
0
        if (tmp == NULL) {
14458
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14459
0
            return -1;
14460
0
        }
14461
0
        else {
14462
0
            int res;
14463
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14464
0
                goto failed;
14465
0
            }
14466
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14467
0
            _Py_LeaveRecursiveCall();
14468
0
            if (res != 0) goto failed;
14469
0
            Py_CLEAR(tmp);
14470
0
        }
14471
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14472
0
            return -1;
14473
0
        }
14474
0
        if (tmp == NULL) {
14475
0
            tmp = PyList_New(0);
14476
0
            if (tmp == NULL) {
14477
0
                return -1;
14478
0
            }
14479
0
        }
14480
0
        {
14481
0
            int res;
14482
0
            Py_ssize_t len;
14483
0
            Py_ssize_t i;
14484
0
            if (!PyList_Check(tmp)) {
14485
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14486
0
                goto failed;
14487
0
            }
14488
0
            len = PyList_GET_SIZE(tmp);
14489
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14490
0
            if (generators == NULL) goto failed;
14491
0
            for (i = 0; i < len; i++) {
14492
0
                comprehension_ty val;
14493
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14494
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14495
0
                    goto failed;
14496
0
                }
14497
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14498
0
                _Py_LeaveRecursiveCall();
14499
0
                Py_DECREF(tmp2);
14500
0
                if (res != 0) goto failed;
14501
0
                if (len != PyList_GET_SIZE(tmp)) {
14502
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14503
0
                    goto failed;
14504
0
                }
14505
0
                asdl_seq_SET(generators, i, val);
14506
0
            }
14507
0
            Py_CLEAR(tmp);
14508
0
        }
14509
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14510
0
                              end_col_offset, arena);
14511
0
        if (*out == NULL) goto failed;
14512
0
        return 0;
14513
0
    }
14514
0
    tp = state->DictComp_type;
14515
0
    isinstance = PyObject_IsInstance(obj, tp);
14516
0
    if (isinstance == -1) {
14517
0
        return -1;
14518
0
    }
14519
0
    if (isinstance) {
14520
0
        expr_ty key;
14521
0
        expr_ty value;
14522
0
        asdl_comprehension_seq* generators;
14523
14524
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14525
0
            return -1;
14526
0
        }
14527
0
        if (tmp == NULL) {
14528
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14529
0
            return -1;
14530
0
        }
14531
0
        else {
14532
0
            int res;
14533
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14534
0
                goto failed;
14535
0
            }
14536
0
            res = obj2ast_expr(state, tmp, &key, arena);
14537
0
            _Py_LeaveRecursiveCall();
14538
0
            if (res != 0) goto failed;
14539
0
            Py_CLEAR(tmp);
14540
0
        }
14541
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14542
0
            return -1;
14543
0
        }
14544
0
        if (tmp == NULL || tmp == Py_None) {
14545
0
            Py_CLEAR(tmp);
14546
0
            value = NULL;
14547
0
        }
14548
0
        else {
14549
0
            int res;
14550
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14551
0
                goto failed;
14552
0
            }
14553
0
            res = obj2ast_expr(state, tmp, &value, arena);
14554
0
            _Py_LeaveRecursiveCall();
14555
0
            if (res != 0) goto failed;
14556
0
            Py_CLEAR(tmp);
14557
0
        }
14558
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14559
0
            return -1;
14560
0
        }
14561
0
        if (tmp == NULL) {
14562
0
            tmp = PyList_New(0);
14563
0
            if (tmp == NULL) {
14564
0
                return -1;
14565
0
            }
14566
0
        }
14567
0
        {
14568
0
            int res;
14569
0
            Py_ssize_t len;
14570
0
            Py_ssize_t i;
14571
0
            if (!PyList_Check(tmp)) {
14572
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14573
0
                goto failed;
14574
0
            }
14575
0
            len = PyList_GET_SIZE(tmp);
14576
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14577
0
            if (generators == NULL) goto failed;
14578
0
            for (i = 0; i < len; i++) {
14579
0
                comprehension_ty val;
14580
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14581
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14582
0
                    goto failed;
14583
0
                }
14584
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14585
0
                _Py_LeaveRecursiveCall();
14586
0
                Py_DECREF(tmp2);
14587
0
                if (res != 0) goto failed;
14588
0
                if (len != PyList_GET_SIZE(tmp)) {
14589
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14590
0
                    goto failed;
14591
0
                }
14592
0
                asdl_seq_SET(generators, i, val);
14593
0
            }
14594
0
            Py_CLEAR(tmp);
14595
0
        }
14596
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14597
0
                               end_lineno, end_col_offset, arena);
14598
0
        if (*out == NULL) goto failed;
14599
0
        return 0;
14600
0
    }
14601
0
    tp = state->GeneratorExp_type;
14602
0
    isinstance = PyObject_IsInstance(obj, tp);
14603
0
    if (isinstance == -1) {
14604
0
        return -1;
14605
0
    }
14606
0
    if (isinstance) {
14607
0
        expr_ty elt;
14608
0
        asdl_comprehension_seq* generators;
14609
14610
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14611
0
            return -1;
14612
0
        }
14613
0
        if (tmp == NULL) {
14614
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14615
0
            return -1;
14616
0
        }
14617
0
        else {
14618
0
            int res;
14619
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14620
0
                goto failed;
14621
0
            }
14622
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14623
0
            _Py_LeaveRecursiveCall();
14624
0
            if (res != 0) goto failed;
14625
0
            Py_CLEAR(tmp);
14626
0
        }
14627
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14628
0
            return -1;
14629
0
        }
14630
0
        if (tmp == NULL) {
14631
0
            tmp = PyList_New(0);
14632
0
            if (tmp == NULL) {
14633
0
                return -1;
14634
0
            }
14635
0
        }
14636
0
        {
14637
0
            int res;
14638
0
            Py_ssize_t len;
14639
0
            Py_ssize_t i;
14640
0
            if (!PyList_Check(tmp)) {
14641
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14642
0
                goto failed;
14643
0
            }
14644
0
            len = PyList_GET_SIZE(tmp);
14645
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14646
0
            if (generators == NULL) goto failed;
14647
0
            for (i = 0; i < len; i++) {
14648
0
                comprehension_ty val;
14649
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14650
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14651
0
                    goto failed;
14652
0
                }
14653
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14654
0
                _Py_LeaveRecursiveCall();
14655
0
                Py_DECREF(tmp2);
14656
0
                if (res != 0) goto failed;
14657
0
                if (len != PyList_GET_SIZE(tmp)) {
14658
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14659
0
                    goto failed;
14660
0
                }
14661
0
                asdl_seq_SET(generators, i, val);
14662
0
            }
14663
0
            Py_CLEAR(tmp);
14664
0
        }
14665
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14666
0
                                   end_lineno, end_col_offset, arena);
14667
0
        if (*out == NULL) goto failed;
14668
0
        return 0;
14669
0
    }
14670
0
    tp = state->Await_type;
14671
0
    isinstance = PyObject_IsInstance(obj, tp);
14672
0
    if (isinstance == -1) {
14673
0
        return -1;
14674
0
    }
14675
0
    if (isinstance) {
14676
0
        expr_ty value;
14677
14678
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14679
0
            return -1;
14680
0
        }
14681
0
        if (tmp == NULL) {
14682
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14683
0
            return -1;
14684
0
        }
14685
0
        else {
14686
0
            int res;
14687
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14688
0
                goto failed;
14689
0
            }
14690
0
            res = obj2ast_expr(state, tmp, &value, arena);
14691
0
            _Py_LeaveRecursiveCall();
14692
0
            if (res != 0) goto failed;
14693
0
            Py_CLEAR(tmp);
14694
0
        }
14695
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14696
0
                            end_col_offset, arena);
14697
0
        if (*out == NULL) goto failed;
14698
0
        return 0;
14699
0
    }
14700
0
    tp = state->Yield_type;
14701
0
    isinstance = PyObject_IsInstance(obj, tp);
14702
0
    if (isinstance == -1) {
14703
0
        return -1;
14704
0
    }
14705
0
    if (isinstance) {
14706
0
        expr_ty value;
14707
14708
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14709
0
            return -1;
14710
0
        }
14711
0
        if (tmp == NULL || tmp == Py_None) {
14712
0
            Py_CLEAR(tmp);
14713
0
            value = NULL;
14714
0
        }
14715
0
        else {
14716
0
            int res;
14717
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14718
0
                goto failed;
14719
0
            }
14720
0
            res = obj2ast_expr(state, tmp, &value, arena);
14721
0
            _Py_LeaveRecursiveCall();
14722
0
            if (res != 0) goto failed;
14723
0
            Py_CLEAR(tmp);
14724
0
        }
14725
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14726
0
                            end_col_offset, arena);
14727
0
        if (*out == NULL) goto failed;
14728
0
        return 0;
14729
0
    }
14730
0
    tp = state->YieldFrom_type;
14731
0
    isinstance = PyObject_IsInstance(obj, tp);
14732
0
    if (isinstance == -1) {
14733
0
        return -1;
14734
0
    }
14735
0
    if (isinstance) {
14736
0
        expr_ty value;
14737
14738
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14739
0
            return -1;
14740
0
        }
14741
0
        if (tmp == NULL) {
14742
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14743
0
            return -1;
14744
0
        }
14745
0
        else {
14746
0
            int res;
14747
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14748
0
                goto failed;
14749
0
            }
14750
0
            res = obj2ast_expr(state, tmp, &value, arena);
14751
0
            _Py_LeaveRecursiveCall();
14752
0
            if (res != 0) goto failed;
14753
0
            Py_CLEAR(tmp);
14754
0
        }
14755
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14756
0
                                end_col_offset, arena);
14757
0
        if (*out == NULL) goto failed;
14758
0
        return 0;
14759
0
    }
14760
0
    tp = state->Compare_type;
14761
0
    isinstance = PyObject_IsInstance(obj, tp);
14762
0
    if (isinstance == -1) {
14763
0
        return -1;
14764
0
    }
14765
0
    if (isinstance) {
14766
0
        expr_ty left;
14767
0
        asdl_int_seq* ops;
14768
0
        asdl_expr_seq* comparators;
14769
14770
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14771
0
            return -1;
14772
0
        }
14773
0
        if (tmp == NULL) {
14774
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14775
0
            return -1;
14776
0
        }
14777
0
        else {
14778
0
            int res;
14779
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14780
0
                goto failed;
14781
0
            }
14782
0
            res = obj2ast_expr(state, tmp, &left, arena);
14783
0
            _Py_LeaveRecursiveCall();
14784
0
            if (res != 0) goto failed;
14785
0
            Py_CLEAR(tmp);
14786
0
        }
14787
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14788
0
            return -1;
14789
0
        }
14790
0
        if (tmp == NULL) {
14791
0
            tmp = PyList_New(0);
14792
0
            if (tmp == NULL) {
14793
0
                return -1;
14794
0
            }
14795
0
        }
14796
0
        {
14797
0
            int res;
14798
0
            Py_ssize_t len;
14799
0
            Py_ssize_t i;
14800
0
            if (!PyList_Check(tmp)) {
14801
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14802
0
                goto failed;
14803
0
            }
14804
0
            len = PyList_GET_SIZE(tmp);
14805
0
            ops = _Py_asdl_int_seq_new(len, arena);
14806
0
            if (ops == NULL) goto failed;
14807
0
            for (i = 0; i < len; i++) {
14808
0
                cmpop_ty val;
14809
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14810
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14811
0
                    goto failed;
14812
0
                }
14813
0
                res = obj2ast_cmpop(state, tmp2, &val, arena);
14814
0
                _Py_LeaveRecursiveCall();
14815
0
                Py_DECREF(tmp2);
14816
0
                if (res != 0) goto failed;
14817
0
                if (len != PyList_GET_SIZE(tmp)) {
14818
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14819
0
                    goto failed;
14820
0
                }
14821
0
                asdl_seq_SET(ops, i, val);
14822
0
            }
14823
0
            Py_CLEAR(tmp);
14824
0
        }
14825
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14826
0
            return -1;
14827
0
        }
14828
0
        if (tmp == NULL) {
14829
0
            tmp = PyList_New(0);
14830
0
            if (tmp == NULL) {
14831
0
                return -1;
14832
0
            }
14833
0
        }
14834
0
        {
14835
0
            int res;
14836
0
            Py_ssize_t len;
14837
0
            Py_ssize_t i;
14838
0
            if (!PyList_Check(tmp)) {
14839
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14840
0
                goto failed;
14841
0
            }
14842
0
            len = PyList_GET_SIZE(tmp);
14843
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14844
0
            if (comparators == NULL) goto failed;
14845
0
            for (i = 0; i < len; i++) {
14846
0
                expr_ty val;
14847
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14848
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14849
0
                    goto failed;
14850
0
                }
14851
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14852
0
                _Py_LeaveRecursiveCall();
14853
0
                Py_DECREF(tmp2);
14854
0
                if (res != 0) goto failed;
14855
0
                if (len != PyList_GET_SIZE(tmp)) {
14856
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14857
0
                    goto failed;
14858
0
                }
14859
0
                asdl_seq_SET(comparators, i, val);
14860
0
            }
14861
0
            Py_CLEAR(tmp);
14862
0
        }
14863
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14864
0
                              end_lineno, end_col_offset, arena);
14865
0
        if (*out == NULL) goto failed;
14866
0
        return 0;
14867
0
    }
14868
0
    tp = state->Call_type;
14869
0
    isinstance = PyObject_IsInstance(obj, tp);
14870
0
    if (isinstance == -1) {
14871
0
        return -1;
14872
0
    }
14873
0
    if (isinstance) {
14874
0
        expr_ty func;
14875
0
        asdl_expr_seq* args;
14876
0
        asdl_keyword_seq* keywords;
14877
14878
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14879
0
            return -1;
14880
0
        }
14881
0
        if (tmp == NULL) {
14882
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14883
0
            return -1;
14884
0
        }
14885
0
        else {
14886
0
            int res;
14887
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14888
0
                goto failed;
14889
0
            }
14890
0
            res = obj2ast_expr(state, tmp, &func, arena);
14891
0
            _Py_LeaveRecursiveCall();
14892
0
            if (res != 0) goto failed;
14893
0
            Py_CLEAR(tmp);
14894
0
        }
14895
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14896
0
            return -1;
14897
0
        }
14898
0
        if (tmp == NULL) {
14899
0
            tmp = PyList_New(0);
14900
0
            if (tmp == NULL) {
14901
0
                return -1;
14902
0
            }
14903
0
        }
14904
0
        {
14905
0
            int res;
14906
0
            Py_ssize_t len;
14907
0
            Py_ssize_t i;
14908
0
            if (!PyList_Check(tmp)) {
14909
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14910
0
                goto failed;
14911
0
            }
14912
0
            len = PyList_GET_SIZE(tmp);
14913
0
            args = _Py_asdl_expr_seq_new(len, arena);
14914
0
            if (args == NULL) goto failed;
14915
0
            for (i = 0; i < len; i++) {
14916
0
                expr_ty val;
14917
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14918
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14919
0
                    goto failed;
14920
0
                }
14921
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14922
0
                _Py_LeaveRecursiveCall();
14923
0
                Py_DECREF(tmp2);
14924
0
                if (res != 0) goto failed;
14925
0
                if (len != PyList_GET_SIZE(tmp)) {
14926
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14927
0
                    goto failed;
14928
0
                }
14929
0
                asdl_seq_SET(args, i, val);
14930
0
            }
14931
0
            Py_CLEAR(tmp);
14932
0
        }
14933
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14934
0
            return -1;
14935
0
        }
14936
0
        if (tmp == NULL) {
14937
0
            tmp = PyList_New(0);
14938
0
            if (tmp == NULL) {
14939
0
                return -1;
14940
0
            }
14941
0
        }
14942
0
        {
14943
0
            int res;
14944
0
            Py_ssize_t len;
14945
0
            Py_ssize_t i;
14946
0
            if (!PyList_Check(tmp)) {
14947
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14948
0
                goto failed;
14949
0
            }
14950
0
            len = PyList_GET_SIZE(tmp);
14951
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
14952
0
            if (keywords == NULL) goto failed;
14953
0
            for (i = 0; i < len; i++) {
14954
0
                keyword_ty val;
14955
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14956
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14957
0
                    goto failed;
14958
0
                }
14959
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
14960
0
                _Py_LeaveRecursiveCall();
14961
0
                Py_DECREF(tmp2);
14962
0
                if (res != 0) goto failed;
14963
0
                if (len != PyList_GET_SIZE(tmp)) {
14964
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
14965
0
                    goto failed;
14966
0
                }
14967
0
                asdl_seq_SET(keywords, i, val);
14968
0
            }
14969
0
            Py_CLEAR(tmp);
14970
0
        }
14971
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
14972
0
                           end_lineno, end_col_offset, arena);
14973
0
        if (*out == NULL) goto failed;
14974
0
        return 0;
14975
0
    }
14976
0
    tp = state->FormattedValue_type;
14977
0
    isinstance = PyObject_IsInstance(obj, tp);
14978
0
    if (isinstance == -1) {
14979
0
        return -1;
14980
0
    }
14981
0
    if (isinstance) {
14982
0
        expr_ty value;
14983
0
        int conversion;
14984
0
        expr_ty format_spec;
14985
14986
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14987
0
            return -1;
14988
0
        }
14989
0
        if (tmp == NULL) {
14990
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
14991
0
            return -1;
14992
0
        }
14993
0
        else {
14994
0
            int res;
14995
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14996
0
                goto failed;
14997
0
            }
14998
0
            res = obj2ast_expr(state, tmp, &value, arena);
14999
0
            _Py_LeaveRecursiveCall();
15000
0
            if (res != 0) goto failed;
15001
0
            Py_CLEAR(tmp);
15002
0
        }
15003
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15004
0
            return -1;
15005
0
        }
15006
0
        if (tmp == NULL) {
15007
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
15008
0
            return -1;
15009
0
        }
15010
0
        else {
15011
0
            int res;
15012
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15013
0
                goto failed;
15014
0
            }
15015
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15016
0
            _Py_LeaveRecursiveCall();
15017
0
            if (res != 0) goto failed;
15018
0
            Py_CLEAR(tmp);
15019
0
        }
15020
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15021
0
            return -1;
15022
0
        }
15023
0
        if (tmp == NULL || tmp == Py_None) {
15024
0
            Py_CLEAR(tmp);
15025
0
            format_spec = NULL;
15026
0
        }
15027
0
        else {
15028
0
            int res;
15029
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15030
0
                goto failed;
15031
0
            }
15032
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15033
0
            _Py_LeaveRecursiveCall();
15034
0
            if (res != 0) goto failed;
15035
0
            Py_CLEAR(tmp);
15036
0
        }
15037
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15038
0
                                     col_offset, end_lineno, end_col_offset,
15039
0
                                     arena);
15040
0
        if (*out == NULL) goto failed;
15041
0
        return 0;
15042
0
    }
15043
0
    tp = state->Interpolation_type;
15044
0
    isinstance = PyObject_IsInstance(obj, tp);
15045
0
    if (isinstance == -1) {
15046
0
        return -1;
15047
0
    }
15048
0
    if (isinstance) {
15049
0
        expr_ty value;
15050
0
        constant str;
15051
0
        int conversion;
15052
0
        expr_ty format_spec;
15053
15054
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15055
0
            return -1;
15056
0
        }
15057
0
        if (tmp == NULL) {
15058
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15059
0
            return -1;
15060
0
        }
15061
0
        else {
15062
0
            int res;
15063
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15064
0
                goto failed;
15065
0
            }
15066
0
            res = obj2ast_expr(state, tmp, &value, arena);
15067
0
            _Py_LeaveRecursiveCall();
15068
0
            if (res != 0) goto failed;
15069
0
            Py_CLEAR(tmp);
15070
0
        }
15071
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15072
0
            return -1;
15073
0
        }
15074
0
        if (tmp == NULL) {
15075
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15076
0
            return -1;
15077
0
        }
15078
0
        else {
15079
0
            int res;
15080
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15081
0
                goto failed;
15082
0
            }
15083
0
            res = obj2ast_constant(state, tmp, &str, arena);
15084
0
            _Py_LeaveRecursiveCall();
15085
0
            if (res != 0) goto failed;
15086
0
            Py_CLEAR(tmp);
15087
0
        }
15088
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15089
0
            return -1;
15090
0
        }
15091
0
        if (tmp == NULL) {
15092
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15093
0
            return -1;
15094
0
        }
15095
0
        else {
15096
0
            int res;
15097
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15098
0
                goto failed;
15099
0
            }
15100
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15101
0
            _Py_LeaveRecursiveCall();
15102
0
            if (res != 0) goto failed;
15103
0
            Py_CLEAR(tmp);
15104
0
        }
15105
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15106
0
            return -1;
15107
0
        }
15108
0
        if (tmp == NULL || tmp == Py_None) {
15109
0
            Py_CLEAR(tmp);
15110
0
            format_spec = NULL;
15111
0
        }
15112
0
        else {
15113
0
            int res;
15114
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15115
0
                goto failed;
15116
0
            }
15117
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15118
0
            _Py_LeaveRecursiveCall();
15119
0
            if (res != 0) goto failed;
15120
0
            Py_CLEAR(tmp);
15121
0
        }
15122
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15123
0
                                    lineno, col_offset, end_lineno,
15124
0
                                    end_col_offset, arena);
15125
0
        if (*out == NULL) goto failed;
15126
0
        return 0;
15127
0
    }
15128
0
    tp = state->JoinedStr_type;
15129
0
    isinstance = PyObject_IsInstance(obj, tp);
15130
0
    if (isinstance == -1) {
15131
0
        return -1;
15132
0
    }
15133
0
    if (isinstance) {
15134
0
        asdl_expr_seq* values;
15135
15136
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15137
0
            return -1;
15138
0
        }
15139
0
        if (tmp == NULL) {
15140
0
            tmp = PyList_New(0);
15141
0
            if (tmp == NULL) {
15142
0
                return -1;
15143
0
            }
15144
0
        }
15145
0
        {
15146
0
            int res;
15147
0
            Py_ssize_t len;
15148
0
            Py_ssize_t i;
15149
0
            if (!PyList_Check(tmp)) {
15150
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15151
0
                goto failed;
15152
0
            }
15153
0
            len = PyList_GET_SIZE(tmp);
15154
0
            values = _Py_asdl_expr_seq_new(len, arena);
15155
0
            if (values == NULL) goto failed;
15156
0
            for (i = 0; i < len; i++) {
15157
0
                expr_ty val;
15158
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15159
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15160
0
                    goto failed;
15161
0
                }
15162
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15163
0
                _Py_LeaveRecursiveCall();
15164
0
                Py_DECREF(tmp2);
15165
0
                if (res != 0) goto failed;
15166
0
                if (len != PyList_GET_SIZE(tmp)) {
15167
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15168
0
                    goto failed;
15169
0
                }
15170
0
                asdl_seq_SET(values, i, val);
15171
0
            }
15172
0
            Py_CLEAR(tmp);
15173
0
        }
15174
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15175
0
                                end_col_offset, arena);
15176
0
        if (*out == NULL) goto failed;
15177
0
        return 0;
15178
0
    }
15179
0
    tp = state->TemplateStr_type;
15180
0
    isinstance = PyObject_IsInstance(obj, tp);
15181
0
    if (isinstance == -1) {
15182
0
        return -1;
15183
0
    }
15184
0
    if (isinstance) {
15185
0
        asdl_expr_seq* values;
15186
15187
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15188
0
            return -1;
15189
0
        }
15190
0
        if (tmp == NULL) {
15191
0
            tmp = PyList_New(0);
15192
0
            if (tmp == NULL) {
15193
0
                return -1;
15194
0
            }
15195
0
        }
15196
0
        {
15197
0
            int res;
15198
0
            Py_ssize_t len;
15199
0
            Py_ssize_t i;
15200
0
            if (!PyList_Check(tmp)) {
15201
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15202
0
                goto failed;
15203
0
            }
15204
0
            len = PyList_GET_SIZE(tmp);
15205
0
            values = _Py_asdl_expr_seq_new(len, arena);
15206
0
            if (values == NULL) goto failed;
15207
0
            for (i = 0; i < len; i++) {
15208
0
                expr_ty val;
15209
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15210
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15211
0
                    goto failed;
15212
0
                }
15213
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15214
0
                _Py_LeaveRecursiveCall();
15215
0
                Py_DECREF(tmp2);
15216
0
                if (res != 0) goto failed;
15217
0
                if (len != PyList_GET_SIZE(tmp)) {
15218
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15219
0
                    goto failed;
15220
0
                }
15221
0
                asdl_seq_SET(values, i, val);
15222
0
            }
15223
0
            Py_CLEAR(tmp);
15224
0
        }
15225
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15226
0
                                  end_col_offset, arena);
15227
0
        if (*out == NULL) goto failed;
15228
0
        return 0;
15229
0
    }
15230
0
    tp = state->Constant_type;
15231
0
    isinstance = PyObject_IsInstance(obj, tp);
15232
0
    if (isinstance == -1) {
15233
0
        return -1;
15234
0
    }
15235
0
    if (isinstance) {
15236
0
        constant value;
15237
0
        string kind;
15238
15239
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15240
0
            return -1;
15241
0
        }
15242
0
        if (tmp == NULL) {
15243
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15244
0
            return -1;
15245
0
        }
15246
0
        else {
15247
0
            int res;
15248
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15249
0
                goto failed;
15250
0
            }
15251
0
            res = obj2ast_constant(state, tmp, &value, arena);
15252
0
            _Py_LeaveRecursiveCall();
15253
0
            if (res != 0) goto failed;
15254
0
            Py_CLEAR(tmp);
15255
0
        }
15256
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15257
0
            return -1;
15258
0
        }
15259
0
        if (tmp == NULL || tmp == Py_None) {
15260
0
            Py_CLEAR(tmp);
15261
0
            kind = NULL;
15262
0
        }
15263
0
        else {
15264
0
            int res;
15265
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15266
0
                goto failed;
15267
0
            }
15268
0
            res = obj2ast_string(state, tmp, &kind, arena);
15269
0
            _Py_LeaveRecursiveCall();
15270
0
            if (res != 0) goto failed;
15271
0
            Py_CLEAR(tmp);
15272
0
        }
15273
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15274
0
                               end_col_offset, arena);
15275
0
        if (*out == NULL) goto failed;
15276
0
        return 0;
15277
0
    }
15278
0
    tp = state->Attribute_type;
15279
0
    isinstance = PyObject_IsInstance(obj, tp);
15280
0
    if (isinstance == -1) {
15281
0
        return -1;
15282
0
    }
15283
0
    if (isinstance) {
15284
0
        expr_ty value;
15285
0
        identifier attr;
15286
0
        expr_context_ty ctx;
15287
15288
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15289
0
            return -1;
15290
0
        }
15291
0
        if (tmp == NULL) {
15292
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15293
0
            return -1;
15294
0
        }
15295
0
        else {
15296
0
            int res;
15297
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15298
0
                goto failed;
15299
0
            }
15300
0
            res = obj2ast_expr(state, tmp, &value, arena);
15301
0
            _Py_LeaveRecursiveCall();
15302
0
            if (res != 0) goto failed;
15303
0
            Py_CLEAR(tmp);
15304
0
        }
15305
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15306
0
            return -1;
15307
0
        }
15308
0
        if (tmp == NULL) {
15309
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15310
0
            return -1;
15311
0
        }
15312
0
        else {
15313
0
            int res;
15314
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15315
0
                goto failed;
15316
0
            }
15317
0
            res = obj2ast_identifier(state, tmp, &attr, arena);
15318
0
            _Py_LeaveRecursiveCall();
15319
0
            if (res != 0) goto failed;
15320
0
            Py_CLEAR(tmp);
15321
0
        }
15322
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15323
0
            return -1;
15324
0
        }
15325
0
        if (tmp == NULL) {
15326
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15327
0
            return -1;
15328
0
        }
15329
0
        else {
15330
0
            int res;
15331
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15332
0
                goto failed;
15333
0
            }
15334
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15335
0
            _Py_LeaveRecursiveCall();
15336
0
            if (res != 0) goto failed;
15337
0
            Py_CLEAR(tmp);
15338
0
        }
15339
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15340
0
                                end_lineno, end_col_offset, arena);
15341
0
        if (*out == NULL) goto failed;
15342
0
        return 0;
15343
0
    }
15344
0
    tp = state->Subscript_type;
15345
0
    isinstance = PyObject_IsInstance(obj, tp);
15346
0
    if (isinstance == -1) {
15347
0
        return -1;
15348
0
    }
15349
0
    if (isinstance) {
15350
0
        expr_ty value;
15351
0
        expr_ty slice;
15352
0
        expr_context_ty ctx;
15353
15354
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15355
0
            return -1;
15356
0
        }
15357
0
        if (tmp == NULL) {
15358
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15359
0
            return -1;
15360
0
        }
15361
0
        else {
15362
0
            int res;
15363
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15364
0
                goto failed;
15365
0
            }
15366
0
            res = obj2ast_expr(state, tmp, &value, arena);
15367
0
            _Py_LeaveRecursiveCall();
15368
0
            if (res != 0) goto failed;
15369
0
            Py_CLEAR(tmp);
15370
0
        }
15371
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15372
0
            return -1;
15373
0
        }
15374
0
        if (tmp == NULL) {
15375
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15376
0
            return -1;
15377
0
        }
15378
0
        else {
15379
0
            int res;
15380
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15381
0
                goto failed;
15382
0
            }
15383
0
            res = obj2ast_expr(state, tmp, &slice, arena);
15384
0
            _Py_LeaveRecursiveCall();
15385
0
            if (res != 0) goto failed;
15386
0
            Py_CLEAR(tmp);
15387
0
        }
15388
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15389
0
            return -1;
15390
0
        }
15391
0
        if (tmp == NULL) {
15392
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15393
0
            return -1;
15394
0
        }
15395
0
        else {
15396
0
            int res;
15397
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15398
0
                goto failed;
15399
0
            }
15400
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15401
0
            _Py_LeaveRecursiveCall();
15402
0
            if (res != 0) goto failed;
15403
0
            Py_CLEAR(tmp);
15404
0
        }
15405
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15406
0
                                end_lineno, end_col_offset, arena);
15407
0
        if (*out == NULL) goto failed;
15408
0
        return 0;
15409
0
    }
15410
0
    tp = state->Starred_type;
15411
0
    isinstance = PyObject_IsInstance(obj, tp);
15412
0
    if (isinstance == -1) {
15413
0
        return -1;
15414
0
    }
15415
0
    if (isinstance) {
15416
0
        expr_ty value;
15417
0
        expr_context_ty ctx;
15418
15419
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15420
0
            return -1;
15421
0
        }
15422
0
        if (tmp == NULL) {
15423
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15424
0
            return -1;
15425
0
        }
15426
0
        else {
15427
0
            int res;
15428
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15429
0
                goto failed;
15430
0
            }
15431
0
            res = obj2ast_expr(state, tmp, &value, arena);
15432
0
            _Py_LeaveRecursiveCall();
15433
0
            if (res != 0) goto failed;
15434
0
            Py_CLEAR(tmp);
15435
0
        }
15436
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15437
0
            return -1;
15438
0
        }
15439
0
        if (tmp == NULL) {
15440
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15441
0
            return -1;
15442
0
        }
15443
0
        else {
15444
0
            int res;
15445
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15446
0
                goto failed;
15447
0
            }
15448
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15449
0
            _Py_LeaveRecursiveCall();
15450
0
            if (res != 0) goto failed;
15451
0
            Py_CLEAR(tmp);
15452
0
        }
15453
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15454
0
                              end_col_offset, arena);
15455
0
        if (*out == NULL) goto failed;
15456
0
        return 0;
15457
0
    }
15458
0
    tp = state->Name_type;
15459
0
    isinstance = PyObject_IsInstance(obj, tp);
15460
0
    if (isinstance == -1) {
15461
0
        return -1;
15462
0
    }
15463
0
    if (isinstance) {
15464
0
        identifier id;
15465
0
        expr_context_ty ctx;
15466
15467
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15468
0
            return -1;
15469
0
        }
15470
0
        if (tmp == NULL) {
15471
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15472
0
            return -1;
15473
0
        }
15474
0
        else {
15475
0
            int res;
15476
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15477
0
                goto failed;
15478
0
            }
15479
0
            res = obj2ast_identifier(state, tmp, &id, arena);
15480
0
            _Py_LeaveRecursiveCall();
15481
0
            if (res != 0) goto failed;
15482
0
            Py_CLEAR(tmp);
15483
0
        }
15484
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15485
0
            return -1;
15486
0
        }
15487
0
        if (tmp == NULL) {
15488
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15489
0
            return -1;
15490
0
        }
15491
0
        else {
15492
0
            int res;
15493
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15494
0
                goto failed;
15495
0
            }
15496
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15497
0
            _Py_LeaveRecursiveCall();
15498
0
            if (res != 0) goto failed;
15499
0
            Py_CLEAR(tmp);
15500
0
        }
15501
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15502
0
                           end_col_offset, arena);
15503
0
        if (*out == NULL) goto failed;
15504
0
        return 0;
15505
0
    }
15506
0
    tp = state->List_type;
15507
0
    isinstance = PyObject_IsInstance(obj, tp);
15508
0
    if (isinstance == -1) {
15509
0
        return -1;
15510
0
    }
15511
0
    if (isinstance) {
15512
0
        asdl_expr_seq* elts;
15513
0
        expr_context_ty ctx;
15514
15515
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15516
0
            return -1;
15517
0
        }
15518
0
        if (tmp == NULL) {
15519
0
            tmp = PyList_New(0);
15520
0
            if (tmp == NULL) {
15521
0
                return -1;
15522
0
            }
15523
0
        }
15524
0
        {
15525
0
            int res;
15526
0
            Py_ssize_t len;
15527
0
            Py_ssize_t i;
15528
0
            if (!PyList_Check(tmp)) {
15529
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15530
0
                goto failed;
15531
0
            }
15532
0
            len = PyList_GET_SIZE(tmp);
15533
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15534
0
            if (elts == NULL) goto failed;
15535
0
            for (i = 0; i < len; i++) {
15536
0
                expr_ty val;
15537
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15538
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15539
0
                    goto failed;
15540
0
                }
15541
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15542
0
                _Py_LeaveRecursiveCall();
15543
0
                Py_DECREF(tmp2);
15544
0
                if (res != 0) goto failed;
15545
0
                if (len != PyList_GET_SIZE(tmp)) {
15546
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15547
0
                    goto failed;
15548
0
                }
15549
0
                asdl_seq_SET(elts, i, val);
15550
0
            }
15551
0
            Py_CLEAR(tmp);
15552
0
        }
15553
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15554
0
            return -1;
15555
0
        }
15556
0
        if (tmp == NULL) {
15557
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15558
0
            return -1;
15559
0
        }
15560
0
        else {
15561
0
            int res;
15562
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15563
0
                goto failed;
15564
0
            }
15565
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15566
0
            _Py_LeaveRecursiveCall();
15567
0
            if (res != 0) goto failed;
15568
0
            Py_CLEAR(tmp);
15569
0
        }
15570
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15571
0
                           end_col_offset, arena);
15572
0
        if (*out == NULL) goto failed;
15573
0
        return 0;
15574
0
    }
15575
0
    tp = state->Tuple_type;
15576
0
    isinstance = PyObject_IsInstance(obj, tp);
15577
0
    if (isinstance == -1) {
15578
0
        return -1;
15579
0
    }
15580
0
    if (isinstance) {
15581
0
        asdl_expr_seq* elts;
15582
0
        expr_context_ty ctx;
15583
15584
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15585
0
            return -1;
15586
0
        }
15587
0
        if (tmp == NULL) {
15588
0
            tmp = PyList_New(0);
15589
0
            if (tmp == NULL) {
15590
0
                return -1;
15591
0
            }
15592
0
        }
15593
0
        {
15594
0
            int res;
15595
0
            Py_ssize_t len;
15596
0
            Py_ssize_t i;
15597
0
            if (!PyList_Check(tmp)) {
15598
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15599
0
                goto failed;
15600
0
            }
15601
0
            len = PyList_GET_SIZE(tmp);
15602
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15603
0
            if (elts == NULL) goto failed;
15604
0
            for (i = 0; i < len; i++) {
15605
0
                expr_ty val;
15606
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15607
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15608
0
                    goto failed;
15609
0
                }
15610
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15611
0
                _Py_LeaveRecursiveCall();
15612
0
                Py_DECREF(tmp2);
15613
0
                if (res != 0) goto failed;
15614
0
                if (len != PyList_GET_SIZE(tmp)) {
15615
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15616
0
                    goto failed;
15617
0
                }
15618
0
                asdl_seq_SET(elts, i, val);
15619
0
            }
15620
0
            Py_CLEAR(tmp);
15621
0
        }
15622
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15623
0
            return -1;
15624
0
        }
15625
0
        if (tmp == NULL) {
15626
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15627
0
            return -1;
15628
0
        }
15629
0
        else {
15630
0
            int res;
15631
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15632
0
                goto failed;
15633
0
            }
15634
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15635
0
            _Py_LeaveRecursiveCall();
15636
0
            if (res != 0) goto failed;
15637
0
            Py_CLEAR(tmp);
15638
0
        }
15639
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15640
0
                            end_col_offset, arena);
15641
0
        if (*out == NULL) goto failed;
15642
0
        return 0;
15643
0
    }
15644
0
    tp = state->Slice_type;
15645
0
    isinstance = PyObject_IsInstance(obj, tp);
15646
0
    if (isinstance == -1) {
15647
0
        return -1;
15648
0
    }
15649
0
    if (isinstance) {
15650
0
        expr_ty lower;
15651
0
        expr_ty upper;
15652
0
        expr_ty step;
15653
15654
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15655
0
            return -1;
15656
0
        }
15657
0
        if (tmp == NULL || tmp == Py_None) {
15658
0
            Py_CLEAR(tmp);
15659
0
            lower = NULL;
15660
0
        }
15661
0
        else {
15662
0
            int res;
15663
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15664
0
                goto failed;
15665
0
            }
15666
0
            res = obj2ast_expr(state, tmp, &lower, arena);
15667
0
            _Py_LeaveRecursiveCall();
15668
0
            if (res != 0) goto failed;
15669
0
            Py_CLEAR(tmp);
15670
0
        }
15671
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15672
0
            return -1;
15673
0
        }
15674
0
        if (tmp == NULL || tmp == Py_None) {
15675
0
            Py_CLEAR(tmp);
15676
0
            upper = NULL;
15677
0
        }
15678
0
        else {
15679
0
            int res;
15680
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15681
0
                goto failed;
15682
0
            }
15683
0
            res = obj2ast_expr(state, tmp, &upper, arena);
15684
0
            _Py_LeaveRecursiveCall();
15685
0
            if (res != 0) goto failed;
15686
0
            Py_CLEAR(tmp);
15687
0
        }
15688
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15689
0
            return -1;
15690
0
        }
15691
0
        if (tmp == NULL || tmp == Py_None) {
15692
0
            Py_CLEAR(tmp);
15693
0
            step = NULL;
15694
0
        }
15695
0
        else {
15696
0
            int res;
15697
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15698
0
                goto failed;
15699
0
            }
15700
0
            res = obj2ast_expr(state, tmp, &step, arena);
15701
0
            _Py_LeaveRecursiveCall();
15702
0
            if (res != 0) goto failed;
15703
0
            Py_CLEAR(tmp);
15704
0
        }
15705
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15706
0
                            end_col_offset, arena);
15707
0
        if (*out == NULL) goto failed;
15708
0
        return 0;
15709
0
    }
15710
15711
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15712
0
    failed:
15713
0
    Py_XDECREF(tmp);
15714
0
    return -1;
15715
0
}
15716
15717
int
15718
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15719
                     out, PyArena* arena)
15720
0
{
15721
0
    int isinstance;
15722
15723
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15724
0
    if (isinstance == -1) {
15725
0
        return -1;
15726
0
    }
15727
0
    if (isinstance) {
15728
0
        *out = Load;
15729
0
        return 0;
15730
0
    }
15731
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15732
0
    if (isinstance == -1) {
15733
0
        return -1;
15734
0
    }
15735
0
    if (isinstance) {
15736
0
        *out = Store;
15737
0
        return 0;
15738
0
    }
15739
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15740
0
    if (isinstance == -1) {
15741
0
        return -1;
15742
0
    }
15743
0
    if (isinstance) {
15744
0
        *out = Del;
15745
0
        return 0;
15746
0
    }
15747
15748
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15749
0
    return -1;
15750
0
}
15751
15752
int
15753
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
15754
               arena)
15755
0
{
15756
0
    int isinstance;
15757
15758
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15759
0
    if (isinstance == -1) {
15760
0
        return -1;
15761
0
    }
15762
0
    if (isinstance) {
15763
0
        *out = And;
15764
0
        return 0;
15765
0
    }
15766
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15767
0
    if (isinstance == -1) {
15768
0
        return -1;
15769
0
    }
15770
0
    if (isinstance) {
15771
0
        *out = Or;
15772
0
        return 0;
15773
0
    }
15774
15775
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15776
0
    return -1;
15777
0
}
15778
15779
int
15780
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15781
                 PyArena* arena)
15782
0
{
15783
0
    int isinstance;
15784
15785
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15786
0
    if (isinstance == -1) {
15787
0
        return -1;
15788
0
    }
15789
0
    if (isinstance) {
15790
0
        *out = Add;
15791
0
        return 0;
15792
0
    }
15793
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15794
0
    if (isinstance == -1) {
15795
0
        return -1;
15796
0
    }
15797
0
    if (isinstance) {
15798
0
        *out = Sub;
15799
0
        return 0;
15800
0
    }
15801
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15802
0
    if (isinstance == -1) {
15803
0
        return -1;
15804
0
    }
15805
0
    if (isinstance) {
15806
0
        *out = Mult;
15807
0
        return 0;
15808
0
    }
15809
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15810
0
    if (isinstance == -1) {
15811
0
        return -1;
15812
0
    }
15813
0
    if (isinstance) {
15814
0
        *out = MatMult;
15815
0
        return 0;
15816
0
    }
15817
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15818
0
    if (isinstance == -1) {
15819
0
        return -1;
15820
0
    }
15821
0
    if (isinstance) {
15822
0
        *out = Div;
15823
0
        return 0;
15824
0
    }
15825
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15826
0
    if (isinstance == -1) {
15827
0
        return -1;
15828
0
    }
15829
0
    if (isinstance) {
15830
0
        *out = Mod;
15831
0
        return 0;
15832
0
    }
15833
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15834
0
    if (isinstance == -1) {
15835
0
        return -1;
15836
0
    }
15837
0
    if (isinstance) {
15838
0
        *out = Pow;
15839
0
        return 0;
15840
0
    }
15841
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15842
0
    if (isinstance == -1) {
15843
0
        return -1;
15844
0
    }
15845
0
    if (isinstance) {
15846
0
        *out = LShift;
15847
0
        return 0;
15848
0
    }
15849
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15850
0
    if (isinstance == -1) {
15851
0
        return -1;
15852
0
    }
15853
0
    if (isinstance) {
15854
0
        *out = RShift;
15855
0
        return 0;
15856
0
    }
15857
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15858
0
    if (isinstance == -1) {
15859
0
        return -1;
15860
0
    }
15861
0
    if (isinstance) {
15862
0
        *out = BitOr;
15863
0
        return 0;
15864
0
    }
15865
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15866
0
    if (isinstance == -1) {
15867
0
        return -1;
15868
0
    }
15869
0
    if (isinstance) {
15870
0
        *out = BitXor;
15871
0
        return 0;
15872
0
    }
15873
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15874
0
    if (isinstance == -1) {
15875
0
        return -1;
15876
0
    }
15877
0
    if (isinstance) {
15878
0
        *out = BitAnd;
15879
0
        return 0;
15880
0
    }
15881
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15882
0
    if (isinstance == -1) {
15883
0
        return -1;
15884
0
    }
15885
0
    if (isinstance) {
15886
0
        *out = FloorDiv;
15887
0
        return 0;
15888
0
    }
15889
15890
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15891
0
    return -1;
15892
0
}
15893
15894
int
15895
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
15896
                PyArena* arena)
15897
0
{
15898
0
    int isinstance;
15899
15900
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15901
0
    if (isinstance == -1) {
15902
0
        return -1;
15903
0
    }
15904
0
    if (isinstance) {
15905
0
        *out = Invert;
15906
0
        return 0;
15907
0
    }
15908
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15909
0
    if (isinstance == -1) {
15910
0
        return -1;
15911
0
    }
15912
0
    if (isinstance) {
15913
0
        *out = Not;
15914
0
        return 0;
15915
0
    }
15916
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15917
0
    if (isinstance == -1) {
15918
0
        return -1;
15919
0
    }
15920
0
    if (isinstance) {
15921
0
        *out = UAdd;
15922
0
        return 0;
15923
0
    }
15924
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15925
0
    if (isinstance == -1) {
15926
0
        return -1;
15927
0
    }
15928
0
    if (isinstance) {
15929
0
        *out = USub;
15930
0
        return 0;
15931
0
    }
15932
15933
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15934
0
    return -1;
15935
0
}
15936
15937
int
15938
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
15939
              arena)
15940
0
{
15941
0
    int isinstance;
15942
15943
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15944
0
    if (isinstance == -1) {
15945
0
        return -1;
15946
0
    }
15947
0
    if (isinstance) {
15948
0
        *out = Eq;
15949
0
        return 0;
15950
0
    }
15951
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
15952
0
    if (isinstance == -1) {
15953
0
        return -1;
15954
0
    }
15955
0
    if (isinstance) {
15956
0
        *out = NotEq;
15957
0
        return 0;
15958
0
    }
15959
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
15960
0
    if (isinstance == -1) {
15961
0
        return -1;
15962
0
    }
15963
0
    if (isinstance) {
15964
0
        *out = Lt;
15965
0
        return 0;
15966
0
    }
15967
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
15968
0
    if (isinstance == -1) {
15969
0
        return -1;
15970
0
    }
15971
0
    if (isinstance) {
15972
0
        *out = LtE;
15973
0
        return 0;
15974
0
    }
15975
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
15976
0
    if (isinstance == -1) {
15977
0
        return -1;
15978
0
    }
15979
0
    if (isinstance) {
15980
0
        *out = Gt;
15981
0
        return 0;
15982
0
    }
15983
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
15984
0
    if (isinstance == -1) {
15985
0
        return -1;
15986
0
    }
15987
0
    if (isinstance) {
15988
0
        *out = GtE;
15989
0
        return 0;
15990
0
    }
15991
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
15992
0
    if (isinstance == -1) {
15993
0
        return -1;
15994
0
    }
15995
0
    if (isinstance) {
15996
0
        *out = Is;
15997
0
        return 0;
15998
0
    }
15999
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
16000
0
    if (isinstance == -1) {
16001
0
        return -1;
16002
0
    }
16003
0
    if (isinstance) {
16004
0
        *out = IsNot;
16005
0
        return 0;
16006
0
    }
16007
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
16008
0
    if (isinstance == -1) {
16009
0
        return -1;
16010
0
    }
16011
0
    if (isinstance) {
16012
0
        *out = In;
16013
0
        return 0;
16014
0
    }
16015
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16016
0
    if (isinstance == -1) {
16017
0
        return -1;
16018
0
    }
16019
0
    if (isinstance) {
16020
0
        *out = NotIn;
16021
0
        return 0;
16022
0
    }
16023
16024
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16025
0
    return -1;
16026
0
}
16027
16028
int
16029
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16030
                      out, PyArena* arena)
16031
0
{
16032
0
    PyObject* tmp = NULL;
16033
0
    expr_ty target;
16034
0
    expr_ty iter;
16035
0
    asdl_expr_seq* ifs;
16036
0
    int is_async;
16037
16038
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16039
0
        return -1;
16040
0
    }
16041
0
    if (tmp == NULL) {
16042
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16043
0
        return -1;
16044
0
    }
16045
0
    else {
16046
0
        int res;
16047
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16048
0
            goto failed;
16049
0
        }
16050
0
        res = obj2ast_expr(state, tmp, &target, arena);
16051
0
        _Py_LeaveRecursiveCall();
16052
0
        if (res != 0) goto failed;
16053
0
        Py_CLEAR(tmp);
16054
0
    }
16055
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16056
0
        return -1;
16057
0
    }
16058
0
    if (tmp == NULL) {
16059
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16060
0
        return -1;
16061
0
    }
16062
0
    else {
16063
0
        int res;
16064
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16065
0
            goto failed;
16066
0
        }
16067
0
        res = obj2ast_expr(state, tmp, &iter, arena);
16068
0
        _Py_LeaveRecursiveCall();
16069
0
        if (res != 0) goto failed;
16070
0
        Py_CLEAR(tmp);
16071
0
    }
16072
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16073
0
        return -1;
16074
0
    }
16075
0
    if (tmp == NULL) {
16076
0
        tmp = PyList_New(0);
16077
0
        if (tmp == NULL) {
16078
0
            return -1;
16079
0
        }
16080
0
    }
16081
0
    {
16082
0
        int res;
16083
0
        Py_ssize_t len;
16084
0
        Py_ssize_t i;
16085
0
        if (!PyList_Check(tmp)) {
16086
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16087
0
            goto failed;
16088
0
        }
16089
0
        len = PyList_GET_SIZE(tmp);
16090
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16091
0
        if (ifs == NULL) goto failed;
16092
0
        for (i = 0; i < len; i++) {
16093
0
            expr_ty val;
16094
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16095
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16096
0
                goto failed;
16097
0
            }
16098
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16099
0
            _Py_LeaveRecursiveCall();
16100
0
            Py_DECREF(tmp2);
16101
0
            if (res != 0) goto failed;
16102
0
            if (len != PyList_GET_SIZE(tmp)) {
16103
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16104
0
                goto failed;
16105
0
            }
16106
0
            asdl_seq_SET(ifs, i, val);
16107
0
        }
16108
0
        Py_CLEAR(tmp);
16109
0
    }
16110
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16111
0
        return -1;
16112
0
    }
16113
0
    if (tmp == NULL) {
16114
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16115
0
        return -1;
16116
0
    }
16117
0
    else {
16118
0
        int res;
16119
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16120
0
            goto failed;
16121
0
        }
16122
0
        res = obj2ast_int(state, tmp, &is_async, arena);
16123
0
        _Py_LeaveRecursiveCall();
16124
0
        if (res != 0) goto failed;
16125
0
        Py_CLEAR(tmp);
16126
0
    }
16127
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16128
0
    if (*out == NULL) goto failed;
16129
0
    return 0;
16130
0
failed:
16131
0
    Py_XDECREF(tmp);
16132
0
    return -1;
16133
0
}
16134
16135
int
16136
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16137
                      out, PyArena* arena)
16138
0
{
16139
0
    int isinstance;
16140
16141
0
    PyObject *tmp = NULL;
16142
0
    PyObject *tp;
16143
0
    int lineno;
16144
0
    int col_offset;
16145
0
    int end_lineno;
16146
0
    int end_col_offset;
16147
16148
0
    if (obj == Py_None) {
16149
0
        *out = NULL;
16150
0
        return 0;
16151
0
    }
16152
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16153
0
        return -1;
16154
0
    }
16155
0
    if (tmp == NULL) {
16156
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16157
0
        return -1;
16158
0
    }
16159
0
    else {
16160
0
        int res;
16161
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16162
0
            goto failed;
16163
0
        }
16164
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16165
0
        _Py_LeaveRecursiveCall();
16166
0
        if (res != 0) goto failed;
16167
0
        Py_CLEAR(tmp);
16168
0
    }
16169
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16170
0
        return -1;
16171
0
    }
16172
0
    if (tmp == NULL) {
16173
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16174
0
        return -1;
16175
0
    }
16176
0
    else {
16177
0
        int res;
16178
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16179
0
            goto failed;
16180
0
        }
16181
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16182
0
        _Py_LeaveRecursiveCall();
16183
0
        if (res != 0) goto failed;
16184
0
        Py_CLEAR(tmp);
16185
0
    }
16186
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16187
0
        return -1;
16188
0
    }
16189
0
    if (tmp == NULL || tmp == Py_None) {
16190
0
        Py_CLEAR(tmp);
16191
0
        end_lineno = lineno;
16192
0
    }
16193
0
    else {
16194
0
        int res;
16195
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16196
0
            goto failed;
16197
0
        }
16198
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16199
0
        _Py_LeaveRecursiveCall();
16200
0
        if (res != 0) goto failed;
16201
0
        Py_CLEAR(tmp);
16202
0
    }
16203
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16204
0
        return -1;
16205
0
    }
16206
0
    if (tmp == NULL || tmp == Py_None) {
16207
0
        Py_CLEAR(tmp);
16208
0
        end_col_offset = col_offset;
16209
0
    }
16210
0
    else {
16211
0
        int res;
16212
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16213
0
            goto failed;
16214
0
        }
16215
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16216
0
        _Py_LeaveRecursiveCall();
16217
0
        if (res != 0) goto failed;
16218
0
        Py_CLEAR(tmp);
16219
0
    }
16220
0
    tp = state->ExceptHandler_type;
16221
0
    isinstance = PyObject_IsInstance(obj, tp);
16222
0
    if (isinstance == -1) {
16223
0
        return -1;
16224
0
    }
16225
0
    if (isinstance) {
16226
0
        expr_ty type;
16227
0
        identifier name;
16228
0
        asdl_stmt_seq* body;
16229
16230
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16231
0
            return -1;
16232
0
        }
16233
0
        if (tmp == NULL || tmp == Py_None) {
16234
0
            Py_CLEAR(tmp);
16235
0
            type = NULL;
16236
0
        }
16237
0
        else {
16238
0
            int res;
16239
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16240
0
                goto failed;
16241
0
            }
16242
0
            res = obj2ast_expr(state, tmp, &type, arena);
16243
0
            _Py_LeaveRecursiveCall();
16244
0
            if (res != 0) goto failed;
16245
0
            Py_CLEAR(tmp);
16246
0
        }
16247
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16248
0
            return -1;
16249
0
        }
16250
0
        if (tmp == NULL || tmp == Py_None) {
16251
0
            Py_CLEAR(tmp);
16252
0
            name = NULL;
16253
0
        }
16254
0
        else {
16255
0
            int res;
16256
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16257
0
                goto failed;
16258
0
            }
16259
0
            res = obj2ast_identifier(state, tmp, &name, arena);
16260
0
            _Py_LeaveRecursiveCall();
16261
0
            if (res != 0) goto failed;
16262
0
            Py_CLEAR(tmp);
16263
0
        }
16264
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16265
0
            return -1;
16266
0
        }
16267
0
        if (tmp == NULL) {
16268
0
            tmp = PyList_New(0);
16269
0
            if (tmp == NULL) {
16270
0
                return -1;
16271
0
            }
16272
0
        }
16273
0
        {
16274
0
            int res;
16275
0
            Py_ssize_t len;
16276
0
            Py_ssize_t i;
16277
0
            if (!PyList_Check(tmp)) {
16278
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16279
0
                goto failed;
16280
0
            }
16281
0
            len = PyList_GET_SIZE(tmp);
16282
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16283
0
            if (body == NULL) goto failed;
16284
0
            for (i = 0; i < len; i++) {
16285
0
                stmt_ty val;
16286
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16287
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16288
0
                    goto failed;
16289
0
                }
16290
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
16291
0
                _Py_LeaveRecursiveCall();
16292
0
                Py_DECREF(tmp2);
16293
0
                if (res != 0) goto failed;
16294
0
                if (len != PyList_GET_SIZE(tmp)) {
16295
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16296
0
                    goto failed;
16297
0
                }
16298
0
                asdl_seq_SET(body, i, val);
16299
0
            }
16300
0
            Py_CLEAR(tmp);
16301
0
        }
16302
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16303
0
                                    end_lineno, end_col_offset, arena);
16304
0
        if (*out == NULL) goto failed;
16305
0
        return 0;
16306
0
    }
16307
16308
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16309
0
    failed:
16310
0
    Py_XDECREF(tmp);
16311
0
    return -1;
16312
0
}
16313
16314
int
16315
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16316
                  PyArena* arena)
16317
0
{
16318
0
    PyObject* tmp = NULL;
16319
0
    asdl_arg_seq* posonlyargs;
16320
0
    asdl_arg_seq* args;
16321
0
    arg_ty vararg;
16322
0
    asdl_arg_seq* kwonlyargs;
16323
0
    asdl_expr_seq* kw_defaults;
16324
0
    arg_ty kwarg;
16325
0
    asdl_expr_seq* defaults;
16326
16327
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16328
0
        return -1;
16329
0
    }
16330
0
    if (tmp == NULL) {
16331
0
        tmp = PyList_New(0);
16332
0
        if (tmp == NULL) {
16333
0
            return -1;
16334
0
        }
16335
0
    }
16336
0
    {
16337
0
        int res;
16338
0
        Py_ssize_t len;
16339
0
        Py_ssize_t i;
16340
0
        if (!PyList_Check(tmp)) {
16341
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16342
0
            goto failed;
16343
0
        }
16344
0
        len = PyList_GET_SIZE(tmp);
16345
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16346
0
        if (posonlyargs == NULL) goto failed;
16347
0
        for (i = 0; i < len; i++) {
16348
0
            arg_ty val;
16349
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16350
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16351
0
                goto failed;
16352
0
            }
16353
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16354
0
            _Py_LeaveRecursiveCall();
16355
0
            Py_DECREF(tmp2);
16356
0
            if (res != 0) goto failed;
16357
0
            if (len != PyList_GET_SIZE(tmp)) {
16358
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16359
0
                goto failed;
16360
0
            }
16361
0
            asdl_seq_SET(posonlyargs, i, val);
16362
0
        }
16363
0
        Py_CLEAR(tmp);
16364
0
    }
16365
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16366
0
        return -1;
16367
0
    }
16368
0
    if (tmp == NULL) {
16369
0
        tmp = PyList_New(0);
16370
0
        if (tmp == NULL) {
16371
0
            return -1;
16372
0
        }
16373
0
    }
16374
0
    {
16375
0
        int res;
16376
0
        Py_ssize_t len;
16377
0
        Py_ssize_t i;
16378
0
        if (!PyList_Check(tmp)) {
16379
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16380
0
            goto failed;
16381
0
        }
16382
0
        len = PyList_GET_SIZE(tmp);
16383
0
        args = _Py_asdl_arg_seq_new(len, arena);
16384
0
        if (args == NULL) goto failed;
16385
0
        for (i = 0; i < len; i++) {
16386
0
            arg_ty val;
16387
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16388
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16389
0
                goto failed;
16390
0
            }
16391
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16392
0
            _Py_LeaveRecursiveCall();
16393
0
            Py_DECREF(tmp2);
16394
0
            if (res != 0) goto failed;
16395
0
            if (len != PyList_GET_SIZE(tmp)) {
16396
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16397
0
                goto failed;
16398
0
            }
16399
0
            asdl_seq_SET(args, i, val);
16400
0
        }
16401
0
        Py_CLEAR(tmp);
16402
0
    }
16403
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16404
0
        return -1;
16405
0
    }
16406
0
    if (tmp == NULL || tmp == Py_None) {
16407
0
        Py_CLEAR(tmp);
16408
0
        vararg = NULL;
16409
0
    }
16410
0
    else {
16411
0
        int res;
16412
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16413
0
            goto failed;
16414
0
        }
16415
0
        res = obj2ast_arg(state, tmp, &vararg, arena);
16416
0
        _Py_LeaveRecursiveCall();
16417
0
        if (res != 0) goto failed;
16418
0
        Py_CLEAR(tmp);
16419
0
    }
16420
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16421
0
        return -1;
16422
0
    }
16423
0
    if (tmp == NULL) {
16424
0
        tmp = PyList_New(0);
16425
0
        if (tmp == NULL) {
16426
0
            return -1;
16427
0
        }
16428
0
    }
16429
0
    {
16430
0
        int res;
16431
0
        Py_ssize_t len;
16432
0
        Py_ssize_t i;
16433
0
        if (!PyList_Check(tmp)) {
16434
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16435
0
            goto failed;
16436
0
        }
16437
0
        len = PyList_GET_SIZE(tmp);
16438
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16439
0
        if (kwonlyargs == NULL) goto failed;
16440
0
        for (i = 0; i < len; i++) {
16441
0
            arg_ty val;
16442
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16443
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16444
0
                goto failed;
16445
0
            }
16446
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16447
0
            _Py_LeaveRecursiveCall();
16448
0
            Py_DECREF(tmp2);
16449
0
            if (res != 0) goto failed;
16450
0
            if (len != PyList_GET_SIZE(tmp)) {
16451
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16452
0
                goto failed;
16453
0
            }
16454
0
            asdl_seq_SET(kwonlyargs, i, val);
16455
0
        }
16456
0
        Py_CLEAR(tmp);
16457
0
    }
16458
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16459
0
        return -1;
16460
0
    }
16461
0
    if (tmp == NULL) {
16462
0
        tmp = PyList_New(0);
16463
0
        if (tmp == NULL) {
16464
0
            return -1;
16465
0
        }
16466
0
    }
16467
0
    {
16468
0
        int res;
16469
0
        Py_ssize_t len;
16470
0
        Py_ssize_t i;
16471
0
        if (!PyList_Check(tmp)) {
16472
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16473
0
            goto failed;
16474
0
        }
16475
0
        len = PyList_GET_SIZE(tmp);
16476
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16477
0
        if (kw_defaults == NULL) goto failed;
16478
0
        for (i = 0; i < len; i++) {
16479
0
            expr_ty val;
16480
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16481
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16482
0
                goto failed;
16483
0
            }
16484
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16485
0
            _Py_LeaveRecursiveCall();
16486
0
            Py_DECREF(tmp2);
16487
0
            if (res != 0) goto failed;
16488
0
            if (len != PyList_GET_SIZE(tmp)) {
16489
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16490
0
                goto failed;
16491
0
            }
16492
0
            asdl_seq_SET(kw_defaults, i, val);
16493
0
        }
16494
0
        Py_CLEAR(tmp);
16495
0
    }
16496
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16497
0
        return -1;
16498
0
    }
16499
0
    if (tmp == NULL || tmp == Py_None) {
16500
0
        Py_CLEAR(tmp);
16501
0
        kwarg = NULL;
16502
0
    }
16503
0
    else {
16504
0
        int res;
16505
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16506
0
            goto failed;
16507
0
        }
16508
0
        res = obj2ast_arg(state, tmp, &kwarg, arena);
16509
0
        _Py_LeaveRecursiveCall();
16510
0
        if (res != 0) goto failed;
16511
0
        Py_CLEAR(tmp);
16512
0
    }
16513
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16514
0
        return -1;
16515
0
    }
16516
0
    if (tmp == NULL) {
16517
0
        tmp = PyList_New(0);
16518
0
        if (tmp == NULL) {
16519
0
            return -1;
16520
0
        }
16521
0
    }
16522
0
    {
16523
0
        int res;
16524
0
        Py_ssize_t len;
16525
0
        Py_ssize_t i;
16526
0
        if (!PyList_Check(tmp)) {
16527
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16528
0
            goto failed;
16529
0
        }
16530
0
        len = PyList_GET_SIZE(tmp);
16531
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16532
0
        if (defaults == NULL) goto failed;
16533
0
        for (i = 0; i < len; i++) {
16534
0
            expr_ty val;
16535
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16536
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16537
0
                goto failed;
16538
0
            }
16539
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16540
0
            _Py_LeaveRecursiveCall();
16541
0
            Py_DECREF(tmp2);
16542
0
            if (res != 0) goto failed;
16543
0
            if (len != PyList_GET_SIZE(tmp)) {
16544
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16545
0
                goto failed;
16546
0
            }
16547
0
            asdl_seq_SET(defaults, i, val);
16548
0
        }
16549
0
        Py_CLEAR(tmp);
16550
0
    }
16551
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16552
0
                            kwarg, defaults, arena);
16553
0
    if (*out == NULL) goto failed;
16554
0
    return 0;
16555
0
failed:
16556
0
    Py_XDECREF(tmp);
16557
0
    return -1;
16558
0
}
16559
16560
int
16561
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
16562
0
{
16563
0
    PyObject* tmp = NULL;
16564
0
    identifier arg;
16565
0
    expr_ty annotation;
16566
0
    string type_comment;
16567
0
    int lineno;
16568
0
    int col_offset;
16569
0
    int end_lineno;
16570
0
    int end_col_offset;
16571
16572
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16573
0
        return -1;
16574
0
    }
16575
0
    if (tmp == NULL) {
16576
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16577
0
        return -1;
16578
0
    }
16579
0
    else {
16580
0
        int res;
16581
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16582
0
            goto failed;
16583
0
        }
16584
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16585
0
        _Py_LeaveRecursiveCall();
16586
0
        if (res != 0) goto failed;
16587
0
        Py_CLEAR(tmp);
16588
0
    }
16589
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16590
0
        return -1;
16591
0
    }
16592
0
    if (tmp == NULL || tmp == Py_None) {
16593
0
        Py_CLEAR(tmp);
16594
0
        annotation = NULL;
16595
0
    }
16596
0
    else {
16597
0
        int res;
16598
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16599
0
            goto failed;
16600
0
        }
16601
0
        res = obj2ast_expr(state, tmp, &annotation, arena);
16602
0
        _Py_LeaveRecursiveCall();
16603
0
        if (res != 0) goto failed;
16604
0
        Py_CLEAR(tmp);
16605
0
    }
16606
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16607
0
        return -1;
16608
0
    }
16609
0
    if (tmp == NULL || tmp == Py_None) {
16610
0
        Py_CLEAR(tmp);
16611
0
        type_comment = NULL;
16612
0
    }
16613
0
    else {
16614
0
        int res;
16615
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16616
0
            goto failed;
16617
0
        }
16618
0
        res = obj2ast_string(state, tmp, &type_comment, arena);
16619
0
        _Py_LeaveRecursiveCall();
16620
0
        if (res != 0) goto failed;
16621
0
        Py_CLEAR(tmp);
16622
0
    }
16623
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16624
0
        return -1;
16625
0
    }
16626
0
    if (tmp == NULL) {
16627
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16628
0
        return -1;
16629
0
    }
16630
0
    else {
16631
0
        int res;
16632
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16633
0
            goto failed;
16634
0
        }
16635
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16636
0
        _Py_LeaveRecursiveCall();
16637
0
        if (res != 0) goto failed;
16638
0
        Py_CLEAR(tmp);
16639
0
    }
16640
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16641
0
        return -1;
16642
0
    }
16643
0
    if (tmp == NULL) {
16644
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16645
0
        return -1;
16646
0
    }
16647
0
    else {
16648
0
        int res;
16649
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16650
0
            goto failed;
16651
0
        }
16652
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16653
0
        _Py_LeaveRecursiveCall();
16654
0
        if (res != 0) goto failed;
16655
0
        Py_CLEAR(tmp);
16656
0
    }
16657
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16658
0
        return -1;
16659
0
    }
16660
0
    if (tmp == NULL || tmp == Py_None) {
16661
0
        Py_CLEAR(tmp);
16662
0
        end_lineno = lineno;
16663
0
    }
16664
0
    else {
16665
0
        int res;
16666
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16667
0
            goto failed;
16668
0
        }
16669
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16670
0
        _Py_LeaveRecursiveCall();
16671
0
        if (res != 0) goto failed;
16672
0
        Py_CLEAR(tmp);
16673
0
    }
16674
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16675
0
        return -1;
16676
0
    }
16677
0
    if (tmp == NULL || tmp == Py_None) {
16678
0
        Py_CLEAR(tmp);
16679
0
        end_col_offset = col_offset;
16680
0
    }
16681
0
    else {
16682
0
        int res;
16683
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16684
0
            goto failed;
16685
0
        }
16686
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16687
0
        _Py_LeaveRecursiveCall();
16688
0
        if (res != 0) goto failed;
16689
0
        Py_CLEAR(tmp);
16690
0
    }
16691
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16692
0
                      end_lineno, end_col_offset, arena);
16693
0
    if (*out == NULL) goto failed;
16694
0
    return 0;
16695
0
failed:
16696
0
    Py_XDECREF(tmp);
16697
0
    return -1;
16698
0
}
16699
16700
int
16701
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
16702
                PyArena* arena)
16703
0
{
16704
0
    PyObject* tmp = NULL;
16705
0
    identifier arg;
16706
0
    expr_ty value;
16707
0
    int lineno;
16708
0
    int col_offset;
16709
0
    int end_lineno;
16710
0
    int end_col_offset;
16711
16712
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16713
0
        return -1;
16714
0
    }
16715
0
    if (tmp == NULL || tmp == Py_None) {
16716
0
        Py_CLEAR(tmp);
16717
0
        arg = NULL;
16718
0
    }
16719
0
    else {
16720
0
        int res;
16721
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16722
0
            goto failed;
16723
0
        }
16724
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16725
0
        _Py_LeaveRecursiveCall();
16726
0
        if (res != 0) goto failed;
16727
0
        Py_CLEAR(tmp);
16728
0
    }
16729
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16730
0
        return -1;
16731
0
    }
16732
0
    if (tmp == NULL) {
16733
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16734
0
        return -1;
16735
0
    }
16736
0
    else {
16737
0
        int res;
16738
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16739
0
            goto failed;
16740
0
        }
16741
0
        res = obj2ast_expr(state, tmp, &value, arena);
16742
0
        _Py_LeaveRecursiveCall();
16743
0
        if (res != 0) goto failed;
16744
0
        Py_CLEAR(tmp);
16745
0
    }
16746
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16747
0
        return -1;
16748
0
    }
16749
0
    if (tmp == NULL) {
16750
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16751
0
        return -1;
16752
0
    }
16753
0
    else {
16754
0
        int res;
16755
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16756
0
            goto failed;
16757
0
        }
16758
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16759
0
        _Py_LeaveRecursiveCall();
16760
0
        if (res != 0) goto failed;
16761
0
        Py_CLEAR(tmp);
16762
0
    }
16763
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16764
0
        return -1;
16765
0
    }
16766
0
    if (tmp == NULL) {
16767
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16768
0
        return -1;
16769
0
    }
16770
0
    else {
16771
0
        int res;
16772
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16773
0
            goto failed;
16774
0
        }
16775
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16776
0
        _Py_LeaveRecursiveCall();
16777
0
        if (res != 0) goto failed;
16778
0
        Py_CLEAR(tmp);
16779
0
    }
16780
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16781
0
        return -1;
16782
0
    }
16783
0
    if (tmp == NULL || tmp == Py_None) {
16784
0
        Py_CLEAR(tmp);
16785
0
        end_lineno = lineno;
16786
0
    }
16787
0
    else {
16788
0
        int res;
16789
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16790
0
            goto failed;
16791
0
        }
16792
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16793
0
        _Py_LeaveRecursiveCall();
16794
0
        if (res != 0) goto failed;
16795
0
        Py_CLEAR(tmp);
16796
0
    }
16797
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16798
0
        return -1;
16799
0
    }
16800
0
    if (tmp == NULL || tmp == Py_None) {
16801
0
        Py_CLEAR(tmp);
16802
0
        end_col_offset = col_offset;
16803
0
    }
16804
0
    else {
16805
0
        int res;
16806
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16807
0
            goto failed;
16808
0
        }
16809
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16810
0
        _Py_LeaveRecursiveCall();
16811
0
        if (res != 0) goto failed;
16812
0
        Py_CLEAR(tmp);
16813
0
    }
16814
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16815
0
                          end_col_offset, arena);
16816
0
    if (*out == NULL) goto failed;
16817
0
    return 0;
16818
0
failed:
16819
0
    Py_XDECREF(tmp);
16820
0
    return -1;
16821
0
}
16822
16823
int
16824
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
16825
              arena)
16826
0
{
16827
0
    PyObject* tmp = NULL;
16828
0
    identifier name;
16829
0
    identifier asname;
16830
0
    int lineno;
16831
0
    int col_offset;
16832
0
    int end_lineno;
16833
0
    int end_col_offset;
16834
16835
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16836
0
        return -1;
16837
0
    }
16838
0
    if (tmp == NULL) {
16839
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16840
0
        return -1;
16841
0
    }
16842
0
    else {
16843
0
        int res;
16844
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16845
0
            goto failed;
16846
0
        }
16847
0
        res = obj2ast_identifier(state, tmp, &name, arena);
16848
0
        _Py_LeaveRecursiveCall();
16849
0
        if (res != 0) goto failed;
16850
0
        Py_CLEAR(tmp);
16851
0
    }
16852
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16853
0
        return -1;
16854
0
    }
16855
0
    if (tmp == NULL || tmp == Py_None) {
16856
0
        Py_CLEAR(tmp);
16857
0
        asname = NULL;
16858
0
    }
16859
0
    else {
16860
0
        int res;
16861
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16862
0
            goto failed;
16863
0
        }
16864
0
        res = obj2ast_identifier(state, tmp, &asname, arena);
16865
0
        _Py_LeaveRecursiveCall();
16866
0
        if (res != 0) goto failed;
16867
0
        Py_CLEAR(tmp);
16868
0
    }
16869
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16870
0
        return -1;
16871
0
    }
16872
0
    if (tmp == NULL) {
16873
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16874
0
        return -1;
16875
0
    }
16876
0
    else {
16877
0
        int res;
16878
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16879
0
            goto failed;
16880
0
        }
16881
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16882
0
        _Py_LeaveRecursiveCall();
16883
0
        if (res != 0) goto failed;
16884
0
        Py_CLEAR(tmp);
16885
0
    }
16886
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16887
0
        return -1;
16888
0
    }
16889
0
    if (tmp == NULL) {
16890
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16891
0
        return -1;
16892
0
    }
16893
0
    else {
16894
0
        int res;
16895
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16896
0
            goto failed;
16897
0
        }
16898
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16899
0
        _Py_LeaveRecursiveCall();
16900
0
        if (res != 0) goto failed;
16901
0
        Py_CLEAR(tmp);
16902
0
    }
16903
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16904
0
        return -1;
16905
0
    }
16906
0
    if (tmp == NULL || tmp == Py_None) {
16907
0
        Py_CLEAR(tmp);
16908
0
        end_lineno = lineno;
16909
0
    }
16910
0
    else {
16911
0
        int res;
16912
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16913
0
            goto failed;
16914
0
        }
16915
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16916
0
        _Py_LeaveRecursiveCall();
16917
0
        if (res != 0) goto failed;
16918
0
        Py_CLEAR(tmp);
16919
0
    }
16920
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16921
0
        return -1;
16922
0
    }
16923
0
    if (tmp == NULL || tmp == Py_None) {
16924
0
        Py_CLEAR(tmp);
16925
0
        end_col_offset = col_offset;
16926
0
    }
16927
0
    else {
16928
0
        int res;
16929
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16930
0
            goto failed;
16931
0
        }
16932
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16933
0
        _Py_LeaveRecursiveCall();
16934
0
        if (res != 0) goto failed;
16935
0
        Py_CLEAR(tmp);
16936
0
    }
16937
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16938
0
                        end_col_offset, arena);
16939
0
    if (*out == NULL) goto failed;
16940
0
    return 0;
16941
0
failed:
16942
0
    Py_XDECREF(tmp);
16943
0
    return -1;
16944
0
}
16945
16946
int
16947
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
16948
                 PyArena* arena)
16949
0
{
16950
0
    PyObject* tmp = NULL;
16951
0
    expr_ty context_expr;
16952
0
    expr_ty optional_vars;
16953
16954
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
16955
0
        return -1;
16956
0
    }
16957
0
    if (tmp == NULL) {
16958
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
16959
0
        return -1;
16960
0
    }
16961
0
    else {
16962
0
        int res;
16963
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16964
0
            goto failed;
16965
0
        }
16966
0
        res = obj2ast_expr(state, tmp, &context_expr, arena);
16967
0
        _Py_LeaveRecursiveCall();
16968
0
        if (res != 0) goto failed;
16969
0
        Py_CLEAR(tmp);
16970
0
    }
16971
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
16972
0
        return -1;
16973
0
    }
16974
0
    if (tmp == NULL || tmp == Py_None) {
16975
0
        Py_CLEAR(tmp);
16976
0
        optional_vars = NULL;
16977
0
    }
16978
0
    else {
16979
0
        int res;
16980
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16981
0
            goto failed;
16982
0
        }
16983
0
        res = obj2ast_expr(state, tmp, &optional_vars, arena);
16984
0
        _Py_LeaveRecursiveCall();
16985
0
        if (res != 0) goto failed;
16986
0
        Py_CLEAR(tmp);
16987
0
    }
16988
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
16989
0
    if (*out == NULL) goto failed;
16990
0
    return 0;
16991
0
failed:
16992
0
    Py_XDECREF(tmp);
16993
0
    return -1;
16994
0
}
16995
16996
int
16997
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
16998
                   PyArena* arena)
16999
0
{
17000
0
    PyObject* tmp = NULL;
17001
0
    pattern_ty pattern;
17002
0
    expr_ty guard;
17003
0
    asdl_stmt_seq* body;
17004
17005
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17006
0
        return -1;
17007
0
    }
17008
0
    if (tmp == NULL) {
17009
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
17010
0
        return -1;
17011
0
    }
17012
0
    else {
17013
0
        int res;
17014
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17015
0
            goto failed;
17016
0
        }
17017
0
        res = obj2ast_pattern(state, tmp, &pattern, arena);
17018
0
        _Py_LeaveRecursiveCall();
17019
0
        if (res != 0) goto failed;
17020
0
        Py_CLEAR(tmp);
17021
0
    }
17022
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17023
0
        return -1;
17024
0
    }
17025
0
    if (tmp == NULL || tmp == Py_None) {
17026
0
        Py_CLEAR(tmp);
17027
0
        guard = NULL;
17028
0
    }
17029
0
    else {
17030
0
        int res;
17031
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17032
0
            goto failed;
17033
0
        }
17034
0
        res = obj2ast_expr(state, tmp, &guard, arena);
17035
0
        _Py_LeaveRecursiveCall();
17036
0
        if (res != 0) goto failed;
17037
0
        Py_CLEAR(tmp);
17038
0
    }
17039
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17040
0
        return -1;
17041
0
    }
17042
0
    if (tmp == NULL) {
17043
0
        tmp = PyList_New(0);
17044
0
        if (tmp == NULL) {
17045
0
            return -1;
17046
0
        }
17047
0
    }
17048
0
    {
17049
0
        int res;
17050
0
        Py_ssize_t len;
17051
0
        Py_ssize_t i;
17052
0
        if (!PyList_Check(tmp)) {
17053
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17054
0
            goto failed;
17055
0
        }
17056
0
        len = PyList_GET_SIZE(tmp);
17057
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17058
0
        if (body == NULL) goto failed;
17059
0
        for (i = 0; i < len; i++) {
17060
0
            stmt_ty val;
17061
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17062
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17063
0
                goto failed;
17064
0
            }
17065
0
            res = obj2ast_stmt(state, tmp2, &val, arena);
17066
0
            _Py_LeaveRecursiveCall();
17067
0
            Py_DECREF(tmp2);
17068
0
            if (res != 0) goto failed;
17069
0
            if (len != PyList_GET_SIZE(tmp)) {
17070
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17071
0
                goto failed;
17072
0
            }
17073
0
            asdl_seq_SET(body, i, val);
17074
0
        }
17075
0
        Py_CLEAR(tmp);
17076
0
    }
17077
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17078
0
    if (*out == NULL) goto failed;
17079
0
    return 0;
17080
0
failed:
17081
0
    Py_XDECREF(tmp);
17082
0
    return -1;
17083
0
}
17084
17085
int
17086
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
17087
                PyArena* arena)
17088
0
{
17089
0
    int isinstance;
17090
17091
0
    PyObject *tmp = NULL;
17092
0
    PyObject *tp;
17093
0
    int lineno;
17094
0
    int col_offset;
17095
0
    int end_lineno;
17096
0
    int end_col_offset;
17097
17098
0
    if (obj == Py_None) {
17099
0
        *out = NULL;
17100
0
        return 0;
17101
0
    }
17102
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17103
0
        return -1;
17104
0
    }
17105
0
    if (tmp == NULL) {
17106
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17107
0
        return -1;
17108
0
    }
17109
0
    else {
17110
0
        int res;
17111
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17112
0
            goto failed;
17113
0
        }
17114
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17115
0
        _Py_LeaveRecursiveCall();
17116
0
        if (res != 0) goto failed;
17117
0
        Py_CLEAR(tmp);
17118
0
    }
17119
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17120
0
        return -1;
17121
0
    }
17122
0
    if (tmp == NULL) {
17123
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17124
0
        return -1;
17125
0
    }
17126
0
    else {
17127
0
        int res;
17128
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17129
0
            goto failed;
17130
0
        }
17131
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17132
0
        _Py_LeaveRecursiveCall();
17133
0
        if (res != 0) goto failed;
17134
0
        Py_CLEAR(tmp);
17135
0
    }
17136
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17137
0
        return -1;
17138
0
    }
17139
0
    if (tmp == NULL) {
17140
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17141
0
        return -1;
17142
0
    }
17143
0
    else {
17144
0
        int res;
17145
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17146
0
            goto failed;
17147
0
        }
17148
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17149
0
        _Py_LeaveRecursiveCall();
17150
0
        if (res != 0) goto failed;
17151
0
        Py_CLEAR(tmp);
17152
0
    }
17153
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17154
0
        return -1;
17155
0
    }
17156
0
    if (tmp == NULL) {
17157
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17158
0
        return -1;
17159
0
    }
17160
0
    else {
17161
0
        int res;
17162
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17163
0
            goto failed;
17164
0
        }
17165
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17166
0
        _Py_LeaveRecursiveCall();
17167
0
        if (res != 0) goto failed;
17168
0
        Py_CLEAR(tmp);
17169
0
    }
17170
0
    tp = state->MatchValue_type;
17171
0
    isinstance = PyObject_IsInstance(obj, tp);
17172
0
    if (isinstance == -1) {
17173
0
        return -1;
17174
0
    }
17175
0
    if (isinstance) {
17176
0
        expr_ty value;
17177
17178
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17179
0
            return -1;
17180
0
        }
17181
0
        if (tmp == NULL) {
17182
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17183
0
            return -1;
17184
0
        }
17185
0
        else {
17186
0
            int res;
17187
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17188
0
                goto failed;
17189
0
            }
17190
0
            res = obj2ast_expr(state, tmp, &value, arena);
17191
0
            _Py_LeaveRecursiveCall();
17192
0
            if (res != 0) goto failed;
17193
0
            Py_CLEAR(tmp);
17194
0
        }
17195
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17196
0
                                 end_col_offset, arena);
17197
0
        if (*out == NULL) goto failed;
17198
0
        return 0;
17199
0
    }
17200
0
    tp = state->MatchSingleton_type;
17201
0
    isinstance = PyObject_IsInstance(obj, tp);
17202
0
    if (isinstance == -1) {
17203
0
        return -1;
17204
0
    }
17205
0
    if (isinstance) {
17206
0
        constant value;
17207
17208
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17209
0
            return -1;
17210
0
        }
17211
0
        if (tmp == NULL) {
17212
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17213
0
            return -1;
17214
0
        }
17215
0
        else {
17216
0
            int res;
17217
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17218
0
                goto failed;
17219
0
            }
17220
0
            res = obj2ast_constant(state, tmp, &value, arena);
17221
0
            _Py_LeaveRecursiveCall();
17222
0
            if (res != 0) goto failed;
17223
0
            Py_CLEAR(tmp);
17224
0
        }
17225
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17226
0
                                     end_col_offset, arena);
17227
0
        if (*out == NULL) goto failed;
17228
0
        return 0;
17229
0
    }
17230
0
    tp = state->MatchSequence_type;
17231
0
    isinstance = PyObject_IsInstance(obj, tp);
17232
0
    if (isinstance == -1) {
17233
0
        return -1;
17234
0
    }
17235
0
    if (isinstance) {
17236
0
        asdl_pattern_seq* patterns;
17237
17238
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17239
0
            return -1;
17240
0
        }
17241
0
        if (tmp == NULL) {
17242
0
            tmp = PyList_New(0);
17243
0
            if (tmp == NULL) {
17244
0
                return -1;
17245
0
            }
17246
0
        }
17247
0
        {
17248
0
            int res;
17249
0
            Py_ssize_t len;
17250
0
            Py_ssize_t i;
17251
0
            if (!PyList_Check(tmp)) {
17252
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17253
0
                goto failed;
17254
0
            }
17255
0
            len = PyList_GET_SIZE(tmp);
17256
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17257
0
            if (patterns == NULL) goto failed;
17258
0
            for (i = 0; i < len; i++) {
17259
0
                pattern_ty val;
17260
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17261
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17262
0
                    goto failed;
17263
0
                }
17264
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17265
0
                _Py_LeaveRecursiveCall();
17266
0
                Py_DECREF(tmp2);
17267
0
                if (res != 0) goto failed;
17268
0
                if (len != PyList_GET_SIZE(tmp)) {
17269
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17270
0
                    goto failed;
17271
0
                }
17272
0
                asdl_seq_SET(patterns, i, val);
17273
0
            }
17274
0
            Py_CLEAR(tmp);
17275
0
        }
17276
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17277
0
                                    end_col_offset, arena);
17278
0
        if (*out == NULL) goto failed;
17279
0
        return 0;
17280
0
    }
17281
0
    tp = state->MatchMapping_type;
17282
0
    isinstance = PyObject_IsInstance(obj, tp);
17283
0
    if (isinstance == -1) {
17284
0
        return -1;
17285
0
    }
17286
0
    if (isinstance) {
17287
0
        asdl_expr_seq* keys;
17288
0
        asdl_pattern_seq* patterns;
17289
0
        identifier rest;
17290
17291
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17292
0
            return -1;
17293
0
        }
17294
0
        if (tmp == NULL) {
17295
0
            tmp = PyList_New(0);
17296
0
            if (tmp == NULL) {
17297
0
                return -1;
17298
0
            }
17299
0
        }
17300
0
        {
17301
0
            int res;
17302
0
            Py_ssize_t len;
17303
0
            Py_ssize_t i;
17304
0
            if (!PyList_Check(tmp)) {
17305
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17306
0
                goto failed;
17307
0
            }
17308
0
            len = PyList_GET_SIZE(tmp);
17309
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17310
0
            if (keys == NULL) goto failed;
17311
0
            for (i = 0; i < len; i++) {
17312
0
                expr_ty val;
17313
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17314
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17315
0
                    goto failed;
17316
0
                }
17317
0
                res = obj2ast_expr(state, tmp2, &val, arena);
17318
0
                _Py_LeaveRecursiveCall();
17319
0
                Py_DECREF(tmp2);
17320
0
                if (res != 0) goto failed;
17321
0
                if (len != PyList_GET_SIZE(tmp)) {
17322
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17323
0
                    goto failed;
17324
0
                }
17325
0
                asdl_seq_SET(keys, i, val);
17326
0
            }
17327
0
            Py_CLEAR(tmp);
17328
0
        }
17329
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17330
0
            return -1;
17331
0
        }
17332
0
        if (tmp == NULL) {
17333
0
            tmp = PyList_New(0);
17334
0
            if (tmp == NULL) {
17335
0
                return -1;
17336
0
            }
17337
0
        }
17338
0
        {
17339
0
            int res;
17340
0
            Py_ssize_t len;
17341
0
            Py_ssize_t i;
17342
0
            if (!PyList_Check(tmp)) {
17343
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17344
0
                goto failed;
17345
0
            }
17346
0
            len = PyList_GET_SIZE(tmp);
17347
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17348
0
            if (patterns == NULL) goto failed;
17349
0
            for (i = 0; i < len; i++) {
17350
0
                pattern_ty val;
17351
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17352
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17353
0
                    goto failed;
17354
0
                }
17355
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17356
0
                _Py_LeaveRecursiveCall();
17357
0
                Py_DECREF(tmp2);
17358
0
                if (res != 0) goto failed;
17359
0
                if (len != PyList_GET_SIZE(tmp)) {
17360
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17361
0
                    goto failed;
17362
0
                }
17363
0
                asdl_seq_SET(patterns, i, val);
17364
0
            }
17365
0
            Py_CLEAR(tmp);
17366
0
        }
17367
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17368
0
            return -1;
17369
0
        }
17370
0
        if (tmp == NULL || tmp == Py_None) {
17371
0
            Py_CLEAR(tmp);
17372
0
            rest = NULL;
17373
0
        }
17374
0
        else {
17375
0
            int res;
17376
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17377
0
                goto failed;
17378
0
            }
17379
0
            res = obj2ast_identifier(state, tmp, &rest, arena);
17380
0
            _Py_LeaveRecursiveCall();
17381
0
            if (res != 0) goto failed;
17382
0
            Py_CLEAR(tmp);
17383
0
        }
17384
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17385
0
                                   end_lineno, end_col_offset, arena);
17386
0
        if (*out == NULL) goto failed;
17387
0
        return 0;
17388
0
    }
17389
0
    tp = state->MatchClass_type;
17390
0
    isinstance = PyObject_IsInstance(obj, tp);
17391
0
    if (isinstance == -1) {
17392
0
        return -1;
17393
0
    }
17394
0
    if (isinstance) {
17395
0
        expr_ty cls;
17396
0
        asdl_pattern_seq* patterns;
17397
0
        asdl_identifier_seq* kwd_attrs;
17398
0
        asdl_pattern_seq* kwd_patterns;
17399
17400
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17401
0
            return -1;
17402
0
        }
17403
0
        if (tmp == NULL) {
17404
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17405
0
            return -1;
17406
0
        }
17407
0
        else {
17408
0
            int res;
17409
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17410
0
                goto failed;
17411
0
            }
17412
0
            res = obj2ast_expr(state, tmp, &cls, arena);
17413
0
            _Py_LeaveRecursiveCall();
17414
0
            if (res != 0) goto failed;
17415
0
            Py_CLEAR(tmp);
17416
0
        }
17417
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17418
0
            return -1;
17419
0
        }
17420
0
        if (tmp == NULL) {
17421
0
            tmp = PyList_New(0);
17422
0
            if (tmp == NULL) {
17423
0
                return -1;
17424
0
            }
17425
0
        }
17426
0
        {
17427
0
            int res;
17428
0
            Py_ssize_t len;
17429
0
            Py_ssize_t i;
17430
0
            if (!PyList_Check(tmp)) {
17431
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17432
0
                goto failed;
17433
0
            }
17434
0
            len = PyList_GET_SIZE(tmp);
17435
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17436
0
            if (patterns == NULL) goto failed;
17437
0
            for (i = 0; i < len; i++) {
17438
0
                pattern_ty val;
17439
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17440
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17441
0
                    goto failed;
17442
0
                }
17443
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17444
0
                _Py_LeaveRecursiveCall();
17445
0
                Py_DECREF(tmp2);
17446
0
                if (res != 0) goto failed;
17447
0
                if (len != PyList_GET_SIZE(tmp)) {
17448
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17449
0
                    goto failed;
17450
0
                }
17451
0
                asdl_seq_SET(patterns, i, val);
17452
0
            }
17453
0
            Py_CLEAR(tmp);
17454
0
        }
17455
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17456
0
            return -1;
17457
0
        }
17458
0
        if (tmp == NULL) {
17459
0
            tmp = PyList_New(0);
17460
0
            if (tmp == NULL) {
17461
0
                return -1;
17462
0
            }
17463
0
        }
17464
0
        {
17465
0
            int res;
17466
0
            Py_ssize_t len;
17467
0
            Py_ssize_t i;
17468
0
            if (!PyList_Check(tmp)) {
17469
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17470
0
                goto failed;
17471
0
            }
17472
0
            len = PyList_GET_SIZE(tmp);
17473
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17474
0
            if (kwd_attrs == NULL) goto failed;
17475
0
            for (i = 0; i < len; i++) {
17476
0
                identifier val;
17477
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17478
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17479
0
                    goto failed;
17480
0
                }
17481
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
17482
0
                _Py_LeaveRecursiveCall();
17483
0
                Py_DECREF(tmp2);
17484
0
                if (res != 0) goto failed;
17485
0
                if (len != PyList_GET_SIZE(tmp)) {
17486
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17487
0
                    goto failed;
17488
0
                }
17489
0
                asdl_seq_SET(kwd_attrs, i, val);
17490
0
            }
17491
0
            Py_CLEAR(tmp);
17492
0
        }
17493
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17494
0
            return -1;
17495
0
        }
17496
0
        if (tmp == NULL) {
17497
0
            tmp = PyList_New(0);
17498
0
            if (tmp == NULL) {
17499
0
                return -1;
17500
0
            }
17501
0
        }
17502
0
        {
17503
0
            int res;
17504
0
            Py_ssize_t len;
17505
0
            Py_ssize_t i;
17506
0
            if (!PyList_Check(tmp)) {
17507
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17508
0
                goto failed;
17509
0
            }
17510
0
            len = PyList_GET_SIZE(tmp);
17511
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17512
0
            if (kwd_patterns == NULL) goto failed;
17513
0
            for (i = 0; i < len; i++) {
17514
0
                pattern_ty val;
17515
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17516
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17517
0
                    goto failed;
17518
0
                }
17519
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17520
0
                _Py_LeaveRecursiveCall();
17521
0
                Py_DECREF(tmp2);
17522
0
                if (res != 0) goto failed;
17523
0
                if (len != PyList_GET_SIZE(tmp)) {
17524
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17525
0
                    goto failed;
17526
0
                }
17527
0
                asdl_seq_SET(kwd_patterns, i, val);
17528
0
            }
17529
0
            Py_CLEAR(tmp);
17530
0
        }
17531
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17532
0
                                 lineno, col_offset, end_lineno,
17533
0
                                 end_col_offset, arena);
17534
0
        if (*out == NULL) goto failed;
17535
0
        return 0;
17536
0
    }
17537
0
    tp = state->MatchStar_type;
17538
0
    isinstance = PyObject_IsInstance(obj, tp);
17539
0
    if (isinstance == -1) {
17540
0
        return -1;
17541
0
    }
17542
0
    if (isinstance) {
17543
0
        identifier name;
17544
17545
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17546
0
            return -1;
17547
0
        }
17548
0
        if (tmp == NULL || tmp == Py_None) {
17549
0
            Py_CLEAR(tmp);
17550
0
            name = NULL;
17551
0
        }
17552
0
        else {
17553
0
            int res;
17554
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17555
0
                goto failed;
17556
0
            }
17557
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17558
0
            _Py_LeaveRecursiveCall();
17559
0
            if (res != 0) goto failed;
17560
0
            Py_CLEAR(tmp);
17561
0
        }
17562
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17563
0
                                end_col_offset, arena);
17564
0
        if (*out == NULL) goto failed;
17565
0
        return 0;
17566
0
    }
17567
0
    tp = state->MatchAs_type;
17568
0
    isinstance = PyObject_IsInstance(obj, tp);
17569
0
    if (isinstance == -1) {
17570
0
        return -1;
17571
0
    }
17572
0
    if (isinstance) {
17573
0
        pattern_ty pattern;
17574
0
        identifier name;
17575
17576
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17577
0
            return -1;
17578
0
        }
17579
0
        if (tmp == NULL || tmp == Py_None) {
17580
0
            Py_CLEAR(tmp);
17581
0
            pattern = NULL;
17582
0
        }
17583
0
        else {
17584
0
            int res;
17585
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17586
0
                goto failed;
17587
0
            }
17588
0
            res = obj2ast_pattern(state, tmp, &pattern, arena);
17589
0
            _Py_LeaveRecursiveCall();
17590
0
            if (res != 0) goto failed;
17591
0
            Py_CLEAR(tmp);
17592
0
        }
17593
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17594
0
            return -1;
17595
0
        }
17596
0
        if (tmp == NULL || tmp == Py_None) {
17597
0
            Py_CLEAR(tmp);
17598
0
            name = NULL;
17599
0
        }
17600
0
        else {
17601
0
            int res;
17602
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17603
0
                goto failed;
17604
0
            }
17605
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17606
0
            _Py_LeaveRecursiveCall();
17607
0
            if (res != 0) goto failed;
17608
0
            Py_CLEAR(tmp);
17609
0
        }
17610
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17611
0
                              end_col_offset, arena);
17612
0
        if (*out == NULL) goto failed;
17613
0
        return 0;
17614
0
    }
17615
0
    tp = state->MatchOr_type;
17616
0
    isinstance = PyObject_IsInstance(obj, tp);
17617
0
    if (isinstance == -1) {
17618
0
        return -1;
17619
0
    }
17620
0
    if (isinstance) {
17621
0
        asdl_pattern_seq* patterns;
17622
17623
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17624
0
            return -1;
17625
0
        }
17626
0
        if (tmp == NULL) {
17627
0
            tmp = PyList_New(0);
17628
0
            if (tmp == NULL) {
17629
0
                return -1;
17630
0
            }
17631
0
        }
17632
0
        {
17633
0
            int res;
17634
0
            Py_ssize_t len;
17635
0
            Py_ssize_t i;
17636
0
            if (!PyList_Check(tmp)) {
17637
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17638
0
                goto failed;
17639
0
            }
17640
0
            len = PyList_GET_SIZE(tmp);
17641
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17642
0
            if (patterns == NULL) goto failed;
17643
0
            for (i = 0; i < len; i++) {
17644
0
                pattern_ty val;
17645
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17646
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17647
0
                    goto failed;
17648
0
                }
17649
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17650
0
                _Py_LeaveRecursiveCall();
17651
0
                Py_DECREF(tmp2);
17652
0
                if (res != 0) goto failed;
17653
0
                if (len != PyList_GET_SIZE(tmp)) {
17654
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17655
0
                    goto failed;
17656
0
                }
17657
0
                asdl_seq_SET(patterns, i, val);
17658
0
            }
17659
0
            Py_CLEAR(tmp);
17660
0
        }
17661
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17662
0
                              end_col_offset, arena);
17663
0
        if (*out == NULL) goto failed;
17664
0
        return 0;
17665
0
    }
17666
17667
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17668
0
    failed:
17669
0
    Py_XDECREF(tmp);
17670
0
    return -1;
17671
0
}
17672
17673
int
17674
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17675
                    out, PyArena* arena)
17676
0
{
17677
0
    int isinstance;
17678
17679
0
    PyObject *tmp = NULL;
17680
0
    PyObject *tp;
17681
17682
0
    if (obj == Py_None) {
17683
0
        *out = NULL;
17684
0
        return 0;
17685
0
    }
17686
0
    tp = state->TypeIgnore_type;
17687
0
    isinstance = PyObject_IsInstance(obj, tp);
17688
0
    if (isinstance == -1) {
17689
0
        return -1;
17690
0
    }
17691
0
    if (isinstance) {
17692
0
        int lineno;
17693
0
        string tag;
17694
17695
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17696
0
            return -1;
17697
0
        }
17698
0
        if (tmp == NULL) {
17699
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17700
0
            return -1;
17701
0
        }
17702
0
        else {
17703
0
            int res;
17704
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17705
0
                goto failed;
17706
0
            }
17707
0
            res = obj2ast_int(state, tmp, &lineno, arena);
17708
0
            _Py_LeaveRecursiveCall();
17709
0
            if (res != 0) goto failed;
17710
0
            Py_CLEAR(tmp);
17711
0
        }
17712
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17713
0
            return -1;
17714
0
        }
17715
0
        if (tmp == NULL) {
17716
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17717
0
            return -1;
17718
0
        }
17719
0
        else {
17720
0
            int res;
17721
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17722
0
                goto failed;
17723
0
            }
17724
0
            res = obj2ast_string(state, tmp, &tag, arena);
17725
0
            _Py_LeaveRecursiveCall();
17726
0
            if (res != 0) goto failed;
17727
0
            Py_CLEAR(tmp);
17728
0
        }
17729
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17730
0
        if (*out == NULL) goto failed;
17731
0
        return 0;
17732
0
    }
17733
17734
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17735
0
    failed:
17736
0
    Py_XDECREF(tmp);
17737
0
    return -1;
17738
0
}
17739
17740
int
17741
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17742
                   PyArena* arena)
17743
0
{
17744
0
    int isinstance;
17745
17746
0
    PyObject *tmp = NULL;
17747
0
    PyObject *tp;
17748
0
    int lineno;
17749
0
    int col_offset;
17750
0
    int end_lineno;
17751
0
    int end_col_offset;
17752
17753
0
    if (obj == Py_None) {
17754
0
        *out = NULL;
17755
0
        return 0;
17756
0
    }
17757
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17758
0
        return -1;
17759
0
    }
17760
0
    if (tmp == NULL) {
17761
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17762
0
        return -1;
17763
0
    }
17764
0
    else {
17765
0
        int res;
17766
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17767
0
            goto failed;
17768
0
        }
17769
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17770
0
        _Py_LeaveRecursiveCall();
17771
0
        if (res != 0) goto failed;
17772
0
        Py_CLEAR(tmp);
17773
0
    }
17774
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17775
0
        return -1;
17776
0
    }
17777
0
    if (tmp == NULL) {
17778
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17779
0
        return -1;
17780
0
    }
17781
0
    else {
17782
0
        int res;
17783
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17784
0
            goto failed;
17785
0
        }
17786
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17787
0
        _Py_LeaveRecursiveCall();
17788
0
        if (res != 0) goto failed;
17789
0
        Py_CLEAR(tmp);
17790
0
    }
17791
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17792
0
        return -1;
17793
0
    }
17794
0
    if (tmp == NULL) {
17795
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17796
0
        return -1;
17797
0
    }
17798
0
    else {
17799
0
        int res;
17800
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17801
0
            goto failed;
17802
0
        }
17803
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17804
0
        _Py_LeaveRecursiveCall();
17805
0
        if (res != 0) goto failed;
17806
0
        Py_CLEAR(tmp);
17807
0
    }
17808
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17809
0
        return -1;
17810
0
    }
17811
0
    if (tmp == NULL) {
17812
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17813
0
        return -1;
17814
0
    }
17815
0
    else {
17816
0
        int res;
17817
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17818
0
            goto failed;
17819
0
        }
17820
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17821
0
        _Py_LeaveRecursiveCall();
17822
0
        if (res != 0) goto failed;
17823
0
        Py_CLEAR(tmp);
17824
0
    }
17825
0
    tp = state->TypeVar_type;
17826
0
    isinstance = PyObject_IsInstance(obj, tp);
17827
0
    if (isinstance == -1) {
17828
0
        return -1;
17829
0
    }
17830
0
    if (isinstance) {
17831
0
        identifier name;
17832
0
        expr_ty bound;
17833
0
        expr_ty default_value;
17834
17835
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17836
0
            return -1;
17837
0
        }
17838
0
        if (tmp == NULL) {
17839
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17840
0
            return -1;
17841
0
        }
17842
0
        else {
17843
0
            int res;
17844
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17845
0
                goto failed;
17846
0
            }
17847
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17848
0
            _Py_LeaveRecursiveCall();
17849
0
            if (res != 0) goto failed;
17850
0
            Py_CLEAR(tmp);
17851
0
        }
17852
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17853
0
            return -1;
17854
0
        }
17855
0
        if (tmp == NULL || tmp == Py_None) {
17856
0
            Py_CLEAR(tmp);
17857
0
            bound = NULL;
17858
0
        }
17859
0
        else {
17860
0
            int res;
17861
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17862
0
                goto failed;
17863
0
            }
17864
0
            res = obj2ast_expr(state, tmp, &bound, arena);
17865
0
            _Py_LeaveRecursiveCall();
17866
0
            if (res != 0) goto failed;
17867
0
            Py_CLEAR(tmp);
17868
0
        }
17869
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17870
0
            return -1;
17871
0
        }
17872
0
        if (tmp == NULL || tmp == Py_None) {
17873
0
            Py_CLEAR(tmp);
17874
0
            default_value = NULL;
17875
0
        }
17876
0
        else {
17877
0
            int res;
17878
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17879
0
                goto failed;
17880
0
            }
17881
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17882
0
            _Py_LeaveRecursiveCall();
17883
0
            if (res != 0) goto failed;
17884
0
            Py_CLEAR(tmp);
17885
0
        }
17886
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17887
0
                              end_lineno, end_col_offset, arena);
17888
0
        if (*out == NULL) goto failed;
17889
0
        return 0;
17890
0
    }
17891
0
    tp = state->ParamSpec_type;
17892
0
    isinstance = PyObject_IsInstance(obj, tp);
17893
0
    if (isinstance == -1) {
17894
0
        return -1;
17895
0
    }
17896
0
    if (isinstance) {
17897
0
        identifier name;
17898
0
        expr_ty default_value;
17899
17900
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17901
0
            return -1;
17902
0
        }
17903
0
        if (tmp == NULL) {
17904
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17905
0
            return -1;
17906
0
        }
17907
0
        else {
17908
0
            int res;
17909
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17910
0
                goto failed;
17911
0
            }
17912
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17913
0
            _Py_LeaveRecursiveCall();
17914
0
            if (res != 0) goto failed;
17915
0
            Py_CLEAR(tmp);
17916
0
        }
17917
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17918
0
            return -1;
17919
0
        }
17920
0
        if (tmp == NULL || tmp == Py_None) {
17921
0
            Py_CLEAR(tmp);
17922
0
            default_value = NULL;
17923
0
        }
17924
0
        else {
17925
0
            int res;
17926
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17927
0
                goto failed;
17928
0
            }
17929
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17930
0
            _Py_LeaveRecursiveCall();
17931
0
            if (res != 0) goto failed;
17932
0
            Py_CLEAR(tmp);
17933
0
        }
17934
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
17935
0
                                end_lineno, end_col_offset, arena);
17936
0
        if (*out == NULL) goto failed;
17937
0
        return 0;
17938
0
    }
17939
0
    tp = state->TypeVarTuple_type;
17940
0
    isinstance = PyObject_IsInstance(obj, tp);
17941
0
    if (isinstance == -1) {
17942
0
        return -1;
17943
0
    }
17944
0
    if (isinstance) {
17945
0
        identifier name;
17946
0
        expr_ty default_value;
17947
17948
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17949
0
            return -1;
17950
0
        }
17951
0
        if (tmp == NULL) {
17952
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
17953
0
            return -1;
17954
0
        }
17955
0
        else {
17956
0
            int res;
17957
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17958
0
                goto failed;
17959
0
            }
17960
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17961
0
            _Py_LeaveRecursiveCall();
17962
0
            if (res != 0) goto failed;
17963
0
            Py_CLEAR(tmp);
17964
0
        }
17965
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17966
0
            return -1;
17967
0
        }
17968
0
        if (tmp == NULL || tmp == Py_None) {
17969
0
            Py_CLEAR(tmp);
17970
0
            default_value = NULL;
17971
0
        }
17972
0
        else {
17973
0
            int res;
17974
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17975
0
                goto failed;
17976
0
            }
17977
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17978
0
            _Py_LeaveRecursiveCall();
17979
0
            if (res != 0) goto failed;
17980
0
            Py_CLEAR(tmp);
17981
0
        }
17982
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
17983
0
                                   end_lineno, end_col_offset, arena);
17984
0
        if (*out == NULL) goto failed;
17985
0
        return 0;
17986
0
    }
17987
17988
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
17989
0
    failed:
17990
0
    Py_XDECREF(tmp);
17991
0
    return -1;
17992
0
}
17993
17994
17995
/* Helper for checking if a node class is abstract in the tests. */
17996
static PyObject *
17997
0
ast_is_abstract(PyObject *Py_UNUSED(module), PyObject *cls) {
17998
0
    struct ast_state *state = get_ast_state();
17999
0
    if (state == NULL) {
18000
0
        return NULL;
18001
0
    }
18002
0
    int contains = PySet_Contains(state->abstract_types, cls);
18003
0
    if (contains == -1) {
18004
0
        return NULL;
18005
0
    }
18006
0
    else if (contains == 1) {
18007
0
        Py_RETURN_TRUE;
18008
0
    }
18009
0
    Py_RETURN_FALSE;
18010
0
}
18011
18012
static struct PyMethodDef astmodule_methods[] = {
18013
    {"_is_abstract", ast_is_abstract, METH_O, NULL},
18014
    {NULL}  /* Sentinel */
18015
};
18016
18017
static int
18018
astmodule_exec(PyObject *m)
18019
9
{
18020
9
    struct ast_state *state = get_ast_state();
18021
9
    if (state == NULL) {
18022
0
        return -1;
18023
0
    }
18024
9
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
18025
0
        return -1;
18026
0
    }
18027
9
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
18028
0
        return -1;
18029
0
    }
18030
9
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
18031
0
        return -1;
18032
0
    }
18033
9
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
18034
0
        return -1;
18035
0
    }
18036
9
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18037
0
        return -1;
18038
0
    }
18039
9
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18040
0
        return -1;
18041
0
    }
18042
9
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18043
0
        return -1;
18044
0
    }
18045
9
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18046
0
        return -1;
18047
0
    }
18048
9
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18049
0
        return -1;
18050
0
    }
18051
9
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18052
0
        {
18053
0
        return -1;
18054
0
    }
18055
9
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18056
0
        return -1;
18057
0
    }
18058
9
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18059
0
        return -1;
18060
0
    }
18061
9
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18062
9
        state->AsyncFunctionDef_type) < 0) {
18063
0
        return -1;
18064
0
    }
18065
9
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18066
0
        return -1;
18067
0
    }
18068
9
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18069
0
        return -1;
18070
0
    }
18071
9
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18072
0
        return -1;
18073
0
    }
18074
9
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18075
0
        return -1;
18076
0
    }
18077
9
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18078
0
        return -1;
18079
0
    }
18080
9
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18081
0
        return -1;
18082
0
    }
18083
9
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18084
0
        return -1;
18085
0
    }
18086
9
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18087
0
        return -1;
18088
0
    }
18089
9
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18090
0
        return -1;
18091
0
    }
18092
9
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18093
0
        return -1;
18094
0
    }
18095
9
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18096
0
        return -1;
18097
0
    }
18098
9
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18099
0
        return -1;
18100
0
    }
18101
9
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18102
0
        return -1;
18103
0
    }
18104
9
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18105
0
        return -1;
18106
0
    }
18107
9
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18108
0
        return -1;
18109
0
    }
18110
9
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18111
0
        return -1;
18112
0
    }
18113
9
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18114
0
        return -1;
18115
0
    }
18116
9
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18117
0
        return -1;
18118
0
    }
18119
9
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18120
0
        return -1;
18121
0
    }
18122
9
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18123
0
        return -1;
18124
0
    }
18125
9
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18126
0
        return -1;
18127
0
    }
18128
9
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18129
0
        return -1;
18130
0
    }
18131
9
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18132
0
        return -1;
18133
0
    }
18134
9
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18135
0
        return -1;
18136
0
    }
18137
9
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18138
0
        return -1;
18139
0
    }
18140
9
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18141
0
        return -1;
18142
0
    }
18143
9
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18144
0
        return -1;
18145
0
    }
18146
9
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18147
0
        return -1;
18148
0
    }
18149
9
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18150
0
        return -1;
18151
0
    }
18152
9
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18153
0
        return -1;
18154
0
    }
18155
9
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18156
0
        return -1;
18157
0
    }
18158
9
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18159
0
        return -1;
18160
0
    }
18161
9
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18162
0
        return -1;
18163
0
    }
18164
9
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18165
0
        return -1;
18166
0
    }
18167
9
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18168
0
        return -1;
18169
0
    }
18170
9
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18171
0
        return -1;
18172
0
    }
18173
9
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18174
0
        return -1;
18175
0
    }
18176
9
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18177
0
        return -1;
18178
0
    }
18179
9
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18180
0
        {
18181
0
        return -1;
18182
0
    }
18183
9
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18184
0
        return -1;
18185
0
    }
18186
9
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18187
0
        return -1;
18188
0
    }
18189
9
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18190
0
        return -1;
18191
0
    }
18192
9
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18193
0
        return -1;
18194
0
    }
18195
9
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18196
0
        return -1;
18197
0
    }
18198
9
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18199
9
        < 0) {
18200
0
        return -1;
18201
0
    }
18202
9
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18203
9
        0) {
18204
0
        return -1;
18205
0
    }
18206
9
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18207
0
        return -1;
18208
0
    }
18209
9
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18210
0
        return -1;
18211
0
    }
18212
9
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18213
0
        return -1;
18214
0
    }
18215
9
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18216
0
        return -1;
18217
0
    }
18218
9
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18219
0
        return -1;
18220
0
    }
18221
9
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18222
0
        return -1;
18223
0
    }
18224
9
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18225
0
        return -1;
18226
0
    }
18227
9
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18228
0
        return -1;
18229
0
    }
18230
9
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18231
0
        return -1;
18232
0
    }
18233
9
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18234
0
        return -1;
18235
0
    }
18236
9
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18237
0
        {
18238
0
        return -1;
18239
0
    }
18240
9
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18241
0
        return -1;
18242
0
    }
18243
9
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18244
0
        return -1;
18245
0
    }
18246
9
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18247
0
        return -1;
18248
0
    }
18249
9
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18250
0
        return -1;
18251
0
    }
18252
9
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18253
0
        return -1;
18254
0
    }
18255
9
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18256
0
        return -1;
18257
0
    }
18258
9
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18259
0
        return -1;
18260
0
    }
18261
9
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18262
0
        return -1;
18263
0
    }
18264
9
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18265
0
        return -1;
18266
0
    }
18267
9
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18268
0
        return -1;
18269
0
    }
18270
9
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18271
0
        return -1;
18272
0
    }
18273
9
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18274
0
        return -1;
18275
0
    }
18276
9
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18277
0
        return -1;
18278
0
    }
18279
9
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18280
0
        return -1;
18281
0
    }
18282
9
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18283
0
        return -1;
18284
0
    }
18285
9
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18286
0
        return -1;
18287
0
    }
18288
9
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18289
0
        return -1;
18290
0
    }
18291
9
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18292
0
        return -1;
18293
0
    }
18294
9
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18295
0
        return -1;
18296
0
    }
18297
9
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18298
0
        return -1;
18299
0
    }
18300
9
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18301
0
        return -1;
18302
0
    }
18303
9
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18304
0
        return -1;
18305
0
    }
18306
9
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18307
0
        return -1;
18308
0
    }
18309
9
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18310
0
        return -1;
18311
0
    }
18312
9
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18313
0
        return -1;
18314
0
    }
18315
9
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18316
0
        return -1;
18317
0
    }
18318
9
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18319
0
        return -1;
18320
0
    }
18321
9
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18322
0
        return -1;
18323
0
    }
18324
9
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18325
0
        return -1;
18326
0
    }
18327
9
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18328
0
        return -1;
18329
0
    }
18330
9
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18331
0
        return -1;
18332
0
    }
18333
9
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18334
0
        return -1;
18335
0
    }
18336
9
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18337
0
        return -1;
18338
0
    }
18339
9
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18340
0
        return -1;
18341
0
    }
18342
9
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18343
0
        return -1;
18344
0
    }
18345
9
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18346
0
        return -1;
18347
0
    }
18348
9
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18349
9
        0) {
18350
0
        return -1;
18351
0
    }
18352
9
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18353
9
        0) {
18354
0
        return -1;
18355
0
    }
18356
9
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18357
9
        0) {
18358
0
        return -1;
18359
0
    }
18360
9
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18361
0
        return -1;
18362
0
    }
18363
9
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18364
0
        return -1;
18365
0
    }
18366
9
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18367
0
        return -1;
18368
0
    }
18369
9
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18370
0
        return -1;
18371
0
    }
18372
9
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18373
0
        return -1;
18374
0
    }
18375
9
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18376
0
        return -1;
18377
0
    }
18378
9
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18379
0
        return -1;
18380
0
    }
18381
9
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18382
0
        return -1;
18383
0
    }
18384
9
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18385
9
        < 0) {
18386
0
        return -1;
18387
0
    }
18388
9
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18389
9
        0) {
18390
0
        return -1;
18391
0
    }
18392
9
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18393
0
        {
18394
0
        return -1;
18395
0
    }
18396
9
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18397
0
        return -1;
18398
0
    }
18399
9
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18400
0
        return -1;
18401
0
    }
18402
9
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18403
0
        return -1;
18404
0
    }
18405
9
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18406
0
        return -1;
18407
0
    }
18408
9
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18409
0
        return -1;
18410
0
    }
18411
9
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18412
0
        return -1;
18413
0
    }
18414
9
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18415
0
        return -1;
18416
0
    }
18417
9
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18418
0
        return -1;
18419
0
    }
18420
9
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18421
0
        return -1;
18422
0
    }
18423
9
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18424
0
        {
18425
0
        return -1;
18426
0
    }
18427
9
    return 0;
18428
9
}
18429
18430
static PyModuleDef_Slot astmodule_slots[] = {
18431
    _Py_ABI_SLOT,
18432
    {Py_mod_exec, astmodule_exec},
18433
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18434
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18435
    {0, NULL}
18436
};
18437
18438
static struct PyModuleDef _astmodule = {
18439
    PyModuleDef_HEAD_INIT,
18440
    .m_name = "_ast",
18441
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18442
    .m_size = 0,
18443
    .m_methods = astmodule_methods,
18444
    .m_slots = astmodule_slots
18445
};
18446
18447
PyMODINIT_FUNC
18448
PyInit__ast(void)
18449
9
{
18450
9
    return PyModuleDef_Init(&_astmodule);
18451
9
}
18452
18453
18454
PyObject* PyAST_mod2obj(mod_ty t)
18455
6.28k
{
18456
6.28k
    struct ast_state *state = get_ast_state();
18457
6.28k
    if (state == NULL) {
18458
0
        return NULL;
18459
0
    }
18460
6.28k
    PyObject *result = ast2obj_mod(state, t);
18461
18462
6.28k
    return result;
18463
6.28k
}
18464
18465
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18466
int PyAst_CheckMode(PyObject *ast, int mode)
18467
0
{
18468
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18469
18470
0
    struct ast_state *state = get_ast_state();
18471
0
    if (state == NULL) {
18472
0
        return -1;
18473
0
    }
18474
18475
0
    PyObject *req_type[3];
18476
0
    req_type[0] = state->Module_type;
18477
0
    req_type[1] = state->Expression_type;
18478
0
    req_type[2] = state->Interactive_type;
18479
18480
0
    assert(0 <= mode && mode <= 2);
18481
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18482
0
    if (isinstance == -1) {
18483
0
        return -1;
18484
0
    }
18485
0
    if (!isinstance) {
18486
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18487
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18488
0
        return -1;
18489
0
    }
18490
0
    return 0;
18491
0
}
18492
18493
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18494
0
{
18495
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18496
0
        return NULL;
18497
0
    }
18498
18499
0
    struct ast_state *state = get_ast_state();
18500
0
    if (state == NULL) {
18501
0
        return NULL;
18502
0
    }
18503
18504
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18505
0
        return NULL;
18506
0
    }
18507
18508
0
    mod_ty res = NULL;
18509
0
    if (obj2ast_mod(state, ast, &res, arena) != 0)
18510
0
        return NULL;
18511
0
    else
18512
0
        return res;
18513
0
}
18514
18515
int PyAST_Check(PyObject* obj)
18516
101k
{
18517
101k
    struct ast_state *state = get_ast_state();
18518
101k
    if (state == NULL) {
18519
0
        return -1;
18520
0
    }
18521
101k
    return PyObject_IsInstance(obj, state->AST_type);
18522
101k
}
18523
18524