Coverage Report

Created: 2026-06-21 06:15

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
116k
{
23
116k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
116k
    struct ast_state *state = &interp->ast;
25
116k
    assert(!state->finalized);
26
116k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
116k
    return state;
30
116k
}
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
814k
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.10M
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
390
9.26k
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.36k
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
466k
{
5173
466k
    AST_object *self = (AST_object*)op;
5174
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5175
466k
    PyTypeObject *tp = Py_TYPE(self);
5176
466k
    PyObject_GC_UnTrack(self);
5177
466k
    Py_CLEAR(self->dict);
5178
466k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5179
466k
    assert(free_func != NULL);
5180
466k
    free_func(self);
5181
466k
    Py_DECREF(tp);
5182
466k
}
5183
5184
static int
5185
ast_traverse(PyObject *op, visitproc visit, void *arg)
5186
451k
{
5187
451k
    AST_object *self = (AST_object*)op;
5188
451k
    Py_VISIT(Py_TYPE(self));
5189
451k
    Py_VISIT(self->dict);
5190
451k
    return 0;
5191
451k
}
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
104k
{
5994
104k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
5995
104k
    PyObject *result = PyList_New(n);
5996
104k
    PyObject *value;
5997
104k
    if (!result)
5998
0
        return NULL;
5999
263k
    for (i = 0; i < n; i++) {
6000
158k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6001
158k
        if (!value) {
6002
0
            Py_DECREF(result);
6003
0
            return NULL;
6004
0
        }
6005
158k
        PyList_SET_ITEM(result, i, value);
6006
158k
    }
6007
104k
    return result;
6008
104k
}
6009
6010
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6011
252k
{
6012
252k
    PyObject *op = (PyObject*)o;
6013
252k
    if (!op) {
6014
85.6k
        op = Py_None;
6015
85.6k
    }
6016
252k
    return Py_NewRef(op);
6017
252k
}
6018
62.9k
#define ast2obj_constant ast2obj_object
6019
113k
#define ast2obj_identifier ast2obj_object
6020
76.0k
#define ast2obj_string ast2obj_object
6021
6022
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6023
1.83M
{
6024
1.83M
    return PyLong_FromLong(b);
6025
1.83M
}
6026
6027
/* Conversion Python -> AST */
6028
6029
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj,
6030
                          PyObject** out,
6031
                          const char* Py_UNUSED(field), PyArena* arena)
6032
0
{
6033
0
    if (obj == Py_None)
6034
0
        obj = NULL;
6035
0
    if (obj) {
6036
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6037
0
            *out = NULL;
6038
0
            return -1;
6039
0
        }
6040
0
        *out = Py_NewRef(obj);
6041
0
    }
6042
0
    else {
6043
0
        *out = NULL;
6044
0
    }
6045
0
    return 0;
6046
0
}
6047
6048
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj,
6049
                            PyObject** out,
6050
                            const char* Py_UNUSED(field), PyArena* arena)
6051
0
{
6052
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6053
0
        *out = NULL;
6054
0
        return -1;
6055
0
    }
6056
0
    *out = Py_NewRef(obj);
6057
0
    return 0;
6058
0
}
6059
6060
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, const char* field, PyArena* arena)
6061
0
{
6062
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6063
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting a string object", field);
6064
0
        return -1;
6065
0
    }
6066
0
    return obj2ast_object(state, obj, out, field, arena);
6067
0
}
6068
6069
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, const char* field, PyArena* arena)
6070
0
{
6071
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6072
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting a string or bytes object", field);
6073
0
        return -1;
6074
0
    }
6075
0
    return obj2ast_object(state, obj, out, field, arena);
6076
0
}
6077
6078
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, const char* field, PyArena* arena)
6079
0
{
6080
0
    int i;
6081
0
    if (!PyLong_Check(obj)) {
6082
0
        PyErr_Format(PyExc_ValueError, "field \"%s\" got an invalid integer value: %R", field, obj);
6083
0
        return -1;
6084
0
    }
6085
6086
0
    i = PyLong_AsInt(obj);
6087
0
    if (i == -1 && PyErr_Occurred())
6088
0
        return -1;
6089
0
    *out = i;
6090
0
    return 0;
6091
0
}
6092
6093
static int add_ast_fields(struct ast_state *state)
6094
16
{
6095
16
    PyObject *empty_tuple;
6096
16
    empty_tuple = PyTuple_New(0);
6097
16
    if (!empty_tuple ||
6098
16
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6099
16
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6100
16
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6101
0
        Py_XDECREF(empty_tuple);
6102
0
        return -1;
6103
0
    }
6104
16
    Py_DECREF(empty_tuple);
6105
16
    return 0;
6106
16
}
6107
6108
6109
6110
static int
6111
init_types(void *arg)
6112
16
{
6113
16
    struct ast_state *state = arg;
6114
16
    if (init_identifiers(state) < 0) {
6115
0
        return -1;
6116
0
    }
6117
16
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6118
16
    if (!state->AST_type) {
6119
0
        return -1;
6120
0
    }
6121
16
    state->abstract_types = PySet_New(NULL);
6122
16
    if (!state->abstract_types) {
6123
0
        return -1;
6124
0
    }
6125
16
    if (PySet_Add(state->abstract_types, state->AST_type) < 0) {
6126
0
        return -1;
6127
0
    }
6128
16
    if (add_ast_fields(state) < 0) {
6129
0
        return -1;
6130
0
    }
6131
16
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6132
16
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6133
16
        "    | Interactive(stmt* body)\n"
6134
16
        "    | Expression(expr body)\n"
6135
16
        "    | FunctionType(expr* argtypes, expr returns)");
6136
16
    if (!state->mod_type) return -1;
6137
16
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6138
16
    if (PySet_Add(state->abstract_types, state->mod_type) < 0) return -1;
6139
16
    state->Module_type = make_type(state, "Module", state->mod_type,
6140
16
                                   Module_fields, 2,
6141
16
        "Module(stmt* body, type_ignore* type_ignores)");
6142
16
    if (!state->Module_type) return -1;
6143
16
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6144
16
                                        Interactive_fields, 1,
6145
16
        "Interactive(stmt* body)");
6146
16
    if (!state->Interactive_type) return -1;
6147
16
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6148
16
                                       Expression_fields, 1,
6149
16
        "Expression(expr body)");
6150
16
    if (!state->Expression_type) return -1;
6151
16
    state->FunctionType_type = make_type(state, "FunctionType",
6152
16
                                         state->mod_type, FunctionType_fields,
6153
16
                                         2,
6154
16
        "FunctionType(expr* argtypes, expr returns)");
6155
16
    if (!state->FunctionType_type) return -1;
6156
16
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6157
16
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6158
16
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6159
16
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6160
16
        "     | Return(expr? value)\n"
6161
16
        "     | Delete(expr* targets)\n"
6162
16
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6163
16
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6164
16
        "     | AugAssign(expr target, operator op, expr value)\n"
6165
16
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6166
16
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6167
16
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6168
16
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6169
16
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6170
16
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6171
16
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6172
16
        "     | Match(expr subject, match_case* cases)\n"
6173
16
        "     | Raise(expr? exc, expr? cause)\n"
6174
16
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6175
16
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6176
16
        "     | Assert(expr test, expr? msg)\n"
6177
16
        "     | Import(alias* names, int? is_lazy)\n"
6178
16
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
6179
16
        "     | Global(identifier* names)\n"
6180
16
        "     | Nonlocal(identifier* names)\n"
6181
16
        "     | Expr(expr value)\n"
6182
16
        "     | Pass\n"
6183
16
        "     | Break\n"
6184
16
        "     | Continue");
6185
16
    if (!state->stmt_type) return -1;
6186
16
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6187
0
        -1;
6188
16
    if (PySet_Add(state->abstract_types, state->stmt_type) < 0) return -1;
6189
16
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6190
0
        return -1;
6191
16
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6192
16
        -1)
6193
0
        return -1;
6194
16
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6195
16
                                        FunctionDef_fields, 7,
6196
16
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6197
16
    if (!state->FunctionDef_type) return -1;
6198
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6199
16
        -1)
6200
0
        return -1;
6201
16
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6202
16
        == -1)
6203
0
        return -1;
6204
16
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6205
16
                                             state->stmt_type,
6206
16
                                             AsyncFunctionDef_fields, 7,
6207
16
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6208
16
    if (!state->AsyncFunctionDef_type) return -1;
6209
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6210
16
        == -1)
6211
0
        return -1;
6212
16
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6213
16
        Py_None) == -1)
6214
0
        return -1;
6215
16
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6216
16
                                     ClassDef_fields, 6,
6217
16
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6218
16
    if (!state->ClassDef_type) return -1;
6219
16
    state->Return_type = make_type(state, "Return", state->stmt_type,
6220
16
                                   Return_fields, 1,
6221
16
        "Return(expr? value)");
6222
16
    if (!state->Return_type) return -1;
6223
16
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6224
0
        return -1;
6225
16
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6226
16
                                   Delete_fields, 1,
6227
16
        "Delete(expr* targets)");
6228
16
    if (!state->Delete_type) return -1;
6229
16
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6230
16
                                   Assign_fields, 3,
6231
16
        "Assign(expr* targets, expr value, string? type_comment)");
6232
16
    if (!state->Assign_type) return -1;
6233
16
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6234
16
        -1)
6235
0
        return -1;
6236
16
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6237
16
                                      TypeAlias_fields, 3,
6238
16
        "TypeAlias(expr name, type_param* type_params, expr value)");
6239
16
    if (!state->TypeAlias_type) return -1;
6240
16
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6241
16
                                      AugAssign_fields, 3,
6242
16
        "AugAssign(expr target, operator op, expr value)");
6243
16
    if (!state->AugAssign_type) return -1;
6244
16
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6245
16
                                      AnnAssign_fields, 4,
6246
16
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6247
16
    if (!state->AnnAssign_type) return -1;
6248
16
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6249
0
        return -1;
6250
16
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6251
16
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6252
16
    if (!state->For_type) return -1;
6253
16
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6254
0
        return -1;
6255
16
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6256
16
                                     AsyncFor_fields, 5,
6257
16
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6258
16
    if (!state->AsyncFor_type) return -1;
6259
16
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6260
16
        -1)
6261
0
        return -1;
6262
16
    state->While_type = make_type(state, "While", state->stmt_type,
6263
16
                                  While_fields, 3,
6264
16
        "While(expr test, stmt* body, stmt* orelse)");
6265
16
    if (!state->While_type) return -1;
6266
16
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6267
16
        "If(expr test, stmt* body, stmt* orelse)");
6268
16
    if (!state->If_type) return -1;
6269
16
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6270
16
                                 3,
6271
16
        "With(withitem* items, stmt* body, string? type_comment)");
6272
16
    if (!state->With_type) return -1;
6273
16
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6274
0
        return -1;
6275
16
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6276
16
                                      AsyncWith_fields, 3,
6277
16
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6278
16
    if (!state->AsyncWith_type) return -1;
6279
16
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6280
16
        == -1)
6281
0
        return -1;
6282
16
    state->Match_type = make_type(state, "Match", state->stmt_type,
6283
16
                                  Match_fields, 2,
6284
16
        "Match(expr subject, match_case* cases)");
6285
16
    if (!state->Match_type) return -1;
6286
16
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6287
16
                                  Raise_fields, 2,
6288
16
        "Raise(expr? exc, expr? cause)");
6289
16
    if (!state->Raise_type) return -1;
6290
16
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6291
0
        return -1;
6292
16
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6293
0
        return -1;
6294
16
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6295
16
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6296
16
    if (!state->Try_type) return -1;
6297
16
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6298
16
                                    TryStar_fields, 4,
6299
16
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6300
16
    if (!state->TryStar_type) return -1;
6301
16
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6302
16
                                   Assert_fields, 2,
6303
16
        "Assert(expr test, expr? msg)");
6304
16
    if (!state->Assert_type) return -1;
6305
16
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6306
0
        return -1;
6307
16
    state->Import_type = make_type(state, "Import", state->stmt_type,
6308
16
                                   Import_fields, 2,
6309
16
        "Import(alias* names, int? is_lazy)");
6310
16
    if (!state->Import_type) return -1;
6311
16
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
6312
0
        return -1;
6313
16
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6314
16
                                       ImportFrom_fields, 4,
6315
16
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
6316
16
    if (!state->ImportFrom_type) return -1;
6317
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6318
0
        return -1;
6319
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6320
0
        return -1;
6321
16
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
6322
0
        return -1;
6323
16
    state->Global_type = make_type(state, "Global", state->stmt_type,
6324
16
                                   Global_fields, 1,
6325
16
        "Global(identifier* names)");
6326
16
    if (!state->Global_type) return -1;
6327
16
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6328
16
                                     Nonlocal_fields, 1,
6329
16
        "Nonlocal(identifier* names)");
6330
16
    if (!state->Nonlocal_type) return -1;
6331
16
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6332
16
                                 1,
6333
16
        "Expr(expr value)");
6334
16
    if (!state->Expr_type) return -1;
6335
16
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6336
16
        "Pass");
6337
16
    if (!state->Pass_type) return -1;
6338
16
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6339
16
        "Break");
6340
16
    if (!state->Break_type) return -1;
6341
16
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6342
16
                                     0,
6343
16
        "Continue");
6344
16
    if (!state->Continue_type) return -1;
6345
16
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6346
16
        "expr = BoolOp(boolop op, expr* values)\n"
6347
16
        "     | NamedExpr(expr target, expr value)\n"
6348
16
        "     | BinOp(expr left, operator op, expr right)\n"
6349
16
        "     | UnaryOp(unaryop op, expr operand)\n"
6350
16
        "     | Lambda(arguments args, expr body)\n"
6351
16
        "     | IfExp(expr test, expr body, expr orelse)\n"
6352
16
        "     | Dict(expr?* keys, expr* values)\n"
6353
16
        "     | Set(expr* elts)\n"
6354
16
        "     | ListComp(expr elt, comprehension* generators)\n"
6355
16
        "     | SetComp(expr elt, comprehension* generators)\n"
6356
16
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6357
16
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6358
16
        "     | Await(expr value)\n"
6359
16
        "     | Yield(expr? value)\n"
6360
16
        "     | YieldFrom(expr value)\n"
6361
16
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6362
16
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6363
16
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6364
16
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6365
16
        "     | JoinedStr(expr* values)\n"
6366
16
        "     | TemplateStr(expr* values)\n"
6367
16
        "     | Constant(constant value, string? kind)\n"
6368
16
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6369
16
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6370
16
        "     | Starred(expr value, expr_context ctx)\n"
6371
16
        "     | Name(identifier id, expr_context ctx)\n"
6372
16
        "     | List(expr* elts, expr_context ctx)\n"
6373
16
        "     | Tuple(expr* elts, expr_context ctx)\n"
6374
16
        "     | Slice(expr? lower, expr? upper, expr? step)");
6375
16
    if (!state->expr_type) return -1;
6376
16
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6377
0
        -1;
6378
16
    if (PySet_Add(state->abstract_types, state->expr_type) < 0) return -1;
6379
16
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6380
0
        return -1;
6381
16
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6382
16
        -1)
6383
0
        return -1;
6384
16
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6385
16
                                   BoolOp_fields, 2,
6386
16
        "BoolOp(boolop op, expr* values)");
6387
16
    if (!state->BoolOp_type) return -1;
6388
16
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6389
16
                                      NamedExpr_fields, 2,
6390
16
        "NamedExpr(expr target, expr value)");
6391
16
    if (!state->NamedExpr_type) return -1;
6392
16
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6393
16
                                  BinOp_fields, 3,
6394
16
        "BinOp(expr left, operator op, expr right)");
6395
16
    if (!state->BinOp_type) return -1;
6396
16
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6397
16
                                    UnaryOp_fields, 2,
6398
16
        "UnaryOp(unaryop op, expr operand)");
6399
16
    if (!state->UnaryOp_type) return -1;
6400
16
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6401
16
                                   Lambda_fields, 2,
6402
16
        "Lambda(arguments args, expr body)");
6403
16
    if (!state->Lambda_type) return -1;
6404
16
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6405
16
                                  IfExp_fields, 3,
6406
16
        "IfExp(expr test, expr body, expr orelse)");
6407
16
    if (!state->IfExp_type) return -1;
6408
16
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6409
16
                                 2,
6410
16
        "Dict(expr?* keys, expr* values)");
6411
16
    if (!state->Dict_type) return -1;
6412
16
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6413
16
        "Set(expr* elts)");
6414
16
    if (!state->Set_type) return -1;
6415
16
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6416
16
                                     ListComp_fields, 2,
6417
16
        "ListComp(expr elt, comprehension* generators)");
6418
16
    if (!state->ListComp_type) return -1;
6419
16
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6420
16
                                    SetComp_fields, 2,
6421
16
        "SetComp(expr elt, comprehension* generators)");
6422
16
    if (!state->SetComp_type) return -1;
6423
16
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6424
16
                                     DictComp_fields, 3,
6425
16
        "DictComp(expr key, expr? value, comprehension* generators)");
6426
16
    if (!state->DictComp_type) return -1;
6427
16
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6428
0
        return -1;
6429
16
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6430
16
                                         state->expr_type, GeneratorExp_fields,
6431
16
                                         2,
6432
16
        "GeneratorExp(expr elt, comprehension* generators)");
6433
16
    if (!state->GeneratorExp_type) return -1;
6434
16
    state->Await_type = make_type(state, "Await", state->expr_type,
6435
16
                                  Await_fields, 1,
6436
16
        "Await(expr value)");
6437
16
    if (!state->Await_type) return -1;
6438
16
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6439
16
                                  Yield_fields, 1,
6440
16
        "Yield(expr? value)");
6441
16
    if (!state->Yield_type) return -1;
6442
16
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6443
0
        return -1;
6444
16
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6445
16
                                      YieldFrom_fields, 1,
6446
16
        "YieldFrom(expr value)");
6447
16
    if (!state->YieldFrom_type) return -1;
6448
16
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6449
16
                                    Compare_fields, 3,
6450
16
        "Compare(expr left, cmpop* ops, expr* comparators)");
6451
16
    if (!state->Compare_type) return -1;
6452
16
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6453
16
                                 3,
6454
16
        "Call(expr func, expr* args, keyword* keywords)");
6455
16
    if (!state->Call_type) return -1;
6456
16
    state->FormattedValue_type = make_type(state, "FormattedValue",
6457
16
                                           state->expr_type,
6458
16
                                           FormattedValue_fields, 3,
6459
16
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6460
16
    if (!state->FormattedValue_type) return -1;
6461
16
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6462
16
        Py_None) == -1)
6463
0
        return -1;
6464
16
    state->Interpolation_type = make_type(state, "Interpolation",
6465
16
                                          state->expr_type,
6466
16
                                          Interpolation_fields, 4,
6467
16
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6468
16
    if (!state->Interpolation_type) return -1;
6469
16
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6470
16
        Py_None) == -1)
6471
0
        return -1;
6472
16
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6473
16
                                      JoinedStr_fields, 1,
6474
16
        "JoinedStr(expr* values)");
6475
16
    if (!state->JoinedStr_type) return -1;
6476
16
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6477
16
                                        TemplateStr_fields, 1,
6478
16
        "TemplateStr(expr* values)");
6479
16
    if (!state->TemplateStr_type) return -1;
6480
16
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6481
16
                                     Constant_fields, 2,
6482
16
        "Constant(constant value, string? kind)");
6483
16
    if (!state->Constant_type) return -1;
6484
16
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6485
0
        return -1;
6486
16
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6487
16
                                      Attribute_fields, 3,
6488
16
        "Attribute(expr value, identifier attr, expr_context ctx)");
6489
16
    if (!state->Attribute_type) return -1;
6490
16
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6491
16
                                      Subscript_fields, 3,
6492
16
        "Subscript(expr value, expr slice, expr_context ctx)");
6493
16
    if (!state->Subscript_type) return -1;
6494
16
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6495
16
                                    Starred_fields, 2,
6496
16
        "Starred(expr value, expr_context ctx)");
6497
16
    if (!state->Starred_type) return -1;
6498
16
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6499
16
                                 2,
6500
16
        "Name(identifier id, expr_context ctx)");
6501
16
    if (!state->Name_type) return -1;
6502
16
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6503
16
                                 2,
6504
16
        "List(expr* elts, expr_context ctx)");
6505
16
    if (!state->List_type) return -1;
6506
16
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6507
16
                                  Tuple_fields, 2,
6508
16
        "Tuple(expr* elts, expr_context ctx)");
6509
16
    if (!state->Tuple_type) return -1;
6510
16
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6511
16
                                  Slice_fields, 3,
6512
16
        "Slice(expr? lower, expr? upper, expr? step)");
6513
16
    if (!state->Slice_type) return -1;
6514
16
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6515
0
        return -1;
6516
16
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6517
0
        return -1;
6518
16
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6519
0
        return -1;
6520
16
    state->expr_context_type = make_type(state, "expr_context",
6521
16
                                         state->AST_type, NULL, 0,
6522
16
        "expr_context = Load | Store | Del");
6523
16
    if (!state->expr_context_type) return -1;
6524
16
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6525
16
    if (PySet_Add(state->abstract_types, state->expr_context_type) < 0) return
6526
0
        -1;
6527
16
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6528
16
                                 0,
6529
16
        "Load");
6530
16
    if (!state->Load_type) return -1;
6531
16
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6532
16
                                              NULL, NULL);
6533
16
    if (!state->Load_singleton) return -1;
6534
16
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6535
16
                                  NULL, 0,
6536
16
        "Store");
6537
16
    if (!state->Store_type) return -1;
6538
16
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6539
16
                                               *)state->Store_type, NULL, NULL);
6540
16
    if (!state->Store_singleton) return -1;
6541
16
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6542
16
        "Del");
6543
16
    if (!state->Del_type) return -1;
6544
16
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6545
16
                                             NULL, NULL);
6546
16
    if (!state->Del_singleton) return -1;
6547
16
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6548
16
        "boolop = And | Or");
6549
16
    if (!state->boolop_type) return -1;
6550
16
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6551
16
    if (PySet_Add(state->abstract_types, state->boolop_type) < 0) return -1;
6552
16
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6553
16
        "And");
6554
16
    if (!state->And_type) return -1;
6555
16
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6556
16
                                             NULL, NULL);
6557
16
    if (!state->And_singleton) return -1;
6558
16
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6559
16
        "Or");
6560
16
    if (!state->Or_type) return -1;
6561
16
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6562
16
                                            NULL, NULL);
6563
16
    if (!state->Or_singleton) return -1;
6564
16
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6565
16
                                     0,
6566
16
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6567
16
    if (!state->operator_type) return -1;
6568
16
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6569
16
    if (PySet_Add(state->abstract_types, state->operator_type) < 0) return -1;
6570
16
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6571
16
        "Add");
6572
16
    if (!state->Add_type) return -1;
6573
16
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6574
16
                                             NULL, NULL);
6575
16
    if (!state->Add_singleton) return -1;
6576
16
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6577
16
        "Sub");
6578
16
    if (!state->Sub_type) return -1;
6579
16
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6580
16
                                             NULL, NULL);
6581
16
    if (!state->Sub_singleton) return -1;
6582
16
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6583
16
        "Mult");
6584
16
    if (!state->Mult_type) return -1;
6585
16
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6586
16
                                              NULL, NULL);
6587
16
    if (!state->Mult_singleton) return -1;
6588
16
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6589
16
                                    NULL, 0,
6590
16
        "MatMult");
6591
16
    if (!state->MatMult_type) return -1;
6592
16
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6593
16
                                                 *)state->MatMult_type, NULL,
6594
16
                                                 NULL);
6595
16
    if (!state->MatMult_singleton) return -1;
6596
16
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6597
16
        "Div");
6598
16
    if (!state->Div_type) return -1;
6599
16
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6600
16
                                             NULL, NULL);
6601
16
    if (!state->Div_singleton) return -1;
6602
16
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6603
16
        "Mod");
6604
16
    if (!state->Mod_type) return -1;
6605
16
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6606
16
                                             NULL, NULL);
6607
16
    if (!state->Mod_singleton) return -1;
6608
16
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6609
16
        "Pow");
6610
16
    if (!state->Pow_type) return -1;
6611
16
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6612
16
                                             NULL, NULL);
6613
16
    if (!state->Pow_singleton) return -1;
6614
16
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6615
16
                                   0,
6616
16
        "LShift");
6617
16
    if (!state->LShift_type) return -1;
6618
16
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6619
16
                                                *)state->LShift_type, NULL,
6620
16
                                                NULL);
6621
16
    if (!state->LShift_singleton) return -1;
6622
16
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6623
16
                                   0,
6624
16
        "RShift");
6625
16
    if (!state->RShift_type) return -1;
6626
16
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6627
16
                                                *)state->RShift_type, NULL,
6628
16
                                                NULL);
6629
16
    if (!state->RShift_singleton) return -1;
6630
16
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6631
16
        "BitOr");
6632
16
    if (!state->BitOr_type) return -1;
6633
16
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6634
16
                                               *)state->BitOr_type, NULL, NULL);
6635
16
    if (!state->BitOr_singleton) return -1;
6636
16
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6637
16
                                   0,
6638
16
        "BitXor");
6639
16
    if (!state->BitXor_type) return -1;
6640
16
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6641
16
                                                *)state->BitXor_type, NULL,
6642
16
                                                NULL);
6643
16
    if (!state->BitXor_singleton) return -1;
6644
16
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6645
16
                                   0,
6646
16
        "BitAnd");
6647
16
    if (!state->BitAnd_type) return -1;
6648
16
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6649
16
                                                *)state->BitAnd_type, NULL,
6650
16
                                                NULL);
6651
16
    if (!state->BitAnd_singleton) return -1;
6652
16
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6653
16
                                     NULL, 0,
6654
16
        "FloorDiv");
6655
16
    if (!state->FloorDiv_type) return -1;
6656
16
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6657
16
                                                  *)state->FloorDiv_type, NULL,
6658
16
                                                  NULL);
6659
16
    if (!state->FloorDiv_singleton) return -1;
6660
16
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6661
16
        "unaryop = Invert | Not | UAdd | USub");
6662
16
    if (!state->unaryop_type) return -1;
6663
16
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6664
16
    if (PySet_Add(state->abstract_types, state->unaryop_type) < 0) return -1;
6665
16
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6666
16
                                   0,
6667
16
        "Invert");
6668
16
    if (!state->Invert_type) return -1;
6669
16
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6670
16
                                                *)state->Invert_type, NULL,
6671
16
                                                NULL);
6672
16
    if (!state->Invert_singleton) return -1;
6673
16
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6674
16
        "Not");
6675
16
    if (!state->Not_type) return -1;
6676
16
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6677
16
                                             NULL, NULL);
6678
16
    if (!state->Not_singleton) return -1;
6679
16
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6680
16
        "UAdd");
6681
16
    if (!state->UAdd_type) return -1;
6682
16
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6683
16
                                              NULL, NULL);
6684
16
    if (!state->UAdd_singleton) return -1;
6685
16
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6686
16
        "USub");
6687
16
    if (!state->USub_type) return -1;
6688
16
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6689
16
                                              NULL, NULL);
6690
16
    if (!state->USub_singleton) return -1;
6691
16
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6692
16
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6693
16
    if (!state->cmpop_type) return -1;
6694
16
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6695
16
    if (PySet_Add(state->abstract_types, state->cmpop_type) < 0) return -1;
6696
16
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6697
16
        "Eq");
6698
16
    if (!state->Eq_type) return -1;
6699
16
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6700
16
                                            NULL, NULL);
6701
16
    if (!state->Eq_singleton) return -1;
6702
16
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6703
16
        "NotEq");
6704
16
    if (!state->NotEq_type) return -1;
6705
16
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6706
16
                                               *)state->NotEq_type, NULL, NULL);
6707
16
    if (!state->NotEq_singleton) return -1;
6708
16
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6709
16
        "Lt");
6710
16
    if (!state->Lt_type) return -1;
6711
16
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6712
16
                                            NULL, NULL);
6713
16
    if (!state->Lt_singleton) return -1;
6714
16
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6715
16
        "LtE");
6716
16
    if (!state->LtE_type) return -1;
6717
16
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6718
16
                                             NULL, NULL);
6719
16
    if (!state->LtE_singleton) return -1;
6720
16
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6721
16
        "Gt");
6722
16
    if (!state->Gt_type) return -1;
6723
16
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6724
16
                                            NULL, NULL);
6725
16
    if (!state->Gt_singleton) return -1;
6726
16
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6727
16
        "GtE");
6728
16
    if (!state->GtE_type) return -1;
6729
16
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6730
16
                                             NULL, NULL);
6731
16
    if (!state->GtE_singleton) return -1;
6732
16
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6733
16
        "Is");
6734
16
    if (!state->Is_type) return -1;
6735
16
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6736
16
                                            NULL, NULL);
6737
16
    if (!state->Is_singleton) return -1;
6738
16
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6739
16
        "IsNot");
6740
16
    if (!state->IsNot_type) return -1;
6741
16
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6742
16
                                               *)state->IsNot_type, NULL, NULL);
6743
16
    if (!state->IsNot_singleton) return -1;
6744
16
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6745
16
        "In");
6746
16
    if (!state->In_type) return -1;
6747
16
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6748
16
                                            NULL, NULL);
6749
16
    if (!state->In_singleton) return -1;
6750
16
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6751
16
        "NotIn");
6752
16
    if (!state->NotIn_type) return -1;
6753
16
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6754
16
                                               *)state->NotIn_type, NULL, NULL);
6755
16
    if (!state->NotIn_singleton) return -1;
6756
16
    state->comprehension_type = make_type(state, "comprehension",
6757
16
                                          state->AST_type,
6758
16
                                          comprehension_fields, 4,
6759
16
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6760
16
    if (!state->comprehension_type) return -1;
6761
16
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6762
0
        -1;
6763
16
    state->excepthandler_type = make_type(state, "excepthandler",
6764
16
                                          state->AST_type, NULL, 0,
6765
16
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6766
16
    if (!state->excepthandler_type) return -1;
6767
16
    if (add_attributes(state, state->excepthandler_type,
6768
16
        excepthandler_attributes, 4) < 0) return -1;
6769
16
    if (PySet_Add(state->abstract_types, state->excepthandler_type) < 0) return
6770
0
        -1;
6771
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6772
16
        == -1)
6773
0
        return -1;
6774
16
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6775
16
        Py_None) == -1)
6776
0
        return -1;
6777
16
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6778
16
                                          state->excepthandler_type,
6779
16
                                          ExceptHandler_fields, 3,
6780
16
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6781
16
    if (!state->ExceptHandler_type) return -1;
6782
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6783
0
        return -1;
6784
16
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6785
0
        return -1;
6786
16
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6787
16
                                      arguments_fields, 7,
6788
16
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6789
16
    if (!state->arguments_type) return -1;
6790
16
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6791
16
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6792
0
        return -1;
6793
16
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6794
0
        return -1;
6795
16
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6796
16
        "arg(identifier arg, expr? annotation, string? type_comment)");
6797
16
    if (!state->arg_type) return -1;
6798
16
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6799
0
        -1;
6800
16
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6801
0
        return -1;
6802
16
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6803
0
        return -1;
6804
16
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6805
0
        return -1;
6806
16
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6807
0
        return -1;
6808
16
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6809
16
                                    keyword_fields, 2,
6810
16
        "keyword(identifier? arg, expr value)");
6811
16
    if (!state->keyword_type) return -1;
6812
16
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6813
0
        return -1;
6814
16
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6815
0
        return -1;
6816
16
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6817
0
        return -1;
6818
16
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6819
16
        == -1)
6820
0
        return -1;
6821
16
    state->alias_type = make_type(state, "alias", state->AST_type,
6822
16
                                  alias_fields, 2,
6823
16
        "alias(identifier name, identifier? asname)");
6824
16
    if (!state->alias_type) return -1;
6825
16
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6826
0
        return -1;
6827
16
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6828
0
        return -1;
6829
16
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6830
0
        return -1;
6831
16
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6832
16
        -1)
6833
0
        return -1;
6834
16
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6835
16
                                     withitem_fields, 2,
6836
16
        "withitem(expr context_expr, expr? optional_vars)");
6837
16
    if (!state->withitem_type) return -1;
6838
16
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6839
16
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6840
16
        == -1)
6841
0
        return -1;
6842
16
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6843
16
                                       match_case_fields, 3,
6844
16
        "match_case(pattern pattern, expr? guard, stmt* body)");
6845
16
    if (!state->match_case_type) return -1;
6846
16
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6847
16
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6848
0
        return -1;
6849
16
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6850
16
        "pattern = MatchValue(expr value)\n"
6851
16
        "        | MatchSingleton(constant value)\n"
6852
16
        "        | MatchSequence(pattern* patterns)\n"
6853
16
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6854
16
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6855
16
        "        | MatchStar(identifier? name)\n"
6856
16
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6857
16
        "        | MatchOr(pattern* patterns)");
6858
16
    if (!state->pattern_type) return -1;
6859
16
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6860
0
        return -1;
6861
16
    if (PySet_Add(state->abstract_types, state->pattern_type) < 0) return -1;
6862
16
    state->MatchValue_type = make_type(state, "MatchValue",
6863
16
                                       state->pattern_type, MatchValue_fields,
6864
16
                                       1,
6865
16
        "MatchValue(expr value)");
6866
16
    if (!state->MatchValue_type) return -1;
6867
16
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6868
16
                                           state->pattern_type,
6869
16
                                           MatchSingleton_fields, 1,
6870
16
        "MatchSingleton(constant value)");
6871
16
    if (!state->MatchSingleton_type) return -1;
6872
16
    state->MatchSequence_type = make_type(state, "MatchSequence",
6873
16
                                          state->pattern_type,
6874
16
                                          MatchSequence_fields, 1,
6875
16
        "MatchSequence(pattern* patterns)");
6876
16
    if (!state->MatchSequence_type) return -1;
6877
16
    state->MatchMapping_type = make_type(state, "MatchMapping",
6878
16
                                         state->pattern_type,
6879
16
                                         MatchMapping_fields, 3,
6880
16
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6881
16
    if (!state->MatchMapping_type) return -1;
6882
16
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6883
0
        return -1;
6884
16
    state->MatchClass_type = make_type(state, "MatchClass",
6885
16
                                       state->pattern_type, MatchClass_fields,
6886
16
                                       4,
6887
16
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6888
16
    if (!state->MatchClass_type) return -1;
6889
16
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6890
16
                                      MatchStar_fields, 1,
6891
16
        "MatchStar(identifier? name)");
6892
16
    if (!state->MatchStar_type) return -1;
6893
16
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6894
0
        return -1;
6895
16
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6896
16
                                    MatchAs_fields, 2,
6897
16
        "MatchAs(pattern? pattern, identifier? name)");
6898
16
    if (!state->MatchAs_type) return -1;
6899
16
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6900
0
        return -1;
6901
16
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6902
0
        return -1;
6903
16
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6904
16
                                    MatchOr_fields, 1,
6905
16
        "MatchOr(pattern* patterns)");
6906
16
    if (!state->MatchOr_type) return -1;
6907
16
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6908
16
                                        NULL, 0,
6909
16
        "type_ignore = TypeIgnore(int lineno, string tag)");
6910
16
    if (!state->type_ignore_type) return -1;
6911
16
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6912
16
    if (PySet_Add(state->abstract_types, state->type_ignore_type) < 0) return
6913
0
        -1;
6914
16
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6915
16
                                       state->type_ignore_type,
6916
16
                                       TypeIgnore_fields, 2,
6917
16
        "TypeIgnore(int lineno, string tag)");
6918
16
    if (!state->TypeIgnore_type) return -1;
6919
16
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6920
16
                                       NULL, 0,
6921
16
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6922
16
        "           | ParamSpec(identifier name, expr? default_value)\n"
6923
16
        "           | TypeVarTuple(identifier name, expr? default_value)");
6924
16
    if (!state->type_param_type) return -1;
6925
16
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6926
16
        < 0) return -1;
6927
16
    if (PySet_Add(state->abstract_types, state->type_param_type) < 0) return -1;
6928
16
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6929
16
                                    TypeVar_fields, 3,
6930
16
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6931
16
    if (!state->TypeVar_type) return -1;
6932
16
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6933
0
        return -1;
6934
16
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6935
16
        -1)
6936
0
        return -1;
6937
16
    state->ParamSpec_type = make_type(state, "ParamSpec",
6938
16
                                      state->type_param_type, ParamSpec_fields,
6939
16
                                      2,
6940
16
        "ParamSpec(identifier name, expr? default_value)");
6941
16
    if (!state->ParamSpec_type) return -1;
6942
16
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6943
16
        == -1)
6944
0
        return -1;
6945
16
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6946
16
                                         state->type_param_type,
6947
16
                                         TypeVarTuple_fields, 2,
6948
16
        "TypeVarTuple(identifier name, expr? default_value)");
6949
16
    if (!state->TypeVarTuple_type) return -1;
6950
16
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6951
16
        Py_None) == -1)
6952
0
        return -1;
6953
6954
16
    if (!add_ast_annotations(state)) {
6955
0
        return -1;
6956
0
    }
6957
16
    return 0;
6958
16
}
6959
6960
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6961
                       const char* field, PyArena* arena);
6962
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6963
                        const char* field, PyArena* arena);
6964
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6965
                        const char* field, PyArena* arena);
6966
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6967
                                expr_context_ty* out, const char* field,
6968
                                PyArena* arena);
6969
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
6970
                          out, const char* field, PyArena* arena);
6971
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
6972
                            operator_ty* out, const char* field, PyArena*
6973
                            arena);
6974
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
6975
                           out, const char* field, PyArena* arena);
6976
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
6977
                         const char* field, PyArena* arena);
6978
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
6979
                                 comprehension_ty* out, const char* field,
6980
                                 PyArena* arena);
6981
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
6982
                                 excepthandler_ty* out, const char* field,
6983
                                 PyArena* arena);
6984
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
6985
                             arguments_ty* out, const char* field, PyArena*
6986
                             arena);
6987
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
6988
                       const char* field, PyArena* arena);
6989
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
6990
                           out, const char* field, PyArena* arena);
6991
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
6992
                         const char* field, PyArena* arena);
6993
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
6994
                            withitem_ty* out, const char* field, PyArena*
6995
                            arena);
6996
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
6997
                              match_case_ty* out, const char* field, PyArena*
6998
                              arena);
6999
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
7000
                           out, const char* field, PyArena* arena);
7001
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
7002
                               type_ignore_ty* out, const char* field, PyArena*
7003
                               arena);
7004
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
7005
                              type_param_ty* out, const char* field, PyArena*
7006
                              arena);
7007
7008
mod_ty
7009
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
7010
              PyArena *arena)
7011
7.22k
{
7012
7.22k
    mod_ty p;
7013
7.22k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7014
7.22k
    if (!p)
7015
0
        return NULL;
7016
7.22k
    p->kind = Module_kind;
7017
7.22k
    p->v.Module.body = body;
7018
7.22k
    p->v.Module.type_ignores = type_ignores;
7019
7.22k
    return p;
7020
7.22k
}
7021
7022
mod_ty
7023
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7024
0
{
7025
0
    mod_ty p;
7026
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7027
0
    if (!p)
7028
0
        return NULL;
7029
0
    p->kind = Interactive_kind;
7030
0
    p->v.Interactive.body = body;
7031
0
    return p;
7032
0
}
7033
7034
mod_ty
7035
_PyAST_Expression(expr_ty body, PyArena *arena)
7036
224
{
7037
224
    mod_ty p;
7038
224
    if (!body) {
7039
0
        PyErr_SetString(PyExc_ValueError,
7040
0
                        "field 'body' is required for Expression");
7041
0
        return NULL;
7042
0
    }
7043
224
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7044
224
    if (!p)
7045
0
        return NULL;
7046
224
    p->kind = Expression_kind;
7047
224
    p->v.Expression.body = body;
7048
224
    return p;
7049
224
}
7050
7051
mod_ty
7052
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7053
0
{
7054
0
    mod_ty p;
7055
0
    if (!returns) {
7056
0
        PyErr_SetString(PyExc_ValueError,
7057
0
                        "field 'returns' is required for FunctionType");
7058
0
        return NULL;
7059
0
    }
7060
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7061
0
    if (!p)
7062
0
        return NULL;
7063
0
    p->kind = FunctionType_kind;
7064
0
    p->v.FunctionType.argtypes = argtypes;
7065
0
    p->v.FunctionType.returns = returns;
7066
0
    return p;
7067
0
}
7068
7069
stmt_ty
7070
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7071
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7072
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7073
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7074
                   *arena)
7075
5.56k
{
7076
5.56k
    stmt_ty p;
7077
5.56k
    if (!name) {
7078
0
        PyErr_SetString(PyExc_ValueError,
7079
0
                        "field 'name' is required for FunctionDef");
7080
0
        return NULL;
7081
0
    }
7082
5.56k
    if (!args) {
7083
0
        PyErr_SetString(PyExc_ValueError,
7084
0
                        "field 'args' is required for FunctionDef");
7085
0
        return NULL;
7086
0
    }
7087
5.56k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7088
5.56k
    if (!p)
7089
0
        return NULL;
7090
5.56k
    p->kind = FunctionDef_kind;
7091
5.56k
    p->v.FunctionDef.name = name;
7092
5.56k
    p->v.FunctionDef.args = args;
7093
5.56k
    p->v.FunctionDef.body = body;
7094
5.56k
    p->v.FunctionDef.decorator_list = decorator_list;
7095
5.56k
    p->v.FunctionDef.returns = returns;
7096
5.56k
    p->v.FunctionDef.type_comment = type_comment;
7097
5.56k
    p->v.FunctionDef.type_params = type_params;
7098
5.56k
    p->lineno = lineno;
7099
5.56k
    p->col_offset = col_offset;
7100
5.56k
    p->end_lineno = end_lineno;
7101
5.56k
    p->end_col_offset = end_col_offset;
7102
5.56k
    return p;
7103
5.56k
}
7104
7105
stmt_ty
7106
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7107
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7108
                        string type_comment, asdl_type_param_seq * type_params,
7109
                        int lineno, int col_offset, int end_lineno, int
7110
                        end_col_offset, PyArena *arena)
7111
556
{
7112
556
    stmt_ty p;
7113
556
    if (!name) {
7114
0
        PyErr_SetString(PyExc_ValueError,
7115
0
                        "field 'name' is required for AsyncFunctionDef");
7116
0
        return NULL;
7117
0
    }
7118
556
    if (!args) {
7119
0
        PyErr_SetString(PyExc_ValueError,
7120
0
                        "field 'args' is required for AsyncFunctionDef");
7121
0
        return NULL;
7122
0
    }
7123
556
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7124
556
    if (!p)
7125
0
        return NULL;
7126
556
    p->kind = AsyncFunctionDef_kind;
7127
556
    p->v.AsyncFunctionDef.name = name;
7128
556
    p->v.AsyncFunctionDef.args = args;
7129
556
    p->v.AsyncFunctionDef.body = body;
7130
556
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7131
556
    p->v.AsyncFunctionDef.returns = returns;
7132
556
    p->v.AsyncFunctionDef.type_comment = type_comment;
7133
556
    p->v.AsyncFunctionDef.type_params = type_params;
7134
556
    p->lineno = lineno;
7135
556
    p->col_offset = col_offset;
7136
556
    p->end_lineno = end_lineno;
7137
556
    p->end_col_offset = end_col_offset;
7138
556
    return p;
7139
556
}
7140
7141
stmt_ty
7142
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7143
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7144
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7145
                int end_lineno, int end_col_offset, PyArena *arena)
7146
2.82k
{
7147
2.82k
    stmt_ty p;
7148
2.82k
    if (!name) {
7149
0
        PyErr_SetString(PyExc_ValueError,
7150
0
                        "field 'name' is required for ClassDef");
7151
0
        return NULL;
7152
0
    }
7153
2.82k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7154
2.82k
    if (!p)
7155
0
        return NULL;
7156
2.82k
    p->kind = ClassDef_kind;
7157
2.82k
    p->v.ClassDef.name = name;
7158
2.82k
    p->v.ClassDef.bases = bases;
7159
2.82k
    p->v.ClassDef.keywords = keywords;
7160
2.82k
    p->v.ClassDef.body = body;
7161
2.82k
    p->v.ClassDef.decorator_list = decorator_list;
7162
2.82k
    p->v.ClassDef.type_params = type_params;
7163
2.82k
    p->lineno = lineno;
7164
2.82k
    p->col_offset = col_offset;
7165
2.82k
    p->end_lineno = end_lineno;
7166
2.82k
    p->end_col_offset = end_col_offset;
7167
2.82k
    return p;
7168
2.82k
}
7169
7170
stmt_ty
7171
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7172
              end_col_offset, PyArena *arena)
7173
2.60k
{
7174
2.60k
    stmt_ty p;
7175
2.60k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7176
2.60k
    if (!p)
7177
0
        return NULL;
7178
2.60k
    p->kind = Return_kind;
7179
2.60k
    p->v.Return.value = value;
7180
2.60k
    p->lineno = lineno;
7181
2.60k
    p->col_offset = col_offset;
7182
2.60k
    p->end_lineno = end_lineno;
7183
2.60k
    p->end_col_offset = end_col_offset;
7184
2.60k
    return p;
7185
2.60k
}
7186
7187
stmt_ty
7188
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7189
              end_lineno, int end_col_offset, PyArena *arena)
7190
432
{
7191
432
    stmt_ty p;
7192
432
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7193
432
    if (!p)
7194
0
        return NULL;
7195
432
    p->kind = Delete_kind;
7196
432
    p->v.Delete.targets = targets;
7197
432
    p->lineno = lineno;
7198
432
    p->col_offset = col_offset;
7199
432
    p->end_lineno = end_lineno;
7200
432
    p->end_col_offset = end_col_offset;
7201
432
    return p;
7202
432
}
7203
7204
stmt_ty
7205
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7206
              lineno, int col_offset, int end_lineno, int end_col_offset,
7207
              PyArena *arena)
7208
4.76k
{
7209
4.76k
    stmt_ty p;
7210
4.76k
    if (!value) {
7211
0
        PyErr_SetString(PyExc_ValueError,
7212
0
                        "field 'value' is required for Assign");
7213
0
        return NULL;
7214
0
    }
7215
4.76k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7216
4.76k
    if (!p)
7217
0
        return NULL;
7218
4.76k
    p->kind = Assign_kind;
7219
4.76k
    p->v.Assign.targets = targets;
7220
4.76k
    p->v.Assign.value = value;
7221
4.76k
    p->v.Assign.type_comment = type_comment;
7222
4.76k
    p->lineno = lineno;
7223
4.76k
    p->col_offset = col_offset;
7224
4.76k
    p->end_lineno = end_lineno;
7225
4.76k
    p->end_col_offset = end_col_offset;
7226
4.76k
    return p;
7227
4.76k
}
7228
7229
stmt_ty
7230
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7231
                 value, int lineno, int col_offset, int end_lineno, int
7232
                 end_col_offset, PyArena *arena)
7233
282
{
7234
282
    stmt_ty p;
7235
282
    if (!name) {
7236
0
        PyErr_SetString(PyExc_ValueError,
7237
0
                        "field 'name' is required for TypeAlias");
7238
0
        return NULL;
7239
0
    }
7240
282
    if (!value) {
7241
0
        PyErr_SetString(PyExc_ValueError,
7242
0
                        "field 'value' is required for TypeAlias");
7243
0
        return NULL;
7244
0
    }
7245
282
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7246
282
    if (!p)
7247
0
        return NULL;
7248
282
    p->kind = TypeAlias_kind;
7249
282
    p->v.TypeAlias.name = name;
7250
282
    p->v.TypeAlias.type_params = type_params;
7251
282
    p->v.TypeAlias.value = value;
7252
282
    p->lineno = lineno;
7253
282
    p->col_offset = col_offset;
7254
282
    p->end_lineno = end_lineno;
7255
282
    p->end_col_offset = end_col_offset;
7256
282
    return p;
7257
282
}
7258
7259
stmt_ty
7260
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7261
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7262
2.22k
{
7263
2.22k
    stmt_ty p;
7264
2.22k
    if (!target) {
7265
0
        PyErr_SetString(PyExc_ValueError,
7266
0
                        "field 'target' is required for AugAssign");
7267
0
        return NULL;
7268
0
    }
7269
2.22k
    if (!op) {
7270
0
        PyErr_SetString(PyExc_ValueError,
7271
0
                        "field 'op' is required for AugAssign");
7272
0
        return NULL;
7273
0
    }
7274
2.22k
    if (!value) {
7275
0
        PyErr_SetString(PyExc_ValueError,
7276
0
                        "field 'value' is required for AugAssign");
7277
0
        return NULL;
7278
0
    }
7279
2.22k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7280
2.22k
    if (!p)
7281
0
        return NULL;
7282
2.22k
    p->kind = AugAssign_kind;
7283
2.22k
    p->v.AugAssign.target = target;
7284
2.22k
    p->v.AugAssign.op = op;
7285
2.22k
    p->v.AugAssign.value = value;
7286
2.22k
    p->lineno = lineno;
7287
2.22k
    p->col_offset = col_offset;
7288
2.22k
    p->end_lineno = end_lineno;
7289
2.22k
    p->end_col_offset = end_col_offset;
7290
2.22k
    return p;
7291
2.22k
}
7292
7293
stmt_ty
7294
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7295
                 int lineno, int col_offset, int end_lineno, int
7296
                 end_col_offset, PyArena *arena)
7297
2.70k
{
7298
2.70k
    stmt_ty p;
7299
2.70k
    if (!target) {
7300
0
        PyErr_SetString(PyExc_ValueError,
7301
0
                        "field 'target' is required for AnnAssign");
7302
0
        return NULL;
7303
0
    }
7304
2.70k
    if (!annotation) {
7305
0
        PyErr_SetString(PyExc_ValueError,
7306
0
                        "field 'annotation' is required for AnnAssign");
7307
0
        return NULL;
7308
0
    }
7309
2.70k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7310
2.70k
    if (!p)
7311
0
        return NULL;
7312
2.70k
    p->kind = AnnAssign_kind;
7313
2.70k
    p->v.AnnAssign.target = target;
7314
2.70k
    p->v.AnnAssign.annotation = annotation;
7315
2.70k
    p->v.AnnAssign.value = value;
7316
2.70k
    p->v.AnnAssign.simple = simple;
7317
2.70k
    p->lineno = lineno;
7318
2.70k
    p->col_offset = col_offset;
7319
2.70k
    p->end_lineno = end_lineno;
7320
2.70k
    p->end_col_offset = end_col_offset;
7321
2.70k
    return p;
7322
2.70k
}
7323
7324
stmt_ty
7325
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7326
           orelse, string type_comment, int lineno, int col_offset, int
7327
           end_lineno, int end_col_offset, PyArena *arena)
7328
926
{
7329
926
    stmt_ty p;
7330
926
    if (!target) {
7331
0
        PyErr_SetString(PyExc_ValueError,
7332
0
                        "field 'target' is required for For");
7333
0
        return NULL;
7334
0
    }
7335
926
    if (!iter) {
7336
0
        PyErr_SetString(PyExc_ValueError,
7337
0
                        "field 'iter' is required for For");
7338
0
        return NULL;
7339
0
    }
7340
926
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7341
926
    if (!p)
7342
0
        return NULL;
7343
926
    p->kind = For_kind;
7344
926
    p->v.For.target = target;
7345
926
    p->v.For.iter = iter;
7346
926
    p->v.For.body = body;
7347
926
    p->v.For.orelse = orelse;
7348
926
    p->v.For.type_comment = type_comment;
7349
926
    p->lineno = lineno;
7350
926
    p->col_offset = col_offset;
7351
926
    p->end_lineno = end_lineno;
7352
926
    p->end_col_offset = end_col_offset;
7353
926
    return p;
7354
926
}
7355
7356
stmt_ty
7357
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7358
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7359
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7360
720
{
7361
720
    stmt_ty p;
7362
720
    if (!target) {
7363
0
        PyErr_SetString(PyExc_ValueError,
7364
0
                        "field 'target' is required for AsyncFor");
7365
0
        return NULL;
7366
0
    }
7367
720
    if (!iter) {
7368
0
        PyErr_SetString(PyExc_ValueError,
7369
0
                        "field 'iter' is required for AsyncFor");
7370
0
        return NULL;
7371
0
    }
7372
720
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7373
720
    if (!p)
7374
0
        return NULL;
7375
720
    p->kind = AsyncFor_kind;
7376
720
    p->v.AsyncFor.target = target;
7377
720
    p->v.AsyncFor.iter = iter;
7378
720
    p->v.AsyncFor.body = body;
7379
720
    p->v.AsyncFor.orelse = orelse;
7380
720
    p->v.AsyncFor.type_comment = type_comment;
7381
720
    p->lineno = lineno;
7382
720
    p->col_offset = col_offset;
7383
720
    p->end_lineno = end_lineno;
7384
720
    p->end_col_offset = end_col_offset;
7385
720
    return p;
7386
720
}
7387
7388
stmt_ty
7389
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7390
             lineno, int col_offset, int end_lineno, int end_col_offset,
7391
             PyArena *arena)
7392
941
{
7393
941
    stmt_ty p;
7394
941
    if (!test) {
7395
0
        PyErr_SetString(PyExc_ValueError,
7396
0
                        "field 'test' is required for While");
7397
0
        return NULL;
7398
0
    }
7399
941
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7400
941
    if (!p)
7401
0
        return NULL;
7402
941
    p->kind = While_kind;
7403
941
    p->v.While.test = test;
7404
941
    p->v.While.body = body;
7405
941
    p->v.While.orelse = orelse;
7406
941
    p->lineno = lineno;
7407
941
    p->col_offset = col_offset;
7408
941
    p->end_lineno = end_lineno;
7409
941
    p->end_col_offset = end_col_offset;
7410
941
    return p;
7411
941
}
7412
7413
stmt_ty
7414
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7415
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7416
          *arena)
7417
3.69k
{
7418
3.69k
    stmt_ty p;
7419
3.69k
    if (!test) {
7420
0
        PyErr_SetString(PyExc_ValueError,
7421
0
                        "field 'test' is required for If");
7422
0
        return NULL;
7423
0
    }
7424
3.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7425
3.69k
    if (!p)
7426
0
        return NULL;
7427
3.69k
    p->kind = If_kind;
7428
3.69k
    p->v.If.test = test;
7429
3.69k
    p->v.If.body = body;
7430
3.69k
    p->v.If.orelse = orelse;
7431
3.69k
    p->lineno = lineno;
7432
3.69k
    p->col_offset = col_offset;
7433
3.69k
    p->end_lineno = end_lineno;
7434
3.69k
    p->end_col_offset = end_col_offset;
7435
3.69k
    return p;
7436
3.69k
}
7437
7438
stmt_ty
7439
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7440
            type_comment, int lineno, int col_offset, int end_lineno, int
7441
            end_col_offset, PyArena *arena)
7442
2.28k
{
7443
2.28k
    stmt_ty p;
7444
2.28k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7445
2.28k
    if (!p)
7446
0
        return NULL;
7447
2.28k
    p->kind = With_kind;
7448
2.28k
    p->v.With.items = items;
7449
2.28k
    p->v.With.body = body;
7450
2.28k
    p->v.With.type_comment = type_comment;
7451
2.28k
    p->lineno = lineno;
7452
2.28k
    p->col_offset = col_offset;
7453
2.28k
    p->end_lineno = end_lineno;
7454
2.28k
    p->end_col_offset = end_col_offset;
7455
2.28k
    return p;
7456
2.28k
}
7457
7458
stmt_ty
7459
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7460
                 type_comment, int lineno, int col_offset, int end_lineno, int
7461
                 end_col_offset, PyArena *arena)
7462
790
{
7463
790
    stmt_ty p;
7464
790
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7465
790
    if (!p)
7466
0
        return NULL;
7467
790
    p->kind = AsyncWith_kind;
7468
790
    p->v.AsyncWith.items = items;
7469
790
    p->v.AsyncWith.body = body;
7470
790
    p->v.AsyncWith.type_comment = type_comment;
7471
790
    p->lineno = lineno;
7472
790
    p->col_offset = col_offset;
7473
790
    p->end_lineno = end_lineno;
7474
790
    p->end_col_offset = end_col_offset;
7475
790
    return p;
7476
790
}
7477
7478
stmt_ty
7479
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7480
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7481
800
{
7482
800
    stmt_ty p;
7483
800
    if (!subject) {
7484
0
        PyErr_SetString(PyExc_ValueError,
7485
0
                        "field 'subject' is required for Match");
7486
0
        return NULL;
7487
0
    }
7488
800
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7489
800
    if (!p)
7490
0
        return NULL;
7491
800
    p->kind = Match_kind;
7492
800
    p->v.Match.subject = subject;
7493
800
    p->v.Match.cases = cases;
7494
800
    p->lineno = lineno;
7495
800
    p->col_offset = col_offset;
7496
800
    p->end_lineno = end_lineno;
7497
800
    p->end_col_offset = end_col_offset;
7498
800
    return p;
7499
800
}
7500
7501
stmt_ty
7502
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7503
             end_lineno, int end_col_offset, PyArena *arena)
7504
1.94k
{
7505
1.94k
    stmt_ty p;
7506
1.94k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7507
1.94k
    if (!p)
7508
0
        return NULL;
7509
1.94k
    p->kind = Raise_kind;
7510
1.94k
    p->v.Raise.exc = exc;
7511
1.94k
    p->v.Raise.cause = cause;
7512
1.94k
    p->lineno = lineno;
7513
1.94k
    p->col_offset = col_offset;
7514
1.94k
    p->end_lineno = end_lineno;
7515
1.94k
    p->end_col_offset = end_col_offset;
7516
1.94k
    return p;
7517
1.94k
}
7518
7519
stmt_ty
7520
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7521
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7522
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7523
2.60k
{
7524
2.60k
    stmt_ty p;
7525
2.60k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7526
2.60k
    if (!p)
7527
0
        return NULL;
7528
2.60k
    p->kind = Try_kind;
7529
2.60k
    p->v.Try.body = body;
7530
2.60k
    p->v.Try.handlers = handlers;
7531
2.60k
    p->v.Try.orelse = orelse;
7532
2.60k
    p->v.Try.finalbody = finalbody;
7533
2.60k
    p->lineno = lineno;
7534
2.60k
    p->col_offset = col_offset;
7535
2.60k
    p->end_lineno = end_lineno;
7536
2.60k
    p->end_col_offset = end_col_offset;
7537
2.60k
    return p;
7538
2.60k
}
7539
7540
stmt_ty
7541
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7542
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7543
               int col_offset, int end_lineno, int end_col_offset, PyArena
7544
               *arena)
7545
1.73k
{
7546
1.73k
    stmt_ty p;
7547
1.73k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7548
1.73k
    if (!p)
7549
0
        return NULL;
7550
1.73k
    p->kind = TryStar_kind;
7551
1.73k
    p->v.TryStar.body = body;
7552
1.73k
    p->v.TryStar.handlers = handlers;
7553
1.73k
    p->v.TryStar.orelse = orelse;
7554
1.73k
    p->v.TryStar.finalbody = finalbody;
7555
1.73k
    p->lineno = lineno;
7556
1.73k
    p->col_offset = col_offset;
7557
1.73k
    p->end_lineno = end_lineno;
7558
1.73k
    p->end_col_offset = end_col_offset;
7559
1.73k
    return p;
7560
1.73k
}
7561
7562
stmt_ty
7563
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7564
              end_lineno, int end_col_offset, PyArena *arena)
7565
673
{
7566
673
    stmt_ty p;
7567
673
    if (!test) {
7568
0
        PyErr_SetString(PyExc_ValueError,
7569
0
                        "field 'test' is required for Assert");
7570
0
        return NULL;
7571
0
    }
7572
673
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7573
673
    if (!p)
7574
0
        return NULL;
7575
673
    p->kind = Assert_kind;
7576
673
    p->v.Assert.test = test;
7577
673
    p->v.Assert.msg = msg;
7578
673
    p->lineno = lineno;
7579
673
    p->col_offset = col_offset;
7580
673
    p->end_lineno = end_lineno;
7581
673
    p->end_col_offset = end_col_offset;
7582
673
    return p;
7583
673
}
7584
7585
stmt_ty
7586
_PyAST_Import(asdl_alias_seq * names, int is_lazy, int lineno, int col_offset,
7587
              int end_lineno, int end_col_offset, PyArena *arena)
7588
2.25k
{
7589
2.25k
    stmt_ty p;
7590
2.25k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7591
2.25k
    if (!p)
7592
0
        return NULL;
7593
2.25k
    p->kind = Import_kind;
7594
2.25k
    p->v.Import.names = names;
7595
2.25k
    p->v.Import.is_lazy = is_lazy;
7596
2.25k
    p->lineno = lineno;
7597
2.25k
    p->col_offset = col_offset;
7598
2.25k
    p->end_lineno = end_lineno;
7599
2.25k
    p->end_col_offset = end_col_offset;
7600
2.25k
    return p;
7601
2.25k
}
7602
7603
stmt_ty
7604
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7605
                  is_lazy, int lineno, int col_offset, int end_lineno, int
7606
                  end_col_offset, PyArena *arena)
7607
2.15k
{
7608
2.15k
    stmt_ty p;
7609
2.15k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7610
2.15k
    if (!p)
7611
0
        return NULL;
7612
2.15k
    p->kind = ImportFrom_kind;
7613
2.15k
    p->v.ImportFrom.module = module;
7614
2.15k
    p->v.ImportFrom.names = names;
7615
2.15k
    p->v.ImportFrom.level = level;
7616
2.15k
    p->v.ImportFrom.is_lazy = is_lazy;
7617
2.15k
    p->lineno = lineno;
7618
2.15k
    p->col_offset = col_offset;
7619
2.15k
    p->end_lineno = end_lineno;
7620
2.15k
    p->end_col_offset = end_col_offset;
7621
2.15k
    return p;
7622
2.15k
}
7623
7624
stmt_ty
7625
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7626
              end_lineno, int end_col_offset, PyArena *arena)
7627
566
{
7628
566
    stmt_ty p;
7629
566
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7630
566
    if (!p)
7631
0
        return NULL;
7632
566
    p->kind = Global_kind;
7633
566
    p->v.Global.names = names;
7634
566
    p->lineno = lineno;
7635
566
    p->col_offset = col_offset;
7636
566
    p->end_lineno = end_lineno;
7637
566
    p->end_col_offset = end_col_offset;
7638
566
    return p;
7639
566
}
7640
7641
stmt_ty
7642
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7643
                end_lineno, int end_col_offset, PyArena *arena)
7644
363
{
7645
363
    stmt_ty p;
7646
363
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7647
363
    if (!p)
7648
0
        return NULL;
7649
363
    p->kind = Nonlocal_kind;
7650
363
    p->v.Nonlocal.names = names;
7651
363
    p->lineno = lineno;
7652
363
    p->col_offset = col_offset;
7653
363
    p->end_lineno = end_lineno;
7654
363
    p->end_col_offset = end_col_offset;
7655
363
    return p;
7656
363
}
7657
7658
stmt_ty
7659
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7660
            end_col_offset, PyArena *arena)
7661
87.5k
{
7662
87.5k
    stmt_ty p;
7663
87.5k
    if (!value) {
7664
0
        PyErr_SetString(PyExc_ValueError,
7665
0
                        "field 'value' is required for Expr");
7666
0
        return NULL;
7667
0
    }
7668
87.5k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7669
87.5k
    if (!p)
7670
0
        return NULL;
7671
87.5k
    p->kind = Expr_kind;
7672
87.5k
    p->v.Expr.value = value;
7673
87.5k
    p->lineno = lineno;
7674
87.5k
    p->col_offset = col_offset;
7675
87.5k
    p->end_lineno = end_lineno;
7676
87.5k
    p->end_col_offset = end_col_offset;
7677
87.5k
    return p;
7678
87.5k
}
7679
7680
stmt_ty
7681
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7682
            PyArena *arena)
7683
1.40k
{
7684
1.40k
    stmt_ty p;
7685
1.40k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7686
1.40k
    if (!p)
7687
0
        return NULL;
7688
1.40k
    p->kind = Pass_kind;
7689
1.40k
    p->lineno = lineno;
7690
1.40k
    p->col_offset = col_offset;
7691
1.40k
    p->end_lineno = end_lineno;
7692
1.40k
    p->end_col_offset = end_col_offset;
7693
1.40k
    return p;
7694
1.40k
}
7695
7696
stmt_ty
7697
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7698
             PyArena *arena)
7699
1.35k
{
7700
1.35k
    stmt_ty p;
7701
1.35k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7702
1.35k
    if (!p)
7703
0
        return NULL;
7704
1.35k
    p->kind = Break_kind;
7705
1.35k
    p->lineno = lineno;
7706
1.35k
    p->col_offset = col_offset;
7707
1.35k
    p->end_lineno = end_lineno;
7708
1.35k
    p->end_col_offset = end_col_offset;
7709
1.35k
    return p;
7710
1.35k
}
7711
7712
stmt_ty
7713
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7714
                PyArena *arena)
7715
2.87k
{
7716
2.87k
    stmt_ty p;
7717
2.87k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7718
2.87k
    if (!p)
7719
0
        return NULL;
7720
2.87k
    p->kind = Continue_kind;
7721
2.87k
    p->lineno = lineno;
7722
2.87k
    p->col_offset = col_offset;
7723
2.87k
    p->end_lineno = end_lineno;
7724
2.87k
    p->end_col_offset = end_col_offset;
7725
2.87k
    return p;
7726
2.87k
}
7727
7728
expr_ty
7729
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7730
              int end_lineno, int end_col_offset, PyArena *arena)
7731
1.81k
{
7732
1.81k
    expr_ty p;
7733
1.81k
    if (!op) {
7734
0
        PyErr_SetString(PyExc_ValueError,
7735
0
                        "field 'op' is required for BoolOp");
7736
0
        return NULL;
7737
0
    }
7738
1.81k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7739
1.81k
    if (!p)
7740
0
        return NULL;
7741
1.81k
    p->kind = BoolOp_kind;
7742
1.81k
    p->v.BoolOp.op = op;
7743
1.81k
    p->v.BoolOp.values = values;
7744
1.81k
    p->lineno = lineno;
7745
1.81k
    p->col_offset = col_offset;
7746
1.81k
    p->end_lineno = end_lineno;
7747
1.81k
    p->end_col_offset = end_col_offset;
7748
1.81k
    return p;
7749
1.81k
}
7750
7751
expr_ty
7752
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7753
                 end_lineno, int end_col_offset, PyArena *arena)
7754
1.69k
{
7755
1.69k
    expr_ty p;
7756
1.69k
    if (!target) {
7757
0
        PyErr_SetString(PyExc_ValueError,
7758
0
                        "field 'target' is required for NamedExpr");
7759
0
        return NULL;
7760
0
    }
7761
1.69k
    if (!value) {
7762
0
        PyErr_SetString(PyExc_ValueError,
7763
0
                        "field 'value' is required for NamedExpr");
7764
0
        return NULL;
7765
0
    }
7766
1.69k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7767
1.69k
    if (!p)
7768
0
        return NULL;
7769
1.69k
    p->kind = NamedExpr_kind;
7770
1.69k
    p->v.NamedExpr.target = target;
7771
1.69k
    p->v.NamedExpr.value = value;
7772
1.69k
    p->lineno = lineno;
7773
1.69k
    p->col_offset = col_offset;
7774
1.69k
    p->end_lineno = end_lineno;
7775
1.69k
    p->end_col_offset = end_col_offset;
7776
1.69k
    return p;
7777
1.69k
}
7778
7779
expr_ty
7780
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7781
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7782
45.0k
{
7783
45.0k
    expr_ty p;
7784
45.0k
    if (!left) {
7785
0
        PyErr_SetString(PyExc_ValueError,
7786
0
                        "field 'left' is required for BinOp");
7787
0
        return NULL;
7788
0
    }
7789
45.0k
    if (!op) {
7790
0
        PyErr_SetString(PyExc_ValueError,
7791
0
                        "field 'op' is required for BinOp");
7792
0
        return NULL;
7793
0
    }
7794
45.0k
    if (!right) {
7795
0
        PyErr_SetString(PyExc_ValueError,
7796
0
                        "field 'right' is required for BinOp");
7797
0
        return NULL;
7798
0
    }
7799
45.0k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7800
45.0k
    if (!p)
7801
0
        return NULL;
7802
45.0k
    p->kind = BinOp_kind;
7803
45.0k
    p->v.BinOp.left = left;
7804
45.0k
    p->v.BinOp.op = op;
7805
45.0k
    p->v.BinOp.right = right;
7806
45.0k
    p->lineno = lineno;
7807
45.0k
    p->col_offset = col_offset;
7808
45.0k
    p->end_lineno = end_lineno;
7809
45.0k
    p->end_col_offset = end_col_offset;
7810
45.0k
    return p;
7811
45.0k
}
7812
7813
expr_ty
7814
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7815
               end_lineno, int end_col_offset, PyArena *arena)
7816
173k
{
7817
173k
    expr_ty p;
7818
173k
    if (!op) {
7819
0
        PyErr_SetString(PyExc_ValueError,
7820
0
                        "field 'op' is required for UnaryOp");
7821
0
        return NULL;
7822
0
    }
7823
173k
    if (!operand) {
7824
0
        PyErr_SetString(PyExc_ValueError,
7825
0
                        "field 'operand' is required for UnaryOp");
7826
0
        return NULL;
7827
0
    }
7828
173k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7829
173k
    if (!p)
7830
0
        return NULL;
7831
173k
    p->kind = UnaryOp_kind;
7832
173k
    p->v.UnaryOp.op = op;
7833
173k
    p->v.UnaryOp.operand = operand;
7834
173k
    p->lineno = lineno;
7835
173k
    p->col_offset = col_offset;
7836
173k
    p->end_lineno = end_lineno;
7837
173k
    p->end_col_offset = end_col_offset;
7838
173k
    return p;
7839
173k
}
7840
7841
expr_ty
7842
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7843
              end_lineno, int end_col_offset, PyArena *arena)
7844
2.76k
{
7845
2.76k
    expr_ty p;
7846
2.76k
    if (!args) {
7847
0
        PyErr_SetString(PyExc_ValueError,
7848
0
                        "field 'args' is required for Lambda");
7849
0
        return NULL;
7850
0
    }
7851
2.76k
    if (!body) {
7852
0
        PyErr_SetString(PyExc_ValueError,
7853
0
                        "field 'body' is required for Lambda");
7854
0
        return NULL;
7855
0
    }
7856
2.76k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7857
2.76k
    if (!p)
7858
0
        return NULL;
7859
2.76k
    p->kind = Lambda_kind;
7860
2.76k
    p->v.Lambda.args = args;
7861
2.76k
    p->v.Lambda.body = body;
7862
2.76k
    p->lineno = lineno;
7863
2.76k
    p->col_offset = col_offset;
7864
2.76k
    p->end_lineno = end_lineno;
7865
2.76k
    p->end_col_offset = end_col_offset;
7866
2.76k
    return p;
7867
2.76k
}
7868
7869
expr_ty
7870
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7871
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7872
845
{
7873
845
    expr_ty p;
7874
845
    if (!test) {
7875
0
        PyErr_SetString(PyExc_ValueError,
7876
0
                        "field 'test' is required for IfExp");
7877
0
        return NULL;
7878
0
    }
7879
845
    if (!body) {
7880
0
        PyErr_SetString(PyExc_ValueError,
7881
0
                        "field 'body' is required for IfExp");
7882
0
        return NULL;
7883
0
    }
7884
845
    if (!orelse) {
7885
0
        PyErr_SetString(PyExc_ValueError,
7886
0
                        "field 'orelse' is required for IfExp");
7887
0
        return NULL;
7888
0
    }
7889
845
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7890
845
    if (!p)
7891
0
        return NULL;
7892
845
    p->kind = IfExp_kind;
7893
845
    p->v.IfExp.test = test;
7894
845
    p->v.IfExp.body = body;
7895
845
    p->v.IfExp.orelse = orelse;
7896
845
    p->lineno = lineno;
7897
845
    p->col_offset = col_offset;
7898
845
    p->end_lineno = end_lineno;
7899
845
    p->end_col_offset = end_col_offset;
7900
845
    return p;
7901
845
}
7902
7903
expr_ty
7904
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7905
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7906
4.33k
{
7907
4.33k
    expr_ty p;
7908
4.33k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7909
4.33k
    if (!p)
7910
0
        return NULL;
7911
4.33k
    p->kind = Dict_kind;
7912
4.33k
    p->v.Dict.keys = keys;
7913
4.33k
    p->v.Dict.values = values;
7914
4.33k
    p->lineno = lineno;
7915
4.33k
    p->col_offset = col_offset;
7916
4.33k
    p->end_lineno = end_lineno;
7917
4.33k
    p->end_col_offset = end_col_offset;
7918
4.33k
    return p;
7919
4.33k
}
7920
7921
expr_ty
7922
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7923
           int end_col_offset, PyArena *arena)
7924
1.22k
{
7925
1.22k
    expr_ty p;
7926
1.22k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7927
1.22k
    if (!p)
7928
0
        return NULL;
7929
1.22k
    p->kind = Set_kind;
7930
1.22k
    p->v.Set.elts = elts;
7931
1.22k
    p->lineno = lineno;
7932
1.22k
    p->col_offset = col_offset;
7933
1.22k
    p->end_lineno = end_lineno;
7934
1.22k
    p->end_col_offset = end_col_offset;
7935
1.22k
    return p;
7936
1.22k
}
7937
7938
expr_ty
7939
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7940
                int col_offset, int end_lineno, int end_col_offset, PyArena
7941
                *arena)
7942
639
{
7943
639
    expr_ty p;
7944
639
    if (!elt) {
7945
0
        PyErr_SetString(PyExc_ValueError,
7946
0
                        "field 'elt' is required for ListComp");
7947
0
        return NULL;
7948
0
    }
7949
639
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7950
639
    if (!p)
7951
0
        return NULL;
7952
639
    p->kind = ListComp_kind;
7953
639
    p->v.ListComp.elt = elt;
7954
639
    p->v.ListComp.generators = generators;
7955
639
    p->lineno = lineno;
7956
639
    p->col_offset = col_offset;
7957
639
    p->end_lineno = end_lineno;
7958
639
    p->end_col_offset = end_col_offset;
7959
639
    return p;
7960
639
}
7961
7962
expr_ty
7963
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7964
               int col_offset, int end_lineno, int end_col_offset, PyArena
7965
               *arena)
7966
978
{
7967
978
    expr_ty p;
7968
978
    if (!elt) {
7969
0
        PyErr_SetString(PyExc_ValueError,
7970
0
                        "field 'elt' is required for SetComp");
7971
0
        return NULL;
7972
0
    }
7973
978
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7974
978
    if (!p)
7975
0
        return NULL;
7976
978
    p->kind = SetComp_kind;
7977
978
    p->v.SetComp.elt = elt;
7978
978
    p->v.SetComp.generators = generators;
7979
978
    p->lineno = lineno;
7980
978
    p->col_offset = col_offset;
7981
978
    p->end_lineno = end_lineno;
7982
978
    p->end_col_offset = end_col_offset;
7983
978
    return p;
7984
978
}
7985
7986
expr_ty
7987
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
7988
                generators, int lineno, int col_offset, int end_lineno, int
7989
                end_col_offset, PyArena *arena)
7990
1.28k
{
7991
1.28k
    expr_ty p;
7992
1.28k
    if (!key) {
7993
0
        PyErr_SetString(PyExc_ValueError,
7994
0
                        "field 'key' is required for DictComp");
7995
0
        return NULL;
7996
0
    }
7997
1.28k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7998
1.28k
    if (!p)
7999
0
        return NULL;
8000
1.28k
    p->kind = DictComp_kind;
8001
1.28k
    p->v.DictComp.key = key;
8002
1.28k
    p->v.DictComp.value = value;
8003
1.28k
    p->v.DictComp.generators = generators;
8004
1.28k
    p->lineno = lineno;
8005
1.28k
    p->col_offset = col_offset;
8006
1.28k
    p->end_lineno = end_lineno;
8007
1.28k
    p->end_col_offset = end_col_offset;
8008
1.28k
    return p;
8009
1.28k
}
8010
8011
expr_ty
8012
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8013
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8014
                    PyArena *arena)
8015
3.91k
{
8016
3.91k
    expr_ty p;
8017
3.91k
    if (!elt) {
8018
0
        PyErr_SetString(PyExc_ValueError,
8019
0
                        "field 'elt' is required for GeneratorExp");
8020
0
        return NULL;
8021
0
    }
8022
3.91k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8023
3.91k
    if (!p)
8024
0
        return NULL;
8025
3.91k
    p->kind = GeneratorExp_kind;
8026
3.91k
    p->v.GeneratorExp.elt = elt;
8027
3.91k
    p->v.GeneratorExp.generators = generators;
8028
3.91k
    p->lineno = lineno;
8029
3.91k
    p->col_offset = col_offset;
8030
3.91k
    p->end_lineno = end_lineno;
8031
3.91k
    p->end_col_offset = end_col_offset;
8032
3.91k
    return p;
8033
3.91k
}
8034
8035
expr_ty
8036
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8037
             end_col_offset, PyArena *arena)
8038
269
{
8039
269
    expr_ty p;
8040
269
    if (!value) {
8041
0
        PyErr_SetString(PyExc_ValueError,
8042
0
                        "field 'value' is required for Await");
8043
0
        return NULL;
8044
0
    }
8045
269
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8046
269
    if (!p)
8047
0
        return NULL;
8048
269
    p->kind = Await_kind;
8049
269
    p->v.Await.value = value;
8050
269
    p->lineno = lineno;
8051
269
    p->col_offset = col_offset;
8052
269
    p->end_lineno = end_lineno;
8053
269
    p->end_col_offset = end_col_offset;
8054
269
    return p;
8055
269
}
8056
8057
expr_ty
8058
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8059
             end_col_offset, PyArena *arena)
8060
2.71k
{
8061
2.71k
    expr_ty p;
8062
2.71k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8063
2.71k
    if (!p)
8064
0
        return NULL;
8065
2.71k
    p->kind = Yield_kind;
8066
2.71k
    p->v.Yield.value = value;
8067
2.71k
    p->lineno = lineno;
8068
2.71k
    p->col_offset = col_offset;
8069
2.71k
    p->end_lineno = end_lineno;
8070
2.71k
    p->end_col_offset = end_col_offset;
8071
2.71k
    return p;
8072
2.71k
}
8073
8074
expr_ty
8075
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8076
                 end_col_offset, PyArena *arena)
8077
364
{
8078
364
    expr_ty p;
8079
364
    if (!value) {
8080
0
        PyErr_SetString(PyExc_ValueError,
8081
0
                        "field 'value' is required for YieldFrom");
8082
0
        return NULL;
8083
0
    }
8084
364
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8085
364
    if (!p)
8086
0
        return NULL;
8087
364
    p->kind = YieldFrom_kind;
8088
364
    p->v.YieldFrom.value = value;
8089
364
    p->lineno = lineno;
8090
364
    p->col_offset = col_offset;
8091
364
    p->end_lineno = end_lineno;
8092
364
    p->end_col_offset = end_col_offset;
8093
364
    return p;
8094
364
}
8095
8096
expr_ty
8097
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8098
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8099
               PyArena *arena)
8100
5.27k
{
8101
5.27k
    expr_ty p;
8102
5.27k
    if (!left) {
8103
0
        PyErr_SetString(PyExc_ValueError,
8104
0
                        "field 'left' is required for Compare");
8105
0
        return NULL;
8106
0
    }
8107
5.27k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8108
5.27k
    if (!p)
8109
0
        return NULL;
8110
5.27k
    p->kind = Compare_kind;
8111
5.27k
    p->v.Compare.left = left;
8112
5.27k
    p->v.Compare.ops = ops;
8113
5.27k
    p->v.Compare.comparators = comparators;
8114
5.27k
    p->lineno = lineno;
8115
5.27k
    p->col_offset = col_offset;
8116
5.27k
    p->end_lineno = end_lineno;
8117
5.27k
    p->end_col_offset = end_col_offset;
8118
5.27k
    return p;
8119
5.27k
}
8120
8121
expr_ty
8122
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8123
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8124
            PyArena *arena)
8125
59.2k
{
8126
59.2k
    expr_ty p;
8127
59.2k
    if (!func) {
8128
0
        PyErr_SetString(PyExc_ValueError,
8129
0
                        "field 'func' is required for Call");
8130
0
        return NULL;
8131
0
    }
8132
59.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8133
59.2k
    if (!p)
8134
0
        return NULL;
8135
59.2k
    p->kind = Call_kind;
8136
59.2k
    p->v.Call.func = func;
8137
59.2k
    p->v.Call.args = args;
8138
59.2k
    p->v.Call.keywords = keywords;
8139
59.2k
    p->lineno = lineno;
8140
59.2k
    p->col_offset = col_offset;
8141
59.2k
    p->end_lineno = end_lineno;
8142
59.2k
    p->end_col_offset = end_col_offset;
8143
59.2k
    return p;
8144
59.2k
}
8145
8146
expr_ty
8147
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8148
                      lineno, int col_offset, int end_lineno, int
8149
                      end_col_offset, PyArena *arena)
8150
21.5k
{
8151
21.5k
    expr_ty p;
8152
21.5k
    if (!value) {
8153
0
        PyErr_SetString(PyExc_ValueError,
8154
0
                        "field 'value' is required for FormattedValue");
8155
0
        return NULL;
8156
0
    }
8157
21.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8158
21.5k
    if (!p)
8159
0
        return NULL;
8160
21.5k
    p->kind = FormattedValue_kind;
8161
21.5k
    p->v.FormattedValue.value = value;
8162
21.5k
    p->v.FormattedValue.conversion = conversion;
8163
21.5k
    p->v.FormattedValue.format_spec = format_spec;
8164
21.5k
    p->lineno = lineno;
8165
21.5k
    p->col_offset = col_offset;
8166
21.5k
    p->end_lineno = end_lineno;
8167
21.5k
    p->end_col_offset = end_col_offset;
8168
21.5k
    return p;
8169
21.5k
}
8170
8171
expr_ty
8172
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8173
                     format_spec, int lineno, int col_offset, int end_lineno,
8174
                     int end_col_offset, PyArena *arena)
8175
6.13k
{
8176
6.13k
    expr_ty p;
8177
6.13k
    if (!value) {
8178
0
        PyErr_SetString(PyExc_ValueError,
8179
0
                        "field 'value' is required for Interpolation");
8180
0
        return NULL;
8181
0
    }
8182
6.13k
    if (!str) {
8183
0
        PyErr_SetString(PyExc_ValueError,
8184
0
                        "field 'str' is required for Interpolation");
8185
0
        return NULL;
8186
0
    }
8187
6.13k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8188
6.13k
    if (!p)
8189
0
        return NULL;
8190
6.13k
    p->kind = Interpolation_kind;
8191
6.13k
    p->v.Interpolation.value = value;
8192
6.13k
    p->v.Interpolation.str = str;
8193
6.13k
    p->v.Interpolation.conversion = conversion;
8194
6.13k
    p->v.Interpolation.format_spec = format_spec;
8195
6.13k
    p->lineno = lineno;
8196
6.13k
    p->col_offset = col_offset;
8197
6.13k
    p->end_lineno = end_lineno;
8198
6.13k
    p->end_col_offset = end_col_offset;
8199
6.13k
    return p;
8200
6.13k
}
8201
8202
expr_ty
8203
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8204
                 end_lineno, int end_col_offset, PyArena *arena)
8205
34.6k
{
8206
34.6k
    expr_ty p;
8207
34.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8208
34.6k
    if (!p)
8209
0
        return NULL;
8210
34.6k
    p->kind = JoinedStr_kind;
8211
34.6k
    p->v.JoinedStr.values = values;
8212
34.6k
    p->lineno = lineno;
8213
34.6k
    p->col_offset = col_offset;
8214
34.6k
    p->end_lineno = end_lineno;
8215
34.6k
    p->end_col_offset = end_col_offset;
8216
34.6k
    return p;
8217
34.6k
}
8218
8219
expr_ty
8220
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8221
                   end_lineno, int end_col_offset, PyArena *arena)
8222
8.49k
{
8223
8.49k
    expr_ty p;
8224
8.49k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8225
8.49k
    if (!p)
8226
0
        return NULL;
8227
8.49k
    p->kind = TemplateStr_kind;
8228
8.49k
    p->v.TemplateStr.values = values;
8229
8.49k
    p->lineno = lineno;
8230
8.49k
    p->col_offset = col_offset;
8231
8.49k
    p->end_lineno = end_lineno;
8232
8.49k
    p->end_col_offset = end_col_offset;
8233
8.49k
    return p;
8234
8.49k
}
8235
8236
expr_ty
8237
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8238
                end_lineno, int end_col_offset, PyArena *arena)
8239
363k
{
8240
363k
    expr_ty p;
8241
363k
    if (!value) {
8242
2
        PyErr_SetString(PyExc_ValueError,
8243
2
                        "field 'value' is required for Constant");
8244
2
        return NULL;
8245
2
    }
8246
363k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8247
363k
    if (!p)
8248
0
        return NULL;
8249
363k
    p->kind = Constant_kind;
8250
363k
    p->v.Constant.value = value;
8251
363k
    p->v.Constant.kind = kind;
8252
363k
    p->lineno = lineno;
8253
363k
    p->col_offset = col_offset;
8254
363k
    p->end_lineno = end_lineno;
8255
363k
    p->end_col_offset = end_col_offset;
8256
363k
    return p;
8257
363k
}
8258
8259
expr_ty
8260
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8261
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8262
                 PyArena *arena)
8263
25.8k
{
8264
25.8k
    expr_ty p;
8265
25.8k
    if (!value) {
8266
0
        PyErr_SetString(PyExc_ValueError,
8267
0
                        "field 'value' is required for Attribute");
8268
0
        return NULL;
8269
0
    }
8270
25.8k
    if (!attr) {
8271
0
        PyErr_SetString(PyExc_ValueError,
8272
0
                        "field 'attr' is required for Attribute");
8273
0
        return NULL;
8274
0
    }
8275
25.8k
    if (!ctx) {
8276
0
        PyErr_SetString(PyExc_ValueError,
8277
0
                        "field 'ctx' is required for Attribute");
8278
0
        return NULL;
8279
0
    }
8280
25.8k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8281
25.8k
    if (!p)
8282
0
        return NULL;
8283
25.8k
    p->kind = Attribute_kind;
8284
25.8k
    p->v.Attribute.value = value;
8285
25.8k
    p->v.Attribute.attr = attr;
8286
25.8k
    p->v.Attribute.ctx = ctx;
8287
25.8k
    p->lineno = lineno;
8288
25.8k
    p->col_offset = col_offset;
8289
25.8k
    p->end_lineno = end_lineno;
8290
25.8k
    p->end_col_offset = end_col_offset;
8291
25.8k
    return p;
8292
25.8k
}
8293
8294
expr_ty
8295
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8296
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8297
                 *arena)
8298
5.94k
{
8299
5.94k
    expr_ty p;
8300
5.94k
    if (!value) {
8301
0
        PyErr_SetString(PyExc_ValueError,
8302
0
                        "field 'value' is required for Subscript");
8303
0
        return NULL;
8304
0
    }
8305
5.94k
    if (!slice) {
8306
0
        PyErr_SetString(PyExc_ValueError,
8307
0
                        "field 'slice' is required for Subscript");
8308
0
        return NULL;
8309
0
    }
8310
5.94k
    if (!ctx) {
8311
0
        PyErr_SetString(PyExc_ValueError,
8312
0
                        "field 'ctx' is required for Subscript");
8313
0
        return NULL;
8314
0
    }
8315
5.94k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8316
5.94k
    if (!p)
8317
0
        return NULL;
8318
5.94k
    p->kind = Subscript_kind;
8319
5.94k
    p->v.Subscript.value = value;
8320
5.94k
    p->v.Subscript.slice = slice;
8321
5.94k
    p->v.Subscript.ctx = ctx;
8322
5.94k
    p->lineno = lineno;
8323
5.94k
    p->col_offset = col_offset;
8324
5.94k
    p->end_lineno = end_lineno;
8325
5.94k
    p->end_col_offset = end_col_offset;
8326
5.94k
    return p;
8327
5.94k
}
8328
8329
expr_ty
8330
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8331
               int end_lineno, int end_col_offset, PyArena *arena)
8332
18.4k
{
8333
18.4k
    expr_ty p;
8334
18.4k
    if (!value) {
8335
0
        PyErr_SetString(PyExc_ValueError,
8336
0
                        "field 'value' is required for Starred");
8337
0
        return NULL;
8338
0
    }
8339
18.4k
    if (!ctx) {
8340
0
        PyErr_SetString(PyExc_ValueError,
8341
0
                        "field 'ctx' is required for Starred");
8342
0
        return NULL;
8343
0
    }
8344
18.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8345
18.4k
    if (!p)
8346
0
        return NULL;
8347
18.4k
    p->kind = Starred_kind;
8348
18.4k
    p->v.Starred.value = value;
8349
18.4k
    p->v.Starred.ctx = ctx;
8350
18.4k
    p->lineno = lineno;
8351
18.4k
    p->col_offset = col_offset;
8352
18.4k
    p->end_lineno = end_lineno;
8353
18.4k
    p->end_col_offset = end_col_offset;
8354
18.4k
    return p;
8355
18.4k
}
8356
8357
expr_ty
8358
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8359
            end_lineno, int end_col_offset, PyArena *arena)
8360
13.1M
{
8361
13.1M
    expr_ty p;
8362
13.1M
    if (!id) {
8363
0
        PyErr_SetString(PyExc_ValueError,
8364
0
                        "field 'id' is required for Name");
8365
0
        return NULL;
8366
0
    }
8367
13.1M
    if (!ctx) {
8368
0
        PyErr_SetString(PyExc_ValueError,
8369
0
                        "field 'ctx' is required for Name");
8370
0
        return NULL;
8371
0
    }
8372
13.1M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8373
13.1M
    if (!p)
8374
0
        return NULL;
8375
13.1M
    p->kind = Name_kind;
8376
13.1M
    p->v.Name.id = id;
8377
13.1M
    p->v.Name.ctx = ctx;
8378
13.1M
    p->lineno = lineno;
8379
13.1M
    p->col_offset = col_offset;
8380
13.1M
    p->end_lineno = end_lineno;
8381
13.1M
    p->end_col_offset = end_col_offset;
8382
13.1M
    return p;
8383
13.1M
}
8384
8385
expr_ty
8386
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8387
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8388
16.2k
{
8389
16.2k
    expr_ty p;
8390
16.2k
    if (!ctx) {
8391
0
        PyErr_SetString(PyExc_ValueError,
8392
0
                        "field 'ctx' is required for List");
8393
0
        return NULL;
8394
0
    }
8395
16.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8396
16.2k
    if (!p)
8397
0
        return NULL;
8398
16.2k
    p->kind = List_kind;
8399
16.2k
    p->v.List.elts = elts;
8400
16.2k
    p->v.List.ctx = ctx;
8401
16.2k
    p->lineno = lineno;
8402
16.2k
    p->col_offset = col_offset;
8403
16.2k
    p->end_lineno = end_lineno;
8404
16.2k
    p->end_col_offset = end_col_offset;
8405
16.2k
    return p;
8406
16.2k
}
8407
8408
expr_ty
8409
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8410
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8411
85.6k
{
8412
85.6k
    expr_ty p;
8413
85.6k
    if (!ctx) {
8414
0
        PyErr_SetString(PyExc_ValueError,
8415
0
                        "field 'ctx' is required for Tuple");
8416
0
        return NULL;
8417
0
    }
8418
85.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8419
85.6k
    if (!p)
8420
0
        return NULL;
8421
85.6k
    p->kind = Tuple_kind;
8422
85.6k
    p->v.Tuple.elts = elts;
8423
85.6k
    p->v.Tuple.ctx = ctx;
8424
85.6k
    p->lineno = lineno;
8425
85.6k
    p->col_offset = col_offset;
8426
85.6k
    p->end_lineno = end_lineno;
8427
85.6k
    p->end_col_offset = end_col_offset;
8428
85.6k
    return p;
8429
85.6k
}
8430
8431
expr_ty
8432
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8433
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8434
15.5k
{
8435
15.5k
    expr_ty p;
8436
15.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8437
15.5k
    if (!p)
8438
0
        return NULL;
8439
15.5k
    p->kind = Slice_kind;
8440
15.5k
    p->v.Slice.lower = lower;
8441
15.5k
    p->v.Slice.upper = upper;
8442
15.5k
    p->v.Slice.step = step;
8443
15.5k
    p->lineno = lineno;
8444
15.5k
    p->col_offset = col_offset;
8445
15.5k
    p->end_lineno = end_lineno;
8446
15.5k
    p->end_col_offset = end_col_offset;
8447
15.5k
    return p;
8448
15.5k
}
8449
8450
comprehension_ty
8451
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8452
                     is_async, PyArena *arena)
8453
9.47k
{
8454
9.47k
    comprehension_ty p;
8455
9.47k
    if (!target) {
8456
0
        PyErr_SetString(PyExc_ValueError,
8457
0
                        "field 'target' is required for comprehension");
8458
0
        return NULL;
8459
0
    }
8460
9.47k
    if (!iter) {
8461
0
        PyErr_SetString(PyExc_ValueError,
8462
0
                        "field 'iter' is required for comprehension");
8463
0
        return NULL;
8464
0
    }
8465
9.47k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8466
9.47k
    if (!p)
8467
0
        return NULL;
8468
9.47k
    p->target = target;
8469
9.47k
    p->iter = iter;
8470
9.47k
    p->ifs = ifs;
8471
9.47k
    p->is_async = is_async;
8472
9.47k
    return p;
8473
9.47k
}
8474
8475
excepthandler_ty
8476
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8477
                     lineno, int col_offset, int end_lineno, int
8478
                     end_col_offset, PyArena *arena)
8479
7.78k
{
8480
7.78k
    excepthandler_ty p;
8481
7.78k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8482
7.78k
    if (!p)
8483
0
        return NULL;
8484
7.78k
    p->kind = ExceptHandler_kind;
8485
7.78k
    p->v.ExceptHandler.type = type;
8486
7.78k
    p->v.ExceptHandler.name = name;
8487
7.78k
    p->v.ExceptHandler.body = body;
8488
7.78k
    p->lineno = lineno;
8489
7.78k
    p->col_offset = col_offset;
8490
7.78k
    p->end_lineno = end_lineno;
8491
7.78k
    p->end_col_offset = end_col_offset;
8492
7.78k
    return p;
8493
7.78k
}
8494
8495
arguments_ty
8496
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8497
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8498
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8499
                 *arena)
8500
370k
{
8501
370k
    arguments_ty p;
8502
370k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8503
370k
    if (!p)
8504
0
        return NULL;
8505
370k
    p->posonlyargs = posonlyargs;
8506
370k
    p->args = args;
8507
370k
    p->vararg = vararg;
8508
370k
    p->kwonlyargs = kwonlyargs;
8509
370k
    p->kw_defaults = kw_defaults;
8510
370k
    p->kwarg = kwarg;
8511
370k
    p->defaults = defaults;
8512
370k
    return p;
8513
370k
}
8514
8515
arg_ty
8516
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8517
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8518
11.4M
{
8519
11.4M
    arg_ty p;
8520
11.4M
    if (!arg) {
8521
0
        PyErr_SetString(PyExc_ValueError,
8522
0
                        "field 'arg' is required for arg");
8523
0
        return NULL;
8524
0
    }
8525
11.4M
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8526
11.4M
    if (!p)
8527
0
        return NULL;
8528
11.4M
    p->arg = arg;
8529
11.4M
    p->annotation = annotation;
8530
11.4M
    p->type_comment = type_comment;
8531
11.4M
    p->lineno = lineno;
8532
11.4M
    p->col_offset = col_offset;
8533
11.4M
    p->end_lineno = end_lineno;
8534
11.4M
    p->end_col_offset = end_col_offset;
8535
11.4M
    return p;
8536
11.4M
}
8537
8538
keyword_ty
8539
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8540
               end_lineno, int end_col_offset, PyArena *arena)
8541
33.2k
{
8542
33.2k
    keyword_ty p;
8543
33.2k
    if (!value) {
8544
0
        PyErr_SetString(PyExc_ValueError,
8545
0
                        "field 'value' is required for keyword");
8546
0
        return NULL;
8547
0
    }
8548
33.2k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8549
33.2k
    if (!p)
8550
0
        return NULL;
8551
33.2k
    p->arg = arg;
8552
33.2k
    p->value = value;
8553
33.2k
    p->lineno = lineno;
8554
33.2k
    p->col_offset = col_offset;
8555
33.2k
    p->end_lineno = end_lineno;
8556
33.2k
    p->end_col_offset = end_col_offset;
8557
33.2k
    return p;
8558
33.2k
}
8559
8560
alias_ty
8561
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8562
             int end_lineno, int end_col_offset, PyArena *arena)
8563
11.7k
{
8564
11.7k
    alias_ty p;
8565
11.7k
    if (!name) {
8566
0
        PyErr_SetString(PyExc_ValueError,
8567
0
                        "field 'name' is required for alias");
8568
0
        return NULL;
8569
0
    }
8570
11.7k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8571
11.7k
    if (!p)
8572
0
        return NULL;
8573
11.7k
    p->name = name;
8574
11.7k
    p->asname = asname;
8575
11.7k
    p->lineno = lineno;
8576
11.7k
    p->col_offset = col_offset;
8577
11.7k
    p->end_lineno = end_lineno;
8578
11.7k
    p->end_col_offset = end_col_offset;
8579
11.7k
    return p;
8580
11.7k
}
8581
8582
withitem_ty
8583
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8584
9.02k
{
8585
9.02k
    withitem_ty p;
8586
9.02k
    if (!context_expr) {
8587
0
        PyErr_SetString(PyExc_ValueError,
8588
0
                        "field 'context_expr' is required for withitem");
8589
0
        return NULL;
8590
0
    }
8591
9.02k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8592
9.02k
    if (!p)
8593
0
        return NULL;
8594
9.02k
    p->context_expr = context_expr;
8595
9.02k
    p->optional_vars = optional_vars;
8596
9.02k
    return p;
8597
9.02k
}
8598
8599
match_case_ty
8600
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8601
                  PyArena *arena)
8602
3.25k
{
8603
3.25k
    match_case_ty p;
8604
3.25k
    if (!pattern) {
8605
0
        PyErr_SetString(PyExc_ValueError,
8606
0
                        "field 'pattern' is required for match_case");
8607
0
        return NULL;
8608
0
    }
8609
3.25k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8610
3.25k
    if (!p)
8611
0
        return NULL;
8612
3.25k
    p->pattern = pattern;
8613
3.25k
    p->guard = guard;
8614
3.25k
    p->body = body;
8615
3.25k
    return p;
8616
3.25k
}
8617
8618
pattern_ty
8619
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8620
                  int end_col_offset, PyArena *arena)
8621
6.06k
{
8622
6.06k
    pattern_ty p;
8623
6.06k
    if (!value) {
8624
0
        PyErr_SetString(PyExc_ValueError,
8625
0
                        "field 'value' is required for MatchValue");
8626
0
        return NULL;
8627
0
    }
8628
6.06k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8629
6.06k
    if (!p)
8630
0
        return NULL;
8631
6.06k
    p->kind = MatchValue_kind;
8632
6.06k
    p->v.MatchValue.value = value;
8633
6.06k
    p->lineno = lineno;
8634
6.06k
    p->col_offset = col_offset;
8635
6.06k
    p->end_lineno = end_lineno;
8636
6.06k
    p->end_col_offset = end_col_offset;
8637
6.06k
    return p;
8638
6.06k
}
8639
8640
pattern_ty
8641
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8642
                      end_lineno, int end_col_offset, PyArena *arena)
8643
996
{
8644
996
    pattern_ty p;
8645
996
    if (!value) {
8646
0
        PyErr_SetString(PyExc_ValueError,
8647
0
                        "field 'value' is required for MatchSingleton");
8648
0
        return NULL;
8649
0
    }
8650
996
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8651
996
    if (!p)
8652
0
        return NULL;
8653
996
    p->kind = MatchSingleton_kind;
8654
996
    p->v.MatchSingleton.value = value;
8655
996
    p->lineno = lineno;
8656
996
    p->col_offset = col_offset;
8657
996
    p->end_lineno = end_lineno;
8658
996
    p->end_col_offset = end_col_offset;
8659
996
    return p;
8660
996
}
8661
8662
pattern_ty
8663
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8664
                     int end_lineno, int end_col_offset, PyArena *arena)
8665
4.07k
{
8666
4.07k
    pattern_ty p;
8667
4.07k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8668
4.07k
    if (!p)
8669
0
        return NULL;
8670
4.07k
    p->kind = MatchSequence_kind;
8671
4.07k
    p->v.MatchSequence.patterns = patterns;
8672
4.07k
    p->lineno = lineno;
8673
4.07k
    p->col_offset = col_offset;
8674
4.07k
    p->end_lineno = end_lineno;
8675
4.07k
    p->end_col_offset = end_col_offset;
8676
4.07k
    return p;
8677
4.07k
}
8678
8679
pattern_ty
8680
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8681
                    identifier rest, int lineno, int col_offset, int
8682
                    end_lineno, int end_col_offset, PyArena *arena)
8683
1.12k
{
8684
1.12k
    pattern_ty p;
8685
1.12k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8686
1.12k
    if (!p)
8687
0
        return NULL;
8688
1.12k
    p->kind = MatchMapping_kind;
8689
1.12k
    p->v.MatchMapping.keys = keys;
8690
1.12k
    p->v.MatchMapping.patterns = patterns;
8691
1.12k
    p->v.MatchMapping.rest = rest;
8692
1.12k
    p->lineno = lineno;
8693
1.12k
    p->col_offset = col_offset;
8694
1.12k
    p->end_lineno = end_lineno;
8695
1.12k
    p->end_col_offset = end_col_offset;
8696
1.12k
    return p;
8697
1.12k
}
8698
8699
pattern_ty
8700
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8701
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8702
                  col_offset, int end_lineno, int end_col_offset, PyArena
8703
                  *arena)
8704
1.95k
{
8705
1.95k
    pattern_ty p;
8706
1.95k
    if (!cls) {
8707
0
        PyErr_SetString(PyExc_ValueError,
8708
0
                        "field 'cls' is required for MatchClass");
8709
0
        return NULL;
8710
0
    }
8711
1.95k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8712
1.95k
    if (!p)
8713
0
        return NULL;
8714
1.95k
    p->kind = MatchClass_kind;
8715
1.95k
    p->v.MatchClass.cls = cls;
8716
1.95k
    p->v.MatchClass.patterns = patterns;
8717
1.95k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8718
1.95k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8719
1.95k
    p->lineno = lineno;
8720
1.95k
    p->col_offset = col_offset;
8721
1.95k
    p->end_lineno = end_lineno;
8722
1.95k
    p->end_col_offset = end_col_offset;
8723
1.95k
    return p;
8724
1.95k
}
8725
8726
pattern_ty
8727
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8728
                 int end_col_offset, PyArena *arena)
8729
1.72k
{
8730
1.72k
    pattern_ty p;
8731
1.72k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8732
1.72k
    if (!p)
8733
0
        return NULL;
8734
1.72k
    p->kind = MatchStar_kind;
8735
1.72k
    p->v.MatchStar.name = name;
8736
1.72k
    p->lineno = lineno;
8737
1.72k
    p->col_offset = col_offset;
8738
1.72k
    p->end_lineno = end_lineno;
8739
1.72k
    p->end_col_offset = end_col_offset;
8740
1.72k
    return p;
8741
1.72k
}
8742
8743
pattern_ty
8744
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8745
               int end_lineno, int end_col_offset, PyArena *arena)
8746
20.8k
{
8747
20.8k
    pattern_ty p;
8748
20.8k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8749
20.8k
    if (!p)
8750
0
        return NULL;
8751
20.8k
    p->kind = MatchAs_kind;
8752
20.8k
    p->v.MatchAs.pattern = pattern;
8753
20.8k
    p->v.MatchAs.name = name;
8754
20.8k
    p->lineno = lineno;
8755
20.8k
    p->col_offset = col_offset;
8756
20.8k
    p->end_lineno = end_lineno;
8757
20.8k
    p->end_col_offset = end_col_offset;
8758
20.8k
    return p;
8759
20.8k
}
8760
8761
pattern_ty
8762
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8763
               end_lineno, int end_col_offset, PyArena *arena)
8764
7.94k
{
8765
7.94k
    pattern_ty p;
8766
7.94k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8767
7.94k
    if (!p)
8768
0
        return NULL;
8769
7.94k
    p->kind = MatchOr_kind;
8770
7.94k
    p->v.MatchOr.patterns = patterns;
8771
7.94k
    p->lineno = lineno;
8772
7.94k
    p->col_offset = col_offset;
8773
7.94k
    p->end_lineno = end_lineno;
8774
7.94k
    p->end_col_offset = end_col_offset;
8775
7.94k
    return p;
8776
7.94k
}
8777
8778
type_ignore_ty
8779
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8780
0
{
8781
0
    type_ignore_ty p;
8782
0
    if (!tag) {
8783
0
        PyErr_SetString(PyExc_ValueError,
8784
0
                        "field 'tag' is required for TypeIgnore");
8785
0
        return NULL;
8786
0
    }
8787
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8788
0
    if (!p)
8789
0
        return NULL;
8790
0
    p->kind = TypeIgnore_kind;
8791
0
    p->v.TypeIgnore.lineno = lineno;
8792
0
    p->v.TypeIgnore.tag = tag;
8793
0
    return p;
8794
0
}
8795
8796
type_param_ty
8797
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8798
               lineno, int col_offset, int end_lineno, int end_col_offset,
8799
               PyArena *arena)
8800
6.84k
{
8801
6.84k
    type_param_ty p;
8802
6.84k
    if (!name) {
8803
0
        PyErr_SetString(PyExc_ValueError,
8804
0
                        "field 'name' is required for TypeVar");
8805
0
        return NULL;
8806
0
    }
8807
6.84k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8808
6.84k
    if (!p)
8809
0
        return NULL;
8810
6.84k
    p->kind = TypeVar_kind;
8811
6.84k
    p->v.TypeVar.name = name;
8812
6.84k
    p->v.TypeVar.bound = bound;
8813
6.84k
    p->v.TypeVar.default_value = default_value;
8814
6.84k
    p->lineno = lineno;
8815
6.84k
    p->col_offset = col_offset;
8816
6.84k
    p->end_lineno = end_lineno;
8817
6.84k
    p->end_col_offset = end_col_offset;
8818
6.84k
    return p;
8819
6.84k
}
8820
8821
type_param_ty
8822
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8823
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8824
630
{
8825
630
    type_param_ty p;
8826
630
    if (!name) {
8827
0
        PyErr_SetString(PyExc_ValueError,
8828
0
                        "field 'name' is required for ParamSpec");
8829
0
        return NULL;
8830
0
    }
8831
630
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8832
630
    if (!p)
8833
0
        return NULL;
8834
630
    p->kind = ParamSpec_kind;
8835
630
    p->v.ParamSpec.name = name;
8836
630
    p->v.ParamSpec.default_value = default_value;
8837
630
    p->lineno = lineno;
8838
630
    p->col_offset = col_offset;
8839
630
    p->end_lineno = end_lineno;
8840
630
    p->end_col_offset = end_col_offset;
8841
630
    return p;
8842
630
}
8843
8844
type_param_ty
8845
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8846
                    col_offset, int end_lineno, int end_col_offset, PyArena
8847
                    *arena)
8848
1.68k
{
8849
1.68k
    type_param_ty p;
8850
1.68k
    if (!name) {
8851
0
        PyErr_SetString(PyExc_ValueError,
8852
0
                        "field 'name' is required for TypeVarTuple");
8853
0
        return NULL;
8854
0
    }
8855
1.68k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8856
1.68k
    if (!p)
8857
0
        return NULL;
8858
1.68k
    p->kind = TypeVarTuple_kind;
8859
1.68k
    p->v.TypeVarTuple.name = name;
8860
1.68k
    p->v.TypeVarTuple.default_value = default_value;
8861
1.68k
    p->lineno = lineno;
8862
1.68k
    p->col_offset = col_offset;
8863
1.68k
    p->end_lineno = end_lineno;
8864
1.68k
    p->end_col_offset = end_col_offset;
8865
1.68k
    return p;
8866
1.68k
}
8867
8868
8869
PyObject*
8870
ast2obj_mod(struct ast_state *state, void* _o)
8871
6.68k
{
8872
6.68k
    mod_ty o = (mod_ty)_o;
8873
6.68k
    PyObject *result = NULL, *value = NULL;
8874
6.68k
    PyTypeObject *tp;
8875
6.68k
    if (!o) {
8876
0
        Py_RETURN_NONE;
8877
0
    }
8878
6.68k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8879
0
        return NULL;
8880
0
    }
8881
6.68k
    switch (o->kind) {
8882
6.68k
    case Module_kind:
8883
6.68k
        tp = (PyTypeObject *)state->Module_type;
8884
6.68k
        result = PyType_GenericNew(tp, NULL, NULL);
8885
6.68k
        if (!result) goto failed;
8886
6.68k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8887
6.68k
        if (!value) goto failed;
8888
6.68k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8889
0
            goto failed;
8890
6.68k
        Py_DECREF(value);
8891
6.68k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8892
6.68k
                             ast2obj_type_ignore);
8893
6.68k
        if (!value) goto failed;
8894
6.68k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8895
0
            goto failed;
8896
6.68k
        Py_DECREF(value);
8897
6.68k
        break;
8898
0
    case Interactive_kind:
8899
0
        tp = (PyTypeObject *)state->Interactive_type;
8900
0
        result = PyType_GenericNew(tp, NULL, NULL);
8901
0
        if (!result) goto failed;
8902
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8903
0
                             ast2obj_stmt);
8904
0
        if (!value) goto failed;
8905
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8906
0
            goto failed;
8907
0
        Py_DECREF(value);
8908
0
        break;
8909
0
    case Expression_kind:
8910
0
        tp = (PyTypeObject *)state->Expression_type;
8911
0
        result = PyType_GenericNew(tp, NULL, NULL);
8912
0
        if (!result) goto failed;
8913
0
        value = ast2obj_expr(state, o->v.Expression.body);
8914
0
        if (!value) goto failed;
8915
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8916
0
            goto failed;
8917
0
        Py_DECREF(value);
8918
0
        break;
8919
0
    case FunctionType_kind:
8920
0
        tp = (PyTypeObject *)state->FunctionType_type;
8921
0
        result = PyType_GenericNew(tp, NULL, NULL);
8922
0
        if (!result) goto failed;
8923
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8924
0
                             ast2obj_expr);
8925
0
        if (!value) goto failed;
8926
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8927
0
            goto failed;
8928
0
        Py_DECREF(value);
8929
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8930
0
        if (!value) goto failed;
8931
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8932
0
            goto failed;
8933
0
        Py_DECREF(value);
8934
0
        break;
8935
6.68k
    }
8936
6.68k
    Py_LeaveRecursiveCall();
8937
6.68k
    return result;
8938
0
failed:
8939
0
    Py_LeaveRecursiveCall();
8940
0
    Py_XDECREF(value);
8941
0
    Py_XDECREF(result);
8942
0
    return NULL;
8943
6.68k
}
8944
8945
PyObject*
8946
ast2obj_stmt(struct ast_state *state, void* _o)
8947
44.1k
{
8948
44.1k
    stmt_ty o = (stmt_ty)_o;
8949
44.1k
    PyObject *result = NULL, *value = NULL;
8950
44.1k
    PyTypeObject *tp;
8951
44.1k
    if (!o) {
8952
0
        Py_RETURN_NONE;
8953
0
    }
8954
44.1k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8955
0
        return NULL;
8956
0
    }
8957
44.1k
    switch (o->kind) {
8958
1.42k
    case FunctionDef_kind:
8959
1.42k
        tp = (PyTypeObject *)state->FunctionDef_type;
8960
1.42k
        result = PyType_GenericNew(tp, NULL, NULL);
8961
1.42k
        if (!result) goto failed;
8962
1.42k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8963
1.42k
        if (!value) goto failed;
8964
1.42k
        if (PyObject_SetAttr(result, state->name, value) == -1)
8965
0
            goto failed;
8966
1.42k
        Py_DECREF(value);
8967
1.42k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8968
1.42k
        if (!value) goto failed;
8969
1.42k
        if (PyObject_SetAttr(result, state->args, value) == -1)
8970
0
            goto failed;
8971
1.42k
        Py_DECREF(value);
8972
1.42k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8973
1.42k
                             ast2obj_stmt);
8974
1.42k
        if (!value) goto failed;
8975
1.42k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8976
0
            goto failed;
8977
1.42k
        Py_DECREF(value);
8978
1.42k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8979
1.42k
                             ast2obj_expr);
8980
1.42k
        if (!value) goto failed;
8981
1.42k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
8982
0
            goto failed;
8983
1.42k
        Py_DECREF(value);
8984
1.42k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
8985
1.42k
        if (!value) goto failed;
8986
1.42k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8987
0
            goto failed;
8988
1.42k
        Py_DECREF(value);
8989
1.42k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
8990
1.42k
        if (!value) goto failed;
8991
1.42k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
8992
0
            goto failed;
8993
1.42k
        Py_DECREF(value);
8994
1.42k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
8995
1.42k
                             ast2obj_type_param);
8996
1.42k
        if (!value) goto failed;
8997
1.42k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
8998
0
            goto failed;
8999
1.42k
        Py_DECREF(value);
9000
1.42k
        break;
9001
332
    case AsyncFunctionDef_kind:
9002
332
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9003
332
        result = PyType_GenericNew(tp, NULL, NULL);
9004
332
        if (!result) goto failed;
9005
332
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9006
332
        if (!value) goto failed;
9007
332
        if (PyObject_SetAttr(result, state->name, value) == -1)
9008
0
            goto failed;
9009
332
        Py_DECREF(value);
9010
332
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9011
332
        if (!value) goto failed;
9012
332
        if (PyObject_SetAttr(result, state->args, value) == -1)
9013
0
            goto failed;
9014
332
        Py_DECREF(value);
9015
332
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9016
332
                             ast2obj_stmt);
9017
332
        if (!value) goto failed;
9018
332
        if (PyObject_SetAttr(result, state->body, value) == -1)
9019
0
            goto failed;
9020
332
        Py_DECREF(value);
9021
332
        value = ast2obj_list(state,
9022
332
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9023
332
                             ast2obj_expr);
9024
332
        if (!value) goto failed;
9025
332
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9026
0
            goto failed;
9027
332
        Py_DECREF(value);
9028
332
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9029
332
        if (!value) goto failed;
9030
332
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9031
0
            goto failed;
9032
332
        Py_DECREF(value);
9033
332
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9034
332
        if (!value) goto failed;
9035
332
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9036
0
            goto failed;
9037
332
        Py_DECREF(value);
9038
332
        value = ast2obj_list(state,
9039
332
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9040
332
                             ast2obj_type_param);
9041
332
        if (!value) goto failed;
9042
332
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9043
0
            goto failed;
9044
332
        Py_DECREF(value);
9045
332
        break;
9046
419
    case ClassDef_kind:
9047
419
        tp = (PyTypeObject *)state->ClassDef_type;
9048
419
        result = PyType_GenericNew(tp, NULL, NULL);
9049
419
        if (!result) goto failed;
9050
419
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9051
419
        if (!value) goto failed;
9052
419
        if (PyObject_SetAttr(result, state->name, value) == -1)
9053
0
            goto failed;
9054
419
        Py_DECREF(value);
9055
419
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9056
419
                             ast2obj_expr);
9057
419
        if (!value) goto failed;
9058
419
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9059
0
            goto failed;
9060
419
        Py_DECREF(value);
9061
419
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9062
419
                             ast2obj_keyword);
9063
419
        if (!value) goto failed;
9064
419
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9065
0
            goto failed;
9066
419
        Py_DECREF(value);
9067
419
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9068
419
                             ast2obj_stmt);
9069
419
        if (!value) goto failed;
9070
419
        if (PyObject_SetAttr(result, state->body, value) == -1)
9071
0
            goto failed;
9072
419
        Py_DECREF(value);
9073
419
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9074
419
                             ast2obj_expr);
9075
419
        if (!value) goto failed;
9076
419
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9077
0
            goto failed;
9078
419
        Py_DECREF(value);
9079
419
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9080
419
                             ast2obj_type_param);
9081
419
        if (!value) goto failed;
9082
419
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9083
0
            goto failed;
9084
419
        Py_DECREF(value);
9085
419
        break;
9086
167
    case Return_kind:
9087
167
        tp = (PyTypeObject *)state->Return_type;
9088
167
        result = PyType_GenericNew(tp, NULL, NULL);
9089
167
        if (!result) goto failed;
9090
167
        value = ast2obj_expr(state, o->v.Return.value);
9091
167
        if (!value) goto failed;
9092
167
        if (PyObject_SetAttr(result, state->value, value) == -1)
9093
0
            goto failed;
9094
167
        Py_DECREF(value);
9095
167
        break;
9096
238
    case Delete_kind:
9097
238
        tp = (PyTypeObject *)state->Delete_type;
9098
238
        result = PyType_GenericNew(tp, NULL, NULL);
9099
238
        if (!result) goto failed;
9100
238
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9101
238
                             ast2obj_expr);
9102
238
        if (!value) goto failed;
9103
238
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9104
0
            goto failed;
9105
238
        Py_DECREF(value);
9106
238
        break;
9107
759
    case Assign_kind:
9108
759
        tp = (PyTypeObject *)state->Assign_type;
9109
759
        result = PyType_GenericNew(tp, NULL, NULL);
9110
759
        if (!result) goto failed;
9111
759
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9112
759
                             ast2obj_expr);
9113
759
        if (!value) goto failed;
9114
759
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9115
0
            goto failed;
9116
759
        Py_DECREF(value);
9117
759
        value = ast2obj_expr(state, o->v.Assign.value);
9118
759
        if (!value) goto failed;
9119
759
        if (PyObject_SetAttr(result, state->value, value) == -1)
9120
0
            goto failed;
9121
759
        Py_DECREF(value);
9122
759
        value = ast2obj_string(state, o->v.Assign.type_comment);
9123
759
        if (!value) goto failed;
9124
759
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9125
0
            goto failed;
9126
759
        Py_DECREF(value);
9127
759
        break;
9128
84
    case TypeAlias_kind:
9129
84
        tp = (PyTypeObject *)state->TypeAlias_type;
9130
84
        result = PyType_GenericNew(tp, NULL, NULL);
9131
84
        if (!result) goto failed;
9132
84
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9133
84
        if (!value) goto failed;
9134
84
        if (PyObject_SetAttr(result, state->name, value) == -1)
9135
0
            goto failed;
9136
84
        Py_DECREF(value);
9137
84
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9138
84
                             ast2obj_type_param);
9139
84
        if (!value) goto failed;
9140
84
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9141
0
            goto failed;
9142
84
        Py_DECREF(value);
9143
84
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9144
84
        if (!value) goto failed;
9145
84
        if (PyObject_SetAttr(result, state->value, value) == -1)
9146
0
            goto failed;
9147
84
        Py_DECREF(value);
9148
84
        break;
9149
264
    case AugAssign_kind:
9150
264
        tp = (PyTypeObject *)state->AugAssign_type;
9151
264
        result = PyType_GenericNew(tp, NULL, NULL);
9152
264
        if (!result) goto failed;
9153
264
        value = ast2obj_expr(state, o->v.AugAssign.target);
9154
264
        if (!value) goto failed;
9155
264
        if (PyObject_SetAttr(result, state->target, value) == -1)
9156
0
            goto failed;
9157
264
        Py_DECREF(value);
9158
264
        value = ast2obj_operator(state, o->v.AugAssign.op);
9159
264
        if (!value) goto failed;
9160
264
        if (PyObject_SetAttr(result, state->op, value) == -1)
9161
0
            goto failed;
9162
264
        Py_DECREF(value);
9163
264
        value = ast2obj_expr(state, o->v.AugAssign.value);
9164
264
        if (!value) goto failed;
9165
264
        if (PyObject_SetAttr(result, state->value, value) == -1)
9166
0
            goto failed;
9167
264
        Py_DECREF(value);
9168
264
        break;
9169
921
    case AnnAssign_kind:
9170
921
        tp = (PyTypeObject *)state->AnnAssign_type;
9171
921
        result = PyType_GenericNew(tp, NULL, NULL);
9172
921
        if (!result) goto failed;
9173
921
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9174
921
        if (!value) goto failed;
9175
921
        if (PyObject_SetAttr(result, state->target, value) == -1)
9176
0
            goto failed;
9177
921
        Py_DECREF(value);
9178
921
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9179
921
        if (!value) goto failed;
9180
921
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9181
0
            goto failed;
9182
921
        Py_DECREF(value);
9183
921
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9184
921
        if (!value) goto failed;
9185
921
        if (PyObject_SetAttr(result, state->value, value) == -1)
9186
0
            goto failed;
9187
921
        Py_DECREF(value);
9188
921
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9189
921
        if (!value) goto failed;
9190
921
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9191
0
            goto failed;
9192
921
        Py_DECREF(value);
9193
921
        break;
9194
285
    case For_kind:
9195
285
        tp = (PyTypeObject *)state->For_type;
9196
285
        result = PyType_GenericNew(tp, NULL, NULL);
9197
285
        if (!result) goto failed;
9198
285
        value = ast2obj_expr(state, o->v.For.target);
9199
285
        if (!value) goto failed;
9200
285
        if (PyObject_SetAttr(result, state->target, value) == -1)
9201
0
            goto failed;
9202
285
        Py_DECREF(value);
9203
285
        value = ast2obj_expr(state, o->v.For.iter);
9204
285
        if (!value) goto failed;
9205
285
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9206
0
            goto failed;
9207
285
        Py_DECREF(value);
9208
285
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9209
285
        if (!value) goto failed;
9210
285
        if (PyObject_SetAttr(result, state->body, value) == -1)
9211
0
            goto failed;
9212
285
        Py_DECREF(value);
9213
285
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9214
285
        if (!value) goto failed;
9215
285
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9216
0
            goto failed;
9217
285
        Py_DECREF(value);
9218
285
        value = ast2obj_string(state, o->v.For.type_comment);
9219
285
        if (!value) goto failed;
9220
285
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9221
0
            goto failed;
9222
285
        Py_DECREF(value);
9223
285
        break;
9224
144
    case AsyncFor_kind:
9225
144
        tp = (PyTypeObject *)state->AsyncFor_type;
9226
144
        result = PyType_GenericNew(tp, NULL, NULL);
9227
144
        if (!result) goto failed;
9228
144
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9229
144
        if (!value) goto failed;
9230
144
        if (PyObject_SetAttr(result, state->target, value) == -1)
9231
0
            goto failed;
9232
144
        Py_DECREF(value);
9233
144
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9234
144
        if (!value) goto failed;
9235
144
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9236
0
            goto failed;
9237
144
        Py_DECREF(value);
9238
144
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9239
144
                             ast2obj_stmt);
9240
144
        if (!value) goto failed;
9241
144
        if (PyObject_SetAttr(result, state->body, value) == -1)
9242
0
            goto failed;
9243
144
        Py_DECREF(value);
9244
144
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9245
144
                             ast2obj_stmt);
9246
144
        if (!value) goto failed;
9247
144
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9248
0
            goto failed;
9249
144
        Py_DECREF(value);
9250
144
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9251
144
        if (!value) goto failed;
9252
144
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9253
0
            goto failed;
9254
144
        Py_DECREF(value);
9255
144
        break;
9256
267
    case While_kind:
9257
267
        tp = (PyTypeObject *)state->While_type;
9258
267
        result = PyType_GenericNew(tp, NULL, NULL);
9259
267
        if (!result) goto failed;
9260
267
        value = ast2obj_expr(state, o->v.While.test);
9261
267
        if (!value) goto failed;
9262
267
        if (PyObject_SetAttr(result, state->test, value) == -1)
9263
0
            goto failed;
9264
267
        Py_DECREF(value);
9265
267
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9266
267
        if (!value) goto failed;
9267
267
        if (PyObject_SetAttr(result, state->body, value) == -1)
9268
0
            goto failed;
9269
267
        Py_DECREF(value);
9270
267
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9271
267
        if (!value) goto failed;
9272
267
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9273
0
            goto failed;
9274
267
        Py_DECREF(value);
9275
267
        break;
9276
314
    case If_kind:
9277
314
        tp = (PyTypeObject *)state->If_type;
9278
314
        result = PyType_GenericNew(tp, NULL, NULL);
9279
314
        if (!result) goto failed;
9280
314
        value = ast2obj_expr(state, o->v.If.test);
9281
314
        if (!value) goto failed;
9282
314
        if (PyObject_SetAttr(result, state->test, value) == -1)
9283
0
            goto failed;
9284
314
        Py_DECREF(value);
9285
314
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9286
314
        if (!value) goto failed;
9287
314
        if (PyObject_SetAttr(result, state->body, value) == -1)
9288
0
            goto failed;
9289
314
        Py_DECREF(value);
9290
314
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9291
314
        if (!value) goto failed;
9292
314
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9293
0
            goto failed;
9294
314
        Py_DECREF(value);
9295
314
        break;
9296
400
    case With_kind:
9297
400
        tp = (PyTypeObject *)state->With_type;
9298
400
        result = PyType_GenericNew(tp, NULL, NULL);
9299
400
        if (!result) goto failed;
9300
400
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9301
400
                             ast2obj_withitem);
9302
400
        if (!value) goto failed;
9303
400
        if (PyObject_SetAttr(result, state->items, value) == -1)
9304
0
            goto failed;
9305
400
        Py_DECREF(value);
9306
400
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9307
400
        if (!value) goto failed;
9308
400
        if (PyObject_SetAttr(result, state->body, value) == -1)
9309
0
            goto failed;
9310
400
        Py_DECREF(value);
9311
400
        value = ast2obj_string(state, o->v.With.type_comment);
9312
400
        if (!value) goto failed;
9313
400
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9314
0
            goto failed;
9315
400
        Py_DECREF(value);
9316
400
        break;
9317
105
    case AsyncWith_kind:
9318
105
        tp = (PyTypeObject *)state->AsyncWith_type;
9319
105
        result = PyType_GenericNew(tp, NULL, NULL);
9320
105
        if (!result) goto failed;
9321
105
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9322
105
                             ast2obj_withitem);
9323
105
        if (!value) goto failed;
9324
105
        if (PyObject_SetAttr(result, state->items, value) == -1)
9325
0
            goto failed;
9326
105
        Py_DECREF(value);
9327
105
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9328
105
                             ast2obj_stmt);
9329
105
        if (!value) goto failed;
9330
105
        if (PyObject_SetAttr(result, state->body, value) == -1)
9331
0
            goto failed;
9332
105
        Py_DECREF(value);
9333
105
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9334
105
        if (!value) goto failed;
9335
105
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9336
0
            goto failed;
9337
105
        Py_DECREF(value);
9338
105
        break;
9339
260
    case Match_kind:
9340
260
        tp = (PyTypeObject *)state->Match_type;
9341
260
        result = PyType_GenericNew(tp, NULL, NULL);
9342
260
        if (!result) goto failed;
9343
260
        value = ast2obj_expr(state, o->v.Match.subject);
9344
260
        if (!value) goto failed;
9345
260
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9346
0
            goto failed;
9347
260
        Py_DECREF(value);
9348
260
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9349
260
                             ast2obj_match_case);
9350
260
        if (!value) goto failed;
9351
260
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9352
0
            goto failed;
9353
260
        Py_DECREF(value);
9354
260
        break;
9355
473
    case Raise_kind:
9356
473
        tp = (PyTypeObject *)state->Raise_type;
9357
473
        result = PyType_GenericNew(tp, NULL, NULL);
9358
473
        if (!result) goto failed;
9359
473
        value = ast2obj_expr(state, o->v.Raise.exc);
9360
473
        if (!value) goto failed;
9361
473
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9362
0
            goto failed;
9363
473
        Py_DECREF(value);
9364
473
        value = ast2obj_expr(state, o->v.Raise.cause);
9365
473
        if (!value) goto failed;
9366
473
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9367
0
            goto failed;
9368
473
        Py_DECREF(value);
9369
473
        break;
9370
337
    case Try_kind:
9371
337
        tp = (PyTypeObject *)state->Try_type;
9372
337
        result = PyType_GenericNew(tp, NULL, NULL);
9373
337
        if (!result) goto failed;
9374
337
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9375
337
        if (!value) goto failed;
9376
337
        if (PyObject_SetAttr(result, state->body, value) == -1)
9377
0
            goto failed;
9378
337
        Py_DECREF(value);
9379
337
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9380
337
                             ast2obj_excepthandler);
9381
337
        if (!value) goto failed;
9382
337
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9383
0
            goto failed;
9384
337
        Py_DECREF(value);
9385
337
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9386
337
        if (!value) goto failed;
9387
337
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9388
0
            goto failed;
9389
337
        Py_DECREF(value);
9390
337
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9391
337
                             ast2obj_stmt);
9392
337
        if (!value) goto failed;
9393
337
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9394
0
            goto failed;
9395
337
        Py_DECREF(value);
9396
337
        break;
9397
501
    case TryStar_kind:
9398
501
        tp = (PyTypeObject *)state->TryStar_type;
9399
501
        result = PyType_GenericNew(tp, NULL, NULL);
9400
501
        if (!result) goto failed;
9401
501
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9402
501
        if (!value) goto failed;
9403
501
        if (PyObject_SetAttr(result, state->body, value) == -1)
9404
0
            goto failed;
9405
501
        Py_DECREF(value);
9406
501
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9407
501
                             ast2obj_excepthandler);
9408
501
        if (!value) goto failed;
9409
501
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9410
0
            goto failed;
9411
501
        Py_DECREF(value);
9412
501
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9413
501
                             ast2obj_stmt);
9414
501
        if (!value) goto failed;
9415
501
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9416
0
            goto failed;
9417
501
        Py_DECREF(value);
9418
501
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9419
501
                             ast2obj_stmt);
9420
501
        if (!value) goto failed;
9421
501
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9422
0
            goto failed;
9423
501
        Py_DECREF(value);
9424
501
        break;
9425
125
    case Assert_kind:
9426
125
        tp = (PyTypeObject *)state->Assert_type;
9427
125
        result = PyType_GenericNew(tp, NULL, NULL);
9428
125
        if (!result) goto failed;
9429
125
        value = ast2obj_expr(state, o->v.Assert.test);
9430
125
        if (!value) goto failed;
9431
125
        if (PyObject_SetAttr(result, state->test, value) == -1)
9432
0
            goto failed;
9433
125
        Py_DECREF(value);
9434
125
        value = ast2obj_expr(state, o->v.Assert.msg);
9435
125
        if (!value) goto failed;
9436
125
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9437
0
            goto failed;
9438
125
        Py_DECREF(value);
9439
125
        break;
9440
617
    case Import_kind:
9441
617
        tp = (PyTypeObject *)state->Import_type;
9442
617
        result = PyType_GenericNew(tp, NULL, NULL);
9443
617
        if (!result) goto failed;
9444
617
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9445
617
                             ast2obj_alias);
9446
617
        if (!value) goto failed;
9447
617
        if (PyObject_SetAttr(result, state->names, value) == -1)
9448
0
            goto failed;
9449
617
        Py_DECREF(value);
9450
617
        value = ast2obj_int(state, o->v.Import.is_lazy);
9451
617
        if (!value) goto failed;
9452
617
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9453
0
            goto failed;
9454
617
        Py_DECREF(value);
9455
617
        break;
9456
661
    case ImportFrom_kind:
9457
661
        tp = (PyTypeObject *)state->ImportFrom_type;
9458
661
        result = PyType_GenericNew(tp, NULL, NULL);
9459
661
        if (!result) goto failed;
9460
661
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9461
661
        if (!value) goto failed;
9462
661
        if (PyObject_SetAttr(result, state->module, value) == -1)
9463
0
            goto failed;
9464
661
        Py_DECREF(value);
9465
661
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9466
661
                             ast2obj_alias);
9467
661
        if (!value) goto failed;
9468
661
        if (PyObject_SetAttr(result, state->names, value) == -1)
9469
0
            goto failed;
9470
661
        Py_DECREF(value);
9471
661
        value = ast2obj_int(state, o->v.ImportFrom.level);
9472
661
        if (!value) goto failed;
9473
661
        if (PyObject_SetAttr(result, state->level, value) == -1)
9474
0
            goto failed;
9475
661
        Py_DECREF(value);
9476
661
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
9477
661
        if (!value) goto failed;
9478
661
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9479
0
            goto failed;
9480
661
        Py_DECREF(value);
9481
661
        break;
9482
144
    case Global_kind:
9483
144
        tp = (PyTypeObject *)state->Global_type;
9484
144
        result = PyType_GenericNew(tp, NULL, NULL);
9485
144
        if (!result) goto failed;
9486
144
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9487
144
                             ast2obj_identifier);
9488
144
        if (!value) goto failed;
9489
144
        if (PyObject_SetAttr(result, state->names, value) == -1)
9490
0
            goto failed;
9491
144
        Py_DECREF(value);
9492
144
        break;
9493
67
    case Nonlocal_kind:
9494
67
        tp = (PyTypeObject *)state->Nonlocal_type;
9495
67
        result = PyType_GenericNew(tp, NULL, NULL);
9496
67
        if (!result) goto failed;
9497
67
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9498
67
                             ast2obj_identifier);
9499
67
        if (!value) goto failed;
9500
67
        if (PyObject_SetAttr(result, state->names, value) == -1)
9501
0
            goto failed;
9502
67
        Py_DECREF(value);
9503
67
        break;
9504
34.4k
    case Expr_kind:
9505
34.4k
        tp = (PyTypeObject *)state->Expr_type;
9506
34.4k
        result = PyType_GenericNew(tp, NULL, NULL);
9507
34.4k
        if (!result) goto failed;
9508
34.4k
        value = ast2obj_expr(state, o->v.Expr.value);
9509
34.4k
        if (!value) goto failed;
9510
34.4k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9511
0
            goto failed;
9512
34.4k
        Py_DECREF(value);
9513
34.4k
        break;
9514
114
    case Pass_kind:
9515
114
        tp = (PyTypeObject *)state->Pass_type;
9516
114
        result = PyType_GenericNew(tp, NULL, NULL);
9517
114
        if (!result) goto failed;
9518
114
        break;
9519
114
    case Break_kind:
9520
93
        tp = (PyTypeObject *)state->Break_type;
9521
93
        result = PyType_GenericNew(tp, NULL, NULL);
9522
93
        if (!result) goto failed;
9523
93
        break;
9524
232
    case Continue_kind:
9525
232
        tp = (PyTypeObject *)state->Continue_type;
9526
232
        result = PyType_GenericNew(tp, NULL, NULL);
9527
232
        if (!result) goto failed;
9528
232
        break;
9529
44.1k
    }
9530
44.1k
    value = ast2obj_int(state, o->lineno);
9531
44.1k
    if (!value) goto failed;
9532
44.1k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9533
0
        goto failed;
9534
44.1k
    Py_DECREF(value);
9535
44.1k
    value = ast2obj_int(state, o->col_offset);
9536
44.1k
    if (!value) goto failed;
9537
44.1k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9538
0
        goto failed;
9539
44.1k
    Py_DECREF(value);
9540
44.1k
    value = ast2obj_int(state, o->end_lineno);
9541
44.1k
    if (!value) goto failed;
9542
44.1k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9543
0
        goto failed;
9544
44.1k
    Py_DECREF(value);
9545
44.1k
    value = ast2obj_int(state, o->end_col_offset);
9546
44.1k
    if (!value) goto failed;
9547
44.1k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9548
0
        goto failed;
9549
44.1k
    Py_DECREF(value);
9550
44.1k
    Py_LeaveRecursiveCall();
9551
44.1k
    return result;
9552
0
failed:
9553
0
    Py_LeaveRecursiveCall();
9554
0
    Py_XDECREF(value);
9555
0
    Py_XDECREF(result);
9556
0
    return NULL;
9557
44.1k
}
9558
9559
PyObject*
9560
ast2obj_expr(struct ast_state *state, void* _o)
9561
416k
{
9562
416k
    expr_ty o = (expr_ty)_o;
9563
416k
    PyObject *result = NULL, *value = NULL;
9564
416k
    PyTypeObject *tp;
9565
416k
    if (!o) {
9566
47.3k
        Py_RETURN_NONE;
9567
47.3k
    }
9568
369k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9569
0
        return NULL;
9570
0
    }
9571
369k
    switch (o->kind) {
9572
563
    case BoolOp_kind:
9573
563
        tp = (PyTypeObject *)state->BoolOp_type;
9574
563
        result = PyType_GenericNew(tp, NULL, NULL);
9575
563
        if (!result) goto failed;
9576
563
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9577
563
        if (!value) goto failed;
9578
563
        if (PyObject_SetAttr(result, state->op, value) == -1)
9579
0
            goto failed;
9580
563
        Py_DECREF(value);
9581
563
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9582
563
                             ast2obj_expr);
9583
563
        if (!value) goto failed;
9584
563
        if (PyObject_SetAttr(result, state->values, value) == -1)
9585
0
            goto failed;
9586
563
        Py_DECREF(value);
9587
563
        break;
9588
71
    case NamedExpr_kind:
9589
71
        tp = (PyTypeObject *)state->NamedExpr_type;
9590
71
        result = PyType_GenericNew(tp, NULL, NULL);
9591
71
        if (!result) goto failed;
9592
71
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9593
71
        if (!value) goto failed;
9594
71
        if (PyObject_SetAttr(result, state->target, value) == -1)
9595
0
            goto failed;
9596
71
        Py_DECREF(value);
9597
71
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9598
71
        if (!value) goto failed;
9599
71
        if (PyObject_SetAttr(result, state->value, value) == -1)
9600
0
            goto failed;
9601
71
        Py_DECREF(value);
9602
71
        break;
9603
26.1k
    case BinOp_kind:
9604
26.1k
        tp = (PyTypeObject *)state->BinOp_type;
9605
26.1k
        result = PyType_GenericNew(tp, NULL, NULL);
9606
26.1k
        if (!result) goto failed;
9607
26.1k
        value = ast2obj_expr(state, o->v.BinOp.left);
9608
26.1k
        if (!value) goto failed;
9609
26.1k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9610
0
            goto failed;
9611
26.1k
        Py_DECREF(value);
9612
26.1k
        value = ast2obj_operator(state, o->v.BinOp.op);
9613
26.1k
        if (!value) goto failed;
9614
26.1k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9615
0
            goto failed;
9616
26.1k
        Py_DECREF(value);
9617
26.1k
        value = ast2obj_expr(state, o->v.BinOp.right);
9618
26.1k
        if (!value) goto failed;
9619
26.1k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9620
0
            goto failed;
9621
26.1k
        Py_DECREF(value);
9622
26.1k
        break;
9623
149k
    case UnaryOp_kind:
9624
149k
        tp = (PyTypeObject *)state->UnaryOp_type;
9625
149k
        result = PyType_GenericNew(tp, NULL, NULL);
9626
149k
        if (!result) goto failed;
9627
149k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9628
149k
        if (!value) goto failed;
9629
149k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9630
0
            goto failed;
9631
149k
        Py_DECREF(value);
9632
149k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9633
149k
        if (!value) goto failed;
9634
149k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9635
0
            goto failed;
9636
149k
        Py_DECREF(value);
9637
149k
        break;
9638
1.00k
    case Lambda_kind:
9639
1.00k
        tp = (PyTypeObject *)state->Lambda_type;
9640
1.00k
        result = PyType_GenericNew(tp, NULL, NULL);
9641
1.00k
        if (!result) goto failed;
9642
1.00k
        value = ast2obj_arguments(state, o->v.Lambda.args);
9643
1.00k
        if (!value) goto failed;
9644
1.00k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9645
0
            goto failed;
9646
1.00k
        Py_DECREF(value);
9647
1.00k
        value = ast2obj_expr(state, o->v.Lambda.body);
9648
1.00k
        if (!value) goto failed;
9649
1.00k
        if (PyObject_SetAttr(result, state->body, value) == -1)
9650
0
            goto failed;
9651
1.00k
        Py_DECREF(value);
9652
1.00k
        break;
9653
76
    case IfExp_kind:
9654
76
        tp = (PyTypeObject *)state->IfExp_type;
9655
76
        result = PyType_GenericNew(tp, NULL, NULL);
9656
76
        if (!result) goto failed;
9657
76
        value = ast2obj_expr(state, o->v.IfExp.test);
9658
76
        if (!value) goto failed;
9659
76
        if (PyObject_SetAttr(result, state->test, value) == -1)
9660
0
            goto failed;
9661
76
        Py_DECREF(value);
9662
76
        value = ast2obj_expr(state, o->v.IfExp.body);
9663
76
        if (!value) goto failed;
9664
76
        if (PyObject_SetAttr(result, state->body, value) == -1)
9665
0
            goto failed;
9666
76
        Py_DECREF(value);
9667
76
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9668
76
        if (!value) goto failed;
9669
76
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9670
0
            goto failed;
9671
76
        Py_DECREF(value);
9672
76
        break;
9673
1.49k
    case Dict_kind:
9674
1.49k
        tp = (PyTypeObject *)state->Dict_type;
9675
1.49k
        result = PyType_GenericNew(tp, NULL, NULL);
9676
1.49k
        if (!result) goto failed;
9677
1.49k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9678
1.49k
        if (!value) goto failed;
9679
1.49k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9680
0
            goto failed;
9681
1.49k
        Py_DECREF(value);
9682
1.49k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9683
1.49k
        if (!value) goto failed;
9684
1.49k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9685
0
            goto failed;
9686
1.49k
        Py_DECREF(value);
9687
1.49k
        break;
9688
264
    case Set_kind:
9689
264
        tp = (PyTypeObject *)state->Set_type;
9690
264
        result = PyType_GenericNew(tp, NULL, NULL);
9691
264
        if (!result) goto failed;
9692
264
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9693
264
        if (!value) goto failed;
9694
264
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9695
0
            goto failed;
9696
264
        Py_DECREF(value);
9697
264
        break;
9698
184
    case ListComp_kind:
9699
184
        tp = (PyTypeObject *)state->ListComp_type;
9700
184
        result = PyType_GenericNew(tp, NULL, NULL);
9701
184
        if (!result) goto failed;
9702
184
        value = ast2obj_expr(state, o->v.ListComp.elt);
9703
184
        if (!value) goto failed;
9704
184
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9705
0
            goto failed;
9706
184
        Py_DECREF(value);
9707
184
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9708
184
                             ast2obj_comprehension);
9709
184
        if (!value) goto failed;
9710
184
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9711
0
            goto failed;
9712
184
        Py_DECREF(value);
9713
184
        break;
9714
370
    case SetComp_kind:
9715
370
        tp = (PyTypeObject *)state->SetComp_type;
9716
370
        result = PyType_GenericNew(tp, NULL, NULL);
9717
370
        if (!result) goto failed;
9718
370
        value = ast2obj_expr(state, o->v.SetComp.elt);
9719
370
        if (!value) goto failed;
9720
370
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9721
0
            goto failed;
9722
370
        Py_DECREF(value);
9723
370
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9724
370
                             ast2obj_comprehension);
9725
370
        if (!value) goto failed;
9726
370
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9727
0
            goto failed;
9728
370
        Py_DECREF(value);
9729
370
        break;
9730
329
    case DictComp_kind:
9731
329
        tp = (PyTypeObject *)state->DictComp_type;
9732
329
        result = PyType_GenericNew(tp, NULL, NULL);
9733
329
        if (!result) goto failed;
9734
329
        value = ast2obj_expr(state, o->v.DictComp.key);
9735
329
        if (!value) goto failed;
9736
329
        if (PyObject_SetAttr(result, state->key, value) == -1)
9737
0
            goto failed;
9738
329
        Py_DECREF(value);
9739
329
        value = ast2obj_expr(state, o->v.DictComp.value);
9740
329
        if (!value) goto failed;
9741
329
        if (PyObject_SetAttr(result, state->value, value) == -1)
9742
0
            goto failed;
9743
329
        Py_DECREF(value);
9744
329
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9745
329
                             ast2obj_comprehension);
9746
329
        if (!value) goto failed;
9747
329
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9748
0
            goto failed;
9749
329
        Py_DECREF(value);
9750
329
        break;
9751
422
    case GeneratorExp_kind:
9752
422
        tp = (PyTypeObject *)state->GeneratorExp_type;
9753
422
        result = PyType_GenericNew(tp, NULL, NULL);
9754
422
        if (!result) goto failed;
9755
422
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9756
422
        if (!value) goto failed;
9757
422
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9758
0
            goto failed;
9759
422
        Py_DECREF(value);
9760
422
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9761
422
                             ast2obj_comprehension);
9762
422
        if (!value) goto failed;
9763
422
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9764
0
            goto failed;
9765
422
        Py_DECREF(value);
9766
422
        break;
9767
73
    case Await_kind:
9768
73
        tp = (PyTypeObject *)state->Await_type;
9769
73
        result = PyType_GenericNew(tp, NULL, NULL);
9770
73
        if (!result) goto failed;
9771
73
        value = ast2obj_expr(state, o->v.Await.value);
9772
73
        if (!value) goto failed;
9773
73
        if (PyObject_SetAttr(result, state->value, value) == -1)
9774
0
            goto failed;
9775
73
        Py_DECREF(value);
9776
73
        break;
9777
996
    case Yield_kind:
9778
996
        tp = (PyTypeObject *)state->Yield_type;
9779
996
        result = PyType_GenericNew(tp, NULL, NULL);
9780
996
        if (!result) goto failed;
9781
996
        value = ast2obj_expr(state, o->v.Yield.value);
9782
996
        if (!value) goto failed;
9783
996
        if (PyObject_SetAttr(result, state->value, value) == -1)
9784
0
            goto failed;
9785
996
        Py_DECREF(value);
9786
996
        break;
9787
80
    case YieldFrom_kind:
9788
80
        tp = (PyTypeObject *)state->YieldFrom_type;
9789
80
        result = PyType_GenericNew(tp, NULL, NULL);
9790
80
        if (!result) goto failed;
9791
80
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9792
80
        if (!value) goto failed;
9793
80
        if (PyObject_SetAttr(result, state->value, value) == -1)
9794
0
            goto failed;
9795
80
        Py_DECREF(value);
9796
80
        break;
9797
1.50k
    case Compare_kind:
9798
1.50k
        tp = (PyTypeObject *)state->Compare_type;
9799
1.50k
        result = PyType_GenericNew(tp, NULL, NULL);
9800
1.50k
        if (!result) goto failed;
9801
1.50k
        value = ast2obj_expr(state, o->v.Compare.left);
9802
1.50k
        if (!value) goto failed;
9803
1.50k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9804
0
            goto failed;
9805
1.50k
        Py_DECREF(value);
9806
1.50k
        {
9807
1.50k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9808
1.50k
            value = PyList_New(n);
9809
1.50k
            if (!value) goto failed;
9810
11.6k
            for(i = 0; i < n; i++)
9811
10.1k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9812
1.50k
        }
9813
1.50k
        if (!value) goto failed;
9814
1.50k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9815
0
            goto failed;
9816
1.50k
        Py_DECREF(value);
9817
1.50k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9818
1.50k
                             ast2obj_expr);
9819
1.50k
        if (!value) goto failed;
9820
1.50k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9821
0
            goto failed;
9822
1.50k
        Py_DECREF(value);
9823
1.50k
        break;
9824
12.3k
    case Call_kind:
9825
12.3k
        tp = (PyTypeObject *)state->Call_type;
9826
12.3k
        result = PyType_GenericNew(tp, NULL, NULL);
9827
12.3k
        if (!result) goto failed;
9828
12.3k
        value = ast2obj_expr(state, o->v.Call.func);
9829
12.3k
        if (!value) goto failed;
9830
12.3k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9831
0
            goto failed;
9832
12.3k
        Py_DECREF(value);
9833
12.3k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9834
12.3k
        if (!value) goto failed;
9835
12.3k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9836
0
            goto failed;
9837
12.3k
        Py_DECREF(value);
9838
12.3k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9839
12.3k
                             ast2obj_keyword);
9840
12.3k
        if (!value) goto failed;
9841
12.3k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9842
0
            goto failed;
9843
12.3k
        Py_DECREF(value);
9844
12.3k
        break;
9845
13.3k
    case FormattedValue_kind:
9846
13.3k
        tp = (PyTypeObject *)state->FormattedValue_type;
9847
13.3k
        result = PyType_GenericNew(tp, NULL, NULL);
9848
13.3k
        if (!result) goto failed;
9849
13.3k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9850
13.3k
        if (!value) goto failed;
9851
13.3k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9852
0
            goto failed;
9853
13.3k
        Py_DECREF(value);
9854
13.3k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9855
13.3k
        if (!value) goto failed;
9856
13.3k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9857
0
            goto failed;
9858
13.3k
        Py_DECREF(value);
9859
13.3k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9860
13.3k
        if (!value) goto failed;
9861
13.3k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9862
0
            goto failed;
9863
13.3k
        Py_DECREF(value);
9864
13.3k
        break;
9865
1.74k
    case Interpolation_kind:
9866
1.74k
        tp = (PyTypeObject *)state->Interpolation_type;
9867
1.74k
        result = PyType_GenericNew(tp, NULL, NULL);
9868
1.74k
        if (!result) goto failed;
9869
1.74k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9870
1.74k
        if (!value) goto failed;
9871
1.74k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9872
0
            goto failed;
9873
1.74k
        Py_DECREF(value);
9874
1.74k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9875
1.74k
        if (!value) goto failed;
9876
1.74k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9877
0
            goto failed;
9878
1.74k
        Py_DECREF(value);
9879
1.74k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9880
1.74k
        if (!value) goto failed;
9881
1.74k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9882
0
            goto failed;
9883
1.74k
        Py_DECREF(value);
9884
1.74k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9885
1.74k
        if (!value) goto failed;
9886
1.74k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9887
0
            goto failed;
9888
1.74k
        Py_DECREF(value);
9889
1.74k
        break;
9890
7.10k
    case JoinedStr_kind:
9891
7.10k
        tp = (PyTypeObject *)state->JoinedStr_type;
9892
7.10k
        result = PyType_GenericNew(tp, NULL, NULL);
9893
7.10k
        if (!result) goto failed;
9894
7.10k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9895
7.10k
                             ast2obj_expr);
9896
7.10k
        if (!value) goto failed;
9897
7.10k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9898
0
            goto failed;
9899
7.10k
        Py_DECREF(value);
9900
7.10k
        break;
9901
696
    case TemplateStr_kind:
9902
696
        tp = (PyTypeObject *)state->TemplateStr_type;
9903
696
        result = PyType_GenericNew(tp, NULL, NULL);
9904
696
        if (!result) goto failed;
9905
696
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9906
696
                             ast2obj_expr);
9907
696
        if (!value) goto failed;
9908
696
        if (PyObject_SetAttr(result, state->values, value) == -1)
9909
0
            goto failed;
9910
696
        Py_DECREF(value);
9911
696
        break;
9912
60.8k
    case Constant_kind:
9913
60.8k
        tp = (PyTypeObject *)state->Constant_type;
9914
60.8k
        result = PyType_GenericNew(tp, NULL, NULL);
9915
60.8k
        if (!result) goto failed;
9916
60.8k
        value = ast2obj_constant(state, o->v.Constant.value);
9917
60.8k
        if (!value) goto failed;
9918
60.8k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9919
0
            goto failed;
9920
60.8k
        Py_DECREF(value);
9921
60.8k
        value = ast2obj_string(state, o->v.Constant.kind);
9922
60.8k
        if (!value) goto failed;
9923
60.8k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9924
0
            goto failed;
9925
60.8k
        Py_DECREF(value);
9926
60.8k
        break;
9927
1.71k
    case Attribute_kind:
9928
1.71k
        tp = (PyTypeObject *)state->Attribute_type;
9929
1.71k
        result = PyType_GenericNew(tp, NULL, NULL);
9930
1.71k
        if (!result) goto failed;
9931
1.71k
        value = ast2obj_expr(state, o->v.Attribute.value);
9932
1.71k
        if (!value) goto failed;
9933
1.71k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9934
0
            goto failed;
9935
1.71k
        Py_DECREF(value);
9936
1.71k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9937
1.71k
        if (!value) goto failed;
9938
1.71k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9939
0
            goto failed;
9940
1.71k
        Py_DECREF(value);
9941
1.71k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9942
1.71k
        if (!value) goto failed;
9943
1.71k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9944
0
            goto failed;
9945
1.71k
        Py_DECREF(value);
9946
1.71k
        break;
9947
1.08k
    case Subscript_kind:
9948
1.08k
        tp = (PyTypeObject *)state->Subscript_type;
9949
1.08k
        result = PyType_GenericNew(tp, NULL, NULL);
9950
1.08k
        if (!result) goto failed;
9951
1.08k
        value = ast2obj_expr(state, o->v.Subscript.value);
9952
1.08k
        if (!value) goto failed;
9953
1.08k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9954
0
            goto failed;
9955
1.08k
        Py_DECREF(value);
9956
1.08k
        value = ast2obj_expr(state, o->v.Subscript.slice);
9957
1.08k
        if (!value) goto failed;
9958
1.08k
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9959
0
            goto failed;
9960
1.08k
        Py_DECREF(value);
9961
1.08k
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9962
1.08k
        if (!value) goto failed;
9963
1.08k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9964
0
            goto failed;
9965
1.08k
        Py_DECREF(value);
9966
1.08k
        break;
9967
651
    case Starred_kind:
9968
651
        tp = (PyTypeObject *)state->Starred_type;
9969
651
        result = PyType_GenericNew(tp, NULL, NULL);
9970
651
        if (!result) goto failed;
9971
651
        value = ast2obj_expr(state, o->v.Starred.value);
9972
651
        if (!value) goto failed;
9973
651
        if (PyObject_SetAttr(result, state->value, value) == -1)
9974
0
            goto failed;
9975
651
        Py_DECREF(value);
9976
651
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9977
651
        if (!value) goto failed;
9978
651
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9979
0
            goto failed;
9980
651
        Py_DECREF(value);
9981
651
        break;
9982
70.5k
    case Name_kind:
9983
70.5k
        tp = (PyTypeObject *)state->Name_type;
9984
70.5k
        result = PyType_GenericNew(tp, NULL, NULL);
9985
70.5k
        if (!result) goto failed;
9986
70.5k
        value = ast2obj_identifier(state, o->v.Name.id);
9987
70.5k
        if (!value) goto failed;
9988
70.5k
        if (PyObject_SetAttr(result, state->id, value) == -1)
9989
0
            goto failed;
9990
70.5k
        Py_DECREF(value);
9991
70.5k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
9992
70.5k
        if (!value) goto failed;
9993
70.5k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9994
0
            goto failed;
9995
70.5k
        Py_DECREF(value);
9996
70.5k
        break;
9997
1.68k
    case List_kind:
9998
1.68k
        tp = (PyTypeObject *)state->List_type;
9999
1.68k
        result = PyType_GenericNew(tp, NULL, NULL);
10000
1.68k
        if (!result) goto failed;
10001
1.68k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10002
1.68k
        if (!value) goto failed;
10003
1.68k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10004
0
            goto failed;
10005
1.68k
        Py_DECREF(value);
10006
1.68k
        value = ast2obj_expr_context(state, o->v.List.ctx);
10007
1.68k
        if (!value) goto failed;
10008
1.68k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10009
0
            goto failed;
10010
1.68k
        Py_DECREF(value);
10011
1.68k
        break;
10012
10.7k
    case Tuple_kind:
10013
10.7k
        tp = (PyTypeObject *)state->Tuple_type;
10014
10.7k
        result = PyType_GenericNew(tp, NULL, NULL);
10015
10.7k
        if (!result) goto failed;
10016
10.7k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10017
10.7k
        if (!value) goto failed;
10018
10.7k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10019
0
            goto failed;
10020
10.7k
        Py_DECREF(value);
10021
10.7k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10022
10.7k
        if (!value) goto failed;
10023
10.7k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10024
0
            goto failed;
10025
10.7k
        Py_DECREF(value);
10026
10.7k
        break;
10027
3.56k
    case Slice_kind:
10028
3.56k
        tp = (PyTypeObject *)state->Slice_type;
10029
3.56k
        result = PyType_GenericNew(tp, NULL, NULL);
10030
3.56k
        if (!result) goto failed;
10031
3.56k
        value = ast2obj_expr(state, o->v.Slice.lower);
10032
3.56k
        if (!value) goto failed;
10033
3.56k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10034
0
            goto failed;
10035
3.56k
        Py_DECREF(value);
10036
3.56k
        value = ast2obj_expr(state, o->v.Slice.upper);
10037
3.56k
        if (!value) goto failed;
10038
3.56k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10039
0
            goto failed;
10040
3.56k
        Py_DECREF(value);
10041
3.56k
        value = ast2obj_expr(state, o->v.Slice.step);
10042
3.56k
        if (!value) goto failed;
10043
3.56k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10044
0
            goto failed;
10045
3.56k
        Py_DECREF(value);
10046
3.56k
        break;
10047
369k
    }
10048
369k
    value = ast2obj_int(state, o->lineno);
10049
369k
    if (!value) goto failed;
10050
369k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10051
0
        goto failed;
10052
369k
    Py_DECREF(value);
10053
369k
    value = ast2obj_int(state, o->col_offset);
10054
369k
    if (!value) goto failed;
10055
369k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10056
0
        goto failed;
10057
369k
    Py_DECREF(value);
10058
369k
    value = ast2obj_int(state, o->end_lineno);
10059
369k
    if (!value) goto failed;
10060
369k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10061
0
        goto failed;
10062
369k
    Py_DECREF(value);
10063
369k
    value = ast2obj_int(state, o->end_col_offset);
10064
369k
    if (!value) goto failed;
10065
369k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10066
0
        goto failed;
10067
369k
    Py_DECREF(value);
10068
369k
    Py_LeaveRecursiveCall();
10069
369k
    return result;
10070
0
failed:
10071
0
    Py_LeaveRecursiveCall();
10072
0
    Py_XDECREF(value);
10073
0
    Py_XDECREF(result);
10074
0
    return NULL;
10075
369k
}
10076
10077
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10078
86.4k
{
10079
86.4k
    switch(o) {
10080
79.7k
        case Load:
10081
79.7k
            return Py_NewRef(state->Load_singleton);
10082
5.90k
        case Store:
10083
5.90k
            return Py_NewRef(state->Store_singleton);
10084
779
        case Del:
10085
779
            return Py_NewRef(state->Del_singleton);
10086
86.4k
    }
10087
86.4k
    Py_UNREACHABLE();
10088
86.4k
}
10089
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10090
563
{
10091
563
    switch(o) {
10092
118
        case And:
10093
118
            return Py_NewRef(state->And_singleton);
10094
445
        case Or:
10095
445
            return Py_NewRef(state->Or_singleton);
10096
563
    }
10097
563
    Py_UNREACHABLE();
10098
563
}
10099
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10100
26.3k
{
10101
26.3k
    switch(o) {
10102
4.25k
        case Add:
10103
4.25k
            return Py_NewRef(state->Add_singleton);
10104
7.70k
        case Sub:
10105
7.70k
            return Py_NewRef(state->Sub_singleton);
10106
6.85k
        case Mult:
10107
6.85k
            return Py_NewRef(state->Mult_singleton);
10108
774
        case MatMult:
10109
774
            return Py_NewRef(state->MatMult_singleton);
10110
905
        case Div:
10111
905
            return Py_NewRef(state->Div_singleton);
10112
1.27k
        case Mod:
10113
1.27k
            return Py_NewRef(state->Mod_singleton);
10114
877
        case Pow:
10115
877
            return Py_NewRef(state->Pow_singleton);
10116
1.10k
        case LShift:
10117
1.10k
            return Py_NewRef(state->LShift_singleton);
10118
239
        case RShift:
10119
239
            return Py_NewRef(state->RShift_singleton);
10120
798
        case BitOr:
10121
798
            return Py_NewRef(state->BitOr_singleton);
10122
608
        case BitXor:
10123
608
            return Py_NewRef(state->BitXor_singleton);
10124
716
        case BitAnd:
10125
716
            return Py_NewRef(state->BitAnd_singleton);
10126
260
        case FloorDiv:
10127
260
            return Py_NewRef(state->FloorDiv_singleton);
10128
26.3k
    }
10129
26.3k
    Py_UNREACHABLE();
10130
26.3k
}
10131
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10132
149k
{
10133
149k
    switch(o) {
10134
38.5k
        case Invert:
10135
38.5k
            return Py_NewRef(state->Invert_singleton);
10136
91
        case Not:
10137
91
            return Py_NewRef(state->Not_singleton);
10138
51.6k
        case UAdd:
10139
51.6k
            return Py_NewRef(state->UAdd_singleton);
10140
59.6k
        case USub:
10141
59.6k
            return Py_NewRef(state->USub_singleton);
10142
149k
    }
10143
149k
    Py_UNREACHABLE();
10144
149k
}
10145
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10146
10.1k
{
10147
10.1k
    switch(o) {
10148
158
        case Eq:
10149
158
            return Py_NewRef(state->Eq_singleton);
10150
205
        case NotEq:
10151
205
            return Py_NewRef(state->NotEq_singleton);
10152
5.34k
        case Lt:
10153
5.34k
            return Py_NewRef(state->Lt_singleton);
10154
69
        case LtE:
10155
69
            return Py_NewRef(state->LtE_singleton);
10156
3.30k
        case Gt:
10157
3.30k
            return Py_NewRef(state->Gt_singleton);
10158
237
        case GtE:
10159
237
            return Py_NewRef(state->GtE_singleton);
10160
304
        case Is:
10161
304
            return Py_NewRef(state->Is_singleton);
10162
88
        case IsNot:
10163
88
            return Py_NewRef(state->IsNot_singleton);
10164
331
        case In:
10165
331
            return Py_NewRef(state->In_singleton);
10166
70
        case NotIn:
10167
70
            return Py_NewRef(state->NotIn_singleton);
10168
10.1k
    }
10169
10.1k
    Py_UNREACHABLE();
10170
10.1k
}
10171
PyObject*
10172
ast2obj_comprehension(struct ast_state *state, void* _o)
10173
1.33k
{
10174
1.33k
    comprehension_ty o = (comprehension_ty)_o;
10175
1.33k
    PyObject *result = NULL, *value = NULL;
10176
1.33k
    PyTypeObject *tp;
10177
1.33k
    if (!o) {
10178
0
        Py_RETURN_NONE;
10179
0
    }
10180
1.33k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10181
0
        return NULL;
10182
0
    }
10183
1.33k
    tp = (PyTypeObject *)state->comprehension_type;
10184
1.33k
    result = PyType_GenericNew(tp, NULL, NULL);
10185
1.33k
    if (!result) return NULL;
10186
1.33k
    value = ast2obj_expr(state, o->target);
10187
1.33k
    if (!value) goto failed;
10188
1.33k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10189
0
        goto failed;
10190
1.33k
    Py_DECREF(value);
10191
1.33k
    value = ast2obj_expr(state, o->iter);
10192
1.33k
    if (!value) goto failed;
10193
1.33k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10194
0
        goto failed;
10195
1.33k
    Py_DECREF(value);
10196
1.33k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10197
1.33k
    if (!value) goto failed;
10198
1.33k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10199
0
        goto failed;
10200
1.33k
    Py_DECREF(value);
10201
1.33k
    value = ast2obj_int(state, o->is_async);
10202
1.33k
    if (!value) goto failed;
10203
1.33k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10204
0
        goto failed;
10205
1.33k
    Py_DECREF(value);
10206
1.33k
    Py_LeaveRecursiveCall();
10207
1.33k
    return result;
10208
0
failed:
10209
0
    Py_LeaveRecursiveCall();
10210
0
    Py_XDECREF(value);
10211
0
    Py_XDECREF(result);
10212
0
    return NULL;
10213
1.33k
}
10214
10215
PyObject*
10216
ast2obj_excepthandler(struct ast_state *state, void* _o)
10217
1.25k
{
10218
1.25k
    excepthandler_ty o = (excepthandler_ty)_o;
10219
1.25k
    PyObject *result = NULL, *value = NULL;
10220
1.25k
    PyTypeObject *tp;
10221
1.25k
    if (!o) {
10222
0
        Py_RETURN_NONE;
10223
0
    }
10224
1.25k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10225
0
        return NULL;
10226
0
    }
10227
1.25k
    switch (o->kind) {
10228
1.25k
    case ExceptHandler_kind:
10229
1.25k
        tp = (PyTypeObject *)state->ExceptHandler_type;
10230
1.25k
        result = PyType_GenericNew(tp, NULL, NULL);
10231
1.25k
        if (!result) goto failed;
10232
1.25k
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10233
1.25k
        if (!value) goto failed;
10234
1.25k
        if (PyObject_SetAttr(result, state->type, value) == -1)
10235
0
            goto failed;
10236
1.25k
        Py_DECREF(value);
10237
1.25k
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10238
1.25k
        if (!value) goto failed;
10239
1.25k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10240
0
            goto failed;
10241
1.25k
        Py_DECREF(value);
10242
1.25k
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10243
1.25k
                             ast2obj_stmt);
10244
1.25k
        if (!value) goto failed;
10245
1.25k
        if (PyObject_SetAttr(result, state->body, value) == -1)
10246
0
            goto failed;
10247
1.25k
        Py_DECREF(value);
10248
1.25k
        break;
10249
1.25k
    }
10250
1.25k
    value = ast2obj_int(state, o->lineno);
10251
1.25k
    if (!value) goto failed;
10252
1.25k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10253
0
        goto failed;
10254
1.25k
    Py_DECREF(value);
10255
1.25k
    value = ast2obj_int(state, o->col_offset);
10256
1.25k
    if (!value) goto failed;
10257
1.25k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10258
0
        goto failed;
10259
1.25k
    Py_DECREF(value);
10260
1.25k
    value = ast2obj_int(state, o->end_lineno);
10261
1.25k
    if (!value) goto failed;
10262
1.25k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10263
0
        goto failed;
10264
1.25k
    Py_DECREF(value);
10265
1.25k
    value = ast2obj_int(state, o->end_col_offset);
10266
1.25k
    if (!value) goto failed;
10267
1.25k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10268
0
        goto failed;
10269
1.25k
    Py_DECREF(value);
10270
1.25k
    Py_LeaveRecursiveCall();
10271
1.25k
    return result;
10272
0
failed:
10273
0
    Py_LeaveRecursiveCall();
10274
0
    Py_XDECREF(value);
10275
0
    Py_XDECREF(result);
10276
0
    return NULL;
10277
1.25k
}
10278
10279
PyObject*
10280
ast2obj_arguments(struct ast_state *state, void* _o)
10281
2.76k
{
10282
2.76k
    arguments_ty o = (arguments_ty)_o;
10283
2.76k
    PyObject *result = NULL, *value = NULL;
10284
2.76k
    PyTypeObject *tp;
10285
2.76k
    if (!o) {
10286
0
        Py_RETURN_NONE;
10287
0
    }
10288
2.76k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10289
0
        return NULL;
10290
0
    }
10291
2.76k
    tp = (PyTypeObject *)state->arguments_type;
10292
2.76k
    result = PyType_GenericNew(tp, NULL, NULL);
10293
2.76k
    if (!result) return NULL;
10294
2.76k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10295
2.76k
    if (!value) goto failed;
10296
2.76k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10297
0
        goto failed;
10298
2.76k
    Py_DECREF(value);
10299
2.76k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10300
2.76k
    if (!value) goto failed;
10301
2.76k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10302
0
        goto failed;
10303
2.76k
    Py_DECREF(value);
10304
2.76k
    value = ast2obj_arg(state, o->vararg);
10305
2.76k
    if (!value) goto failed;
10306
2.76k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10307
0
        goto failed;
10308
2.76k
    Py_DECREF(value);
10309
2.76k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10310
2.76k
    if (!value) goto failed;
10311
2.76k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10312
0
        goto failed;
10313
2.76k
    Py_DECREF(value);
10314
2.76k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10315
2.76k
    if (!value) goto failed;
10316
2.76k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10317
0
        goto failed;
10318
2.76k
    Py_DECREF(value);
10319
2.76k
    value = ast2obj_arg(state, o->kwarg);
10320
2.76k
    if (!value) goto failed;
10321
2.76k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10322
0
        goto failed;
10323
2.76k
    Py_DECREF(value);
10324
2.76k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10325
2.76k
    if (!value) goto failed;
10326
2.76k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10327
0
        goto failed;
10328
2.76k
    Py_DECREF(value);
10329
2.76k
    Py_LeaveRecursiveCall();
10330
2.76k
    return result;
10331
0
failed:
10332
0
    Py_LeaveRecursiveCall();
10333
0
    Py_XDECREF(value);
10334
0
    Py_XDECREF(result);
10335
0
    return NULL;
10336
2.76k
}
10337
10338
PyObject*
10339
ast2obj_arg(struct ast_state *state, void* _o)
10340
16.3k
{
10341
16.3k
    arg_ty o = (arg_ty)_o;
10342
16.3k
    PyObject *result = NULL, *value = NULL;
10343
16.3k
    PyTypeObject *tp;
10344
16.3k
    if (!o) {
10345
4.62k
        Py_RETURN_NONE;
10346
4.62k
    }
10347
11.6k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10348
0
        return NULL;
10349
0
    }
10350
11.6k
    tp = (PyTypeObject *)state->arg_type;
10351
11.6k
    result = PyType_GenericNew(tp, NULL, NULL);
10352
11.6k
    if (!result) return NULL;
10353
11.6k
    value = ast2obj_identifier(state, o->arg);
10354
11.6k
    if (!value) goto failed;
10355
11.6k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10356
0
        goto failed;
10357
11.6k
    Py_DECREF(value);
10358
11.6k
    value = ast2obj_expr(state, o->annotation);
10359
11.6k
    if (!value) goto failed;
10360
11.6k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10361
0
        goto failed;
10362
11.6k
    Py_DECREF(value);
10363
11.6k
    value = ast2obj_string(state, o->type_comment);
10364
11.6k
    if (!value) goto failed;
10365
11.6k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10366
0
        goto failed;
10367
11.6k
    Py_DECREF(value);
10368
11.6k
    value = ast2obj_int(state, o->lineno);
10369
11.6k
    if (!value) goto failed;
10370
11.6k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10371
0
        goto failed;
10372
11.6k
    Py_DECREF(value);
10373
11.6k
    value = ast2obj_int(state, o->col_offset);
10374
11.6k
    if (!value) goto failed;
10375
11.6k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10376
0
        goto failed;
10377
11.6k
    Py_DECREF(value);
10378
11.6k
    value = ast2obj_int(state, o->end_lineno);
10379
11.6k
    if (!value) goto failed;
10380
11.6k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10381
0
        goto failed;
10382
11.6k
    Py_DECREF(value);
10383
11.6k
    value = ast2obj_int(state, o->end_col_offset);
10384
11.6k
    if (!value) goto failed;
10385
11.6k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10386
0
        goto failed;
10387
11.6k
    Py_DECREF(value);
10388
11.6k
    Py_LeaveRecursiveCall();
10389
11.6k
    return result;
10390
0
failed:
10391
0
    Py_LeaveRecursiveCall();
10392
0
    Py_XDECREF(value);
10393
0
    Py_XDECREF(result);
10394
0
    return NULL;
10395
11.6k
}
10396
10397
PyObject*
10398
ast2obj_keyword(struct ast_state *state, void* _o)
10399
1.64k
{
10400
1.64k
    keyword_ty o = (keyword_ty)_o;
10401
1.64k
    PyObject *result = NULL, *value = NULL;
10402
1.64k
    PyTypeObject *tp;
10403
1.64k
    if (!o) {
10404
0
        Py_RETURN_NONE;
10405
0
    }
10406
1.64k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10407
0
        return NULL;
10408
0
    }
10409
1.64k
    tp = (PyTypeObject *)state->keyword_type;
10410
1.64k
    result = PyType_GenericNew(tp, NULL, NULL);
10411
1.64k
    if (!result) return NULL;
10412
1.64k
    value = ast2obj_identifier(state, o->arg);
10413
1.64k
    if (!value) goto failed;
10414
1.64k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10415
0
        goto failed;
10416
1.64k
    Py_DECREF(value);
10417
1.64k
    value = ast2obj_expr(state, o->value);
10418
1.64k
    if (!value) goto failed;
10419
1.64k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10420
0
        goto failed;
10421
1.64k
    Py_DECREF(value);
10422
1.64k
    value = ast2obj_int(state, o->lineno);
10423
1.64k
    if (!value) goto failed;
10424
1.64k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10425
0
        goto failed;
10426
1.64k
    Py_DECREF(value);
10427
1.64k
    value = ast2obj_int(state, o->col_offset);
10428
1.64k
    if (!value) goto failed;
10429
1.64k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10430
0
        goto failed;
10431
1.64k
    Py_DECREF(value);
10432
1.64k
    value = ast2obj_int(state, o->end_lineno);
10433
1.64k
    if (!value) goto failed;
10434
1.64k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10435
0
        goto failed;
10436
1.64k
    Py_DECREF(value);
10437
1.64k
    value = ast2obj_int(state, o->end_col_offset);
10438
1.64k
    if (!value) goto failed;
10439
1.64k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10440
0
        goto failed;
10441
1.64k
    Py_DECREF(value);
10442
1.64k
    Py_LeaveRecursiveCall();
10443
1.64k
    return result;
10444
0
failed:
10445
0
    Py_LeaveRecursiveCall();
10446
0
    Py_XDECREF(value);
10447
0
    Py_XDECREF(result);
10448
0
    return NULL;
10449
1.64k
}
10450
10451
PyObject*
10452
ast2obj_alias(struct ast_state *state, void* _o)
10453
3.23k
{
10454
3.23k
    alias_ty o = (alias_ty)_o;
10455
3.23k
    PyObject *result = NULL, *value = NULL;
10456
3.23k
    PyTypeObject *tp;
10457
3.23k
    if (!o) {
10458
0
        Py_RETURN_NONE;
10459
0
    }
10460
3.23k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10461
0
        return NULL;
10462
0
    }
10463
3.23k
    tp = (PyTypeObject *)state->alias_type;
10464
3.23k
    result = PyType_GenericNew(tp, NULL, NULL);
10465
3.23k
    if (!result) return NULL;
10466
3.23k
    value = ast2obj_identifier(state, o->name);
10467
3.23k
    if (!value) goto failed;
10468
3.23k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10469
0
        goto failed;
10470
3.23k
    Py_DECREF(value);
10471
3.23k
    value = ast2obj_identifier(state, o->asname);
10472
3.23k
    if (!value) goto failed;
10473
3.23k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10474
0
        goto failed;
10475
3.23k
    Py_DECREF(value);
10476
3.23k
    value = ast2obj_int(state, o->lineno);
10477
3.23k
    if (!value) goto failed;
10478
3.23k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10479
0
        goto failed;
10480
3.23k
    Py_DECREF(value);
10481
3.23k
    value = ast2obj_int(state, o->col_offset);
10482
3.23k
    if (!value) goto failed;
10483
3.23k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10484
0
        goto failed;
10485
3.23k
    Py_DECREF(value);
10486
3.23k
    value = ast2obj_int(state, o->end_lineno);
10487
3.23k
    if (!value) goto failed;
10488
3.23k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10489
0
        goto failed;
10490
3.23k
    Py_DECREF(value);
10491
3.23k
    value = ast2obj_int(state, o->end_col_offset);
10492
3.23k
    if (!value) goto failed;
10493
3.23k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10494
0
        goto failed;
10495
3.23k
    Py_DECREF(value);
10496
3.23k
    Py_LeaveRecursiveCall();
10497
3.23k
    return result;
10498
0
failed:
10499
0
    Py_LeaveRecursiveCall();
10500
0
    Py_XDECREF(value);
10501
0
    Py_XDECREF(result);
10502
0
    return NULL;
10503
3.23k
}
10504
10505
PyObject*
10506
ast2obj_withitem(struct ast_state *state, void* _o)
10507
1.71k
{
10508
1.71k
    withitem_ty o = (withitem_ty)_o;
10509
1.71k
    PyObject *result = NULL, *value = NULL;
10510
1.71k
    PyTypeObject *tp;
10511
1.71k
    if (!o) {
10512
0
        Py_RETURN_NONE;
10513
0
    }
10514
1.71k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10515
0
        return NULL;
10516
0
    }
10517
1.71k
    tp = (PyTypeObject *)state->withitem_type;
10518
1.71k
    result = PyType_GenericNew(tp, NULL, NULL);
10519
1.71k
    if (!result) return NULL;
10520
1.71k
    value = ast2obj_expr(state, o->context_expr);
10521
1.71k
    if (!value) goto failed;
10522
1.71k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10523
0
        goto failed;
10524
1.71k
    Py_DECREF(value);
10525
1.71k
    value = ast2obj_expr(state, o->optional_vars);
10526
1.71k
    if (!value) goto failed;
10527
1.71k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10528
0
        goto failed;
10529
1.71k
    Py_DECREF(value);
10530
1.71k
    Py_LeaveRecursiveCall();
10531
1.71k
    return result;
10532
0
failed:
10533
0
    Py_LeaveRecursiveCall();
10534
0
    Py_XDECREF(value);
10535
0
    Py_XDECREF(result);
10536
0
    return NULL;
10537
1.71k
}
10538
10539
PyObject*
10540
ast2obj_match_case(struct ast_state *state, void* _o)
10541
693
{
10542
693
    match_case_ty o = (match_case_ty)_o;
10543
693
    PyObject *result = NULL, *value = NULL;
10544
693
    PyTypeObject *tp;
10545
693
    if (!o) {
10546
0
        Py_RETURN_NONE;
10547
0
    }
10548
693
    if (Py_EnterRecursiveCall("during  ast construction")) {
10549
0
        return NULL;
10550
0
    }
10551
693
    tp = (PyTypeObject *)state->match_case_type;
10552
693
    result = PyType_GenericNew(tp, NULL, NULL);
10553
693
    if (!result) return NULL;
10554
693
    value = ast2obj_pattern(state, o->pattern);
10555
693
    if (!value) goto failed;
10556
693
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10557
0
        goto failed;
10558
693
    Py_DECREF(value);
10559
693
    value = ast2obj_expr(state, o->guard);
10560
693
    if (!value) goto failed;
10561
693
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10562
0
        goto failed;
10563
693
    Py_DECREF(value);
10564
693
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10565
693
    if (!value) goto failed;
10566
693
    if (PyObject_SetAttr(result, state->body, value) == -1)
10567
0
        goto failed;
10568
693
    Py_DECREF(value);
10569
693
    Py_LeaveRecursiveCall();
10570
693
    return result;
10571
0
failed:
10572
0
    Py_LeaveRecursiveCall();
10573
0
    Py_XDECREF(value);
10574
0
    Py_XDECREF(result);
10575
0
    return NULL;
10576
693
}
10577
10578
PyObject*
10579
ast2obj_pattern(struct ast_state *state, void* _o)
10580
22.3k
{
10581
22.3k
    pattern_ty o = (pattern_ty)_o;
10582
22.3k
    PyObject *result = NULL, *value = NULL;
10583
22.3k
    PyTypeObject *tp;
10584
22.3k
    if (!o) {
10585
8.26k
        Py_RETURN_NONE;
10586
8.26k
    }
10587
14.0k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10588
0
        return NULL;
10589
0
    }
10590
14.0k
    switch (o->kind) {
10591
797
    case MatchValue_kind:
10592
797
        tp = (PyTypeObject *)state->MatchValue_type;
10593
797
        result = PyType_GenericNew(tp, NULL, NULL);
10594
797
        if (!result) goto failed;
10595
797
        value = ast2obj_expr(state, o->v.MatchValue.value);
10596
797
        if (!value) goto failed;
10597
797
        if (PyObject_SetAttr(result, state->value, value) == -1)
10598
0
            goto failed;
10599
797
        Py_DECREF(value);
10600
797
        break;
10601
349
    case MatchSingleton_kind:
10602
349
        tp = (PyTypeObject *)state->MatchSingleton_type;
10603
349
        result = PyType_GenericNew(tp, NULL, NULL);
10604
349
        if (!result) goto failed;
10605
349
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10606
349
        if (!value) goto failed;
10607
349
        if (PyObject_SetAttr(result, state->value, value) == -1)
10608
0
            goto failed;
10609
349
        Py_DECREF(value);
10610
349
        break;
10611
467
    case MatchSequence_kind:
10612
467
        tp = (PyTypeObject *)state->MatchSequence_type;
10613
467
        result = PyType_GenericNew(tp, NULL, NULL);
10614
467
        if (!result) goto failed;
10615
467
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10616
467
                             ast2obj_pattern);
10617
467
        if (!value) goto failed;
10618
467
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10619
0
            goto failed;
10620
467
        Py_DECREF(value);
10621
467
        break;
10622
259
    case MatchMapping_kind:
10623
259
        tp = (PyTypeObject *)state->MatchMapping_type;
10624
259
        result = PyType_GenericNew(tp, NULL, NULL);
10625
259
        if (!result) goto failed;
10626
259
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10627
259
                             ast2obj_expr);
10628
259
        if (!value) goto failed;
10629
259
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10630
0
            goto failed;
10631
259
        Py_DECREF(value);
10632
259
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10633
259
                             ast2obj_pattern);
10634
259
        if (!value) goto failed;
10635
259
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10636
0
            goto failed;
10637
259
        Py_DECREF(value);
10638
259
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10639
259
        if (!value) goto failed;
10640
259
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10641
0
            goto failed;
10642
259
        Py_DECREF(value);
10643
259
        break;
10644
704
    case MatchClass_kind:
10645
704
        tp = (PyTypeObject *)state->MatchClass_type;
10646
704
        result = PyType_GenericNew(tp, NULL, NULL);
10647
704
        if (!result) goto failed;
10648
704
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10649
704
        if (!value) goto failed;
10650
704
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10651
0
            goto failed;
10652
704
        Py_DECREF(value);
10653
704
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10654
704
                             ast2obj_pattern);
10655
704
        if (!value) goto failed;
10656
704
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10657
0
            goto failed;
10658
704
        Py_DECREF(value);
10659
704
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10660
704
                             ast2obj_identifier);
10661
704
        if (!value) goto failed;
10662
704
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10663
0
            goto failed;
10664
704
        Py_DECREF(value);
10665
704
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10666
704
                             ast2obj_pattern);
10667
704
        if (!value) goto failed;
10668
704
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10669
0
            goto failed;
10670
704
        Py_DECREF(value);
10671
704
        break;
10672
277
    case MatchStar_kind:
10673
277
        tp = (PyTypeObject *)state->MatchStar_type;
10674
277
        result = PyType_GenericNew(tp, NULL, NULL);
10675
277
        if (!result) goto failed;
10676
277
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10677
277
        if (!value) goto failed;
10678
277
        if (PyObject_SetAttr(result, state->name, value) == -1)
10679
0
            goto failed;
10680
277
        Py_DECREF(value);
10681
277
        break;
10682
8.30k
    case MatchAs_kind:
10683
8.30k
        tp = (PyTypeObject *)state->MatchAs_type;
10684
8.30k
        result = PyType_GenericNew(tp, NULL, NULL);
10685
8.30k
        if (!result) goto failed;
10686
8.30k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10687
8.30k
        if (!value) goto failed;
10688
8.30k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10689
0
            goto failed;
10690
8.30k
        Py_DECREF(value);
10691
8.30k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10692
8.30k
        if (!value) goto failed;
10693
8.30k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10694
0
            goto failed;
10695
8.30k
        Py_DECREF(value);
10696
8.30k
        break;
10697
2.94k
    case MatchOr_kind:
10698
2.94k
        tp = (PyTypeObject *)state->MatchOr_type;
10699
2.94k
        result = PyType_GenericNew(tp, NULL, NULL);
10700
2.94k
        if (!result) goto failed;
10701
2.94k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10702
2.94k
                             ast2obj_pattern);
10703
2.94k
        if (!value) goto failed;
10704
2.94k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10705
0
            goto failed;
10706
2.94k
        Py_DECREF(value);
10707
2.94k
        break;
10708
14.0k
    }
10709
14.0k
    value = ast2obj_int(state, o->lineno);
10710
14.0k
    if (!value) goto failed;
10711
14.0k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10712
0
        goto failed;
10713
14.0k
    Py_DECREF(value);
10714
14.0k
    value = ast2obj_int(state, o->col_offset);
10715
14.0k
    if (!value) goto failed;
10716
14.0k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10717
0
        goto failed;
10718
14.0k
    Py_DECREF(value);
10719
14.0k
    value = ast2obj_int(state, o->end_lineno);
10720
14.0k
    if (!value) goto failed;
10721
14.0k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10722
0
        goto failed;
10723
14.0k
    Py_DECREF(value);
10724
14.0k
    value = ast2obj_int(state, o->end_col_offset);
10725
14.0k
    if (!value) goto failed;
10726
14.0k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10727
0
        goto failed;
10728
14.0k
    Py_DECREF(value);
10729
14.0k
    Py_LeaveRecursiveCall();
10730
14.0k
    return result;
10731
0
failed:
10732
0
    Py_LeaveRecursiveCall();
10733
0
    Py_XDECREF(value);
10734
0
    Py_XDECREF(result);
10735
0
    return NULL;
10736
14.0k
}
10737
10738
PyObject*
10739
ast2obj_type_ignore(struct ast_state *state, void* _o)
10740
0
{
10741
0
    type_ignore_ty o = (type_ignore_ty)_o;
10742
0
    PyObject *result = NULL, *value = NULL;
10743
0
    PyTypeObject *tp;
10744
0
    if (!o) {
10745
0
        Py_RETURN_NONE;
10746
0
    }
10747
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10748
0
        return NULL;
10749
0
    }
10750
0
    switch (o->kind) {
10751
0
    case TypeIgnore_kind:
10752
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10753
0
        result = PyType_GenericNew(tp, NULL, NULL);
10754
0
        if (!result) goto failed;
10755
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10756
0
        if (!value) goto failed;
10757
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10758
0
            goto failed;
10759
0
        Py_DECREF(value);
10760
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10761
0
        if (!value) goto failed;
10762
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10763
0
            goto failed;
10764
0
        Py_DECREF(value);
10765
0
        break;
10766
0
    }
10767
0
    Py_LeaveRecursiveCall();
10768
0
    return result;
10769
0
failed:
10770
0
    Py_LeaveRecursiveCall();
10771
0
    Py_XDECREF(value);
10772
0
    Py_XDECREF(result);
10773
0
    return NULL;
10774
0
}
10775
10776
PyObject*
10777
ast2obj_type_param(struct ast_state *state, void* _o)
10778
7.15k
{
10779
7.15k
    type_param_ty o = (type_param_ty)_o;
10780
7.15k
    PyObject *result = NULL, *value = NULL;
10781
7.15k
    PyTypeObject *tp;
10782
7.15k
    if (!o) {
10783
0
        Py_RETURN_NONE;
10784
0
    }
10785
7.15k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10786
0
        return NULL;
10787
0
    }
10788
7.15k
    switch (o->kind) {
10789
5.47k
    case TypeVar_kind:
10790
5.47k
        tp = (PyTypeObject *)state->TypeVar_type;
10791
5.47k
        result = PyType_GenericNew(tp, NULL, NULL);
10792
5.47k
        if (!result) goto failed;
10793
5.47k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10794
5.47k
        if (!value) goto failed;
10795
5.47k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10796
0
            goto failed;
10797
5.47k
        Py_DECREF(value);
10798
5.47k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10799
5.47k
        if (!value) goto failed;
10800
5.47k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10801
0
            goto failed;
10802
5.47k
        Py_DECREF(value);
10803
5.47k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10804
5.47k
        if (!value) goto failed;
10805
5.47k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10806
0
            goto failed;
10807
5.47k
        Py_DECREF(value);
10808
5.47k
        break;
10809
483
    case ParamSpec_kind:
10810
483
        tp = (PyTypeObject *)state->ParamSpec_type;
10811
483
        result = PyType_GenericNew(tp, NULL, NULL);
10812
483
        if (!result) goto failed;
10813
483
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10814
483
        if (!value) goto failed;
10815
483
        if (PyObject_SetAttr(result, state->name, value) == -1)
10816
0
            goto failed;
10817
483
        Py_DECREF(value);
10818
483
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10819
483
        if (!value) goto failed;
10820
483
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10821
0
            goto failed;
10822
483
        Py_DECREF(value);
10823
483
        break;
10824
1.19k
    case TypeVarTuple_kind:
10825
1.19k
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10826
1.19k
        result = PyType_GenericNew(tp, NULL, NULL);
10827
1.19k
        if (!result) goto failed;
10828
1.19k
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10829
1.19k
        if (!value) goto failed;
10830
1.19k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10831
0
            goto failed;
10832
1.19k
        Py_DECREF(value);
10833
1.19k
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10834
1.19k
        if (!value) goto failed;
10835
1.19k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10836
0
            goto failed;
10837
1.19k
        Py_DECREF(value);
10838
1.19k
        break;
10839
7.15k
    }
10840
7.15k
    value = ast2obj_int(state, o->lineno);
10841
7.15k
    if (!value) goto failed;
10842
7.15k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10843
0
        goto failed;
10844
7.15k
    Py_DECREF(value);
10845
7.15k
    value = ast2obj_int(state, o->col_offset);
10846
7.15k
    if (!value) goto failed;
10847
7.15k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10848
0
        goto failed;
10849
7.15k
    Py_DECREF(value);
10850
7.15k
    value = ast2obj_int(state, o->end_lineno);
10851
7.15k
    if (!value) goto failed;
10852
7.15k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10853
0
        goto failed;
10854
7.15k
    Py_DECREF(value);
10855
7.15k
    value = ast2obj_int(state, o->end_col_offset);
10856
7.15k
    if (!value) goto failed;
10857
7.15k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10858
0
        goto failed;
10859
7.15k
    Py_DECREF(value);
10860
7.15k
    Py_LeaveRecursiveCall();
10861
7.15k
    return result;
10862
0
failed:
10863
0
    Py_LeaveRecursiveCall();
10864
0
    Py_XDECREF(value);
10865
0
    Py_XDECREF(result);
10866
0
    return NULL;
10867
7.15k
}
10868
10869
10870
int
10871
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, const char*
10872
            field, PyArena* arena)
10873
0
{
10874
0
    int isinstance;
10875
10876
0
    PyObject *tmp = NULL;
10877
0
    PyObject *tp;
10878
10879
0
    if (obj == Py_None) {
10880
0
        *out = NULL;
10881
0
        return 0;
10882
0
    }
10883
0
    tp = state->mod_type;
10884
0
    isinstance = PyObject_IsInstance(obj, tp);
10885
0
    if (isinstance == -1) {
10886
0
        return 1;
10887
0
    }
10888
0
    if (!isinstance && field != NULL) {
10889
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'mod', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
10890
0
        return 1;
10891
0
    }
10892
0
    tp = state->Module_type;
10893
0
    isinstance = PyObject_IsInstance(obj, tp);
10894
0
    if (isinstance == -1) {
10895
0
        return -1;
10896
0
    }
10897
0
    if (isinstance) {
10898
0
        asdl_stmt_seq* body;
10899
0
        asdl_type_ignore_seq* type_ignores;
10900
10901
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10902
0
            return -1;
10903
0
        }
10904
0
        if (tmp == NULL) {
10905
0
            tmp = PyList_New(0);
10906
0
            if (tmp == NULL) {
10907
0
                return -1;
10908
0
            }
10909
0
        }
10910
0
        {
10911
0
            int res;
10912
0
            Py_ssize_t len;
10913
0
            Py_ssize_t i;
10914
0
            if (!PyList_Check(tmp)) {
10915
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10916
0
                goto failed;
10917
0
            }
10918
0
            len = PyList_GET_SIZE(tmp);
10919
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10920
0
            if (body == NULL) goto failed;
10921
0
            for (i = 0; i < len; i++) {
10922
0
                stmt_ty val;
10923
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10924
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10925
0
                    goto failed;
10926
0
                }
10927
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
10928
0
                _Py_LeaveRecursiveCall();
10929
0
                Py_DECREF(tmp2);
10930
0
                if (res != 0) goto failed;
10931
0
                if (len != PyList_GET_SIZE(tmp)) {
10932
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10933
0
                    goto failed;
10934
0
                }
10935
0
                asdl_seq_SET(body, i, val);
10936
0
            }
10937
0
            Py_CLEAR(tmp);
10938
0
        }
10939
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10940
0
            return -1;
10941
0
        }
10942
0
        if (tmp == NULL) {
10943
0
            tmp = PyList_New(0);
10944
0
            if (tmp == NULL) {
10945
0
                return -1;
10946
0
            }
10947
0
        }
10948
0
        {
10949
0
            int res;
10950
0
            Py_ssize_t len;
10951
0
            Py_ssize_t i;
10952
0
            if (!PyList_Check(tmp)) {
10953
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10954
0
                goto failed;
10955
0
            }
10956
0
            len = PyList_GET_SIZE(tmp);
10957
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
10958
0
            if (type_ignores == NULL) goto failed;
10959
0
            for (i = 0; i < len; i++) {
10960
0
                type_ignore_ty val;
10961
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10962
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10963
0
                    goto failed;
10964
0
                }
10965
0
                res = obj2ast_type_ignore(state, tmp2, &val, "type_ignores", arena);
10966
0
                _Py_LeaveRecursiveCall();
10967
0
                Py_DECREF(tmp2);
10968
0
                if (res != 0) goto failed;
10969
0
                if (len != PyList_GET_SIZE(tmp)) {
10970
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
10971
0
                    goto failed;
10972
0
                }
10973
0
                asdl_seq_SET(type_ignores, i, val);
10974
0
            }
10975
0
            Py_CLEAR(tmp);
10976
0
        }
10977
0
        *out = _PyAST_Module(body, type_ignores, arena);
10978
0
        if (*out == NULL) goto failed;
10979
0
        return 0;
10980
0
    }
10981
0
    tp = state->Interactive_type;
10982
0
    isinstance = PyObject_IsInstance(obj, tp);
10983
0
    if (isinstance == -1) {
10984
0
        return -1;
10985
0
    }
10986
0
    if (isinstance) {
10987
0
        asdl_stmt_seq* body;
10988
10989
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10990
0
            return -1;
10991
0
        }
10992
0
        if (tmp == NULL) {
10993
0
            tmp = PyList_New(0);
10994
0
            if (tmp == NULL) {
10995
0
                return -1;
10996
0
            }
10997
0
        }
10998
0
        {
10999
0
            int res;
11000
0
            Py_ssize_t len;
11001
0
            Py_ssize_t i;
11002
0
            if (!PyList_Check(tmp)) {
11003
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11004
0
                goto failed;
11005
0
            }
11006
0
            len = PyList_GET_SIZE(tmp);
11007
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11008
0
            if (body == NULL) goto failed;
11009
0
            for (i = 0; i < len; i++) {
11010
0
                stmt_ty val;
11011
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11012
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
11013
0
                    goto failed;
11014
0
                }
11015
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11016
0
                _Py_LeaveRecursiveCall();
11017
0
                Py_DECREF(tmp2);
11018
0
                if (res != 0) goto failed;
11019
0
                if (len != PyList_GET_SIZE(tmp)) {
11020
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
11021
0
                    goto failed;
11022
0
                }
11023
0
                asdl_seq_SET(body, i, val);
11024
0
            }
11025
0
            Py_CLEAR(tmp);
11026
0
        }
11027
0
        *out = _PyAST_Interactive(body, arena);
11028
0
        if (*out == NULL) goto failed;
11029
0
        return 0;
11030
0
    }
11031
0
    tp = state->Expression_type;
11032
0
    isinstance = PyObject_IsInstance(obj, tp);
11033
0
    if (isinstance == -1) {
11034
0
        return -1;
11035
0
    }
11036
0
    if (isinstance) {
11037
0
        expr_ty body;
11038
11039
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11040
0
            return -1;
11041
0
        }
11042
0
        if (tmp == NULL) {
11043
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11044
0
            return -1;
11045
0
        }
11046
0
        else {
11047
0
            int res;
11048
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11049
0
                goto failed;
11050
0
            }
11051
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
11052
0
            _Py_LeaveRecursiveCall();
11053
0
            if (res != 0) goto failed;
11054
0
            Py_CLEAR(tmp);
11055
0
        }
11056
0
        *out = _PyAST_Expression(body, arena);
11057
0
        if (*out == NULL) goto failed;
11058
0
        return 0;
11059
0
    }
11060
0
    tp = state->FunctionType_type;
11061
0
    isinstance = PyObject_IsInstance(obj, tp);
11062
0
    if (isinstance == -1) {
11063
0
        return -1;
11064
0
    }
11065
0
    if (isinstance) {
11066
0
        asdl_expr_seq* argtypes;
11067
0
        expr_ty returns;
11068
11069
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11070
0
            return -1;
11071
0
        }
11072
0
        if (tmp == NULL) {
11073
0
            tmp = PyList_New(0);
11074
0
            if (tmp == NULL) {
11075
0
                return -1;
11076
0
            }
11077
0
        }
11078
0
        {
11079
0
            int res;
11080
0
            Py_ssize_t len;
11081
0
            Py_ssize_t i;
11082
0
            if (!PyList_Check(tmp)) {
11083
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11084
0
                goto failed;
11085
0
            }
11086
0
            len = PyList_GET_SIZE(tmp);
11087
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11088
0
            if (argtypes == NULL) goto failed;
11089
0
            for (i = 0; i < len; i++) {
11090
0
                expr_ty val;
11091
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11092
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11093
0
                    goto failed;
11094
0
                }
11095
0
                res = obj2ast_expr(state, tmp2, &val, "argtypes", arena);
11096
0
                _Py_LeaveRecursiveCall();
11097
0
                Py_DECREF(tmp2);
11098
0
                if (res != 0) goto failed;
11099
0
                if (len != PyList_GET_SIZE(tmp)) {
11100
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11101
0
                    goto failed;
11102
0
                }
11103
0
                asdl_seq_SET(argtypes, i, val);
11104
0
            }
11105
0
            Py_CLEAR(tmp);
11106
0
        }
11107
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11108
0
            return -1;
11109
0
        }
11110
0
        if (tmp == NULL) {
11111
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11112
0
            return -1;
11113
0
        }
11114
0
        else {
11115
0
            int res;
11116
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11117
0
                goto failed;
11118
0
            }
11119
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
11120
0
            _Py_LeaveRecursiveCall();
11121
0
            if (res != 0) goto failed;
11122
0
            Py_CLEAR(tmp);
11123
0
        }
11124
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11125
0
        if (*out == NULL) goto failed;
11126
0
        return 0;
11127
0
    }
11128
11129
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11130
0
    failed:
11131
0
    Py_XDECREF(tmp);
11132
0
    return -1;
11133
0
}
11134
11135
int
11136
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, const char*
11137
             field, PyArena* arena)
11138
0
{
11139
0
    int isinstance;
11140
11141
0
    PyObject *tmp = NULL;
11142
0
    PyObject *tp;
11143
0
    int lineno;
11144
0
    int col_offset;
11145
0
    int end_lineno;
11146
0
    int end_col_offset;
11147
11148
0
    if (obj == Py_None) {
11149
0
        *out = NULL;
11150
0
        return 0;
11151
0
    }
11152
0
    tp = state->stmt_type;
11153
0
    isinstance = PyObject_IsInstance(obj, tp);
11154
0
    if (isinstance == -1) {
11155
0
        return 1;
11156
0
    }
11157
0
    if (!isinstance && field != NULL) {
11158
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'stmt', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
11159
0
        return 1;
11160
0
    }
11161
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11162
0
        return -1;
11163
0
    }
11164
0
    if (tmp == NULL) {
11165
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11166
0
        return -1;
11167
0
    }
11168
0
    else {
11169
0
        int res;
11170
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11171
0
            goto failed;
11172
0
        }
11173
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
11174
0
        _Py_LeaveRecursiveCall();
11175
0
        if (res != 0) goto failed;
11176
0
        Py_CLEAR(tmp);
11177
0
    }
11178
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11179
0
        return -1;
11180
0
    }
11181
0
    if (tmp == NULL) {
11182
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11183
0
        return -1;
11184
0
    }
11185
0
    else {
11186
0
        int res;
11187
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11188
0
            goto failed;
11189
0
        }
11190
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
11191
0
        _Py_LeaveRecursiveCall();
11192
0
        if (res != 0) goto failed;
11193
0
        Py_CLEAR(tmp);
11194
0
    }
11195
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11196
0
        return -1;
11197
0
    }
11198
0
    if (tmp == NULL || tmp == Py_None) {
11199
0
        Py_CLEAR(tmp);
11200
0
        end_lineno = lineno;
11201
0
    }
11202
0
    else {
11203
0
        int res;
11204
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11205
0
            goto failed;
11206
0
        }
11207
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
11208
0
        _Py_LeaveRecursiveCall();
11209
0
        if (res != 0) goto failed;
11210
0
        Py_CLEAR(tmp);
11211
0
    }
11212
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11213
0
        return -1;
11214
0
    }
11215
0
    if (tmp == NULL || tmp == Py_None) {
11216
0
        Py_CLEAR(tmp);
11217
0
        end_col_offset = col_offset;
11218
0
    }
11219
0
    else {
11220
0
        int res;
11221
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11222
0
            goto failed;
11223
0
        }
11224
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
11225
0
        _Py_LeaveRecursiveCall();
11226
0
        if (res != 0) goto failed;
11227
0
        Py_CLEAR(tmp);
11228
0
    }
11229
0
    tp = state->FunctionDef_type;
11230
0
    isinstance = PyObject_IsInstance(obj, tp);
11231
0
    if (isinstance == -1) {
11232
0
        return -1;
11233
0
    }
11234
0
    if (isinstance) {
11235
0
        identifier name;
11236
0
        arguments_ty args;
11237
0
        asdl_stmt_seq* body;
11238
0
        asdl_expr_seq* decorator_list;
11239
0
        expr_ty returns;
11240
0
        string type_comment;
11241
0
        asdl_type_param_seq* type_params;
11242
11243
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11244
0
            return -1;
11245
0
        }
11246
0
        if (tmp == NULL) {
11247
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11248
0
            return -1;
11249
0
        }
11250
0
        else {
11251
0
            int res;
11252
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11253
0
                goto failed;
11254
0
            }
11255
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
11256
0
            _Py_LeaveRecursiveCall();
11257
0
            if (res != 0) goto failed;
11258
0
            Py_CLEAR(tmp);
11259
0
        }
11260
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11261
0
            return -1;
11262
0
        }
11263
0
        if (tmp == NULL) {
11264
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11265
0
            return -1;
11266
0
        }
11267
0
        else {
11268
0
            int res;
11269
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11270
0
                goto failed;
11271
0
            }
11272
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
11273
0
            _Py_LeaveRecursiveCall();
11274
0
            if (res != 0) goto failed;
11275
0
            Py_CLEAR(tmp);
11276
0
        }
11277
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11278
0
            return -1;
11279
0
        }
11280
0
        if (tmp == NULL) {
11281
0
            tmp = PyList_New(0);
11282
0
            if (tmp == NULL) {
11283
0
                return -1;
11284
0
            }
11285
0
        }
11286
0
        {
11287
0
            int res;
11288
0
            Py_ssize_t len;
11289
0
            Py_ssize_t i;
11290
0
            if (!PyList_Check(tmp)) {
11291
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11292
0
                goto failed;
11293
0
            }
11294
0
            len = PyList_GET_SIZE(tmp);
11295
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11296
0
            if (body == NULL) goto failed;
11297
0
            for (i = 0; i < len; i++) {
11298
0
                stmt_ty val;
11299
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11300
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11301
0
                    goto failed;
11302
0
                }
11303
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11304
0
                _Py_LeaveRecursiveCall();
11305
0
                Py_DECREF(tmp2);
11306
0
                if (res != 0) goto failed;
11307
0
                if (len != PyList_GET_SIZE(tmp)) {
11308
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11309
0
                    goto failed;
11310
0
                }
11311
0
                asdl_seq_SET(body, i, val);
11312
0
            }
11313
0
            Py_CLEAR(tmp);
11314
0
        }
11315
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11316
0
            return -1;
11317
0
        }
11318
0
        if (tmp == NULL) {
11319
0
            tmp = PyList_New(0);
11320
0
            if (tmp == NULL) {
11321
0
                return -1;
11322
0
            }
11323
0
        }
11324
0
        {
11325
0
            int res;
11326
0
            Py_ssize_t len;
11327
0
            Py_ssize_t i;
11328
0
            if (!PyList_Check(tmp)) {
11329
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11330
0
                goto failed;
11331
0
            }
11332
0
            len = PyList_GET_SIZE(tmp);
11333
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11334
0
            if (decorator_list == NULL) goto failed;
11335
0
            for (i = 0; i < len; i++) {
11336
0
                expr_ty val;
11337
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11338
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11339
0
                    goto failed;
11340
0
                }
11341
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
11342
0
                _Py_LeaveRecursiveCall();
11343
0
                Py_DECREF(tmp2);
11344
0
                if (res != 0) goto failed;
11345
0
                if (len != PyList_GET_SIZE(tmp)) {
11346
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11347
0
                    goto failed;
11348
0
                }
11349
0
                asdl_seq_SET(decorator_list, i, val);
11350
0
            }
11351
0
            Py_CLEAR(tmp);
11352
0
        }
11353
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11354
0
            return -1;
11355
0
        }
11356
0
        if (tmp == NULL || tmp == Py_None) {
11357
0
            Py_CLEAR(tmp);
11358
0
            returns = NULL;
11359
0
        }
11360
0
        else {
11361
0
            int res;
11362
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11363
0
                goto failed;
11364
0
            }
11365
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
11366
0
            _Py_LeaveRecursiveCall();
11367
0
            if (res != 0) goto failed;
11368
0
            Py_CLEAR(tmp);
11369
0
        }
11370
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11371
0
            return -1;
11372
0
        }
11373
0
        if (tmp == NULL || tmp == Py_None) {
11374
0
            Py_CLEAR(tmp);
11375
0
            type_comment = NULL;
11376
0
        }
11377
0
        else {
11378
0
            int res;
11379
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11380
0
                goto failed;
11381
0
            }
11382
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
11383
0
                                 arena);
11384
0
            _Py_LeaveRecursiveCall();
11385
0
            if (res != 0) goto failed;
11386
0
            Py_CLEAR(tmp);
11387
0
        }
11388
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11389
0
            return -1;
11390
0
        }
11391
0
        if (tmp == NULL) {
11392
0
            tmp = PyList_New(0);
11393
0
            if (tmp == NULL) {
11394
0
                return -1;
11395
0
            }
11396
0
        }
11397
0
        {
11398
0
            int res;
11399
0
            Py_ssize_t len;
11400
0
            Py_ssize_t i;
11401
0
            if (!PyList_Check(tmp)) {
11402
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11403
0
                goto failed;
11404
0
            }
11405
0
            len = PyList_GET_SIZE(tmp);
11406
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11407
0
            if (type_params == NULL) goto failed;
11408
0
            for (i = 0; i < len; i++) {
11409
0
                type_param_ty val;
11410
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11411
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11412
0
                    goto failed;
11413
0
                }
11414
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
11415
0
                _Py_LeaveRecursiveCall();
11416
0
                Py_DECREF(tmp2);
11417
0
                if (res != 0) goto failed;
11418
0
                if (len != PyList_GET_SIZE(tmp)) {
11419
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11420
0
                    goto failed;
11421
0
                }
11422
0
                asdl_seq_SET(type_params, i, val);
11423
0
            }
11424
0
            Py_CLEAR(tmp);
11425
0
        }
11426
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11427
0
                                  type_comment, type_params, lineno,
11428
0
                                  col_offset, end_lineno, end_col_offset,
11429
0
                                  arena);
11430
0
        if (*out == NULL) goto failed;
11431
0
        return 0;
11432
0
    }
11433
0
    tp = state->AsyncFunctionDef_type;
11434
0
    isinstance = PyObject_IsInstance(obj, tp);
11435
0
    if (isinstance == -1) {
11436
0
        return -1;
11437
0
    }
11438
0
    if (isinstance) {
11439
0
        identifier name;
11440
0
        arguments_ty args;
11441
0
        asdl_stmt_seq* body;
11442
0
        asdl_expr_seq* decorator_list;
11443
0
        expr_ty returns;
11444
0
        string type_comment;
11445
0
        asdl_type_param_seq* type_params;
11446
11447
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11448
0
            return -1;
11449
0
        }
11450
0
        if (tmp == NULL) {
11451
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11452
0
            return -1;
11453
0
        }
11454
0
        else {
11455
0
            int res;
11456
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11457
0
                goto failed;
11458
0
            }
11459
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
11460
0
            _Py_LeaveRecursiveCall();
11461
0
            if (res != 0) goto failed;
11462
0
            Py_CLEAR(tmp);
11463
0
        }
11464
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11465
0
            return -1;
11466
0
        }
11467
0
        if (tmp == NULL) {
11468
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11469
0
            return -1;
11470
0
        }
11471
0
        else {
11472
0
            int res;
11473
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11474
0
                goto failed;
11475
0
            }
11476
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
11477
0
            _Py_LeaveRecursiveCall();
11478
0
            if (res != 0) goto failed;
11479
0
            Py_CLEAR(tmp);
11480
0
        }
11481
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11482
0
            return -1;
11483
0
        }
11484
0
        if (tmp == NULL) {
11485
0
            tmp = PyList_New(0);
11486
0
            if (tmp == NULL) {
11487
0
                return -1;
11488
0
            }
11489
0
        }
11490
0
        {
11491
0
            int res;
11492
0
            Py_ssize_t len;
11493
0
            Py_ssize_t i;
11494
0
            if (!PyList_Check(tmp)) {
11495
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11496
0
                goto failed;
11497
0
            }
11498
0
            len = PyList_GET_SIZE(tmp);
11499
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11500
0
            if (body == NULL) goto failed;
11501
0
            for (i = 0; i < len; i++) {
11502
0
                stmt_ty val;
11503
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11504
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11505
0
                    goto failed;
11506
0
                }
11507
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11508
0
                _Py_LeaveRecursiveCall();
11509
0
                Py_DECREF(tmp2);
11510
0
                if (res != 0) goto failed;
11511
0
                if (len != PyList_GET_SIZE(tmp)) {
11512
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11513
0
                    goto failed;
11514
0
                }
11515
0
                asdl_seq_SET(body, i, val);
11516
0
            }
11517
0
            Py_CLEAR(tmp);
11518
0
        }
11519
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11520
0
            return -1;
11521
0
        }
11522
0
        if (tmp == NULL) {
11523
0
            tmp = PyList_New(0);
11524
0
            if (tmp == NULL) {
11525
0
                return -1;
11526
0
            }
11527
0
        }
11528
0
        {
11529
0
            int res;
11530
0
            Py_ssize_t len;
11531
0
            Py_ssize_t i;
11532
0
            if (!PyList_Check(tmp)) {
11533
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11534
0
                goto failed;
11535
0
            }
11536
0
            len = PyList_GET_SIZE(tmp);
11537
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11538
0
            if (decorator_list == NULL) goto failed;
11539
0
            for (i = 0; i < len; i++) {
11540
0
                expr_ty val;
11541
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11542
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11543
0
                    goto failed;
11544
0
                }
11545
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
11546
0
                _Py_LeaveRecursiveCall();
11547
0
                Py_DECREF(tmp2);
11548
0
                if (res != 0) goto failed;
11549
0
                if (len != PyList_GET_SIZE(tmp)) {
11550
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11551
0
                    goto failed;
11552
0
                }
11553
0
                asdl_seq_SET(decorator_list, i, val);
11554
0
            }
11555
0
            Py_CLEAR(tmp);
11556
0
        }
11557
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11558
0
            return -1;
11559
0
        }
11560
0
        if (tmp == NULL || tmp == Py_None) {
11561
0
            Py_CLEAR(tmp);
11562
0
            returns = NULL;
11563
0
        }
11564
0
        else {
11565
0
            int res;
11566
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11567
0
                goto failed;
11568
0
            }
11569
0
            res = obj2ast_expr(state, tmp, &returns, "returns", arena);
11570
0
            _Py_LeaveRecursiveCall();
11571
0
            if (res != 0) goto failed;
11572
0
            Py_CLEAR(tmp);
11573
0
        }
11574
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11575
0
            return -1;
11576
0
        }
11577
0
        if (tmp == NULL || tmp == Py_None) {
11578
0
            Py_CLEAR(tmp);
11579
0
            type_comment = NULL;
11580
0
        }
11581
0
        else {
11582
0
            int res;
11583
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11584
0
                goto failed;
11585
0
            }
11586
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
11587
0
                                 arena);
11588
0
            _Py_LeaveRecursiveCall();
11589
0
            if (res != 0) goto failed;
11590
0
            Py_CLEAR(tmp);
11591
0
        }
11592
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11593
0
            return -1;
11594
0
        }
11595
0
        if (tmp == NULL) {
11596
0
            tmp = PyList_New(0);
11597
0
            if (tmp == NULL) {
11598
0
                return -1;
11599
0
            }
11600
0
        }
11601
0
        {
11602
0
            int res;
11603
0
            Py_ssize_t len;
11604
0
            Py_ssize_t i;
11605
0
            if (!PyList_Check(tmp)) {
11606
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11607
0
                goto failed;
11608
0
            }
11609
0
            len = PyList_GET_SIZE(tmp);
11610
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11611
0
            if (type_params == NULL) goto failed;
11612
0
            for (i = 0; i < len; i++) {
11613
0
                type_param_ty val;
11614
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11615
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11616
0
                    goto failed;
11617
0
                }
11618
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
11619
0
                _Py_LeaveRecursiveCall();
11620
0
                Py_DECREF(tmp2);
11621
0
                if (res != 0) goto failed;
11622
0
                if (len != PyList_GET_SIZE(tmp)) {
11623
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11624
0
                    goto failed;
11625
0
                }
11626
0
                asdl_seq_SET(type_params, i, val);
11627
0
            }
11628
0
            Py_CLEAR(tmp);
11629
0
        }
11630
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11631
0
                                       returns, type_comment, type_params,
11632
0
                                       lineno, col_offset, end_lineno,
11633
0
                                       end_col_offset, arena);
11634
0
        if (*out == NULL) goto failed;
11635
0
        return 0;
11636
0
    }
11637
0
    tp = state->ClassDef_type;
11638
0
    isinstance = PyObject_IsInstance(obj, tp);
11639
0
    if (isinstance == -1) {
11640
0
        return -1;
11641
0
    }
11642
0
    if (isinstance) {
11643
0
        identifier name;
11644
0
        asdl_expr_seq* bases;
11645
0
        asdl_keyword_seq* keywords;
11646
0
        asdl_stmt_seq* body;
11647
0
        asdl_expr_seq* decorator_list;
11648
0
        asdl_type_param_seq* type_params;
11649
11650
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11651
0
            return -1;
11652
0
        }
11653
0
        if (tmp == NULL) {
11654
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11655
0
            return -1;
11656
0
        }
11657
0
        else {
11658
0
            int res;
11659
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11660
0
                goto failed;
11661
0
            }
11662
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
11663
0
            _Py_LeaveRecursiveCall();
11664
0
            if (res != 0) goto failed;
11665
0
            Py_CLEAR(tmp);
11666
0
        }
11667
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11668
0
            return -1;
11669
0
        }
11670
0
        if (tmp == NULL) {
11671
0
            tmp = PyList_New(0);
11672
0
            if (tmp == NULL) {
11673
0
                return -1;
11674
0
            }
11675
0
        }
11676
0
        {
11677
0
            int res;
11678
0
            Py_ssize_t len;
11679
0
            Py_ssize_t i;
11680
0
            if (!PyList_Check(tmp)) {
11681
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11682
0
                goto failed;
11683
0
            }
11684
0
            len = PyList_GET_SIZE(tmp);
11685
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11686
0
            if (bases == NULL) goto failed;
11687
0
            for (i = 0; i < len; i++) {
11688
0
                expr_ty val;
11689
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11690
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11691
0
                    goto failed;
11692
0
                }
11693
0
                res = obj2ast_expr(state, tmp2, &val, "bases", arena);
11694
0
                _Py_LeaveRecursiveCall();
11695
0
                Py_DECREF(tmp2);
11696
0
                if (res != 0) goto failed;
11697
0
                if (len != PyList_GET_SIZE(tmp)) {
11698
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11699
0
                    goto failed;
11700
0
                }
11701
0
                asdl_seq_SET(bases, i, val);
11702
0
            }
11703
0
            Py_CLEAR(tmp);
11704
0
        }
11705
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11706
0
            return -1;
11707
0
        }
11708
0
        if (tmp == NULL) {
11709
0
            tmp = PyList_New(0);
11710
0
            if (tmp == NULL) {
11711
0
                return -1;
11712
0
            }
11713
0
        }
11714
0
        {
11715
0
            int res;
11716
0
            Py_ssize_t len;
11717
0
            Py_ssize_t i;
11718
0
            if (!PyList_Check(tmp)) {
11719
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11720
0
                goto failed;
11721
0
            }
11722
0
            len = PyList_GET_SIZE(tmp);
11723
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11724
0
            if (keywords == NULL) goto failed;
11725
0
            for (i = 0; i < len; i++) {
11726
0
                keyword_ty val;
11727
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11728
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11729
0
                    goto failed;
11730
0
                }
11731
0
                res = obj2ast_keyword(state, tmp2, &val, "keywords", arena);
11732
0
                _Py_LeaveRecursiveCall();
11733
0
                Py_DECREF(tmp2);
11734
0
                if (res != 0) goto failed;
11735
0
                if (len != PyList_GET_SIZE(tmp)) {
11736
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11737
0
                    goto failed;
11738
0
                }
11739
0
                asdl_seq_SET(keywords, i, val);
11740
0
            }
11741
0
            Py_CLEAR(tmp);
11742
0
        }
11743
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11744
0
            return -1;
11745
0
        }
11746
0
        if (tmp == NULL) {
11747
0
            tmp = PyList_New(0);
11748
0
            if (tmp == NULL) {
11749
0
                return -1;
11750
0
            }
11751
0
        }
11752
0
        {
11753
0
            int res;
11754
0
            Py_ssize_t len;
11755
0
            Py_ssize_t i;
11756
0
            if (!PyList_Check(tmp)) {
11757
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11758
0
                goto failed;
11759
0
            }
11760
0
            len = PyList_GET_SIZE(tmp);
11761
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11762
0
            if (body == NULL) goto failed;
11763
0
            for (i = 0; i < len; i++) {
11764
0
                stmt_ty val;
11765
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11766
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11767
0
                    goto failed;
11768
0
                }
11769
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
11770
0
                _Py_LeaveRecursiveCall();
11771
0
                Py_DECREF(tmp2);
11772
0
                if (res != 0) goto failed;
11773
0
                if (len != PyList_GET_SIZE(tmp)) {
11774
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11775
0
                    goto failed;
11776
0
                }
11777
0
                asdl_seq_SET(body, i, val);
11778
0
            }
11779
0
            Py_CLEAR(tmp);
11780
0
        }
11781
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11782
0
            return -1;
11783
0
        }
11784
0
        if (tmp == NULL) {
11785
0
            tmp = PyList_New(0);
11786
0
            if (tmp == NULL) {
11787
0
                return -1;
11788
0
            }
11789
0
        }
11790
0
        {
11791
0
            int res;
11792
0
            Py_ssize_t len;
11793
0
            Py_ssize_t i;
11794
0
            if (!PyList_Check(tmp)) {
11795
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11796
0
                goto failed;
11797
0
            }
11798
0
            len = PyList_GET_SIZE(tmp);
11799
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11800
0
            if (decorator_list == NULL) goto failed;
11801
0
            for (i = 0; i < len; i++) {
11802
0
                expr_ty val;
11803
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11804
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11805
0
                    goto failed;
11806
0
                }
11807
0
                res = obj2ast_expr(state, tmp2, &val, "decorator_list", arena);
11808
0
                _Py_LeaveRecursiveCall();
11809
0
                Py_DECREF(tmp2);
11810
0
                if (res != 0) goto failed;
11811
0
                if (len != PyList_GET_SIZE(tmp)) {
11812
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11813
0
                    goto failed;
11814
0
                }
11815
0
                asdl_seq_SET(decorator_list, i, val);
11816
0
            }
11817
0
            Py_CLEAR(tmp);
11818
0
        }
11819
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11820
0
            return -1;
11821
0
        }
11822
0
        if (tmp == NULL) {
11823
0
            tmp = PyList_New(0);
11824
0
            if (tmp == NULL) {
11825
0
                return -1;
11826
0
            }
11827
0
        }
11828
0
        {
11829
0
            int res;
11830
0
            Py_ssize_t len;
11831
0
            Py_ssize_t i;
11832
0
            if (!PyList_Check(tmp)) {
11833
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11834
0
                goto failed;
11835
0
            }
11836
0
            len = PyList_GET_SIZE(tmp);
11837
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11838
0
            if (type_params == NULL) goto failed;
11839
0
            for (i = 0; i < len; i++) {
11840
0
                type_param_ty val;
11841
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11842
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11843
0
                    goto failed;
11844
0
                }
11845
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
11846
0
                _Py_LeaveRecursiveCall();
11847
0
                Py_DECREF(tmp2);
11848
0
                if (res != 0) goto failed;
11849
0
                if (len != PyList_GET_SIZE(tmp)) {
11850
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11851
0
                    goto failed;
11852
0
                }
11853
0
                asdl_seq_SET(type_params, i, val);
11854
0
            }
11855
0
            Py_CLEAR(tmp);
11856
0
        }
11857
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11858
0
                               type_params, lineno, col_offset, end_lineno,
11859
0
                               end_col_offset, arena);
11860
0
        if (*out == NULL) goto failed;
11861
0
        return 0;
11862
0
    }
11863
0
    tp = state->Return_type;
11864
0
    isinstance = PyObject_IsInstance(obj, tp);
11865
0
    if (isinstance == -1) {
11866
0
        return -1;
11867
0
    }
11868
0
    if (isinstance) {
11869
0
        expr_ty value;
11870
11871
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11872
0
            return -1;
11873
0
        }
11874
0
        if (tmp == NULL || tmp == Py_None) {
11875
0
            Py_CLEAR(tmp);
11876
0
            value = NULL;
11877
0
        }
11878
0
        else {
11879
0
            int res;
11880
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11881
0
                goto failed;
11882
0
            }
11883
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
11884
0
            _Py_LeaveRecursiveCall();
11885
0
            if (res != 0) goto failed;
11886
0
            Py_CLEAR(tmp);
11887
0
        }
11888
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11889
0
                             end_col_offset, arena);
11890
0
        if (*out == NULL) goto failed;
11891
0
        return 0;
11892
0
    }
11893
0
    tp = state->Delete_type;
11894
0
    isinstance = PyObject_IsInstance(obj, tp);
11895
0
    if (isinstance == -1) {
11896
0
        return -1;
11897
0
    }
11898
0
    if (isinstance) {
11899
0
        asdl_expr_seq* targets;
11900
11901
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11902
0
            return -1;
11903
0
        }
11904
0
        if (tmp == NULL) {
11905
0
            tmp = PyList_New(0);
11906
0
            if (tmp == NULL) {
11907
0
                return -1;
11908
0
            }
11909
0
        }
11910
0
        {
11911
0
            int res;
11912
0
            Py_ssize_t len;
11913
0
            Py_ssize_t i;
11914
0
            if (!PyList_Check(tmp)) {
11915
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11916
0
                goto failed;
11917
0
            }
11918
0
            len = PyList_GET_SIZE(tmp);
11919
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11920
0
            if (targets == NULL) goto failed;
11921
0
            for (i = 0; i < len; i++) {
11922
0
                expr_ty val;
11923
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11924
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11925
0
                    goto failed;
11926
0
                }
11927
0
                res = obj2ast_expr(state, tmp2, &val, "targets", arena);
11928
0
                _Py_LeaveRecursiveCall();
11929
0
                Py_DECREF(tmp2);
11930
0
                if (res != 0) goto failed;
11931
0
                if (len != PyList_GET_SIZE(tmp)) {
11932
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11933
0
                    goto failed;
11934
0
                }
11935
0
                asdl_seq_SET(targets, i, val);
11936
0
            }
11937
0
            Py_CLEAR(tmp);
11938
0
        }
11939
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11940
0
                             end_col_offset, arena);
11941
0
        if (*out == NULL) goto failed;
11942
0
        return 0;
11943
0
    }
11944
0
    tp = state->Assign_type;
11945
0
    isinstance = PyObject_IsInstance(obj, tp);
11946
0
    if (isinstance == -1) {
11947
0
        return -1;
11948
0
    }
11949
0
    if (isinstance) {
11950
0
        asdl_expr_seq* targets;
11951
0
        expr_ty value;
11952
0
        string type_comment;
11953
11954
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11955
0
            return -1;
11956
0
        }
11957
0
        if (tmp == NULL) {
11958
0
            tmp = PyList_New(0);
11959
0
            if (tmp == NULL) {
11960
0
                return -1;
11961
0
            }
11962
0
        }
11963
0
        {
11964
0
            int res;
11965
0
            Py_ssize_t len;
11966
0
            Py_ssize_t i;
11967
0
            if (!PyList_Check(tmp)) {
11968
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11969
0
                goto failed;
11970
0
            }
11971
0
            len = PyList_GET_SIZE(tmp);
11972
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11973
0
            if (targets == NULL) goto failed;
11974
0
            for (i = 0; i < len; i++) {
11975
0
                expr_ty val;
11976
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11977
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11978
0
                    goto failed;
11979
0
                }
11980
0
                res = obj2ast_expr(state, tmp2, &val, "targets", arena);
11981
0
                _Py_LeaveRecursiveCall();
11982
0
                Py_DECREF(tmp2);
11983
0
                if (res != 0) goto failed;
11984
0
                if (len != PyList_GET_SIZE(tmp)) {
11985
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
11986
0
                    goto failed;
11987
0
                }
11988
0
                asdl_seq_SET(targets, i, val);
11989
0
            }
11990
0
            Py_CLEAR(tmp);
11991
0
        }
11992
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11993
0
            return -1;
11994
0
        }
11995
0
        if (tmp == NULL) {
11996
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11997
0
            return -1;
11998
0
        }
11999
0
        else {
12000
0
            int res;
12001
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12002
0
                goto failed;
12003
0
            }
12004
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12005
0
            _Py_LeaveRecursiveCall();
12006
0
            if (res != 0) goto failed;
12007
0
            Py_CLEAR(tmp);
12008
0
        }
12009
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12010
0
            return -1;
12011
0
        }
12012
0
        if (tmp == NULL || tmp == Py_None) {
12013
0
            Py_CLEAR(tmp);
12014
0
            type_comment = NULL;
12015
0
        }
12016
0
        else {
12017
0
            int res;
12018
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12019
0
                goto failed;
12020
0
            }
12021
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12022
0
                                 arena);
12023
0
            _Py_LeaveRecursiveCall();
12024
0
            if (res != 0) goto failed;
12025
0
            Py_CLEAR(tmp);
12026
0
        }
12027
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
12028
0
                             end_lineno, end_col_offset, arena);
12029
0
        if (*out == NULL) goto failed;
12030
0
        return 0;
12031
0
    }
12032
0
    tp = state->TypeAlias_type;
12033
0
    isinstance = PyObject_IsInstance(obj, tp);
12034
0
    if (isinstance == -1) {
12035
0
        return -1;
12036
0
    }
12037
0
    if (isinstance) {
12038
0
        expr_ty name;
12039
0
        asdl_type_param_seq* type_params;
12040
0
        expr_ty value;
12041
12042
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12043
0
            return -1;
12044
0
        }
12045
0
        if (tmp == NULL) {
12046
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12047
0
            return -1;
12048
0
        }
12049
0
        else {
12050
0
            int res;
12051
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12052
0
                goto failed;
12053
0
            }
12054
0
            res = obj2ast_expr(state, tmp, &name, "name", arena);
12055
0
            _Py_LeaveRecursiveCall();
12056
0
            if (res != 0) goto failed;
12057
0
            Py_CLEAR(tmp);
12058
0
        }
12059
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12060
0
            return -1;
12061
0
        }
12062
0
        if (tmp == NULL) {
12063
0
            tmp = PyList_New(0);
12064
0
            if (tmp == NULL) {
12065
0
                return -1;
12066
0
            }
12067
0
        }
12068
0
        {
12069
0
            int res;
12070
0
            Py_ssize_t len;
12071
0
            Py_ssize_t i;
12072
0
            if (!PyList_Check(tmp)) {
12073
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12074
0
                goto failed;
12075
0
            }
12076
0
            len = PyList_GET_SIZE(tmp);
12077
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12078
0
            if (type_params == NULL) goto failed;
12079
0
            for (i = 0; i < len; i++) {
12080
0
                type_param_ty val;
12081
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12082
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12083
0
                    goto failed;
12084
0
                }
12085
0
                res = obj2ast_type_param(state, tmp2, &val, "type_params", arena);
12086
0
                _Py_LeaveRecursiveCall();
12087
0
                Py_DECREF(tmp2);
12088
0
                if (res != 0) goto failed;
12089
0
                if (len != PyList_GET_SIZE(tmp)) {
12090
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12091
0
                    goto failed;
12092
0
                }
12093
0
                asdl_seq_SET(type_params, i, val);
12094
0
            }
12095
0
            Py_CLEAR(tmp);
12096
0
        }
12097
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12098
0
            return -1;
12099
0
        }
12100
0
        if (tmp == NULL) {
12101
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12102
0
            return -1;
12103
0
        }
12104
0
        else {
12105
0
            int res;
12106
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12107
0
                goto failed;
12108
0
            }
12109
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12110
0
            _Py_LeaveRecursiveCall();
12111
0
            if (res != 0) goto failed;
12112
0
            Py_CLEAR(tmp);
12113
0
        }
12114
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12115
0
                                end_lineno, end_col_offset, arena);
12116
0
        if (*out == NULL) goto failed;
12117
0
        return 0;
12118
0
    }
12119
0
    tp = state->AugAssign_type;
12120
0
    isinstance = PyObject_IsInstance(obj, tp);
12121
0
    if (isinstance == -1) {
12122
0
        return -1;
12123
0
    }
12124
0
    if (isinstance) {
12125
0
        expr_ty target;
12126
0
        operator_ty op;
12127
0
        expr_ty value;
12128
12129
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12130
0
            return -1;
12131
0
        }
12132
0
        if (tmp == NULL) {
12133
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12134
0
            return -1;
12135
0
        }
12136
0
        else {
12137
0
            int res;
12138
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12139
0
                goto failed;
12140
0
            }
12141
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12142
0
            _Py_LeaveRecursiveCall();
12143
0
            if (res != 0) goto failed;
12144
0
            Py_CLEAR(tmp);
12145
0
        }
12146
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12147
0
            return -1;
12148
0
        }
12149
0
        if (tmp == NULL) {
12150
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12151
0
            return -1;
12152
0
        }
12153
0
        else {
12154
0
            int res;
12155
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12156
0
                goto failed;
12157
0
            }
12158
0
            res = obj2ast_operator(state, tmp, &op, "op", arena);
12159
0
            _Py_LeaveRecursiveCall();
12160
0
            if (res != 0) goto failed;
12161
0
            Py_CLEAR(tmp);
12162
0
        }
12163
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12164
0
            return -1;
12165
0
        }
12166
0
        if (tmp == NULL) {
12167
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12168
0
            return -1;
12169
0
        }
12170
0
        else {
12171
0
            int res;
12172
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12173
0
                goto failed;
12174
0
            }
12175
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12176
0
            _Py_LeaveRecursiveCall();
12177
0
            if (res != 0) goto failed;
12178
0
            Py_CLEAR(tmp);
12179
0
        }
12180
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12181
0
                                end_lineno, end_col_offset, arena);
12182
0
        if (*out == NULL) goto failed;
12183
0
        return 0;
12184
0
    }
12185
0
    tp = state->AnnAssign_type;
12186
0
    isinstance = PyObject_IsInstance(obj, tp);
12187
0
    if (isinstance == -1) {
12188
0
        return -1;
12189
0
    }
12190
0
    if (isinstance) {
12191
0
        expr_ty target;
12192
0
        expr_ty annotation;
12193
0
        expr_ty value;
12194
0
        int simple;
12195
12196
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12197
0
            return -1;
12198
0
        }
12199
0
        if (tmp == NULL) {
12200
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12201
0
            return -1;
12202
0
        }
12203
0
        else {
12204
0
            int res;
12205
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12206
0
                goto failed;
12207
0
            }
12208
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12209
0
            _Py_LeaveRecursiveCall();
12210
0
            if (res != 0) goto failed;
12211
0
            Py_CLEAR(tmp);
12212
0
        }
12213
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12214
0
            return -1;
12215
0
        }
12216
0
        if (tmp == NULL) {
12217
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12218
0
            return -1;
12219
0
        }
12220
0
        else {
12221
0
            int res;
12222
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12223
0
                goto failed;
12224
0
            }
12225
0
            res = obj2ast_expr(state, tmp, &annotation, "annotation", arena);
12226
0
            _Py_LeaveRecursiveCall();
12227
0
            if (res != 0) goto failed;
12228
0
            Py_CLEAR(tmp);
12229
0
        }
12230
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12231
0
            return -1;
12232
0
        }
12233
0
        if (tmp == NULL || tmp == Py_None) {
12234
0
            Py_CLEAR(tmp);
12235
0
            value = NULL;
12236
0
        }
12237
0
        else {
12238
0
            int res;
12239
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12240
0
                goto failed;
12241
0
            }
12242
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
12243
0
            _Py_LeaveRecursiveCall();
12244
0
            if (res != 0) goto failed;
12245
0
            Py_CLEAR(tmp);
12246
0
        }
12247
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
12248
0
            return -1;
12249
0
        }
12250
0
        if (tmp == NULL) {
12251
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12252
0
            return -1;
12253
0
        }
12254
0
        else {
12255
0
            int res;
12256
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12257
0
                goto failed;
12258
0
            }
12259
0
            res = obj2ast_int(state, tmp, &simple, "simple", arena);
12260
0
            _Py_LeaveRecursiveCall();
12261
0
            if (res != 0) goto failed;
12262
0
            Py_CLEAR(tmp);
12263
0
        }
12264
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12265
0
                                col_offset, end_lineno, end_col_offset, arena);
12266
0
        if (*out == NULL) goto failed;
12267
0
        return 0;
12268
0
    }
12269
0
    tp = state->For_type;
12270
0
    isinstance = PyObject_IsInstance(obj, tp);
12271
0
    if (isinstance == -1) {
12272
0
        return -1;
12273
0
    }
12274
0
    if (isinstance) {
12275
0
        expr_ty target;
12276
0
        expr_ty iter;
12277
0
        asdl_stmt_seq* body;
12278
0
        asdl_stmt_seq* orelse;
12279
0
        string type_comment;
12280
12281
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12282
0
            return -1;
12283
0
        }
12284
0
        if (tmp == NULL) {
12285
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12286
0
            return -1;
12287
0
        }
12288
0
        else {
12289
0
            int res;
12290
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12291
0
                goto failed;
12292
0
            }
12293
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12294
0
            _Py_LeaveRecursiveCall();
12295
0
            if (res != 0) goto failed;
12296
0
            Py_CLEAR(tmp);
12297
0
        }
12298
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12299
0
            return -1;
12300
0
        }
12301
0
        if (tmp == NULL) {
12302
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12303
0
            return -1;
12304
0
        }
12305
0
        else {
12306
0
            int res;
12307
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12308
0
                goto failed;
12309
0
            }
12310
0
            res = obj2ast_expr(state, tmp, &iter, "iter", arena);
12311
0
            _Py_LeaveRecursiveCall();
12312
0
            if (res != 0) goto failed;
12313
0
            Py_CLEAR(tmp);
12314
0
        }
12315
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12316
0
            return -1;
12317
0
        }
12318
0
        if (tmp == NULL) {
12319
0
            tmp = PyList_New(0);
12320
0
            if (tmp == NULL) {
12321
0
                return -1;
12322
0
            }
12323
0
        }
12324
0
        {
12325
0
            int res;
12326
0
            Py_ssize_t len;
12327
0
            Py_ssize_t i;
12328
0
            if (!PyList_Check(tmp)) {
12329
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12330
0
                goto failed;
12331
0
            }
12332
0
            len = PyList_GET_SIZE(tmp);
12333
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12334
0
            if (body == NULL) goto failed;
12335
0
            for (i = 0; i < len; i++) {
12336
0
                stmt_ty val;
12337
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12338
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12339
0
                    goto failed;
12340
0
                }
12341
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12342
0
                _Py_LeaveRecursiveCall();
12343
0
                Py_DECREF(tmp2);
12344
0
                if (res != 0) goto failed;
12345
0
                if (len != PyList_GET_SIZE(tmp)) {
12346
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12347
0
                    goto failed;
12348
0
                }
12349
0
                asdl_seq_SET(body, i, val);
12350
0
            }
12351
0
            Py_CLEAR(tmp);
12352
0
        }
12353
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12354
0
            return -1;
12355
0
        }
12356
0
        if (tmp == NULL) {
12357
0
            tmp = PyList_New(0);
12358
0
            if (tmp == NULL) {
12359
0
                return -1;
12360
0
            }
12361
0
        }
12362
0
        {
12363
0
            int res;
12364
0
            Py_ssize_t len;
12365
0
            Py_ssize_t i;
12366
0
            if (!PyList_Check(tmp)) {
12367
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12368
0
                goto failed;
12369
0
            }
12370
0
            len = PyList_GET_SIZE(tmp);
12371
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12372
0
            if (orelse == NULL) goto failed;
12373
0
            for (i = 0; i < len; i++) {
12374
0
                stmt_ty val;
12375
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12376
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12377
0
                    goto failed;
12378
0
                }
12379
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12380
0
                _Py_LeaveRecursiveCall();
12381
0
                Py_DECREF(tmp2);
12382
0
                if (res != 0) goto failed;
12383
0
                if (len != PyList_GET_SIZE(tmp)) {
12384
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12385
0
                    goto failed;
12386
0
                }
12387
0
                asdl_seq_SET(orelse, i, val);
12388
0
            }
12389
0
            Py_CLEAR(tmp);
12390
0
        }
12391
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12392
0
            return -1;
12393
0
        }
12394
0
        if (tmp == NULL || tmp == Py_None) {
12395
0
            Py_CLEAR(tmp);
12396
0
            type_comment = NULL;
12397
0
        }
12398
0
        else {
12399
0
            int res;
12400
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12401
0
                goto failed;
12402
0
            }
12403
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12404
0
                                 arena);
12405
0
            _Py_LeaveRecursiveCall();
12406
0
            if (res != 0) goto failed;
12407
0
            Py_CLEAR(tmp);
12408
0
        }
12409
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12410
0
                          col_offset, end_lineno, end_col_offset, arena);
12411
0
        if (*out == NULL) goto failed;
12412
0
        return 0;
12413
0
    }
12414
0
    tp = state->AsyncFor_type;
12415
0
    isinstance = PyObject_IsInstance(obj, tp);
12416
0
    if (isinstance == -1) {
12417
0
        return -1;
12418
0
    }
12419
0
    if (isinstance) {
12420
0
        expr_ty target;
12421
0
        expr_ty iter;
12422
0
        asdl_stmt_seq* body;
12423
0
        asdl_stmt_seq* orelse;
12424
0
        string type_comment;
12425
12426
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12427
0
            return -1;
12428
0
        }
12429
0
        if (tmp == NULL) {
12430
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12431
0
            return -1;
12432
0
        }
12433
0
        else {
12434
0
            int res;
12435
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12436
0
                goto failed;
12437
0
            }
12438
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
12439
0
            _Py_LeaveRecursiveCall();
12440
0
            if (res != 0) goto failed;
12441
0
            Py_CLEAR(tmp);
12442
0
        }
12443
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12444
0
            return -1;
12445
0
        }
12446
0
        if (tmp == NULL) {
12447
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12448
0
            return -1;
12449
0
        }
12450
0
        else {
12451
0
            int res;
12452
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12453
0
                goto failed;
12454
0
            }
12455
0
            res = obj2ast_expr(state, tmp, &iter, "iter", arena);
12456
0
            _Py_LeaveRecursiveCall();
12457
0
            if (res != 0) goto failed;
12458
0
            Py_CLEAR(tmp);
12459
0
        }
12460
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12461
0
            return -1;
12462
0
        }
12463
0
        if (tmp == NULL) {
12464
0
            tmp = PyList_New(0);
12465
0
            if (tmp == NULL) {
12466
0
                return -1;
12467
0
            }
12468
0
        }
12469
0
        {
12470
0
            int res;
12471
0
            Py_ssize_t len;
12472
0
            Py_ssize_t i;
12473
0
            if (!PyList_Check(tmp)) {
12474
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12475
0
                goto failed;
12476
0
            }
12477
0
            len = PyList_GET_SIZE(tmp);
12478
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12479
0
            if (body == NULL) goto failed;
12480
0
            for (i = 0; i < len; i++) {
12481
0
                stmt_ty val;
12482
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12483
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12484
0
                    goto failed;
12485
0
                }
12486
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12487
0
                _Py_LeaveRecursiveCall();
12488
0
                Py_DECREF(tmp2);
12489
0
                if (res != 0) goto failed;
12490
0
                if (len != PyList_GET_SIZE(tmp)) {
12491
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12492
0
                    goto failed;
12493
0
                }
12494
0
                asdl_seq_SET(body, i, val);
12495
0
            }
12496
0
            Py_CLEAR(tmp);
12497
0
        }
12498
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12499
0
            return -1;
12500
0
        }
12501
0
        if (tmp == NULL) {
12502
0
            tmp = PyList_New(0);
12503
0
            if (tmp == NULL) {
12504
0
                return -1;
12505
0
            }
12506
0
        }
12507
0
        {
12508
0
            int res;
12509
0
            Py_ssize_t len;
12510
0
            Py_ssize_t i;
12511
0
            if (!PyList_Check(tmp)) {
12512
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12513
0
                goto failed;
12514
0
            }
12515
0
            len = PyList_GET_SIZE(tmp);
12516
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12517
0
            if (orelse == NULL) goto failed;
12518
0
            for (i = 0; i < len; i++) {
12519
0
                stmt_ty val;
12520
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12521
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12522
0
                    goto failed;
12523
0
                }
12524
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12525
0
                _Py_LeaveRecursiveCall();
12526
0
                Py_DECREF(tmp2);
12527
0
                if (res != 0) goto failed;
12528
0
                if (len != PyList_GET_SIZE(tmp)) {
12529
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12530
0
                    goto failed;
12531
0
                }
12532
0
                asdl_seq_SET(orelse, i, val);
12533
0
            }
12534
0
            Py_CLEAR(tmp);
12535
0
        }
12536
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12537
0
            return -1;
12538
0
        }
12539
0
        if (tmp == NULL || tmp == Py_None) {
12540
0
            Py_CLEAR(tmp);
12541
0
            type_comment = NULL;
12542
0
        }
12543
0
        else {
12544
0
            int res;
12545
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12546
0
                goto failed;
12547
0
            }
12548
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12549
0
                                 arena);
12550
0
            _Py_LeaveRecursiveCall();
12551
0
            if (res != 0) goto failed;
12552
0
            Py_CLEAR(tmp);
12553
0
        }
12554
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12555
0
                               lineno, col_offset, end_lineno, end_col_offset,
12556
0
                               arena);
12557
0
        if (*out == NULL) goto failed;
12558
0
        return 0;
12559
0
    }
12560
0
    tp = state->While_type;
12561
0
    isinstance = PyObject_IsInstance(obj, tp);
12562
0
    if (isinstance == -1) {
12563
0
        return -1;
12564
0
    }
12565
0
    if (isinstance) {
12566
0
        expr_ty test;
12567
0
        asdl_stmt_seq* body;
12568
0
        asdl_stmt_seq* orelse;
12569
12570
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12571
0
            return -1;
12572
0
        }
12573
0
        if (tmp == NULL) {
12574
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12575
0
            return -1;
12576
0
        }
12577
0
        else {
12578
0
            int res;
12579
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12580
0
                goto failed;
12581
0
            }
12582
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
12583
0
            _Py_LeaveRecursiveCall();
12584
0
            if (res != 0) goto failed;
12585
0
            Py_CLEAR(tmp);
12586
0
        }
12587
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12588
0
            return -1;
12589
0
        }
12590
0
        if (tmp == NULL) {
12591
0
            tmp = PyList_New(0);
12592
0
            if (tmp == NULL) {
12593
0
                return -1;
12594
0
            }
12595
0
        }
12596
0
        {
12597
0
            int res;
12598
0
            Py_ssize_t len;
12599
0
            Py_ssize_t i;
12600
0
            if (!PyList_Check(tmp)) {
12601
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12602
0
                goto failed;
12603
0
            }
12604
0
            len = PyList_GET_SIZE(tmp);
12605
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12606
0
            if (body == NULL) goto failed;
12607
0
            for (i = 0; i < len; i++) {
12608
0
                stmt_ty val;
12609
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12610
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12611
0
                    goto failed;
12612
0
                }
12613
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12614
0
                _Py_LeaveRecursiveCall();
12615
0
                Py_DECREF(tmp2);
12616
0
                if (res != 0) goto failed;
12617
0
                if (len != PyList_GET_SIZE(tmp)) {
12618
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12619
0
                    goto failed;
12620
0
                }
12621
0
                asdl_seq_SET(body, i, val);
12622
0
            }
12623
0
            Py_CLEAR(tmp);
12624
0
        }
12625
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12626
0
            return -1;
12627
0
        }
12628
0
        if (tmp == NULL) {
12629
0
            tmp = PyList_New(0);
12630
0
            if (tmp == NULL) {
12631
0
                return -1;
12632
0
            }
12633
0
        }
12634
0
        {
12635
0
            int res;
12636
0
            Py_ssize_t len;
12637
0
            Py_ssize_t i;
12638
0
            if (!PyList_Check(tmp)) {
12639
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12640
0
                goto failed;
12641
0
            }
12642
0
            len = PyList_GET_SIZE(tmp);
12643
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12644
0
            if (orelse == NULL) goto failed;
12645
0
            for (i = 0; i < len; i++) {
12646
0
                stmt_ty val;
12647
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12648
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12649
0
                    goto failed;
12650
0
                }
12651
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12652
0
                _Py_LeaveRecursiveCall();
12653
0
                Py_DECREF(tmp2);
12654
0
                if (res != 0) goto failed;
12655
0
                if (len != PyList_GET_SIZE(tmp)) {
12656
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12657
0
                    goto failed;
12658
0
                }
12659
0
                asdl_seq_SET(orelse, i, val);
12660
0
            }
12661
0
            Py_CLEAR(tmp);
12662
0
        }
12663
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12664
0
                            end_col_offset, arena);
12665
0
        if (*out == NULL) goto failed;
12666
0
        return 0;
12667
0
    }
12668
0
    tp = state->If_type;
12669
0
    isinstance = PyObject_IsInstance(obj, tp);
12670
0
    if (isinstance == -1) {
12671
0
        return -1;
12672
0
    }
12673
0
    if (isinstance) {
12674
0
        expr_ty test;
12675
0
        asdl_stmt_seq* body;
12676
0
        asdl_stmt_seq* orelse;
12677
12678
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12679
0
            return -1;
12680
0
        }
12681
0
        if (tmp == NULL) {
12682
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12683
0
            return -1;
12684
0
        }
12685
0
        else {
12686
0
            int res;
12687
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12688
0
                goto failed;
12689
0
            }
12690
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
12691
0
            _Py_LeaveRecursiveCall();
12692
0
            if (res != 0) goto failed;
12693
0
            Py_CLEAR(tmp);
12694
0
        }
12695
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12696
0
            return -1;
12697
0
        }
12698
0
        if (tmp == NULL) {
12699
0
            tmp = PyList_New(0);
12700
0
            if (tmp == NULL) {
12701
0
                return -1;
12702
0
            }
12703
0
        }
12704
0
        {
12705
0
            int res;
12706
0
            Py_ssize_t len;
12707
0
            Py_ssize_t i;
12708
0
            if (!PyList_Check(tmp)) {
12709
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12710
0
                goto failed;
12711
0
            }
12712
0
            len = PyList_GET_SIZE(tmp);
12713
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12714
0
            if (body == NULL) goto failed;
12715
0
            for (i = 0; i < len; i++) {
12716
0
                stmt_ty val;
12717
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12718
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12719
0
                    goto failed;
12720
0
                }
12721
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12722
0
                _Py_LeaveRecursiveCall();
12723
0
                Py_DECREF(tmp2);
12724
0
                if (res != 0) goto failed;
12725
0
                if (len != PyList_GET_SIZE(tmp)) {
12726
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12727
0
                    goto failed;
12728
0
                }
12729
0
                asdl_seq_SET(body, i, val);
12730
0
            }
12731
0
            Py_CLEAR(tmp);
12732
0
        }
12733
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12734
0
            return -1;
12735
0
        }
12736
0
        if (tmp == NULL) {
12737
0
            tmp = PyList_New(0);
12738
0
            if (tmp == NULL) {
12739
0
                return -1;
12740
0
            }
12741
0
        }
12742
0
        {
12743
0
            int res;
12744
0
            Py_ssize_t len;
12745
0
            Py_ssize_t i;
12746
0
            if (!PyList_Check(tmp)) {
12747
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12748
0
                goto failed;
12749
0
            }
12750
0
            len = PyList_GET_SIZE(tmp);
12751
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12752
0
            if (orelse == NULL) goto failed;
12753
0
            for (i = 0; i < len; i++) {
12754
0
                stmt_ty val;
12755
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12756
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12757
0
                    goto failed;
12758
0
                }
12759
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
12760
0
                _Py_LeaveRecursiveCall();
12761
0
                Py_DECREF(tmp2);
12762
0
                if (res != 0) goto failed;
12763
0
                if (len != PyList_GET_SIZE(tmp)) {
12764
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12765
0
                    goto failed;
12766
0
                }
12767
0
                asdl_seq_SET(orelse, i, val);
12768
0
            }
12769
0
            Py_CLEAR(tmp);
12770
0
        }
12771
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12772
0
                         end_col_offset, arena);
12773
0
        if (*out == NULL) goto failed;
12774
0
        return 0;
12775
0
    }
12776
0
    tp = state->With_type;
12777
0
    isinstance = PyObject_IsInstance(obj, tp);
12778
0
    if (isinstance == -1) {
12779
0
        return -1;
12780
0
    }
12781
0
    if (isinstance) {
12782
0
        asdl_withitem_seq* items;
12783
0
        asdl_stmt_seq* body;
12784
0
        string type_comment;
12785
12786
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12787
0
            return -1;
12788
0
        }
12789
0
        if (tmp == NULL) {
12790
0
            tmp = PyList_New(0);
12791
0
            if (tmp == NULL) {
12792
0
                return -1;
12793
0
            }
12794
0
        }
12795
0
        {
12796
0
            int res;
12797
0
            Py_ssize_t len;
12798
0
            Py_ssize_t i;
12799
0
            if (!PyList_Check(tmp)) {
12800
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12801
0
                goto failed;
12802
0
            }
12803
0
            len = PyList_GET_SIZE(tmp);
12804
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12805
0
            if (items == NULL) goto failed;
12806
0
            for (i = 0; i < len; i++) {
12807
0
                withitem_ty val;
12808
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12809
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12810
0
                    goto failed;
12811
0
                }
12812
0
                res = obj2ast_withitem(state, tmp2, &val, "items", arena);
12813
0
                _Py_LeaveRecursiveCall();
12814
0
                Py_DECREF(tmp2);
12815
0
                if (res != 0) goto failed;
12816
0
                if (len != PyList_GET_SIZE(tmp)) {
12817
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12818
0
                    goto failed;
12819
0
                }
12820
0
                asdl_seq_SET(items, i, val);
12821
0
            }
12822
0
            Py_CLEAR(tmp);
12823
0
        }
12824
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12825
0
            return -1;
12826
0
        }
12827
0
        if (tmp == NULL) {
12828
0
            tmp = PyList_New(0);
12829
0
            if (tmp == NULL) {
12830
0
                return -1;
12831
0
            }
12832
0
        }
12833
0
        {
12834
0
            int res;
12835
0
            Py_ssize_t len;
12836
0
            Py_ssize_t i;
12837
0
            if (!PyList_Check(tmp)) {
12838
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12839
0
                goto failed;
12840
0
            }
12841
0
            len = PyList_GET_SIZE(tmp);
12842
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12843
0
            if (body == NULL) goto failed;
12844
0
            for (i = 0; i < len; i++) {
12845
0
                stmt_ty val;
12846
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12847
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12848
0
                    goto failed;
12849
0
                }
12850
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12851
0
                _Py_LeaveRecursiveCall();
12852
0
                Py_DECREF(tmp2);
12853
0
                if (res != 0) goto failed;
12854
0
                if (len != PyList_GET_SIZE(tmp)) {
12855
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12856
0
                    goto failed;
12857
0
                }
12858
0
                asdl_seq_SET(body, i, val);
12859
0
            }
12860
0
            Py_CLEAR(tmp);
12861
0
        }
12862
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12863
0
            return -1;
12864
0
        }
12865
0
        if (tmp == NULL || tmp == Py_None) {
12866
0
            Py_CLEAR(tmp);
12867
0
            type_comment = NULL;
12868
0
        }
12869
0
        else {
12870
0
            int res;
12871
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12872
0
                goto failed;
12873
0
            }
12874
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12875
0
                                 arena);
12876
0
            _Py_LeaveRecursiveCall();
12877
0
            if (res != 0) goto failed;
12878
0
            Py_CLEAR(tmp);
12879
0
        }
12880
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12881
0
                           end_lineno, end_col_offset, arena);
12882
0
        if (*out == NULL) goto failed;
12883
0
        return 0;
12884
0
    }
12885
0
    tp = state->AsyncWith_type;
12886
0
    isinstance = PyObject_IsInstance(obj, tp);
12887
0
    if (isinstance == -1) {
12888
0
        return -1;
12889
0
    }
12890
0
    if (isinstance) {
12891
0
        asdl_withitem_seq* items;
12892
0
        asdl_stmt_seq* body;
12893
0
        string type_comment;
12894
12895
0
        if (PyObject_GetOptionalAttr(obj, state->items, &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 \"items\" 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
            items = _Py_asdl_withitem_seq_new(len, arena);
12914
0
            if (items == NULL) goto failed;
12915
0
            for (i = 0; i < len; i++) {
12916
0
                withitem_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_withitem(state, tmp2, &val, "items", 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 \"items\" changed size during iteration");
12927
0
                    goto failed;
12928
0
                }
12929
0
                asdl_seq_SET(items, i, val);
12930
0
            }
12931
0
            Py_CLEAR(tmp);
12932
0
        }
12933
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12934
0
            return -1;
12935
0
        }
12936
0
        if (tmp == NULL) {
12937
0
            tmp = PyList_New(0);
12938
0
            if (tmp == NULL) {
12939
0
                return -1;
12940
0
            }
12941
0
        }
12942
0
        {
12943
0
            int res;
12944
0
            Py_ssize_t len;
12945
0
            Py_ssize_t i;
12946
0
            if (!PyList_Check(tmp)) {
12947
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12948
0
                goto failed;
12949
0
            }
12950
0
            len = PyList_GET_SIZE(tmp);
12951
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12952
0
            if (body == NULL) goto failed;
12953
0
            for (i = 0; i < len; i++) {
12954
0
                stmt_ty val;
12955
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12956
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12957
0
                    goto failed;
12958
0
                }
12959
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
12960
0
                _Py_LeaveRecursiveCall();
12961
0
                Py_DECREF(tmp2);
12962
0
                if (res != 0) goto failed;
12963
0
                if (len != PyList_GET_SIZE(tmp)) {
12964
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12965
0
                    goto failed;
12966
0
                }
12967
0
                asdl_seq_SET(body, i, val);
12968
0
            }
12969
0
            Py_CLEAR(tmp);
12970
0
        }
12971
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12972
0
            return -1;
12973
0
        }
12974
0
        if (tmp == NULL || tmp == Py_None) {
12975
0
            Py_CLEAR(tmp);
12976
0
            type_comment = NULL;
12977
0
        }
12978
0
        else {
12979
0
            int res;
12980
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12981
0
                goto failed;
12982
0
            }
12983
0
            res = obj2ast_string(state, tmp, &type_comment, "type_comment",
12984
0
                                 arena);
12985
0
            _Py_LeaveRecursiveCall();
12986
0
            if (res != 0) goto failed;
12987
0
            Py_CLEAR(tmp);
12988
0
        }
12989
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12990
0
                                end_lineno, end_col_offset, arena);
12991
0
        if (*out == NULL) goto failed;
12992
0
        return 0;
12993
0
    }
12994
0
    tp = state->Match_type;
12995
0
    isinstance = PyObject_IsInstance(obj, tp);
12996
0
    if (isinstance == -1) {
12997
0
        return -1;
12998
0
    }
12999
0
    if (isinstance) {
13000
0
        expr_ty subject;
13001
0
        asdl_match_case_seq* cases;
13002
13003
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
13004
0
            return -1;
13005
0
        }
13006
0
        if (tmp == NULL) {
13007
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
13008
0
            return -1;
13009
0
        }
13010
0
        else {
13011
0
            int res;
13012
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13013
0
                goto failed;
13014
0
            }
13015
0
            res = obj2ast_expr(state, tmp, &subject, "subject", arena);
13016
0
            _Py_LeaveRecursiveCall();
13017
0
            if (res != 0) goto failed;
13018
0
            Py_CLEAR(tmp);
13019
0
        }
13020
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
13021
0
            return -1;
13022
0
        }
13023
0
        if (tmp == NULL) {
13024
0
            tmp = PyList_New(0);
13025
0
            if (tmp == NULL) {
13026
0
                return -1;
13027
0
            }
13028
0
        }
13029
0
        {
13030
0
            int res;
13031
0
            Py_ssize_t len;
13032
0
            Py_ssize_t i;
13033
0
            if (!PyList_Check(tmp)) {
13034
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13035
0
                goto failed;
13036
0
            }
13037
0
            len = PyList_GET_SIZE(tmp);
13038
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13039
0
            if (cases == NULL) goto failed;
13040
0
            for (i = 0; i < len; i++) {
13041
0
                match_case_ty val;
13042
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13043
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13044
0
                    goto failed;
13045
0
                }
13046
0
                res = obj2ast_match_case(state, tmp2, &val, "cases", arena);
13047
0
                _Py_LeaveRecursiveCall();
13048
0
                Py_DECREF(tmp2);
13049
0
                if (res != 0) goto failed;
13050
0
                if (len != PyList_GET_SIZE(tmp)) {
13051
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13052
0
                    goto failed;
13053
0
                }
13054
0
                asdl_seq_SET(cases, i, val);
13055
0
            }
13056
0
            Py_CLEAR(tmp);
13057
0
        }
13058
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13059
0
                            end_col_offset, arena);
13060
0
        if (*out == NULL) goto failed;
13061
0
        return 0;
13062
0
    }
13063
0
    tp = state->Raise_type;
13064
0
    isinstance = PyObject_IsInstance(obj, tp);
13065
0
    if (isinstance == -1) {
13066
0
        return -1;
13067
0
    }
13068
0
    if (isinstance) {
13069
0
        expr_ty exc;
13070
0
        expr_ty cause;
13071
13072
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13073
0
            return -1;
13074
0
        }
13075
0
        if (tmp == NULL || tmp == Py_None) {
13076
0
            Py_CLEAR(tmp);
13077
0
            exc = NULL;
13078
0
        }
13079
0
        else {
13080
0
            int res;
13081
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13082
0
                goto failed;
13083
0
            }
13084
0
            res = obj2ast_expr(state, tmp, &exc, "exc", arena);
13085
0
            _Py_LeaveRecursiveCall();
13086
0
            if (res != 0) goto failed;
13087
0
            Py_CLEAR(tmp);
13088
0
        }
13089
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13090
0
            return -1;
13091
0
        }
13092
0
        if (tmp == NULL || tmp == Py_None) {
13093
0
            Py_CLEAR(tmp);
13094
0
            cause = NULL;
13095
0
        }
13096
0
        else {
13097
0
            int res;
13098
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13099
0
                goto failed;
13100
0
            }
13101
0
            res = obj2ast_expr(state, tmp, &cause, "cause", arena);
13102
0
            _Py_LeaveRecursiveCall();
13103
0
            if (res != 0) goto failed;
13104
0
            Py_CLEAR(tmp);
13105
0
        }
13106
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13107
0
                            end_col_offset, arena);
13108
0
        if (*out == NULL) goto failed;
13109
0
        return 0;
13110
0
    }
13111
0
    tp = state->Try_type;
13112
0
    isinstance = PyObject_IsInstance(obj, tp);
13113
0
    if (isinstance == -1) {
13114
0
        return -1;
13115
0
    }
13116
0
    if (isinstance) {
13117
0
        asdl_stmt_seq* body;
13118
0
        asdl_excepthandler_seq* handlers;
13119
0
        asdl_stmt_seq* orelse;
13120
0
        asdl_stmt_seq* finalbody;
13121
13122
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13123
0
            return -1;
13124
0
        }
13125
0
        if (tmp == NULL) {
13126
0
            tmp = PyList_New(0);
13127
0
            if (tmp == NULL) {
13128
0
                return -1;
13129
0
            }
13130
0
        }
13131
0
        {
13132
0
            int res;
13133
0
            Py_ssize_t len;
13134
0
            Py_ssize_t i;
13135
0
            if (!PyList_Check(tmp)) {
13136
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13137
0
                goto failed;
13138
0
            }
13139
0
            len = PyList_GET_SIZE(tmp);
13140
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13141
0
            if (body == NULL) goto failed;
13142
0
            for (i = 0; i < len; i++) {
13143
0
                stmt_ty val;
13144
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13145
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13146
0
                    goto failed;
13147
0
                }
13148
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
13149
0
                _Py_LeaveRecursiveCall();
13150
0
                Py_DECREF(tmp2);
13151
0
                if (res != 0) goto failed;
13152
0
                if (len != PyList_GET_SIZE(tmp)) {
13153
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13154
0
                    goto failed;
13155
0
                }
13156
0
                asdl_seq_SET(body, i, val);
13157
0
            }
13158
0
            Py_CLEAR(tmp);
13159
0
        }
13160
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13161
0
            return -1;
13162
0
        }
13163
0
        if (tmp == NULL) {
13164
0
            tmp = PyList_New(0);
13165
0
            if (tmp == NULL) {
13166
0
                return -1;
13167
0
            }
13168
0
        }
13169
0
        {
13170
0
            int res;
13171
0
            Py_ssize_t len;
13172
0
            Py_ssize_t i;
13173
0
            if (!PyList_Check(tmp)) {
13174
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13175
0
                goto failed;
13176
0
            }
13177
0
            len = PyList_GET_SIZE(tmp);
13178
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13179
0
            if (handlers == NULL) goto failed;
13180
0
            for (i = 0; i < len; i++) {
13181
0
                excepthandler_ty val;
13182
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13183
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13184
0
                    goto failed;
13185
0
                }
13186
0
                res = obj2ast_excepthandler(state, tmp2, &val, "handlers", arena);
13187
0
                _Py_LeaveRecursiveCall();
13188
0
                Py_DECREF(tmp2);
13189
0
                if (res != 0) goto failed;
13190
0
                if (len != PyList_GET_SIZE(tmp)) {
13191
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13192
0
                    goto failed;
13193
0
                }
13194
0
                asdl_seq_SET(handlers, i, val);
13195
0
            }
13196
0
            Py_CLEAR(tmp);
13197
0
        }
13198
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13199
0
            return -1;
13200
0
        }
13201
0
        if (tmp == NULL) {
13202
0
            tmp = PyList_New(0);
13203
0
            if (tmp == NULL) {
13204
0
                return -1;
13205
0
            }
13206
0
        }
13207
0
        {
13208
0
            int res;
13209
0
            Py_ssize_t len;
13210
0
            Py_ssize_t i;
13211
0
            if (!PyList_Check(tmp)) {
13212
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13213
0
                goto failed;
13214
0
            }
13215
0
            len = PyList_GET_SIZE(tmp);
13216
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13217
0
            if (orelse == NULL) goto failed;
13218
0
            for (i = 0; i < len; i++) {
13219
0
                stmt_ty val;
13220
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13221
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13222
0
                    goto failed;
13223
0
                }
13224
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
13225
0
                _Py_LeaveRecursiveCall();
13226
0
                Py_DECREF(tmp2);
13227
0
                if (res != 0) goto failed;
13228
0
                if (len != PyList_GET_SIZE(tmp)) {
13229
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13230
0
                    goto failed;
13231
0
                }
13232
0
                asdl_seq_SET(orelse, i, val);
13233
0
            }
13234
0
            Py_CLEAR(tmp);
13235
0
        }
13236
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13237
0
            return -1;
13238
0
        }
13239
0
        if (tmp == NULL) {
13240
0
            tmp = PyList_New(0);
13241
0
            if (tmp == NULL) {
13242
0
                return -1;
13243
0
            }
13244
0
        }
13245
0
        {
13246
0
            int res;
13247
0
            Py_ssize_t len;
13248
0
            Py_ssize_t i;
13249
0
            if (!PyList_Check(tmp)) {
13250
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13251
0
                goto failed;
13252
0
            }
13253
0
            len = PyList_GET_SIZE(tmp);
13254
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13255
0
            if (finalbody == NULL) goto failed;
13256
0
            for (i = 0; i < len; i++) {
13257
0
                stmt_ty val;
13258
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13259
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13260
0
                    goto failed;
13261
0
                }
13262
0
                res = obj2ast_stmt(state, tmp2, &val, "finalbody", arena);
13263
0
                _Py_LeaveRecursiveCall();
13264
0
                Py_DECREF(tmp2);
13265
0
                if (res != 0) goto failed;
13266
0
                if (len != PyList_GET_SIZE(tmp)) {
13267
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13268
0
                    goto failed;
13269
0
                }
13270
0
                asdl_seq_SET(finalbody, i, val);
13271
0
            }
13272
0
            Py_CLEAR(tmp);
13273
0
        }
13274
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13275
0
                          col_offset, end_lineno, end_col_offset, arena);
13276
0
        if (*out == NULL) goto failed;
13277
0
        return 0;
13278
0
    }
13279
0
    tp = state->TryStar_type;
13280
0
    isinstance = PyObject_IsInstance(obj, tp);
13281
0
    if (isinstance == -1) {
13282
0
        return -1;
13283
0
    }
13284
0
    if (isinstance) {
13285
0
        asdl_stmt_seq* body;
13286
0
        asdl_excepthandler_seq* handlers;
13287
0
        asdl_stmt_seq* orelse;
13288
0
        asdl_stmt_seq* finalbody;
13289
13290
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13291
0
            return -1;
13292
0
        }
13293
0
        if (tmp == NULL) {
13294
0
            tmp = PyList_New(0);
13295
0
            if (tmp == NULL) {
13296
0
                return -1;
13297
0
            }
13298
0
        }
13299
0
        {
13300
0
            int res;
13301
0
            Py_ssize_t len;
13302
0
            Py_ssize_t i;
13303
0
            if (!PyList_Check(tmp)) {
13304
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13305
0
                goto failed;
13306
0
            }
13307
0
            len = PyList_GET_SIZE(tmp);
13308
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13309
0
            if (body == NULL) goto failed;
13310
0
            for (i = 0; i < len; i++) {
13311
0
                stmt_ty val;
13312
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13313
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13314
0
                    goto failed;
13315
0
                }
13316
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
13317
0
                _Py_LeaveRecursiveCall();
13318
0
                Py_DECREF(tmp2);
13319
0
                if (res != 0) goto failed;
13320
0
                if (len != PyList_GET_SIZE(tmp)) {
13321
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13322
0
                    goto failed;
13323
0
                }
13324
0
                asdl_seq_SET(body, i, val);
13325
0
            }
13326
0
            Py_CLEAR(tmp);
13327
0
        }
13328
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13329
0
            return -1;
13330
0
        }
13331
0
        if (tmp == NULL) {
13332
0
            tmp = PyList_New(0);
13333
0
            if (tmp == NULL) {
13334
0
                return -1;
13335
0
            }
13336
0
        }
13337
0
        {
13338
0
            int res;
13339
0
            Py_ssize_t len;
13340
0
            Py_ssize_t i;
13341
0
            if (!PyList_Check(tmp)) {
13342
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13343
0
                goto failed;
13344
0
            }
13345
0
            len = PyList_GET_SIZE(tmp);
13346
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13347
0
            if (handlers == NULL) goto failed;
13348
0
            for (i = 0; i < len; i++) {
13349
0
                excepthandler_ty val;
13350
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13351
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13352
0
                    goto failed;
13353
0
                }
13354
0
                res = obj2ast_excepthandler(state, tmp2, &val, "handlers", arena);
13355
0
                _Py_LeaveRecursiveCall();
13356
0
                Py_DECREF(tmp2);
13357
0
                if (res != 0) goto failed;
13358
0
                if (len != PyList_GET_SIZE(tmp)) {
13359
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13360
0
                    goto failed;
13361
0
                }
13362
0
                asdl_seq_SET(handlers, i, val);
13363
0
            }
13364
0
            Py_CLEAR(tmp);
13365
0
        }
13366
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13367
0
            return -1;
13368
0
        }
13369
0
        if (tmp == NULL) {
13370
0
            tmp = PyList_New(0);
13371
0
            if (tmp == NULL) {
13372
0
                return -1;
13373
0
            }
13374
0
        }
13375
0
        {
13376
0
            int res;
13377
0
            Py_ssize_t len;
13378
0
            Py_ssize_t i;
13379
0
            if (!PyList_Check(tmp)) {
13380
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13381
0
                goto failed;
13382
0
            }
13383
0
            len = PyList_GET_SIZE(tmp);
13384
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13385
0
            if (orelse == NULL) goto failed;
13386
0
            for (i = 0; i < len; i++) {
13387
0
                stmt_ty val;
13388
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13389
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13390
0
                    goto failed;
13391
0
                }
13392
0
                res = obj2ast_stmt(state, tmp2, &val, "orelse", arena);
13393
0
                _Py_LeaveRecursiveCall();
13394
0
                Py_DECREF(tmp2);
13395
0
                if (res != 0) goto failed;
13396
0
                if (len != PyList_GET_SIZE(tmp)) {
13397
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13398
0
                    goto failed;
13399
0
                }
13400
0
                asdl_seq_SET(orelse, i, val);
13401
0
            }
13402
0
            Py_CLEAR(tmp);
13403
0
        }
13404
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13405
0
            return -1;
13406
0
        }
13407
0
        if (tmp == NULL) {
13408
0
            tmp = PyList_New(0);
13409
0
            if (tmp == NULL) {
13410
0
                return -1;
13411
0
            }
13412
0
        }
13413
0
        {
13414
0
            int res;
13415
0
            Py_ssize_t len;
13416
0
            Py_ssize_t i;
13417
0
            if (!PyList_Check(tmp)) {
13418
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13419
0
                goto failed;
13420
0
            }
13421
0
            len = PyList_GET_SIZE(tmp);
13422
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13423
0
            if (finalbody == NULL) goto failed;
13424
0
            for (i = 0; i < len; i++) {
13425
0
                stmt_ty val;
13426
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13427
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13428
0
                    goto failed;
13429
0
                }
13430
0
                res = obj2ast_stmt(state, tmp2, &val, "finalbody", arena);
13431
0
                _Py_LeaveRecursiveCall();
13432
0
                Py_DECREF(tmp2);
13433
0
                if (res != 0) goto failed;
13434
0
                if (len != PyList_GET_SIZE(tmp)) {
13435
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13436
0
                    goto failed;
13437
0
                }
13438
0
                asdl_seq_SET(finalbody, i, val);
13439
0
            }
13440
0
            Py_CLEAR(tmp);
13441
0
        }
13442
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13443
0
                              col_offset, end_lineno, end_col_offset, arena);
13444
0
        if (*out == NULL) goto failed;
13445
0
        return 0;
13446
0
    }
13447
0
    tp = state->Assert_type;
13448
0
    isinstance = PyObject_IsInstance(obj, tp);
13449
0
    if (isinstance == -1) {
13450
0
        return -1;
13451
0
    }
13452
0
    if (isinstance) {
13453
0
        expr_ty test;
13454
0
        expr_ty msg;
13455
13456
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13457
0
            return -1;
13458
0
        }
13459
0
        if (tmp == NULL) {
13460
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13461
0
            return -1;
13462
0
        }
13463
0
        else {
13464
0
            int res;
13465
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13466
0
                goto failed;
13467
0
            }
13468
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
13469
0
            _Py_LeaveRecursiveCall();
13470
0
            if (res != 0) goto failed;
13471
0
            Py_CLEAR(tmp);
13472
0
        }
13473
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13474
0
            return -1;
13475
0
        }
13476
0
        if (tmp == NULL || tmp == Py_None) {
13477
0
            Py_CLEAR(tmp);
13478
0
            msg = NULL;
13479
0
        }
13480
0
        else {
13481
0
            int res;
13482
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13483
0
                goto failed;
13484
0
            }
13485
0
            res = obj2ast_expr(state, tmp, &msg, "msg", arena);
13486
0
            _Py_LeaveRecursiveCall();
13487
0
            if (res != 0) goto failed;
13488
0
            Py_CLEAR(tmp);
13489
0
        }
13490
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13491
0
                             end_col_offset, arena);
13492
0
        if (*out == NULL) goto failed;
13493
0
        return 0;
13494
0
    }
13495
0
    tp = state->Import_type;
13496
0
    isinstance = PyObject_IsInstance(obj, tp);
13497
0
    if (isinstance == -1) {
13498
0
        return -1;
13499
0
    }
13500
0
    if (isinstance) {
13501
0
        asdl_alias_seq* names;
13502
0
        int is_lazy;
13503
13504
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13505
0
            return -1;
13506
0
        }
13507
0
        if (tmp == NULL) {
13508
0
            tmp = PyList_New(0);
13509
0
            if (tmp == NULL) {
13510
0
                return -1;
13511
0
            }
13512
0
        }
13513
0
        {
13514
0
            int res;
13515
0
            Py_ssize_t len;
13516
0
            Py_ssize_t i;
13517
0
            if (!PyList_Check(tmp)) {
13518
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13519
0
                goto failed;
13520
0
            }
13521
0
            len = PyList_GET_SIZE(tmp);
13522
0
            names = _Py_asdl_alias_seq_new(len, arena);
13523
0
            if (names == NULL) goto failed;
13524
0
            for (i = 0; i < len; i++) {
13525
0
                alias_ty val;
13526
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13527
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13528
0
                    goto failed;
13529
0
                }
13530
0
                res = obj2ast_alias(state, tmp2, &val, "names", arena);
13531
0
                _Py_LeaveRecursiveCall();
13532
0
                Py_DECREF(tmp2);
13533
0
                if (res != 0) goto failed;
13534
0
                if (len != PyList_GET_SIZE(tmp)) {
13535
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13536
0
                    goto failed;
13537
0
                }
13538
0
                asdl_seq_SET(names, i, val);
13539
0
            }
13540
0
            Py_CLEAR(tmp);
13541
0
        }
13542
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13543
0
            return -1;
13544
0
        }
13545
0
        if (tmp == NULL || tmp == Py_None) {
13546
0
            Py_CLEAR(tmp);
13547
0
            is_lazy = 0;
13548
0
        }
13549
0
        else {
13550
0
            int res;
13551
0
            if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13552
0
                goto failed;
13553
0
            }
13554
0
            res = obj2ast_int(state, tmp, &is_lazy, "is_lazy", arena);
13555
0
            _Py_LeaveRecursiveCall();
13556
0
            if (res != 0) goto failed;
13557
0
            Py_CLEAR(tmp);
13558
0
        }
13559
0
        *out = _PyAST_Import(names, is_lazy, lineno, col_offset, end_lineno,
13560
0
                             end_col_offset, arena);
13561
0
        if (*out == NULL) goto failed;
13562
0
        return 0;
13563
0
    }
13564
0
    tp = state->ImportFrom_type;
13565
0
    isinstance = PyObject_IsInstance(obj, tp);
13566
0
    if (isinstance == -1) {
13567
0
        return -1;
13568
0
    }
13569
0
    if (isinstance) {
13570
0
        identifier module;
13571
0
        asdl_alias_seq* names;
13572
0
        int level;
13573
0
        int is_lazy;
13574
13575
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13576
0
            return -1;
13577
0
        }
13578
0
        if (tmp == NULL || tmp == Py_None) {
13579
0
            Py_CLEAR(tmp);
13580
0
            module = NULL;
13581
0
        }
13582
0
        else {
13583
0
            int res;
13584
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13585
0
                goto failed;
13586
0
            }
13587
0
            res = obj2ast_identifier(state, tmp, &module, "module", arena);
13588
0
            _Py_LeaveRecursiveCall();
13589
0
            if (res != 0) goto failed;
13590
0
            Py_CLEAR(tmp);
13591
0
        }
13592
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13593
0
            return -1;
13594
0
        }
13595
0
        if (tmp == NULL) {
13596
0
            tmp = PyList_New(0);
13597
0
            if (tmp == NULL) {
13598
0
                return -1;
13599
0
            }
13600
0
        }
13601
0
        {
13602
0
            int res;
13603
0
            Py_ssize_t len;
13604
0
            Py_ssize_t i;
13605
0
            if (!PyList_Check(tmp)) {
13606
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13607
0
                goto failed;
13608
0
            }
13609
0
            len = PyList_GET_SIZE(tmp);
13610
0
            names = _Py_asdl_alias_seq_new(len, arena);
13611
0
            if (names == NULL) goto failed;
13612
0
            for (i = 0; i < len; i++) {
13613
0
                alias_ty val;
13614
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13615
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13616
0
                    goto failed;
13617
0
                }
13618
0
                res = obj2ast_alias(state, tmp2, &val, "names", arena);
13619
0
                _Py_LeaveRecursiveCall();
13620
0
                Py_DECREF(tmp2);
13621
0
                if (res != 0) goto failed;
13622
0
                if (len != PyList_GET_SIZE(tmp)) {
13623
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13624
0
                    goto failed;
13625
0
                }
13626
0
                asdl_seq_SET(names, i, val);
13627
0
            }
13628
0
            Py_CLEAR(tmp);
13629
0
        }
13630
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13631
0
            return -1;
13632
0
        }
13633
0
        if (tmp == NULL || tmp == Py_None) {
13634
0
            Py_CLEAR(tmp);
13635
0
            level = 0;
13636
0
        }
13637
0
        else {
13638
0
            int res;
13639
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13640
0
                goto failed;
13641
0
            }
13642
0
            res = obj2ast_int(state, tmp, &level, "level", arena);
13643
0
            _Py_LeaveRecursiveCall();
13644
0
            if (res != 0) goto failed;
13645
0
            Py_CLEAR(tmp);
13646
0
        }
13647
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13648
0
            return -1;
13649
0
        }
13650
0
        if (tmp == NULL || tmp == Py_None) {
13651
0
            Py_CLEAR(tmp);
13652
0
            is_lazy = 0;
13653
0
        }
13654
0
        else {
13655
0
            int res;
13656
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13657
0
                goto failed;
13658
0
            }
13659
0
            res = obj2ast_int(state, tmp, &is_lazy, "is_lazy", arena);
13660
0
            _Py_LeaveRecursiveCall();
13661
0
            if (res != 0) goto failed;
13662
0
            Py_CLEAR(tmp);
13663
0
        }
13664
0
        *out = _PyAST_ImportFrom(module, names, level, is_lazy, lineno,
13665
0
                                 col_offset, end_lineno, end_col_offset, arena);
13666
0
        if (*out == NULL) goto failed;
13667
0
        return 0;
13668
0
    }
13669
0
    tp = state->Global_type;
13670
0
    isinstance = PyObject_IsInstance(obj, tp);
13671
0
    if (isinstance == -1) {
13672
0
        return -1;
13673
0
    }
13674
0
    if (isinstance) {
13675
0
        asdl_identifier_seq* names;
13676
13677
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13678
0
            return -1;
13679
0
        }
13680
0
        if (tmp == NULL) {
13681
0
            tmp = PyList_New(0);
13682
0
            if (tmp == NULL) {
13683
0
                return -1;
13684
0
            }
13685
0
        }
13686
0
        {
13687
0
            int res;
13688
0
            Py_ssize_t len;
13689
0
            Py_ssize_t i;
13690
0
            if (!PyList_Check(tmp)) {
13691
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13692
0
                goto failed;
13693
0
            }
13694
0
            len = PyList_GET_SIZE(tmp);
13695
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13696
0
            if (names == NULL) goto failed;
13697
0
            for (i = 0; i < len; i++) {
13698
0
                identifier val;
13699
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13700
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13701
0
                    goto failed;
13702
0
                }
13703
0
                res = obj2ast_identifier(state, tmp2, &val, "names", arena);
13704
0
                _Py_LeaveRecursiveCall();
13705
0
                Py_DECREF(tmp2);
13706
0
                if (res != 0) goto failed;
13707
0
                if (len != PyList_GET_SIZE(tmp)) {
13708
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13709
0
                    goto failed;
13710
0
                }
13711
0
                asdl_seq_SET(names, i, val);
13712
0
            }
13713
0
            Py_CLEAR(tmp);
13714
0
        }
13715
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13716
0
                             end_col_offset, arena);
13717
0
        if (*out == NULL) goto failed;
13718
0
        return 0;
13719
0
    }
13720
0
    tp = state->Nonlocal_type;
13721
0
    isinstance = PyObject_IsInstance(obj, tp);
13722
0
    if (isinstance == -1) {
13723
0
        return -1;
13724
0
    }
13725
0
    if (isinstance) {
13726
0
        asdl_identifier_seq* names;
13727
13728
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13729
0
            return -1;
13730
0
        }
13731
0
        if (tmp == NULL) {
13732
0
            tmp = PyList_New(0);
13733
0
            if (tmp == NULL) {
13734
0
                return -1;
13735
0
            }
13736
0
        }
13737
0
        {
13738
0
            int res;
13739
0
            Py_ssize_t len;
13740
0
            Py_ssize_t i;
13741
0
            if (!PyList_Check(tmp)) {
13742
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13743
0
                goto failed;
13744
0
            }
13745
0
            len = PyList_GET_SIZE(tmp);
13746
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13747
0
            if (names == NULL) goto failed;
13748
0
            for (i = 0; i < len; i++) {
13749
0
                identifier val;
13750
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13751
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13752
0
                    goto failed;
13753
0
                }
13754
0
                res = obj2ast_identifier(state, tmp2, &val, "names", arena);
13755
0
                _Py_LeaveRecursiveCall();
13756
0
                Py_DECREF(tmp2);
13757
0
                if (res != 0) goto failed;
13758
0
                if (len != PyList_GET_SIZE(tmp)) {
13759
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13760
0
                    goto failed;
13761
0
                }
13762
0
                asdl_seq_SET(names, i, val);
13763
0
            }
13764
0
            Py_CLEAR(tmp);
13765
0
        }
13766
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13767
0
                               end_col_offset, arena);
13768
0
        if (*out == NULL) goto failed;
13769
0
        return 0;
13770
0
    }
13771
0
    tp = state->Expr_type;
13772
0
    isinstance = PyObject_IsInstance(obj, tp);
13773
0
    if (isinstance == -1) {
13774
0
        return -1;
13775
0
    }
13776
0
    if (isinstance) {
13777
0
        expr_ty value;
13778
13779
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13780
0
            return -1;
13781
0
        }
13782
0
        if (tmp == NULL) {
13783
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13784
0
            return -1;
13785
0
        }
13786
0
        else {
13787
0
            int res;
13788
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13789
0
                goto failed;
13790
0
            }
13791
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
13792
0
            _Py_LeaveRecursiveCall();
13793
0
            if (res != 0) goto failed;
13794
0
            Py_CLEAR(tmp);
13795
0
        }
13796
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13797
0
                           end_col_offset, arena);
13798
0
        if (*out == NULL) goto failed;
13799
0
        return 0;
13800
0
    }
13801
0
    tp = state->Pass_type;
13802
0
    isinstance = PyObject_IsInstance(obj, tp);
13803
0
    if (isinstance == -1) {
13804
0
        return -1;
13805
0
    }
13806
0
    if (isinstance) {
13807
13808
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13809
0
                           arena);
13810
0
        if (*out == NULL) goto failed;
13811
0
        return 0;
13812
0
    }
13813
0
    tp = state->Break_type;
13814
0
    isinstance = PyObject_IsInstance(obj, tp);
13815
0
    if (isinstance == -1) {
13816
0
        return -1;
13817
0
    }
13818
0
    if (isinstance) {
13819
13820
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13821
0
                            arena);
13822
0
        if (*out == NULL) goto failed;
13823
0
        return 0;
13824
0
    }
13825
0
    tp = state->Continue_type;
13826
0
    isinstance = PyObject_IsInstance(obj, tp);
13827
0
    if (isinstance == -1) {
13828
0
        return -1;
13829
0
    }
13830
0
    if (isinstance) {
13831
13832
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13833
0
                               arena);
13834
0
        if (*out == NULL) goto failed;
13835
0
        return 0;
13836
0
    }
13837
13838
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13839
0
    failed:
13840
0
    Py_XDECREF(tmp);
13841
0
    return -1;
13842
0
}
13843
13844
int
13845
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, const char*
13846
             field, PyArena* arena)
13847
0
{
13848
0
    int isinstance;
13849
13850
0
    PyObject *tmp = NULL;
13851
0
    PyObject *tp;
13852
0
    int lineno;
13853
0
    int col_offset;
13854
0
    int end_lineno;
13855
0
    int end_col_offset;
13856
13857
0
    if (obj == Py_None) {
13858
0
        *out = NULL;
13859
0
        return 0;
13860
0
    }
13861
0
    tp = state->expr_type;
13862
0
    isinstance = PyObject_IsInstance(obj, tp);
13863
0
    if (isinstance == -1) {
13864
0
        return 1;
13865
0
    }
13866
0
    if (!isinstance && field != NULL) {
13867
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'expr', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
13868
0
        return 1;
13869
0
    }
13870
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13871
0
        return -1;
13872
0
    }
13873
0
    if (tmp == NULL) {
13874
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13875
0
        return -1;
13876
0
    }
13877
0
    else {
13878
0
        int res;
13879
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13880
0
            goto failed;
13881
0
        }
13882
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
13883
0
        _Py_LeaveRecursiveCall();
13884
0
        if (res != 0) goto failed;
13885
0
        Py_CLEAR(tmp);
13886
0
    }
13887
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13888
0
        return -1;
13889
0
    }
13890
0
    if (tmp == NULL) {
13891
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13892
0
        return -1;
13893
0
    }
13894
0
    else {
13895
0
        int res;
13896
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13897
0
            goto failed;
13898
0
        }
13899
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
13900
0
        _Py_LeaveRecursiveCall();
13901
0
        if (res != 0) goto failed;
13902
0
        Py_CLEAR(tmp);
13903
0
    }
13904
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13905
0
        return -1;
13906
0
    }
13907
0
    if (tmp == NULL || tmp == Py_None) {
13908
0
        Py_CLEAR(tmp);
13909
0
        end_lineno = lineno;
13910
0
    }
13911
0
    else {
13912
0
        int res;
13913
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13914
0
            goto failed;
13915
0
        }
13916
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
13917
0
        _Py_LeaveRecursiveCall();
13918
0
        if (res != 0) goto failed;
13919
0
        Py_CLEAR(tmp);
13920
0
    }
13921
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13922
0
        return -1;
13923
0
    }
13924
0
    if (tmp == NULL || tmp == Py_None) {
13925
0
        Py_CLEAR(tmp);
13926
0
        end_col_offset = col_offset;
13927
0
    }
13928
0
    else {
13929
0
        int res;
13930
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13931
0
            goto failed;
13932
0
        }
13933
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
13934
0
        _Py_LeaveRecursiveCall();
13935
0
        if (res != 0) goto failed;
13936
0
        Py_CLEAR(tmp);
13937
0
    }
13938
0
    tp = state->BoolOp_type;
13939
0
    isinstance = PyObject_IsInstance(obj, tp);
13940
0
    if (isinstance == -1) {
13941
0
        return -1;
13942
0
    }
13943
0
    if (isinstance) {
13944
0
        boolop_ty op;
13945
0
        asdl_expr_seq* values;
13946
13947
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13948
0
            return -1;
13949
0
        }
13950
0
        if (tmp == NULL) {
13951
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13952
0
            return -1;
13953
0
        }
13954
0
        else {
13955
0
            int res;
13956
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13957
0
                goto failed;
13958
0
            }
13959
0
            res = obj2ast_boolop(state, tmp, &op, "op", arena);
13960
0
            _Py_LeaveRecursiveCall();
13961
0
            if (res != 0) goto failed;
13962
0
            Py_CLEAR(tmp);
13963
0
        }
13964
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13965
0
            return -1;
13966
0
        }
13967
0
        if (tmp == NULL) {
13968
0
            tmp = PyList_New(0);
13969
0
            if (tmp == NULL) {
13970
0
                return -1;
13971
0
            }
13972
0
        }
13973
0
        {
13974
0
            int res;
13975
0
            Py_ssize_t len;
13976
0
            Py_ssize_t i;
13977
0
            if (!PyList_Check(tmp)) {
13978
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13979
0
                goto failed;
13980
0
            }
13981
0
            len = PyList_GET_SIZE(tmp);
13982
0
            values = _Py_asdl_expr_seq_new(len, arena);
13983
0
            if (values == NULL) goto failed;
13984
0
            for (i = 0; i < len; i++) {
13985
0
                expr_ty val;
13986
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13987
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13988
0
                    goto failed;
13989
0
                }
13990
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
13991
0
                _Py_LeaveRecursiveCall();
13992
0
                Py_DECREF(tmp2);
13993
0
                if (res != 0) goto failed;
13994
0
                if (len != PyList_GET_SIZE(tmp)) {
13995
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13996
0
                    goto failed;
13997
0
                }
13998
0
                asdl_seq_SET(values, i, val);
13999
0
            }
14000
0
            Py_CLEAR(tmp);
14001
0
        }
14002
0
        *out = _PyAST_BoolOp(op, values, 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->NamedExpr_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 target;
14014
0
        expr_ty value;
14015
14016
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
14017
0
            return -1;
14018
0
        }
14019
0
        if (tmp == NULL) {
14020
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
14021
0
            return -1;
14022
0
        }
14023
0
        else {
14024
0
            int res;
14025
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
14026
0
                goto failed;
14027
0
            }
14028
0
            res = obj2ast_expr(state, tmp, &target, "target", arena);
14029
0
            _Py_LeaveRecursiveCall();
14030
0
            if (res != 0) goto failed;
14031
0
            Py_CLEAR(tmp);
14032
0
        }
14033
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14034
0
            return -1;
14035
0
        }
14036
0
        if (tmp == NULL) {
14037
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
14038
0
            return -1;
14039
0
        }
14040
0
        else {
14041
0
            int res;
14042
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
14043
0
                goto failed;
14044
0
            }
14045
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14046
0
            _Py_LeaveRecursiveCall();
14047
0
            if (res != 0) goto failed;
14048
0
            Py_CLEAR(tmp);
14049
0
        }
14050
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
14051
0
                                end_col_offset, arena);
14052
0
        if (*out == NULL) goto failed;
14053
0
        return 0;
14054
0
    }
14055
0
    tp = state->BinOp_type;
14056
0
    isinstance = PyObject_IsInstance(obj, tp);
14057
0
    if (isinstance == -1) {
14058
0
        return -1;
14059
0
    }
14060
0
    if (isinstance) {
14061
0
        expr_ty left;
14062
0
        operator_ty op;
14063
0
        expr_ty right;
14064
14065
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14066
0
            return -1;
14067
0
        }
14068
0
        if (tmp == NULL) {
14069
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14070
0
            return -1;
14071
0
        }
14072
0
        else {
14073
0
            int res;
14074
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14075
0
                goto failed;
14076
0
            }
14077
0
            res = obj2ast_expr(state, tmp, &left, "left", arena);
14078
0
            _Py_LeaveRecursiveCall();
14079
0
            if (res != 0) goto failed;
14080
0
            Py_CLEAR(tmp);
14081
0
        }
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 BinOp");
14087
0
            return -1;
14088
0
        }
14089
0
        else {
14090
0
            int res;
14091
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14092
0
                goto failed;
14093
0
            }
14094
0
            res = obj2ast_operator(state, tmp, &op, "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->right, &tmp) < 0) {
14100
0
            return -1;
14101
0
        }
14102
0
        if (tmp == NULL) {
14103
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14104
0
            return -1;
14105
0
        }
14106
0
        else {
14107
0
            int res;
14108
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14109
0
                goto failed;
14110
0
            }
14111
0
            res = obj2ast_expr(state, tmp, &right, "right", arena);
14112
0
            _Py_LeaveRecursiveCall();
14113
0
            if (res != 0) goto failed;
14114
0
            Py_CLEAR(tmp);
14115
0
        }
14116
0
        *out = _PyAST_BinOp(left, op, right, 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->UnaryOp_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
        unaryop_ty op;
14128
0
        expr_ty operand;
14129
14130
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14131
0
            return -1;
14132
0
        }
14133
0
        if (tmp == NULL) {
14134
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14135
0
            return -1;
14136
0
        }
14137
0
        else {
14138
0
            int res;
14139
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14140
0
                goto failed;
14141
0
            }
14142
0
            res = obj2ast_unaryop(state, tmp, &op, "op", 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->operand, &tmp) < 0) {
14148
0
            return -1;
14149
0
        }
14150
0
        if (tmp == NULL) {
14151
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14152
0
            return -1;
14153
0
        }
14154
0
        else {
14155
0
            int res;
14156
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14157
0
                goto failed;
14158
0
            }
14159
0
            res = obj2ast_expr(state, tmp, &operand, "operand", arena);
14160
0
            _Py_LeaveRecursiveCall();
14161
0
            if (res != 0) goto failed;
14162
0
            Py_CLEAR(tmp);
14163
0
        }
14164
0
        *out = _PyAST_UnaryOp(op, operand, 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->Lambda_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
        arguments_ty args;
14176
0
        expr_ty body;
14177
14178
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14179
0
            return -1;
14180
0
        }
14181
0
        if (tmp == NULL) {
14182
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14183
0
            return -1;
14184
0
        }
14185
0
        else {
14186
0
            int res;
14187
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14188
0
                goto failed;
14189
0
            }
14190
0
            res = obj2ast_arguments(state, tmp, &args, "args", arena);
14191
0
            _Py_LeaveRecursiveCall();
14192
0
            if (res != 0) goto failed;
14193
0
            Py_CLEAR(tmp);
14194
0
        }
14195
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14196
0
            return -1;
14197
0
        }
14198
0
        if (tmp == NULL) {
14199
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14200
0
            return -1;
14201
0
        }
14202
0
        else {
14203
0
            int res;
14204
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14205
0
                goto failed;
14206
0
            }
14207
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
14208
0
            _Py_LeaveRecursiveCall();
14209
0
            if (res != 0) goto failed;
14210
0
            Py_CLEAR(tmp);
14211
0
        }
14212
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14213
0
                             end_col_offset, arena);
14214
0
        if (*out == NULL) goto failed;
14215
0
        return 0;
14216
0
    }
14217
0
    tp = state->IfExp_type;
14218
0
    isinstance = PyObject_IsInstance(obj, tp);
14219
0
    if (isinstance == -1) {
14220
0
        return -1;
14221
0
    }
14222
0
    if (isinstance) {
14223
0
        expr_ty test;
14224
0
        expr_ty body;
14225
0
        expr_ty orelse;
14226
14227
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14228
0
            return -1;
14229
0
        }
14230
0
        if (tmp == NULL) {
14231
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14232
0
            return -1;
14233
0
        }
14234
0
        else {
14235
0
            int res;
14236
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14237
0
                goto failed;
14238
0
            }
14239
0
            res = obj2ast_expr(state, tmp, &test, "test", arena);
14240
0
            _Py_LeaveRecursiveCall();
14241
0
            if (res != 0) goto failed;
14242
0
            Py_CLEAR(tmp);
14243
0
        }
14244
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14245
0
            return -1;
14246
0
        }
14247
0
        if (tmp == NULL) {
14248
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14249
0
            return -1;
14250
0
        }
14251
0
        else {
14252
0
            int res;
14253
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14254
0
                goto failed;
14255
0
            }
14256
0
            res = obj2ast_expr(state, tmp, &body, "body", arena);
14257
0
            _Py_LeaveRecursiveCall();
14258
0
            if (res != 0) goto failed;
14259
0
            Py_CLEAR(tmp);
14260
0
        }
14261
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14262
0
            return -1;
14263
0
        }
14264
0
        if (tmp == NULL) {
14265
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14266
0
            return -1;
14267
0
        }
14268
0
        else {
14269
0
            int res;
14270
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14271
0
                goto failed;
14272
0
            }
14273
0
            res = obj2ast_expr(state, tmp, &orelse, "orelse", arena);
14274
0
            _Py_LeaveRecursiveCall();
14275
0
            if (res != 0) goto failed;
14276
0
            Py_CLEAR(tmp);
14277
0
        }
14278
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14279
0
                            end_col_offset, arena);
14280
0
        if (*out == NULL) goto failed;
14281
0
        return 0;
14282
0
    }
14283
0
    tp = state->Dict_type;
14284
0
    isinstance = PyObject_IsInstance(obj, tp);
14285
0
    if (isinstance == -1) {
14286
0
        return -1;
14287
0
    }
14288
0
    if (isinstance) {
14289
0
        asdl_expr_seq* keys;
14290
0
        asdl_expr_seq* values;
14291
14292
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14293
0
            return -1;
14294
0
        }
14295
0
        if (tmp == NULL) {
14296
0
            tmp = PyList_New(0);
14297
0
            if (tmp == NULL) {
14298
0
                return -1;
14299
0
            }
14300
0
        }
14301
0
        {
14302
0
            int res;
14303
0
            Py_ssize_t len;
14304
0
            Py_ssize_t i;
14305
0
            if (!PyList_Check(tmp)) {
14306
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14307
0
                goto failed;
14308
0
            }
14309
0
            len = PyList_GET_SIZE(tmp);
14310
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14311
0
            if (keys == NULL) goto failed;
14312
0
            for (i = 0; i < len; i++) {
14313
0
                expr_ty val;
14314
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14315
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14316
0
                    goto failed;
14317
0
                }
14318
0
                res = obj2ast_expr(state, tmp2, &val, "keys", arena);
14319
0
                _Py_LeaveRecursiveCall();
14320
0
                Py_DECREF(tmp2);
14321
0
                if (res != 0) goto failed;
14322
0
                if (len != PyList_GET_SIZE(tmp)) {
14323
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14324
0
                    goto failed;
14325
0
                }
14326
0
                asdl_seq_SET(keys, i, val);
14327
0
            }
14328
0
            Py_CLEAR(tmp);
14329
0
        }
14330
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14331
0
            return -1;
14332
0
        }
14333
0
        if (tmp == NULL) {
14334
0
            tmp = PyList_New(0);
14335
0
            if (tmp == NULL) {
14336
0
                return -1;
14337
0
            }
14338
0
        }
14339
0
        {
14340
0
            int res;
14341
0
            Py_ssize_t len;
14342
0
            Py_ssize_t i;
14343
0
            if (!PyList_Check(tmp)) {
14344
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14345
0
                goto failed;
14346
0
            }
14347
0
            len = PyList_GET_SIZE(tmp);
14348
0
            values = _Py_asdl_expr_seq_new(len, arena);
14349
0
            if (values == NULL) goto failed;
14350
0
            for (i = 0; i < len; i++) {
14351
0
                expr_ty val;
14352
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14353
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14354
0
                    goto failed;
14355
0
                }
14356
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
14357
0
                _Py_LeaveRecursiveCall();
14358
0
                Py_DECREF(tmp2);
14359
0
                if (res != 0) goto failed;
14360
0
                if (len != PyList_GET_SIZE(tmp)) {
14361
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14362
0
                    goto failed;
14363
0
                }
14364
0
                asdl_seq_SET(values, i, val);
14365
0
            }
14366
0
            Py_CLEAR(tmp);
14367
0
        }
14368
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14369
0
                           end_col_offset, arena);
14370
0
        if (*out == NULL) goto failed;
14371
0
        return 0;
14372
0
    }
14373
0
    tp = state->Set_type;
14374
0
    isinstance = PyObject_IsInstance(obj, tp);
14375
0
    if (isinstance == -1) {
14376
0
        return -1;
14377
0
    }
14378
0
    if (isinstance) {
14379
0
        asdl_expr_seq* elts;
14380
14381
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14382
0
            return -1;
14383
0
        }
14384
0
        if (tmp == NULL) {
14385
0
            tmp = PyList_New(0);
14386
0
            if (tmp == NULL) {
14387
0
                return -1;
14388
0
            }
14389
0
        }
14390
0
        {
14391
0
            int res;
14392
0
            Py_ssize_t len;
14393
0
            Py_ssize_t i;
14394
0
            if (!PyList_Check(tmp)) {
14395
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14396
0
                goto failed;
14397
0
            }
14398
0
            len = PyList_GET_SIZE(tmp);
14399
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14400
0
            if (elts == NULL) goto failed;
14401
0
            for (i = 0; i < len; i++) {
14402
0
                expr_ty val;
14403
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14404
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14405
0
                    goto failed;
14406
0
                }
14407
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
14408
0
                _Py_LeaveRecursiveCall();
14409
0
                Py_DECREF(tmp2);
14410
0
                if (res != 0) goto failed;
14411
0
                if (len != PyList_GET_SIZE(tmp)) {
14412
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14413
0
                    goto failed;
14414
0
                }
14415
0
                asdl_seq_SET(elts, i, val);
14416
0
            }
14417
0
            Py_CLEAR(tmp);
14418
0
        }
14419
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14420
0
                          arena);
14421
0
        if (*out == NULL) goto failed;
14422
0
        return 0;
14423
0
    }
14424
0
    tp = state->ListComp_type;
14425
0
    isinstance = PyObject_IsInstance(obj, tp);
14426
0
    if (isinstance == -1) {
14427
0
        return -1;
14428
0
    }
14429
0
    if (isinstance) {
14430
0
        expr_ty elt;
14431
0
        asdl_comprehension_seq* generators;
14432
14433
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14434
0
            return -1;
14435
0
        }
14436
0
        if (tmp == NULL) {
14437
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14438
0
            return -1;
14439
0
        }
14440
0
        else {
14441
0
            int res;
14442
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14443
0
                goto failed;
14444
0
            }
14445
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
14446
0
            _Py_LeaveRecursiveCall();
14447
0
            if (res != 0) goto failed;
14448
0
            Py_CLEAR(tmp);
14449
0
        }
14450
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14451
0
            return -1;
14452
0
        }
14453
0
        if (tmp == NULL) {
14454
0
            tmp = PyList_New(0);
14455
0
            if (tmp == NULL) {
14456
0
                return -1;
14457
0
            }
14458
0
        }
14459
0
        {
14460
0
            int res;
14461
0
            Py_ssize_t len;
14462
0
            Py_ssize_t i;
14463
0
            if (!PyList_Check(tmp)) {
14464
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14465
0
                goto failed;
14466
0
            }
14467
0
            len = PyList_GET_SIZE(tmp);
14468
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14469
0
            if (generators == NULL) goto failed;
14470
0
            for (i = 0; i < len; i++) {
14471
0
                comprehension_ty val;
14472
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14473
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14474
0
                    goto failed;
14475
0
                }
14476
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14477
0
                _Py_LeaveRecursiveCall();
14478
0
                Py_DECREF(tmp2);
14479
0
                if (res != 0) goto failed;
14480
0
                if (len != PyList_GET_SIZE(tmp)) {
14481
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14482
0
                    goto failed;
14483
0
                }
14484
0
                asdl_seq_SET(generators, i, val);
14485
0
            }
14486
0
            Py_CLEAR(tmp);
14487
0
        }
14488
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14489
0
                               end_col_offset, arena);
14490
0
        if (*out == NULL) goto failed;
14491
0
        return 0;
14492
0
    }
14493
0
    tp = state->SetComp_type;
14494
0
    isinstance = PyObject_IsInstance(obj, tp);
14495
0
    if (isinstance == -1) {
14496
0
        return -1;
14497
0
    }
14498
0
    if (isinstance) {
14499
0
        expr_ty elt;
14500
0
        asdl_comprehension_seq* generators;
14501
14502
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14503
0
            return -1;
14504
0
        }
14505
0
        if (tmp == NULL) {
14506
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14507
0
            return -1;
14508
0
        }
14509
0
        else {
14510
0
            int res;
14511
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14512
0
                goto failed;
14513
0
            }
14514
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
14515
0
            _Py_LeaveRecursiveCall();
14516
0
            if (res != 0) goto failed;
14517
0
            Py_CLEAR(tmp);
14518
0
        }
14519
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14520
0
            return -1;
14521
0
        }
14522
0
        if (tmp == NULL) {
14523
0
            tmp = PyList_New(0);
14524
0
            if (tmp == NULL) {
14525
0
                return -1;
14526
0
            }
14527
0
        }
14528
0
        {
14529
0
            int res;
14530
0
            Py_ssize_t len;
14531
0
            Py_ssize_t i;
14532
0
            if (!PyList_Check(tmp)) {
14533
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14534
0
                goto failed;
14535
0
            }
14536
0
            len = PyList_GET_SIZE(tmp);
14537
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14538
0
            if (generators == NULL) goto failed;
14539
0
            for (i = 0; i < len; i++) {
14540
0
                comprehension_ty val;
14541
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14542
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14543
0
                    goto failed;
14544
0
                }
14545
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14546
0
                _Py_LeaveRecursiveCall();
14547
0
                Py_DECREF(tmp2);
14548
0
                if (res != 0) goto failed;
14549
0
                if (len != PyList_GET_SIZE(tmp)) {
14550
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14551
0
                    goto failed;
14552
0
                }
14553
0
                asdl_seq_SET(generators, i, val);
14554
0
            }
14555
0
            Py_CLEAR(tmp);
14556
0
        }
14557
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14558
0
                              end_col_offset, arena);
14559
0
        if (*out == NULL) goto failed;
14560
0
        return 0;
14561
0
    }
14562
0
    tp = state->DictComp_type;
14563
0
    isinstance = PyObject_IsInstance(obj, tp);
14564
0
    if (isinstance == -1) {
14565
0
        return -1;
14566
0
    }
14567
0
    if (isinstance) {
14568
0
        expr_ty key;
14569
0
        expr_ty value;
14570
0
        asdl_comprehension_seq* generators;
14571
14572
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14573
0
            return -1;
14574
0
        }
14575
0
        if (tmp == NULL) {
14576
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14577
0
            return -1;
14578
0
        }
14579
0
        else {
14580
0
            int res;
14581
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14582
0
                goto failed;
14583
0
            }
14584
0
            res = obj2ast_expr(state, tmp, &key, "key", arena);
14585
0
            _Py_LeaveRecursiveCall();
14586
0
            if (res != 0) goto failed;
14587
0
            Py_CLEAR(tmp);
14588
0
        }
14589
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14590
0
            return -1;
14591
0
        }
14592
0
        if (tmp == NULL || tmp == Py_None) {
14593
0
            Py_CLEAR(tmp);
14594
0
            value = NULL;
14595
0
        }
14596
0
        else {
14597
0
            int res;
14598
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14599
0
                goto failed;
14600
0
            }
14601
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14602
0
            _Py_LeaveRecursiveCall();
14603
0
            if (res != 0) goto failed;
14604
0
            Py_CLEAR(tmp);
14605
0
        }
14606
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14607
0
            return -1;
14608
0
        }
14609
0
        if (tmp == NULL) {
14610
0
            tmp = PyList_New(0);
14611
0
            if (tmp == NULL) {
14612
0
                return -1;
14613
0
            }
14614
0
        }
14615
0
        {
14616
0
            int res;
14617
0
            Py_ssize_t len;
14618
0
            Py_ssize_t i;
14619
0
            if (!PyList_Check(tmp)) {
14620
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14621
0
                goto failed;
14622
0
            }
14623
0
            len = PyList_GET_SIZE(tmp);
14624
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14625
0
            if (generators == NULL) goto failed;
14626
0
            for (i = 0; i < len; i++) {
14627
0
                comprehension_ty val;
14628
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14629
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14630
0
                    goto failed;
14631
0
                }
14632
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14633
0
                _Py_LeaveRecursiveCall();
14634
0
                Py_DECREF(tmp2);
14635
0
                if (res != 0) goto failed;
14636
0
                if (len != PyList_GET_SIZE(tmp)) {
14637
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14638
0
                    goto failed;
14639
0
                }
14640
0
                asdl_seq_SET(generators, i, val);
14641
0
            }
14642
0
            Py_CLEAR(tmp);
14643
0
        }
14644
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14645
0
                               end_lineno, end_col_offset, arena);
14646
0
        if (*out == NULL) goto failed;
14647
0
        return 0;
14648
0
    }
14649
0
    tp = state->GeneratorExp_type;
14650
0
    isinstance = PyObject_IsInstance(obj, tp);
14651
0
    if (isinstance == -1) {
14652
0
        return -1;
14653
0
    }
14654
0
    if (isinstance) {
14655
0
        expr_ty elt;
14656
0
        asdl_comprehension_seq* generators;
14657
14658
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14659
0
            return -1;
14660
0
        }
14661
0
        if (tmp == NULL) {
14662
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14663
0
            return -1;
14664
0
        }
14665
0
        else {
14666
0
            int res;
14667
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14668
0
                goto failed;
14669
0
            }
14670
0
            res = obj2ast_expr(state, tmp, &elt, "elt", arena);
14671
0
            _Py_LeaveRecursiveCall();
14672
0
            if (res != 0) goto failed;
14673
0
            Py_CLEAR(tmp);
14674
0
        }
14675
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14676
0
            return -1;
14677
0
        }
14678
0
        if (tmp == NULL) {
14679
0
            tmp = PyList_New(0);
14680
0
            if (tmp == NULL) {
14681
0
                return -1;
14682
0
            }
14683
0
        }
14684
0
        {
14685
0
            int res;
14686
0
            Py_ssize_t len;
14687
0
            Py_ssize_t i;
14688
0
            if (!PyList_Check(tmp)) {
14689
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14690
0
                goto failed;
14691
0
            }
14692
0
            len = PyList_GET_SIZE(tmp);
14693
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14694
0
            if (generators == NULL) goto failed;
14695
0
            for (i = 0; i < len; i++) {
14696
0
                comprehension_ty val;
14697
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14698
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14699
0
                    goto failed;
14700
0
                }
14701
0
                res = obj2ast_comprehension(state, tmp2, &val, "generators", arena);
14702
0
                _Py_LeaveRecursiveCall();
14703
0
                Py_DECREF(tmp2);
14704
0
                if (res != 0) goto failed;
14705
0
                if (len != PyList_GET_SIZE(tmp)) {
14706
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14707
0
                    goto failed;
14708
0
                }
14709
0
                asdl_seq_SET(generators, i, val);
14710
0
            }
14711
0
            Py_CLEAR(tmp);
14712
0
        }
14713
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14714
0
                                   end_lineno, end_col_offset, arena);
14715
0
        if (*out == NULL) goto failed;
14716
0
        return 0;
14717
0
    }
14718
0
    tp = state->Await_type;
14719
0
    isinstance = PyObject_IsInstance(obj, tp);
14720
0
    if (isinstance == -1) {
14721
0
        return -1;
14722
0
    }
14723
0
    if (isinstance) {
14724
0
        expr_ty value;
14725
14726
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14727
0
            return -1;
14728
0
        }
14729
0
        if (tmp == NULL) {
14730
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14731
0
            return -1;
14732
0
        }
14733
0
        else {
14734
0
            int res;
14735
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14736
0
                goto failed;
14737
0
            }
14738
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14739
0
            _Py_LeaveRecursiveCall();
14740
0
            if (res != 0) goto failed;
14741
0
            Py_CLEAR(tmp);
14742
0
        }
14743
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14744
0
                            end_col_offset, arena);
14745
0
        if (*out == NULL) goto failed;
14746
0
        return 0;
14747
0
    }
14748
0
    tp = state->Yield_type;
14749
0
    isinstance = PyObject_IsInstance(obj, tp);
14750
0
    if (isinstance == -1) {
14751
0
        return -1;
14752
0
    }
14753
0
    if (isinstance) {
14754
0
        expr_ty value;
14755
14756
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14757
0
            return -1;
14758
0
        }
14759
0
        if (tmp == NULL || tmp == Py_None) {
14760
0
            Py_CLEAR(tmp);
14761
0
            value = NULL;
14762
0
        }
14763
0
        else {
14764
0
            int res;
14765
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14766
0
                goto failed;
14767
0
            }
14768
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14769
0
            _Py_LeaveRecursiveCall();
14770
0
            if (res != 0) goto failed;
14771
0
            Py_CLEAR(tmp);
14772
0
        }
14773
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14774
0
                            end_col_offset, arena);
14775
0
        if (*out == NULL) goto failed;
14776
0
        return 0;
14777
0
    }
14778
0
    tp = state->YieldFrom_type;
14779
0
    isinstance = PyObject_IsInstance(obj, tp);
14780
0
    if (isinstance == -1) {
14781
0
        return -1;
14782
0
    }
14783
0
    if (isinstance) {
14784
0
        expr_ty value;
14785
14786
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14787
0
            return -1;
14788
0
        }
14789
0
        if (tmp == NULL) {
14790
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14791
0
            return -1;
14792
0
        }
14793
0
        else {
14794
0
            int res;
14795
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14796
0
                goto failed;
14797
0
            }
14798
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
14799
0
            _Py_LeaveRecursiveCall();
14800
0
            if (res != 0) goto failed;
14801
0
            Py_CLEAR(tmp);
14802
0
        }
14803
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14804
0
                                end_col_offset, arena);
14805
0
        if (*out == NULL) goto failed;
14806
0
        return 0;
14807
0
    }
14808
0
    tp = state->Compare_type;
14809
0
    isinstance = PyObject_IsInstance(obj, tp);
14810
0
    if (isinstance == -1) {
14811
0
        return -1;
14812
0
    }
14813
0
    if (isinstance) {
14814
0
        expr_ty left;
14815
0
        asdl_int_seq* ops;
14816
0
        asdl_expr_seq* comparators;
14817
14818
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14819
0
            return -1;
14820
0
        }
14821
0
        if (tmp == NULL) {
14822
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14823
0
            return -1;
14824
0
        }
14825
0
        else {
14826
0
            int res;
14827
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14828
0
                goto failed;
14829
0
            }
14830
0
            res = obj2ast_expr(state, tmp, &left, "left", arena);
14831
0
            _Py_LeaveRecursiveCall();
14832
0
            if (res != 0) goto failed;
14833
0
            Py_CLEAR(tmp);
14834
0
        }
14835
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14836
0
            return -1;
14837
0
        }
14838
0
        if (tmp == NULL) {
14839
0
            tmp = PyList_New(0);
14840
0
            if (tmp == NULL) {
14841
0
                return -1;
14842
0
            }
14843
0
        }
14844
0
        {
14845
0
            int res;
14846
0
            Py_ssize_t len;
14847
0
            Py_ssize_t i;
14848
0
            if (!PyList_Check(tmp)) {
14849
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14850
0
                goto failed;
14851
0
            }
14852
0
            len = PyList_GET_SIZE(tmp);
14853
0
            ops = _Py_asdl_int_seq_new(len, arena);
14854
0
            if (ops == NULL) goto failed;
14855
0
            for (i = 0; i < len; i++) {
14856
0
                cmpop_ty val;
14857
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14858
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14859
0
                    goto failed;
14860
0
                }
14861
0
                res = obj2ast_cmpop(state, tmp2, &val, "ops", arena);
14862
0
                _Py_LeaveRecursiveCall();
14863
0
                Py_DECREF(tmp2);
14864
0
                if (res != 0) goto failed;
14865
0
                if (len != PyList_GET_SIZE(tmp)) {
14866
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14867
0
                    goto failed;
14868
0
                }
14869
0
                asdl_seq_SET(ops, i, val);
14870
0
            }
14871
0
            Py_CLEAR(tmp);
14872
0
        }
14873
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14874
0
            return -1;
14875
0
        }
14876
0
        if (tmp == NULL) {
14877
0
            tmp = PyList_New(0);
14878
0
            if (tmp == NULL) {
14879
0
                return -1;
14880
0
            }
14881
0
        }
14882
0
        {
14883
0
            int res;
14884
0
            Py_ssize_t len;
14885
0
            Py_ssize_t i;
14886
0
            if (!PyList_Check(tmp)) {
14887
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14888
0
                goto failed;
14889
0
            }
14890
0
            len = PyList_GET_SIZE(tmp);
14891
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14892
0
            if (comparators == NULL) goto failed;
14893
0
            for (i = 0; i < len; i++) {
14894
0
                expr_ty val;
14895
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14896
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14897
0
                    goto failed;
14898
0
                }
14899
0
                res = obj2ast_expr(state, tmp2, &val, "comparators", arena);
14900
0
                _Py_LeaveRecursiveCall();
14901
0
                Py_DECREF(tmp2);
14902
0
                if (res != 0) goto failed;
14903
0
                if (len != PyList_GET_SIZE(tmp)) {
14904
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14905
0
                    goto failed;
14906
0
                }
14907
0
                asdl_seq_SET(comparators, i, val);
14908
0
            }
14909
0
            Py_CLEAR(tmp);
14910
0
        }
14911
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14912
0
                              end_lineno, end_col_offset, arena);
14913
0
        if (*out == NULL) goto failed;
14914
0
        return 0;
14915
0
    }
14916
0
    tp = state->Call_type;
14917
0
    isinstance = PyObject_IsInstance(obj, tp);
14918
0
    if (isinstance == -1) {
14919
0
        return -1;
14920
0
    }
14921
0
    if (isinstance) {
14922
0
        expr_ty func;
14923
0
        asdl_expr_seq* args;
14924
0
        asdl_keyword_seq* keywords;
14925
14926
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14927
0
            return -1;
14928
0
        }
14929
0
        if (tmp == NULL) {
14930
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14931
0
            return -1;
14932
0
        }
14933
0
        else {
14934
0
            int res;
14935
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14936
0
                goto failed;
14937
0
            }
14938
0
            res = obj2ast_expr(state, tmp, &func, "func", arena);
14939
0
            _Py_LeaveRecursiveCall();
14940
0
            if (res != 0) goto failed;
14941
0
            Py_CLEAR(tmp);
14942
0
        }
14943
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14944
0
            return -1;
14945
0
        }
14946
0
        if (tmp == NULL) {
14947
0
            tmp = PyList_New(0);
14948
0
            if (tmp == NULL) {
14949
0
                return -1;
14950
0
            }
14951
0
        }
14952
0
        {
14953
0
            int res;
14954
0
            Py_ssize_t len;
14955
0
            Py_ssize_t i;
14956
0
            if (!PyList_Check(tmp)) {
14957
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14958
0
                goto failed;
14959
0
            }
14960
0
            len = PyList_GET_SIZE(tmp);
14961
0
            args = _Py_asdl_expr_seq_new(len, arena);
14962
0
            if (args == NULL) goto failed;
14963
0
            for (i = 0; i < len; i++) {
14964
0
                expr_ty val;
14965
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14966
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14967
0
                    goto failed;
14968
0
                }
14969
0
                res = obj2ast_expr(state, tmp2, &val, "args", arena);
14970
0
                _Py_LeaveRecursiveCall();
14971
0
                Py_DECREF(tmp2);
14972
0
                if (res != 0) goto failed;
14973
0
                if (len != PyList_GET_SIZE(tmp)) {
14974
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14975
0
                    goto failed;
14976
0
                }
14977
0
                asdl_seq_SET(args, i, val);
14978
0
            }
14979
0
            Py_CLEAR(tmp);
14980
0
        }
14981
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14982
0
            return -1;
14983
0
        }
14984
0
        if (tmp == NULL) {
14985
0
            tmp = PyList_New(0);
14986
0
            if (tmp == NULL) {
14987
0
                return -1;
14988
0
            }
14989
0
        }
14990
0
        {
14991
0
            int res;
14992
0
            Py_ssize_t len;
14993
0
            Py_ssize_t i;
14994
0
            if (!PyList_Check(tmp)) {
14995
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14996
0
                goto failed;
14997
0
            }
14998
0
            len = PyList_GET_SIZE(tmp);
14999
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
15000
0
            if (keywords == NULL) goto failed;
15001
0
            for (i = 0; i < len; i++) {
15002
0
                keyword_ty val;
15003
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15004
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
15005
0
                    goto failed;
15006
0
                }
15007
0
                res = obj2ast_keyword(state, tmp2, &val, "keywords", arena);
15008
0
                _Py_LeaveRecursiveCall();
15009
0
                Py_DECREF(tmp2);
15010
0
                if (res != 0) goto failed;
15011
0
                if (len != PyList_GET_SIZE(tmp)) {
15012
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
15013
0
                    goto failed;
15014
0
                }
15015
0
                asdl_seq_SET(keywords, i, val);
15016
0
            }
15017
0
            Py_CLEAR(tmp);
15018
0
        }
15019
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
15020
0
                           end_lineno, end_col_offset, arena);
15021
0
        if (*out == NULL) goto failed;
15022
0
        return 0;
15023
0
    }
15024
0
    tp = state->FormattedValue_type;
15025
0
    isinstance = PyObject_IsInstance(obj, tp);
15026
0
    if (isinstance == -1) {
15027
0
        return -1;
15028
0
    }
15029
0
    if (isinstance) {
15030
0
        expr_ty value;
15031
0
        int conversion;
15032
0
        expr_ty format_spec;
15033
15034
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15035
0
            return -1;
15036
0
        }
15037
0
        if (tmp == NULL) {
15038
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
15039
0
            return -1;
15040
0
        }
15041
0
        else {
15042
0
            int res;
15043
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15044
0
                goto failed;
15045
0
            }
15046
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15047
0
            _Py_LeaveRecursiveCall();
15048
0
            if (res != 0) goto failed;
15049
0
            Py_CLEAR(tmp);
15050
0
        }
15051
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15052
0
            return -1;
15053
0
        }
15054
0
        if (tmp == NULL) {
15055
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
15056
0
            return -1;
15057
0
        }
15058
0
        else {
15059
0
            int res;
15060
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15061
0
                goto failed;
15062
0
            }
15063
0
            res = obj2ast_int(state, tmp, &conversion, "conversion", arena);
15064
0
            _Py_LeaveRecursiveCall();
15065
0
            if (res != 0) goto failed;
15066
0
            Py_CLEAR(tmp);
15067
0
        }
15068
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15069
0
            return -1;
15070
0
        }
15071
0
        if (tmp == NULL || tmp == Py_None) {
15072
0
            Py_CLEAR(tmp);
15073
0
            format_spec = NULL;
15074
0
        }
15075
0
        else {
15076
0
            int res;
15077
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15078
0
                goto failed;
15079
0
            }
15080
0
            res = obj2ast_expr(state, tmp, &format_spec, "format_spec", arena);
15081
0
            _Py_LeaveRecursiveCall();
15082
0
            if (res != 0) goto failed;
15083
0
            Py_CLEAR(tmp);
15084
0
        }
15085
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15086
0
                                     col_offset, end_lineno, end_col_offset,
15087
0
                                     arena);
15088
0
        if (*out == NULL) goto failed;
15089
0
        return 0;
15090
0
    }
15091
0
    tp = state->Interpolation_type;
15092
0
    isinstance = PyObject_IsInstance(obj, tp);
15093
0
    if (isinstance == -1) {
15094
0
        return -1;
15095
0
    }
15096
0
    if (isinstance) {
15097
0
        expr_ty value;
15098
0
        constant str;
15099
0
        int conversion;
15100
0
        expr_ty format_spec;
15101
15102
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15103
0
            return -1;
15104
0
        }
15105
0
        if (tmp == NULL) {
15106
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15107
0
            return -1;
15108
0
        }
15109
0
        else {
15110
0
            int res;
15111
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15112
0
                goto failed;
15113
0
            }
15114
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15115
0
            _Py_LeaveRecursiveCall();
15116
0
            if (res != 0) goto failed;
15117
0
            Py_CLEAR(tmp);
15118
0
        }
15119
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15120
0
            return -1;
15121
0
        }
15122
0
        if (tmp == NULL) {
15123
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15124
0
            return -1;
15125
0
        }
15126
0
        else {
15127
0
            int res;
15128
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15129
0
                goto failed;
15130
0
            }
15131
0
            res = obj2ast_constant(state, tmp, &str, "str", arena);
15132
0
            _Py_LeaveRecursiveCall();
15133
0
            if (res != 0) goto failed;
15134
0
            Py_CLEAR(tmp);
15135
0
        }
15136
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15137
0
            return -1;
15138
0
        }
15139
0
        if (tmp == NULL) {
15140
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15141
0
            return -1;
15142
0
        }
15143
0
        else {
15144
0
            int res;
15145
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15146
0
                goto failed;
15147
0
            }
15148
0
            res = obj2ast_int(state, tmp, &conversion, "conversion", arena);
15149
0
            _Py_LeaveRecursiveCall();
15150
0
            if (res != 0) goto failed;
15151
0
            Py_CLEAR(tmp);
15152
0
        }
15153
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15154
0
            return -1;
15155
0
        }
15156
0
        if (tmp == NULL || tmp == Py_None) {
15157
0
            Py_CLEAR(tmp);
15158
0
            format_spec = NULL;
15159
0
        }
15160
0
        else {
15161
0
            int res;
15162
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15163
0
                goto failed;
15164
0
            }
15165
0
            res = obj2ast_expr(state, tmp, &format_spec, "format_spec", arena);
15166
0
            _Py_LeaveRecursiveCall();
15167
0
            if (res != 0) goto failed;
15168
0
            Py_CLEAR(tmp);
15169
0
        }
15170
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15171
0
                                    lineno, col_offset, end_lineno,
15172
0
                                    end_col_offset, arena);
15173
0
        if (*out == NULL) goto failed;
15174
0
        return 0;
15175
0
    }
15176
0
    tp = state->JoinedStr_type;
15177
0
    isinstance = PyObject_IsInstance(obj, tp);
15178
0
    if (isinstance == -1) {
15179
0
        return -1;
15180
0
    }
15181
0
    if (isinstance) {
15182
0
        asdl_expr_seq* values;
15183
15184
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15185
0
            return -1;
15186
0
        }
15187
0
        if (tmp == NULL) {
15188
0
            tmp = PyList_New(0);
15189
0
            if (tmp == NULL) {
15190
0
                return -1;
15191
0
            }
15192
0
        }
15193
0
        {
15194
0
            int res;
15195
0
            Py_ssize_t len;
15196
0
            Py_ssize_t i;
15197
0
            if (!PyList_Check(tmp)) {
15198
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15199
0
                goto failed;
15200
0
            }
15201
0
            len = PyList_GET_SIZE(tmp);
15202
0
            values = _Py_asdl_expr_seq_new(len, arena);
15203
0
            if (values == NULL) goto failed;
15204
0
            for (i = 0; i < len; i++) {
15205
0
                expr_ty val;
15206
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15207
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15208
0
                    goto failed;
15209
0
                }
15210
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
15211
0
                _Py_LeaveRecursiveCall();
15212
0
                Py_DECREF(tmp2);
15213
0
                if (res != 0) goto failed;
15214
0
                if (len != PyList_GET_SIZE(tmp)) {
15215
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15216
0
                    goto failed;
15217
0
                }
15218
0
                asdl_seq_SET(values, i, val);
15219
0
            }
15220
0
            Py_CLEAR(tmp);
15221
0
        }
15222
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15223
0
                                end_col_offset, arena);
15224
0
        if (*out == NULL) goto failed;
15225
0
        return 0;
15226
0
    }
15227
0
    tp = state->TemplateStr_type;
15228
0
    isinstance = PyObject_IsInstance(obj, tp);
15229
0
    if (isinstance == -1) {
15230
0
        return -1;
15231
0
    }
15232
0
    if (isinstance) {
15233
0
        asdl_expr_seq* values;
15234
15235
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15236
0
            return -1;
15237
0
        }
15238
0
        if (tmp == NULL) {
15239
0
            tmp = PyList_New(0);
15240
0
            if (tmp == NULL) {
15241
0
                return -1;
15242
0
            }
15243
0
        }
15244
0
        {
15245
0
            int res;
15246
0
            Py_ssize_t len;
15247
0
            Py_ssize_t i;
15248
0
            if (!PyList_Check(tmp)) {
15249
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15250
0
                goto failed;
15251
0
            }
15252
0
            len = PyList_GET_SIZE(tmp);
15253
0
            values = _Py_asdl_expr_seq_new(len, arena);
15254
0
            if (values == NULL) goto failed;
15255
0
            for (i = 0; i < len; i++) {
15256
0
                expr_ty val;
15257
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15258
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15259
0
                    goto failed;
15260
0
                }
15261
0
                res = obj2ast_expr(state, tmp2, &val, "values", arena);
15262
0
                _Py_LeaveRecursiveCall();
15263
0
                Py_DECREF(tmp2);
15264
0
                if (res != 0) goto failed;
15265
0
                if (len != PyList_GET_SIZE(tmp)) {
15266
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15267
0
                    goto failed;
15268
0
                }
15269
0
                asdl_seq_SET(values, i, val);
15270
0
            }
15271
0
            Py_CLEAR(tmp);
15272
0
        }
15273
0
        *out = _PyAST_TemplateStr(values, 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->Constant_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
        constant value;
15285
0
        string kind;
15286
15287
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15288
0
            return -1;
15289
0
        }
15290
0
        if (tmp == NULL) {
15291
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15292
0
            return -1;
15293
0
        }
15294
0
        else {
15295
0
            int res;
15296
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15297
0
                goto failed;
15298
0
            }
15299
0
            res = obj2ast_constant(state, tmp, &value, "value", arena);
15300
0
            _Py_LeaveRecursiveCall();
15301
0
            if (res != 0) goto failed;
15302
0
            Py_CLEAR(tmp);
15303
0
        }
15304
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15305
0
            return -1;
15306
0
        }
15307
0
        if (tmp == NULL || tmp == Py_None) {
15308
0
            Py_CLEAR(tmp);
15309
0
            kind = NULL;
15310
0
        }
15311
0
        else {
15312
0
            int res;
15313
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15314
0
                goto failed;
15315
0
            }
15316
0
            res = obj2ast_string(state, tmp, &kind, "kind", arena);
15317
0
            _Py_LeaveRecursiveCall();
15318
0
            if (res != 0) goto failed;
15319
0
            Py_CLEAR(tmp);
15320
0
        }
15321
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15322
0
                               end_col_offset, arena);
15323
0
        if (*out == NULL) goto failed;
15324
0
        return 0;
15325
0
    }
15326
0
    tp = state->Attribute_type;
15327
0
    isinstance = PyObject_IsInstance(obj, tp);
15328
0
    if (isinstance == -1) {
15329
0
        return -1;
15330
0
    }
15331
0
    if (isinstance) {
15332
0
        expr_ty value;
15333
0
        identifier attr;
15334
0
        expr_context_ty ctx;
15335
15336
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15337
0
            return -1;
15338
0
        }
15339
0
        if (tmp == NULL) {
15340
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15341
0
            return -1;
15342
0
        }
15343
0
        else {
15344
0
            int res;
15345
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15346
0
                goto failed;
15347
0
            }
15348
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15349
0
            _Py_LeaveRecursiveCall();
15350
0
            if (res != 0) goto failed;
15351
0
            Py_CLEAR(tmp);
15352
0
        }
15353
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15354
0
            return -1;
15355
0
        }
15356
0
        if (tmp == NULL) {
15357
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15358
0
            return -1;
15359
0
        }
15360
0
        else {
15361
0
            int res;
15362
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15363
0
                goto failed;
15364
0
            }
15365
0
            res = obj2ast_identifier(state, tmp, &attr, "attr", arena);
15366
0
            _Py_LeaveRecursiveCall();
15367
0
            if (res != 0) goto failed;
15368
0
            Py_CLEAR(tmp);
15369
0
        }
15370
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15371
0
            return -1;
15372
0
        }
15373
0
        if (tmp == NULL) {
15374
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15375
0
            return -1;
15376
0
        }
15377
0
        else {
15378
0
            int res;
15379
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15380
0
                goto failed;
15381
0
            }
15382
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15383
0
            _Py_LeaveRecursiveCall();
15384
0
            if (res != 0) goto failed;
15385
0
            Py_CLEAR(tmp);
15386
0
        }
15387
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15388
0
                                end_lineno, end_col_offset, arena);
15389
0
        if (*out == NULL) goto failed;
15390
0
        return 0;
15391
0
    }
15392
0
    tp = state->Subscript_type;
15393
0
    isinstance = PyObject_IsInstance(obj, tp);
15394
0
    if (isinstance == -1) {
15395
0
        return -1;
15396
0
    }
15397
0
    if (isinstance) {
15398
0
        expr_ty value;
15399
0
        expr_ty slice;
15400
0
        expr_context_ty ctx;
15401
15402
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15403
0
            return -1;
15404
0
        }
15405
0
        if (tmp == NULL) {
15406
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15407
0
            return -1;
15408
0
        }
15409
0
        else {
15410
0
            int res;
15411
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15412
0
                goto failed;
15413
0
            }
15414
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
15415
0
            _Py_LeaveRecursiveCall();
15416
0
            if (res != 0) goto failed;
15417
0
            Py_CLEAR(tmp);
15418
0
        }
15419
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15420
0
            return -1;
15421
0
        }
15422
0
        if (tmp == NULL) {
15423
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15424
0
            return -1;
15425
0
        }
15426
0
        else {
15427
0
            int res;
15428
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15429
0
                goto failed;
15430
0
            }
15431
0
            res = obj2ast_expr(state, tmp, &slice, "slice", 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 Subscript");
15441
0
            return -1;
15442
0
        }
15443
0
        else {
15444
0
            int res;
15445
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15446
0
                goto failed;
15447
0
            }
15448
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15449
0
            _Py_LeaveRecursiveCall();
15450
0
            if (res != 0) goto failed;
15451
0
            Py_CLEAR(tmp);
15452
0
        }
15453
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15454
0
                                end_lineno, end_col_offset, arena);
15455
0
        if (*out == NULL) goto failed;
15456
0
        return 0;
15457
0
    }
15458
0
    tp = state->Starred_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
        expr_ty value;
15465
0
        expr_context_ty ctx;
15466
15467
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15468
0
            return -1;
15469
0
        }
15470
0
        if (tmp == NULL) {
15471
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15472
0
            return -1;
15473
0
        }
15474
0
        else {
15475
0
            int res;
15476
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15477
0
                goto failed;
15478
0
            }
15479
0
            res = obj2ast_expr(state, tmp, &value, "value", 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 Starred");
15489
0
            return -1;
15490
0
        }
15491
0
        else {
15492
0
            int res;
15493
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15494
0
                goto failed;
15495
0
            }
15496
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15497
0
            _Py_LeaveRecursiveCall();
15498
0
            if (res != 0) goto failed;
15499
0
            Py_CLEAR(tmp);
15500
0
        }
15501
0
        *out = _PyAST_Starred(value, 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->Name_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
        identifier id;
15513
0
        expr_context_ty ctx;
15514
15515
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15516
0
            return -1;
15517
0
        }
15518
0
        if (tmp == NULL) {
15519
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15520
0
            return -1;
15521
0
        }
15522
0
        else {
15523
0
            int res;
15524
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15525
0
                goto failed;
15526
0
            }
15527
0
            res = obj2ast_identifier(state, tmp, &id, "id", arena);
15528
0
            _Py_LeaveRecursiveCall();
15529
0
            if (res != 0) goto failed;
15530
0
            Py_CLEAR(tmp);
15531
0
        }
15532
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15533
0
            return -1;
15534
0
        }
15535
0
        if (tmp == NULL) {
15536
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15537
0
            return -1;
15538
0
        }
15539
0
        else {
15540
0
            int res;
15541
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15542
0
                goto failed;
15543
0
            }
15544
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15545
0
            _Py_LeaveRecursiveCall();
15546
0
            if (res != 0) goto failed;
15547
0
            Py_CLEAR(tmp);
15548
0
        }
15549
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15550
0
                           end_col_offset, arena);
15551
0
        if (*out == NULL) goto failed;
15552
0
        return 0;
15553
0
    }
15554
0
    tp = state->List_type;
15555
0
    isinstance = PyObject_IsInstance(obj, tp);
15556
0
    if (isinstance == -1) {
15557
0
        return -1;
15558
0
    }
15559
0
    if (isinstance) {
15560
0
        asdl_expr_seq* elts;
15561
0
        expr_context_ty ctx;
15562
15563
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15564
0
            return -1;
15565
0
        }
15566
0
        if (tmp == NULL) {
15567
0
            tmp = PyList_New(0);
15568
0
            if (tmp == NULL) {
15569
0
                return -1;
15570
0
            }
15571
0
        }
15572
0
        {
15573
0
            int res;
15574
0
            Py_ssize_t len;
15575
0
            Py_ssize_t i;
15576
0
            if (!PyList_Check(tmp)) {
15577
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15578
0
                goto failed;
15579
0
            }
15580
0
            len = PyList_GET_SIZE(tmp);
15581
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15582
0
            if (elts == NULL) goto failed;
15583
0
            for (i = 0; i < len; i++) {
15584
0
                expr_ty val;
15585
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15586
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15587
0
                    goto failed;
15588
0
                }
15589
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
15590
0
                _Py_LeaveRecursiveCall();
15591
0
                Py_DECREF(tmp2);
15592
0
                if (res != 0) goto failed;
15593
0
                if (len != PyList_GET_SIZE(tmp)) {
15594
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15595
0
                    goto failed;
15596
0
                }
15597
0
                asdl_seq_SET(elts, i, val);
15598
0
            }
15599
0
            Py_CLEAR(tmp);
15600
0
        }
15601
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15602
0
            return -1;
15603
0
        }
15604
0
        if (tmp == NULL) {
15605
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15606
0
            return -1;
15607
0
        }
15608
0
        else {
15609
0
            int res;
15610
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15611
0
                goto failed;
15612
0
            }
15613
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15614
0
            _Py_LeaveRecursiveCall();
15615
0
            if (res != 0) goto failed;
15616
0
            Py_CLEAR(tmp);
15617
0
        }
15618
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15619
0
                           end_col_offset, arena);
15620
0
        if (*out == NULL) goto failed;
15621
0
        return 0;
15622
0
    }
15623
0
    tp = state->Tuple_type;
15624
0
    isinstance = PyObject_IsInstance(obj, tp);
15625
0
    if (isinstance == -1) {
15626
0
        return -1;
15627
0
    }
15628
0
    if (isinstance) {
15629
0
        asdl_expr_seq* elts;
15630
0
        expr_context_ty ctx;
15631
15632
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15633
0
            return -1;
15634
0
        }
15635
0
        if (tmp == NULL) {
15636
0
            tmp = PyList_New(0);
15637
0
            if (tmp == NULL) {
15638
0
                return -1;
15639
0
            }
15640
0
        }
15641
0
        {
15642
0
            int res;
15643
0
            Py_ssize_t len;
15644
0
            Py_ssize_t i;
15645
0
            if (!PyList_Check(tmp)) {
15646
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15647
0
                goto failed;
15648
0
            }
15649
0
            len = PyList_GET_SIZE(tmp);
15650
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15651
0
            if (elts == NULL) goto failed;
15652
0
            for (i = 0; i < len; i++) {
15653
0
                expr_ty val;
15654
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15655
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15656
0
                    goto failed;
15657
0
                }
15658
0
                res = obj2ast_expr(state, tmp2, &val, "elts", arena);
15659
0
                _Py_LeaveRecursiveCall();
15660
0
                Py_DECREF(tmp2);
15661
0
                if (res != 0) goto failed;
15662
0
                if (len != PyList_GET_SIZE(tmp)) {
15663
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15664
0
                    goto failed;
15665
0
                }
15666
0
                asdl_seq_SET(elts, i, val);
15667
0
            }
15668
0
            Py_CLEAR(tmp);
15669
0
        }
15670
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15671
0
            return -1;
15672
0
        }
15673
0
        if (tmp == NULL) {
15674
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15675
0
            return -1;
15676
0
        }
15677
0
        else {
15678
0
            int res;
15679
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15680
0
                goto failed;
15681
0
            }
15682
0
            res = obj2ast_expr_context(state, tmp, &ctx, "ctx", arena);
15683
0
            _Py_LeaveRecursiveCall();
15684
0
            if (res != 0) goto failed;
15685
0
            Py_CLEAR(tmp);
15686
0
        }
15687
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15688
0
                            end_col_offset, arena);
15689
0
        if (*out == NULL) goto failed;
15690
0
        return 0;
15691
0
    }
15692
0
    tp = state->Slice_type;
15693
0
    isinstance = PyObject_IsInstance(obj, tp);
15694
0
    if (isinstance == -1) {
15695
0
        return -1;
15696
0
    }
15697
0
    if (isinstance) {
15698
0
        expr_ty lower;
15699
0
        expr_ty upper;
15700
0
        expr_ty step;
15701
15702
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15703
0
            return -1;
15704
0
        }
15705
0
        if (tmp == NULL || tmp == Py_None) {
15706
0
            Py_CLEAR(tmp);
15707
0
            lower = NULL;
15708
0
        }
15709
0
        else {
15710
0
            int res;
15711
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15712
0
                goto failed;
15713
0
            }
15714
0
            res = obj2ast_expr(state, tmp, &lower, "lower", arena);
15715
0
            _Py_LeaveRecursiveCall();
15716
0
            if (res != 0) goto failed;
15717
0
            Py_CLEAR(tmp);
15718
0
        }
15719
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15720
0
            return -1;
15721
0
        }
15722
0
        if (tmp == NULL || tmp == Py_None) {
15723
0
            Py_CLEAR(tmp);
15724
0
            upper = NULL;
15725
0
        }
15726
0
        else {
15727
0
            int res;
15728
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15729
0
                goto failed;
15730
0
            }
15731
0
            res = obj2ast_expr(state, tmp, &upper, "upper", arena);
15732
0
            _Py_LeaveRecursiveCall();
15733
0
            if (res != 0) goto failed;
15734
0
            Py_CLEAR(tmp);
15735
0
        }
15736
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15737
0
            return -1;
15738
0
        }
15739
0
        if (tmp == NULL || tmp == Py_None) {
15740
0
            Py_CLEAR(tmp);
15741
0
            step = NULL;
15742
0
        }
15743
0
        else {
15744
0
            int res;
15745
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15746
0
                goto failed;
15747
0
            }
15748
0
            res = obj2ast_expr(state, tmp, &step, "step", arena);
15749
0
            _Py_LeaveRecursiveCall();
15750
0
            if (res != 0) goto failed;
15751
0
            Py_CLEAR(tmp);
15752
0
        }
15753
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15754
0
                            end_col_offset, arena);
15755
0
        if (*out == NULL) goto failed;
15756
0
        return 0;
15757
0
    }
15758
15759
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15760
0
    failed:
15761
0
    Py_XDECREF(tmp);
15762
0
    return -1;
15763
0
}
15764
15765
int
15766
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15767
                     out, const char* field, PyArena* arena)
15768
0
{
15769
0
    int isinstance;
15770
15771
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15772
0
    if (isinstance == -1) {
15773
0
        return -1;
15774
0
    }
15775
0
    if (isinstance) {
15776
0
        *out = Load;
15777
0
        return 0;
15778
0
    }
15779
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15780
0
    if (isinstance == -1) {
15781
0
        return -1;
15782
0
    }
15783
0
    if (isinstance) {
15784
0
        *out = Store;
15785
0
        return 0;
15786
0
    }
15787
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15788
0
    if (isinstance == -1) {
15789
0
        return -1;
15790
0
    }
15791
0
    if (isinstance) {
15792
0
        *out = Del;
15793
0
        return 0;
15794
0
    }
15795
15796
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15797
0
    return -1;
15798
0
}
15799
15800
int
15801
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, const
15802
               char* field, PyArena* arena)
15803
0
{
15804
0
    int isinstance;
15805
15806
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15807
0
    if (isinstance == -1) {
15808
0
        return -1;
15809
0
    }
15810
0
    if (isinstance) {
15811
0
        *out = And;
15812
0
        return 0;
15813
0
    }
15814
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15815
0
    if (isinstance == -1) {
15816
0
        return -1;
15817
0
    }
15818
0
    if (isinstance) {
15819
0
        *out = Or;
15820
0
        return 0;
15821
0
    }
15822
15823
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15824
0
    return -1;
15825
0
}
15826
15827
int
15828
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15829
                 const char* field, PyArena* arena)
15830
0
{
15831
0
    int isinstance;
15832
15833
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15834
0
    if (isinstance == -1) {
15835
0
        return -1;
15836
0
    }
15837
0
    if (isinstance) {
15838
0
        *out = Add;
15839
0
        return 0;
15840
0
    }
15841
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15842
0
    if (isinstance == -1) {
15843
0
        return -1;
15844
0
    }
15845
0
    if (isinstance) {
15846
0
        *out = Sub;
15847
0
        return 0;
15848
0
    }
15849
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15850
0
    if (isinstance == -1) {
15851
0
        return -1;
15852
0
    }
15853
0
    if (isinstance) {
15854
0
        *out = Mult;
15855
0
        return 0;
15856
0
    }
15857
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15858
0
    if (isinstance == -1) {
15859
0
        return -1;
15860
0
    }
15861
0
    if (isinstance) {
15862
0
        *out = MatMult;
15863
0
        return 0;
15864
0
    }
15865
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15866
0
    if (isinstance == -1) {
15867
0
        return -1;
15868
0
    }
15869
0
    if (isinstance) {
15870
0
        *out = Div;
15871
0
        return 0;
15872
0
    }
15873
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15874
0
    if (isinstance == -1) {
15875
0
        return -1;
15876
0
    }
15877
0
    if (isinstance) {
15878
0
        *out = Mod;
15879
0
        return 0;
15880
0
    }
15881
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15882
0
    if (isinstance == -1) {
15883
0
        return -1;
15884
0
    }
15885
0
    if (isinstance) {
15886
0
        *out = Pow;
15887
0
        return 0;
15888
0
    }
15889
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15890
0
    if (isinstance == -1) {
15891
0
        return -1;
15892
0
    }
15893
0
    if (isinstance) {
15894
0
        *out = LShift;
15895
0
        return 0;
15896
0
    }
15897
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15898
0
    if (isinstance == -1) {
15899
0
        return -1;
15900
0
    }
15901
0
    if (isinstance) {
15902
0
        *out = RShift;
15903
0
        return 0;
15904
0
    }
15905
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15906
0
    if (isinstance == -1) {
15907
0
        return -1;
15908
0
    }
15909
0
    if (isinstance) {
15910
0
        *out = BitOr;
15911
0
        return 0;
15912
0
    }
15913
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15914
0
    if (isinstance == -1) {
15915
0
        return -1;
15916
0
    }
15917
0
    if (isinstance) {
15918
0
        *out = BitXor;
15919
0
        return 0;
15920
0
    }
15921
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15922
0
    if (isinstance == -1) {
15923
0
        return -1;
15924
0
    }
15925
0
    if (isinstance) {
15926
0
        *out = BitAnd;
15927
0
        return 0;
15928
0
    }
15929
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15930
0
    if (isinstance == -1) {
15931
0
        return -1;
15932
0
    }
15933
0
    if (isinstance) {
15934
0
        *out = FloorDiv;
15935
0
        return 0;
15936
0
    }
15937
15938
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15939
0
    return -1;
15940
0
}
15941
15942
int
15943
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out, const
15944
                char* field, PyArena* arena)
15945
0
{
15946
0
    int isinstance;
15947
15948
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15949
0
    if (isinstance == -1) {
15950
0
        return -1;
15951
0
    }
15952
0
    if (isinstance) {
15953
0
        *out = Invert;
15954
0
        return 0;
15955
0
    }
15956
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15957
0
    if (isinstance == -1) {
15958
0
        return -1;
15959
0
    }
15960
0
    if (isinstance) {
15961
0
        *out = Not;
15962
0
        return 0;
15963
0
    }
15964
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15965
0
    if (isinstance == -1) {
15966
0
        return -1;
15967
0
    }
15968
0
    if (isinstance) {
15969
0
        *out = UAdd;
15970
0
        return 0;
15971
0
    }
15972
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15973
0
    if (isinstance == -1) {
15974
0
        return -1;
15975
0
    }
15976
0
    if (isinstance) {
15977
0
        *out = USub;
15978
0
        return 0;
15979
0
    }
15980
15981
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15982
0
    return -1;
15983
0
}
15984
15985
int
15986
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, const
15987
              char* field, PyArena* arena)
15988
0
{
15989
0
    int isinstance;
15990
15991
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15992
0
    if (isinstance == -1) {
15993
0
        return -1;
15994
0
    }
15995
0
    if (isinstance) {
15996
0
        *out = Eq;
15997
0
        return 0;
15998
0
    }
15999
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
16000
0
    if (isinstance == -1) {
16001
0
        return -1;
16002
0
    }
16003
0
    if (isinstance) {
16004
0
        *out = NotEq;
16005
0
        return 0;
16006
0
    }
16007
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
16008
0
    if (isinstance == -1) {
16009
0
        return -1;
16010
0
    }
16011
0
    if (isinstance) {
16012
0
        *out = Lt;
16013
0
        return 0;
16014
0
    }
16015
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
16016
0
    if (isinstance == -1) {
16017
0
        return -1;
16018
0
    }
16019
0
    if (isinstance) {
16020
0
        *out = LtE;
16021
0
        return 0;
16022
0
    }
16023
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
16024
0
    if (isinstance == -1) {
16025
0
        return -1;
16026
0
    }
16027
0
    if (isinstance) {
16028
0
        *out = Gt;
16029
0
        return 0;
16030
0
    }
16031
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
16032
0
    if (isinstance == -1) {
16033
0
        return -1;
16034
0
    }
16035
0
    if (isinstance) {
16036
0
        *out = GtE;
16037
0
        return 0;
16038
0
    }
16039
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
16040
0
    if (isinstance == -1) {
16041
0
        return -1;
16042
0
    }
16043
0
    if (isinstance) {
16044
0
        *out = Is;
16045
0
        return 0;
16046
0
    }
16047
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
16048
0
    if (isinstance == -1) {
16049
0
        return -1;
16050
0
    }
16051
0
    if (isinstance) {
16052
0
        *out = IsNot;
16053
0
        return 0;
16054
0
    }
16055
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
16056
0
    if (isinstance == -1) {
16057
0
        return -1;
16058
0
    }
16059
0
    if (isinstance) {
16060
0
        *out = In;
16061
0
        return 0;
16062
0
    }
16063
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16064
0
    if (isinstance == -1) {
16065
0
        return -1;
16066
0
    }
16067
0
    if (isinstance) {
16068
0
        *out = NotIn;
16069
0
        return 0;
16070
0
    }
16071
16072
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16073
0
    return -1;
16074
0
}
16075
16076
int
16077
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16078
                      out, const char* field, PyArena* arena)
16079
0
{
16080
0
    PyObject* tmp = NULL;
16081
0
    expr_ty target;
16082
0
    expr_ty iter;
16083
0
    asdl_expr_seq* ifs;
16084
0
    int is_async;
16085
16086
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16087
0
        return -1;
16088
0
    }
16089
0
    if (tmp == NULL) {
16090
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16091
0
        return -1;
16092
0
    }
16093
0
    else {
16094
0
        int res;
16095
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16096
0
            goto failed;
16097
0
        }
16098
0
        res = obj2ast_expr(state, tmp, &target, "target", arena);
16099
0
        _Py_LeaveRecursiveCall();
16100
0
        if (res != 0) goto failed;
16101
0
        Py_CLEAR(tmp);
16102
0
    }
16103
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16104
0
        return -1;
16105
0
    }
16106
0
    if (tmp == NULL) {
16107
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16108
0
        return -1;
16109
0
    }
16110
0
    else {
16111
0
        int res;
16112
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16113
0
            goto failed;
16114
0
        }
16115
0
        res = obj2ast_expr(state, tmp, &iter, "iter", arena);
16116
0
        _Py_LeaveRecursiveCall();
16117
0
        if (res != 0) goto failed;
16118
0
        Py_CLEAR(tmp);
16119
0
    }
16120
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16121
0
        return -1;
16122
0
    }
16123
0
    if (tmp == NULL) {
16124
0
        tmp = PyList_New(0);
16125
0
        if (tmp == NULL) {
16126
0
            return -1;
16127
0
        }
16128
0
    }
16129
0
    {
16130
0
        int res;
16131
0
        Py_ssize_t len;
16132
0
        Py_ssize_t i;
16133
0
        if (!PyList_Check(tmp)) {
16134
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16135
0
            goto failed;
16136
0
        }
16137
0
        len = PyList_GET_SIZE(tmp);
16138
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16139
0
        if (ifs == NULL) goto failed;
16140
0
        for (i = 0; i < len; i++) {
16141
0
            expr_ty val;
16142
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16143
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16144
0
                goto failed;
16145
0
            }
16146
0
            res = obj2ast_expr(state, tmp2, &val, "ifs", arena);
16147
0
            _Py_LeaveRecursiveCall();
16148
0
            Py_DECREF(tmp2);
16149
0
            if (res != 0) goto failed;
16150
0
            if (len != PyList_GET_SIZE(tmp)) {
16151
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16152
0
                goto failed;
16153
0
            }
16154
0
            asdl_seq_SET(ifs, i, val);
16155
0
        }
16156
0
        Py_CLEAR(tmp);
16157
0
    }
16158
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16159
0
        return -1;
16160
0
    }
16161
0
    if (tmp == NULL) {
16162
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16163
0
        return -1;
16164
0
    }
16165
0
    else {
16166
0
        int res;
16167
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16168
0
            goto failed;
16169
0
        }
16170
0
        res = obj2ast_int(state, tmp, &is_async, "is_async", arena);
16171
0
        _Py_LeaveRecursiveCall();
16172
0
        if (res != 0) goto failed;
16173
0
        Py_CLEAR(tmp);
16174
0
    }
16175
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16176
0
    if (*out == NULL) goto failed;
16177
0
    return 0;
16178
0
failed:
16179
0
    Py_XDECREF(tmp);
16180
0
    return -1;
16181
0
}
16182
16183
int
16184
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16185
                      out, const char* field, PyArena* arena)
16186
0
{
16187
0
    int isinstance;
16188
16189
0
    PyObject *tmp = NULL;
16190
0
    PyObject *tp;
16191
0
    int lineno;
16192
0
    int col_offset;
16193
0
    int end_lineno;
16194
0
    int end_col_offset;
16195
16196
0
    if (obj == Py_None) {
16197
0
        *out = NULL;
16198
0
        return 0;
16199
0
    }
16200
0
    tp = state->excepthandler_type;
16201
0
    isinstance = PyObject_IsInstance(obj, tp);
16202
0
    if (isinstance == -1) {
16203
0
        return 1;
16204
0
    }
16205
0
    if (!isinstance && field != NULL) {
16206
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'excepthandler', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
16207
0
        return 1;
16208
0
    }
16209
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16210
0
        return -1;
16211
0
    }
16212
0
    if (tmp == NULL) {
16213
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16214
0
        return -1;
16215
0
    }
16216
0
    else {
16217
0
        int res;
16218
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16219
0
            goto failed;
16220
0
        }
16221
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16222
0
        _Py_LeaveRecursiveCall();
16223
0
        if (res != 0) goto failed;
16224
0
        Py_CLEAR(tmp);
16225
0
    }
16226
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16227
0
        return -1;
16228
0
    }
16229
0
    if (tmp == NULL) {
16230
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16231
0
        return -1;
16232
0
    }
16233
0
    else {
16234
0
        int res;
16235
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16236
0
            goto failed;
16237
0
        }
16238
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
16239
0
        _Py_LeaveRecursiveCall();
16240
0
        if (res != 0) goto failed;
16241
0
        Py_CLEAR(tmp);
16242
0
    }
16243
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16244
0
        return -1;
16245
0
    }
16246
0
    if (tmp == NULL || tmp == Py_None) {
16247
0
        Py_CLEAR(tmp);
16248
0
        end_lineno = lineno;
16249
0
    }
16250
0
    else {
16251
0
        int res;
16252
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16253
0
            goto failed;
16254
0
        }
16255
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16256
0
        _Py_LeaveRecursiveCall();
16257
0
        if (res != 0) goto failed;
16258
0
        Py_CLEAR(tmp);
16259
0
    }
16260
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16261
0
        return -1;
16262
0
    }
16263
0
    if (tmp == NULL || tmp == Py_None) {
16264
0
        Py_CLEAR(tmp);
16265
0
        end_col_offset = col_offset;
16266
0
    }
16267
0
    else {
16268
0
        int res;
16269
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16270
0
            goto failed;
16271
0
        }
16272
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16273
0
        _Py_LeaveRecursiveCall();
16274
0
        if (res != 0) goto failed;
16275
0
        Py_CLEAR(tmp);
16276
0
    }
16277
0
    tp = state->ExceptHandler_type;
16278
0
    isinstance = PyObject_IsInstance(obj, tp);
16279
0
    if (isinstance == -1) {
16280
0
        return -1;
16281
0
    }
16282
0
    if (isinstance) {
16283
0
        expr_ty type;
16284
0
        identifier name;
16285
0
        asdl_stmt_seq* body;
16286
16287
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16288
0
            return -1;
16289
0
        }
16290
0
        if (tmp == NULL || tmp == Py_None) {
16291
0
            Py_CLEAR(tmp);
16292
0
            type = NULL;
16293
0
        }
16294
0
        else {
16295
0
            int res;
16296
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16297
0
                goto failed;
16298
0
            }
16299
0
            res = obj2ast_expr(state, tmp, &type, "type", arena);
16300
0
            _Py_LeaveRecursiveCall();
16301
0
            if (res != 0) goto failed;
16302
0
            Py_CLEAR(tmp);
16303
0
        }
16304
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16305
0
            return -1;
16306
0
        }
16307
0
        if (tmp == NULL || tmp == Py_None) {
16308
0
            Py_CLEAR(tmp);
16309
0
            name = NULL;
16310
0
        }
16311
0
        else {
16312
0
            int res;
16313
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16314
0
                goto failed;
16315
0
            }
16316
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
16317
0
            _Py_LeaveRecursiveCall();
16318
0
            if (res != 0) goto failed;
16319
0
            Py_CLEAR(tmp);
16320
0
        }
16321
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16322
0
            return -1;
16323
0
        }
16324
0
        if (tmp == NULL) {
16325
0
            tmp = PyList_New(0);
16326
0
            if (tmp == NULL) {
16327
0
                return -1;
16328
0
            }
16329
0
        }
16330
0
        {
16331
0
            int res;
16332
0
            Py_ssize_t len;
16333
0
            Py_ssize_t i;
16334
0
            if (!PyList_Check(tmp)) {
16335
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16336
0
                goto failed;
16337
0
            }
16338
0
            len = PyList_GET_SIZE(tmp);
16339
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16340
0
            if (body == NULL) goto failed;
16341
0
            for (i = 0; i < len; i++) {
16342
0
                stmt_ty val;
16343
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16344
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16345
0
                    goto failed;
16346
0
                }
16347
0
                res = obj2ast_stmt(state, tmp2, &val, "body", arena);
16348
0
                _Py_LeaveRecursiveCall();
16349
0
                Py_DECREF(tmp2);
16350
0
                if (res != 0) goto failed;
16351
0
                if (len != PyList_GET_SIZE(tmp)) {
16352
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16353
0
                    goto failed;
16354
0
                }
16355
0
                asdl_seq_SET(body, i, val);
16356
0
            }
16357
0
            Py_CLEAR(tmp);
16358
0
        }
16359
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16360
0
                                    end_lineno, end_col_offset, arena);
16361
0
        if (*out == NULL) goto failed;
16362
0
        return 0;
16363
0
    }
16364
16365
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16366
0
    failed:
16367
0
    Py_XDECREF(tmp);
16368
0
    return -1;
16369
0
}
16370
16371
int
16372
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16373
                  const char* field, PyArena* arena)
16374
0
{
16375
0
    PyObject* tmp = NULL;
16376
0
    asdl_arg_seq* posonlyargs;
16377
0
    asdl_arg_seq* args;
16378
0
    arg_ty vararg;
16379
0
    asdl_arg_seq* kwonlyargs;
16380
0
    asdl_expr_seq* kw_defaults;
16381
0
    arg_ty kwarg;
16382
0
    asdl_expr_seq* defaults;
16383
16384
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16385
0
        return -1;
16386
0
    }
16387
0
    if (tmp == NULL) {
16388
0
        tmp = PyList_New(0);
16389
0
        if (tmp == NULL) {
16390
0
            return -1;
16391
0
        }
16392
0
    }
16393
0
    {
16394
0
        int res;
16395
0
        Py_ssize_t len;
16396
0
        Py_ssize_t i;
16397
0
        if (!PyList_Check(tmp)) {
16398
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16399
0
            goto failed;
16400
0
        }
16401
0
        len = PyList_GET_SIZE(tmp);
16402
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16403
0
        if (posonlyargs == NULL) goto failed;
16404
0
        for (i = 0; i < len; i++) {
16405
0
            arg_ty val;
16406
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16407
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16408
0
                goto failed;
16409
0
            }
16410
0
            res = obj2ast_arg(state, tmp2, &val, "posonlyargs", arena);
16411
0
            _Py_LeaveRecursiveCall();
16412
0
            Py_DECREF(tmp2);
16413
0
            if (res != 0) goto failed;
16414
0
            if (len != PyList_GET_SIZE(tmp)) {
16415
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16416
0
                goto failed;
16417
0
            }
16418
0
            asdl_seq_SET(posonlyargs, i, val);
16419
0
        }
16420
0
        Py_CLEAR(tmp);
16421
0
    }
16422
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16423
0
        return -1;
16424
0
    }
16425
0
    if (tmp == NULL) {
16426
0
        tmp = PyList_New(0);
16427
0
        if (tmp == NULL) {
16428
0
            return -1;
16429
0
        }
16430
0
    }
16431
0
    {
16432
0
        int res;
16433
0
        Py_ssize_t len;
16434
0
        Py_ssize_t i;
16435
0
        if (!PyList_Check(tmp)) {
16436
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16437
0
            goto failed;
16438
0
        }
16439
0
        len = PyList_GET_SIZE(tmp);
16440
0
        args = _Py_asdl_arg_seq_new(len, arena);
16441
0
        if (args == NULL) goto failed;
16442
0
        for (i = 0; i < len; i++) {
16443
0
            arg_ty val;
16444
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16445
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16446
0
                goto failed;
16447
0
            }
16448
0
            res = obj2ast_arg(state, tmp2, &val, "args", arena);
16449
0
            _Py_LeaveRecursiveCall();
16450
0
            Py_DECREF(tmp2);
16451
0
            if (res != 0) goto failed;
16452
0
            if (len != PyList_GET_SIZE(tmp)) {
16453
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16454
0
                goto failed;
16455
0
            }
16456
0
            asdl_seq_SET(args, i, val);
16457
0
        }
16458
0
        Py_CLEAR(tmp);
16459
0
    }
16460
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16461
0
        return -1;
16462
0
    }
16463
0
    if (tmp == NULL || tmp == Py_None) {
16464
0
        Py_CLEAR(tmp);
16465
0
        vararg = NULL;
16466
0
    }
16467
0
    else {
16468
0
        int res;
16469
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16470
0
            goto failed;
16471
0
        }
16472
0
        res = obj2ast_arg(state, tmp, &vararg, "vararg", arena);
16473
0
        _Py_LeaveRecursiveCall();
16474
0
        if (res != 0) goto failed;
16475
0
        Py_CLEAR(tmp);
16476
0
    }
16477
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16478
0
        return -1;
16479
0
    }
16480
0
    if (tmp == NULL) {
16481
0
        tmp = PyList_New(0);
16482
0
        if (tmp == NULL) {
16483
0
            return -1;
16484
0
        }
16485
0
    }
16486
0
    {
16487
0
        int res;
16488
0
        Py_ssize_t len;
16489
0
        Py_ssize_t i;
16490
0
        if (!PyList_Check(tmp)) {
16491
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16492
0
            goto failed;
16493
0
        }
16494
0
        len = PyList_GET_SIZE(tmp);
16495
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16496
0
        if (kwonlyargs == NULL) goto failed;
16497
0
        for (i = 0; i < len; i++) {
16498
0
            arg_ty val;
16499
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16500
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16501
0
                goto failed;
16502
0
            }
16503
0
            res = obj2ast_arg(state, tmp2, &val, "kwonlyargs", arena);
16504
0
            _Py_LeaveRecursiveCall();
16505
0
            Py_DECREF(tmp2);
16506
0
            if (res != 0) goto failed;
16507
0
            if (len != PyList_GET_SIZE(tmp)) {
16508
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16509
0
                goto failed;
16510
0
            }
16511
0
            asdl_seq_SET(kwonlyargs, i, val);
16512
0
        }
16513
0
        Py_CLEAR(tmp);
16514
0
    }
16515
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16516
0
        return -1;
16517
0
    }
16518
0
    if (tmp == NULL) {
16519
0
        tmp = PyList_New(0);
16520
0
        if (tmp == NULL) {
16521
0
            return -1;
16522
0
        }
16523
0
    }
16524
0
    {
16525
0
        int res;
16526
0
        Py_ssize_t len;
16527
0
        Py_ssize_t i;
16528
0
        if (!PyList_Check(tmp)) {
16529
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16530
0
            goto failed;
16531
0
        }
16532
0
        len = PyList_GET_SIZE(tmp);
16533
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16534
0
        if (kw_defaults == NULL) goto failed;
16535
0
        for (i = 0; i < len; i++) {
16536
0
            expr_ty val;
16537
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16538
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16539
0
                goto failed;
16540
0
            }
16541
0
            res = obj2ast_expr(state, tmp2, &val, "kw_defaults", arena);
16542
0
            _Py_LeaveRecursiveCall();
16543
0
            Py_DECREF(tmp2);
16544
0
            if (res != 0) goto failed;
16545
0
            if (len != PyList_GET_SIZE(tmp)) {
16546
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16547
0
                goto failed;
16548
0
            }
16549
0
            asdl_seq_SET(kw_defaults, i, val);
16550
0
        }
16551
0
        Py_CLEAR(tmp);
16552
0
    }
16553
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16554
0
        return -1;
16555
0
    }
16556
0
    if (tmp == NULL || tmp == Py_None) {
16557
0
        Py_CLEAR(tmp);
16558
0
        kwarg = NULL;
16559
0
    }
16560
0
    else {
16561
0
        int res;
16562
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16563
0
            goto failed;
16564
0
        }
16565
0
        res = obj2ast_arg(state, tmp, &kwarg, "kwarg", arena);
16566
0
        _Py_LeaveRecursiveCall();
16567
0
        if (res != 0) goto failed;
16568
0
        Py_CLEAR(tmp);
16569
0
    }
16570
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16571
0
        return -1;
16572
0
    }
16573
0
    if (tmp == NULL) {
16574
0
        tmp = PyList_New(0);
16575
0
        if (tmp == NULL) {
16576
0
            return -1;
16577
0
        }
16578
0
    }
16579
0
    {
16580
0
        int res;
16581
0
        Py_ssize_t len;
16582
0
        Py_ssize_t i;
16583
0
        if (!PyList_Check(tmp)) {
16584
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16585
0
            goto failed;
16586
0
        }
16587
0
        len = PyList_GET_SIZE(tmp);
16588
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16589
0
        if (defaults == NULL) goto failed;
16590
0
        for (i = 0; i < len; i++) {
16591
0
            expr_ty val;
16592
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16593
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16594
0
                goto failed;
16595
0
            }
16596
0
            res = obj2ast_expr(state, tmp2, &val, "defaults", arena);
16597
0
            _Py_LeaveRecursiveCall();
16598
0
            Py_DECREF(tmp2);
16599
0
            if (res != 0) goto failed;
16600
0
            if (len != PyList_GET_SIZE(tmp)) {
16601
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16602
0
                goto failed;
16603
0
            }
16604
0
            asdl_seq_SET(defaults, i, val);
16605
0
        }
16606
0
        Py_CLEAR(tmp);
16607
0
    }
16608
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16609
0
                            kwarg, defaults, arena);
16610
0
    if (*out == NULL) goto failed;
16611
0
    return 0;
16612
0
failed:
16613
0
    Py_XDECREF(tmp);
16614
0
    return -1;
16615
0
}
16616
16617
int
16618
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, const char*
16619
            field, PyArena* arena)
16620
0
{
16621
0
    PyObject* tmp = NULL;
16622
0
    identifier arg;
16623
0
    expr_ty annotation;
16624
0
    string type_comment;
16625
0
    int lineno;
16626
0
    int col_offset;
16627
0
    int end_lineno;
16628
0
    int end_col_offset;
16629
16630
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16631
0
        return -1;
16632
0
    }
16633
0
    if (tmp == NULL) {
16634
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16635
0
        return -1;
16636
0
    }
16637
0
    else {
16638
0
        int res;
16639
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16640
0
            goto failed;
16641
0
        }
16642
0
        res = obj2ast_identifier(state, tmp, &arg, "arg", arena);
16643
0
        _Py_LeaveRecursiveCall();
16644
0
        if (res != 0) goto failed;
16645
0
        Py_CLEAR(tmp);
16646
0
    }
16647
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16648
0
        return -1;
16649
0
    }
16650
0
    if (tmp == NULL || tmp == Py_None) {
16651
0
        Py_CLEAR(tmp);
16652
0
        annotation = NULL;
16653
0
    }
16654
0
    else {
16655
0
        int res;
16656
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16657
0
            goto failed;
16658
0
        }
16659
0
        res = obj2ast_expr(state, tmp, &annotation, "annotation", arena);
16660
0
        _Py_LeaveRecursiveCall();
16661
0
        if (res != 0) goto failed;
16662
0
        Py_CLEAR(tmp);
16663
0
    }
16664
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16665
0
        return -1;
16666
0
    }
16667
0
    if (tmp == NULL || tmp == Py_None) {
16668
0
        Py_CLEAR(tmp);
16669
0
        type_comment = NULL;
16670
0
    }
16671
0
    else {
16672
0
        int res;
16673
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16674
0
            goto failed;
16675
0
        }
16676
0
        res = obj2ast_string(state, tmp, &type_comment, "type_comment", arena);
16677
0
        _Py_LeaveRecursiveCall();
16678
0
        if (res != 0) goto failed;
16679
0
        Py_CLEAR(tmp);
16680
0
    }
16681
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16682
0
        return -1;
16683
0
    }
16684
0
    if (tmp == NULL) {
16685
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16686
0
        return -1;
16687
0
    }
16688
0
    else {
16689
0
        int res;
16690
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16691
0
            goto failed;
16692
0
        }
16693
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16694
0
        _Py_LeaveRecursiveCall();
16695
0
        if (res != 0) goto failed;
16696
0
        Py_CLEAR(tmp);
16697
0
    }
16698
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16699
0
        return -1;
16700
0
    }
16701
0
    if (tmp == NULL) {
16702
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16703
0
        return -1;
16704
0
    }
16705
0
    else {
16706
0
        int res;
16707
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16708
0
            goto failed;
16709
0
        }
16710
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
16711
0
        _Py_LeaveRecursiveCall();
16712
0
        if (res != 0) goto failed;
16713
0
        Py_CLEAR(tmp);
16714
0
    }
16715
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16716
0
        return -1;
16717
0
    }
16718
0
    if (tmp == NULL || tmp == Py_None) {
16719
0
        Py_CLEAR(tmp);
16720
0
        end_lineno = lineno;
16721
0
    }
16722
0
    else {
16723
0
        int res;
16724
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16725
0
            goto failed;
16726
0
        }
16727
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16728
0
        _Py_LeaveRecursiveCall();
16729
0
        if (res != 0) goto failed;
16730
0
        Py_CLEAR(tmp);
16731
0
    }
16732
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16733
0
        return -1;
16734
0
    }
16735
0
    if (tmp == NULL || tmp == Py_None) {
16736
0
        Py_CLEAR(tmp);
16737
0
        end_col_offset = col_offset;
16738
0
    }
16739
0
    else {
16740
0
        int res;
16741
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16742
0
            goto failed;
16743
0
        }
16744
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16745
0
        _Py_LeaveRecursiveCall();
16746
0
        if (res != 0) goto failed;
16747
0
        Py_CLEAR(tmp);
16748
0
    }
16749
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16750
0
                      end_lineno, end_col_offset, arena);
16751
0
    if (*out == NULL) goto failed;
16752
0
    return 0;
16753
0
failed:
16754
0
    Py_XDECREF(tmp);
16755
0
    return -1;
16756
0
}
16757
16758
int
16759
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out, const
16760
                char* field, PyArena* arena)
16761
0
{
16762
0
    PyObject* tmp = NULL;
16763
0
    identifier arg;
16764
0
    expr_ty value;
16765
0
    int lineno;
16766
0
    int col_offset;
16767
0
    int end_lineno;
16768
0
    int end_col_offset;
16769
16770
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16771
0
        return -1;
16772
0
    }
16773
0
    if (tmp == NULL || tmp == Py_None) {
16774
0
        Py_CLEAR(tmp);
16775
0
        arg = NULL;
16776
0
    }
16777
0
    else {
16778
0
        int res;
16779
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16780
0
            goto failed;
16781
0
        }
16782
0
        res = obj2ast_identifier(state, tmp, &arg, "arg", arena);
16783
0
        _Py_LeaveRecursiveCall();
16784
0
        if (res != 0) goto failed;
16785
0
        Py_CLEAR(tmp);
16786
0
    }
16787
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16788
0
        return -1;
16789
0
    }
16790
0
    if (tmp == NULL) {
16791
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16792
0
        return -1;
16793
0
    }
16794
0
    else {
16795
0
        int res;
16796
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16797
0
            goto failed;
16798
0
        }
16799
0
        res = obj2ast_expr(state, tmp, &value, "value", arena);
16800
0
        _Py_LeaveRecursiveCall();
16801
0
        if (res != 0) goto failed;
16802
0
        Py_CLEAR(tmp);
16803
0
    }
16804
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16805
0
        return -1;
16806
0
    }
16807
0
    if (tmp == NULL) {
16808
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16809
0
        return -1;
16810
0
    }
16811
0
    else {
16812
0
        int res;
16813
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16814
0
            goto failed;
16815
0
        }
16816
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16817
0
        _Py_LeaveRecursiveCall();
16818
0
        if (res != 0) goto failed;
16819
0
        Py_CLEAR(tmp);
16820
0
    }
16821
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16822
0
        return -1;
16823
0
    }
16824
0
    if (tmp == NULL) {
16825
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16826
0
        return -1;
16827
0
    }
16828
0
    else {
16829
0
        int res;
16830
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16831
0
            goto failed;
16832
0
        }
16833
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
16834
0
        _Py_LeaveRecursiveCall();
16835
0
        if (res != 0) goto failed;
16836
0
        Py_CLEAR(tmp);
16837
0
    }
16838
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16839
0
        return -1;
16840
0
    }
16841
0
    if (tmp == NULL || tmp == Py_None) {
16842
0
        Py_CLEAR(tmp);
16843
0
        end_lineno = lineno;
16844
0
    }
16845
0
    else {
16846
0
        int res;
16847
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16848
0
            goto failed;
16849
0
        }
16850
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16851
0
        _Py_LeaveRecursiveCall();
16852
0
        if (res != 0) goto failed;
16853
0
        Py_CLEAR(tmp);
16854
0
    }
16855
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16856
0
        return -1;
16857
0
    }
16858
0
    if (tmp == NULL || tmp == Py_None) {
16859
0
        Py_CLEAR(tmp);
16860
0
        end_col_offset = col_offset;
16861
0
    }
16862
0
    else {
16863
0
        int res;
16864
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16865
0
            goto failed;
16866
0
        }
16867
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16868
0
        _Py_LeaveRecursiveCall();
16869
0
        if (res != 0) goto failed;
16870
0
        Py_CLEAR(tmp);
16871
0
    }
16872
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16873
0
                          end_col_offset, arena);
16874
0
    if (*out == NULL) goto failed;
16875
0
    return 0;
16876
0
failed:
16877
0
    Py_XDECREF(tmp);
16878
0
    return -1;
16879
0
}
16880
16881
int
16882
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, const
16883
              char* field, PyArena* arena)
16884
0
{
16885
0
    PyObject* tmp = NULL;
16886
0
    identifier name;
16887
0
    identifier asname;
16888
0
    int lineno;
16889
0
    int col_offset;
16890
0
    int end_lineno;
16891
0
    int end_col_offset;
16892
16893
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16894
0
        return -1;
16895
0
    }
16896
0
    if (tmp == NULL) {
16897
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16898
0
        return -1;
16899
0
    }
16900
0
    else {
16901
0
        int res;
16902
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16903
0
            goto failed;
16904
0
        }
16905
0
        res = obj2ast_identifier(state, tmp, &name, "name", arena);
16906
0
        _Py_LeaveRecursiveCall();
16907
0
        if (res != 0) goto failed;
16908
0
        Py_CLEAR(tmp);
16909
0
    }
16910
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16911
0
        return -1;
16912
0
    }
16913
0
    if (tmp == NULL || tmp == Py_None) {
16914
0
        Py_CLEAR(tmp);
16915
0
        asname = NULL;
16916
0
    }
16917
0
    else {
16918
0
        int res;
16919
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16920
0
            goto failed;
16921
0
        }
16922
0
        res = obj2ast_identifier(state, tmp, &asname, "asname", arena);
16923
0
        _Py_LeaveRecursiveCall();
16924
0
        if (res != 0) goto failed;
16925
0
        Py_CLEAR(tmp);
16926
0
    }
16927
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16928
0
        return -1;
16929
0
    }
16930
0
    if (tmp == NULL) {
16931
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16932
0
        return -1;
16933
0
    }
16934
0
    else {
16935
0
        int res;
16936
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16937
0
            goto failed;
16938
0
        }
16939
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
16940
0
        _Py_LeaveRecursiveCall();
16941
0
        if (res != 0) goto failed;
16942
0
        Py_CLEAR(tmp);
16943
0
    }
16944
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16945
0
        return -1;
16946
0
    }
16947
0
    if (tmp == NULL) {
16948
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16949
0
        return -1;
16950
0
    }
16951
0
    else {
16952
0
        int res;
16953
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16954
0
            goto failed;
16955
0
        }
16956
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
16957
0
        _Py_LeaveRecursiveCall();
16958
0
        if (res != 0) goto failed;
16959
0
        Py_CLEAR(tmp);
16960
0
    }
16961
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16962
0
        return -1;
16963
0
    }
16964
0
    if (tmp == NULL || tmp == Py_None) {
16965
0
        Py_CLEAR(tmp);
16966
0
        end_lineno = lineno;
16967
0
    }
16968
0
    else {
16969
0
        int res;
16970
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16971
0
            goto failed;
16972
0
        }
16973
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
16974
0
        _Py_LeaveRecursiveCall();
16975
0
        if (res != 0) goto failed;
16976
0
        Py_CLEAR(tmp);
16977
0
    }
16978
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16979
0
        return -1;
16980
0
    }
16981
0
    if (tmp == NULL || tmp == Py_None) {
16982
0
        Py_CLEAR(tmp);
16983
0
        end_col_offset = col_offset;
16984
0
    }
16985
0
    else {
16986
0
        int res;
16987
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16988
0
            goto failed;
16989
0
        }
16990
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
16991
0
        _Py_LeaveRecursiveCall();
16992
0
        if (res != 0) goto failed;
16993
0
        Py_CLEAR(tmp);
16994
0
    }
16995
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16996
0
                        end_col_offset, arena);
16997
0
    if (*out == NULL) goto failed;
16998
0
    return 0;
16999
0
failed:
17000
0
    Py_XDECREF(tmp);
17001
0
    return -1;
17002
0
}
17003
17004
int
17005
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
17006
                 const char* field, PyArena* arena)
17007
0
{
17008
0
    PyObject* tmp = NULL;
17009
0
    expr_ty context_expr;
17010
0
    expr_ty optional_vars;
17011
17012
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
17013
0
        return -1;
17014
0
    }
17015
0
    if (tmp == NULL) {
17016
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
17017
0
        return -1;
17018
0
    }
17019
0
    else {
17020
0
        int res;
17021
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
17022
0
            goto failed;
17023
0
        }
17024
0
        res = obj2ast_expr(state, tmp, &context_expr, "context_expr", arena);
17025
0
        _Py_LeaveRecursiveCall();
17026
0
        if (res != 0) goto failed;
17027
0
        Py_CLEAR(tmp);
17028
0
    }
17029
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
17030
0
        return -1;
17031
0
    }
17032
0
    if (tmp == NULL || tmp == Py_None) {
17033
0
        Py_CLEAR(tmp);
17034
0
        optional_vars = NULL;
17035
0
    }
17036
0
    else {
17037
0
        int res;
17038
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
17039
0
            goto failed;
17040
0
        }
17041
0
        res = obj2ast_expr(state, tmp, &optional_vars, "optional_vars", arena);
17042
0
        _Py_LeaveRecursiveCall();
17043
0
        if (res != 0) goto failed;
17044
0
        Py_CLEAR(tmp);
17045
0
    }
17046
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
17047
0
    if (*out == NULL) goto failed;
17048
0
    return 0;
17049
0
failed:
17050
0
    Py_XDECREF(tmp);
17051
0
    return -1;
17052
0
}
17053
17054
int
17055
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
17056
                   const char* field, PyArena* arena)
17057
0
{
17058
0
    PyObject* tmp = NULL;
17059
0
    pattern_ty pattern;
17060
0
    expr_ty guard;
17061
0
    asdl_stmt_seq* body;
17062
17063
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17064
0
        return -1;
17065
0
    }
17066
0
    if (tmp == NULL) {
17067
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
17068
0
        return -1;
17069
0
    }
17070
0
    else {
17071
0
        int res;
17072
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17073
0
            goto failed;
17074
0
        }
17075
0
        res = obj2ast_pattern(state, tmp, &pattern, "pattern", arena);
17076
0
        _Py_LeaveRecursiveCall();
17077
0
        if (res != 0) goto failed;
17078
0
        Py_CLEAR(tmp);
17079
0
    }
17080
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17081
0
        return -1;
17082
0
    }
17083
0
    if (tmp == NULL || tmp == Py_None) {
17084
0
        Py_CLEAR(tmp);
17085
0
        guard = NULL;
17086
0
    }
17087
0
    else {
17088
0
        int res;
17089
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17090
0
            goto failed;
17091
0
        }
17092
0
        res = obj2ast_expr(state, tmp, &guard, "guard", arena);
17093
0
        _Py_LeaveRecursiveCall();
17094
0
        if (res != 0) goto failed;
17095
0
        Py_CLEAR(tmp);
17096
0
    }
17097
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17098
0
        return -1;
17099
0
    }
17100
0
    if (tmp == NULL) {
17101
0
        tmp = PyList_New(0);
17102
0
        if (tmp == NULL) {
17103
0
            return -1;
17104
0
        }
17105
0
    }
17106
0
    {
17107
0
        int res;
17108
0
        Py_ssize_t len;
17109
0
        Py_ssize_t i;
17110
0
        if (!PyList_Check(tmp)) {
17111
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17112
0
            goto failed;
17113
0
        }
17114
0
        len = PyList_GET_SIZE(tmp);
17115
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17116
0
        if (body == NULL) goto failed;
17117
0
        for (i = 0; i < len; i++) {
17118
0
            stmt_ty val;
17119
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17120
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17121
0
                goto failed;
17122
0
            }
17123
0
            res = obj2ast_stmt(state, tmp2, &val, "body", arena);
17124
0
            _Py_LeaveRecursiveCall();
17125
0
            Py_DECREF(tmp2);
17126
0
            if (res != 0) goto failed;
17127
0
            if (len != PyList_GET_SIZE(tmp)) {
17128
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17129
0
                goto failed;
17130
0
            }
17131
0
            asdl_seq_SET(body, i, val);
17132
0
        }
17133
0
        Py_CLEAR(tmp);
17134
0
    }
17135
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17136
0
    if (*out == NULL) goto failed;
17137
0
    return 0;
17138
0
failed:
17139
0
    Py_XDECREF(tmp);
17140
0
    return -1;
17141
0
}
17142
17143
int
17144
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out, const
17145
                char* field, PyArena* arena)
17146
0
{
17147
0
    int isinstance;
17148
17149
0
    PyObject *tmp = NULL;
17150
0
    PyObject *tp;
17151
0
    int lineno;
17152
0
    int col_offset;
17153
0
    int end_lineno;
17154
0
    int end_col_offset;
17155
17156
0
    if (obj == Py_None) {
17157
0
        *out = NULL;
17158
0
        return 0;
17159
0
    }
17160
0
    tp = state->pattern_type;
17161
0
    isinstance = PyObject_IsInstance(obj, tp);
17162
0
    if (isinstance == -1) {
17163
0
        return 1;
17164
0
    }
17165
0
    if (!isinstance && field != NULL) {
17166
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'pattern', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
17167
0
        return 1;
17168
0
    }
17169
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17170
0
        return -1;
17171
0
    }
17172
0
    if (tmp == NULL) {
17173
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17174
0
        return -1;
17175
0
    }
17176
0
    else {
17177
0
        int res;
17178
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17179
0
            goto failed;
17180
0
        }
17181
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
17182
0
        _Py_LeaveRecursiveCall();
17183
0
        if (res != 0) goto failed;
17184
0
        Py_CLEAR(tmp);
17185
0
    }
17186
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17187
0
        return -1;
17188
0
    }
17189
0
    if (tmp == NULL) {
17190
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17191
0
        return -1;
17192
0
    }
17193
0
    else {
17194
0
        int res;
17195
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17196
0
            goto failed;
17197
0
        }
17198
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
17199
0
        _Py_LeaveRecursiveCall();
17200
0
        if (res != 0) goto failed;
17201
0
        Py_CLEAR(tmp);
17202
0
    }
17203
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17204
0
        return -1;
17205
0
    }
17206
0
    if (tmp == NULL) {
17207
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17208
0
        return -1;
17209
0
    }
17210
0
    else {
17211
0
        int res;
17212
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17213
0
            goto failed;
17214
0
        }
17215
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
17216
0
        _Py_LeaveRecursiveCall();
17217
0
        if (res != 0) goto failed;
17218
0
        Py_CLEAR(tmp);
17219
0
    }
17220
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17221
0
        return -1;
17222
0
    }
17223
0
    if (tmp == NULL) {
17224
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17225
0
        return -1;
17226
0
    }
17227
0
    else {
17228
0
        int res;
17229
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17230
0
            goto failed;
17231
0
        }
17232
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
17233
0
        _Py_LeaveRecursiveCall();
17234
0
        if (res != 0) goto failed;
17235
0
        Py_CLEAR(tmp);
17236
0
    }
17237
0
    tp = state->MatchValue_type;
17238
0
    isinstance = PyObject_IsInstance(obj, tp);
17239
0
    if (isinstance == -1) {
17240
0
        return -1;
17241
0
    }
17242
0
    if (isinstance) {
17243
0
        expr_ty value;
17244
17245
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17246
0
            return -1;
17247
0
        }
17248
0
        if (tmp == NULL) {
17249
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17250
0
            return -1;
17251
0
        }
17252
0
        else {
17253
0
            int res;
17254
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17255
0
                goto failed;
17256
0
            }
17257
0
            res = obj2ast_expr(state, tmp, &value, "value", arena);
17258
0
            _Py_LeaveRecursiveCall();
17259
0
            if (res != 0) goto failed;
17260
0
            Py_CLEAR(tmp);
17261
0
        }
17262
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17263
0
                                 end_col_offset, arena);
17264
0
        if (*out == NULL) goto failed;
17265
0
        return 0;
17266
0
    }
17267
0
    tp = state->MatchSingleton_type;
17268
0
    isinstance = PyObject_IsInstance(obj, tp);
17269
0
    if (isinstance == -1) {
17270
0
        return -1;
17271
0
    }
17272
0
    if (isinstance) {
17273
0
        constant value;
17274
17275
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17276
0
            return -1;
17277
0
        }
17278
0
        if (tmp == NULL) {
17279
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17280
0
            return -1;
17281
0
        }
17282
0
        else {
17283
0
            int res;
17284
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17285
0
                goto failed;
17286
0
            }
17287
0
            res = obj2ast_constant(state, tmp, &value, "value", arena);
17288
0
            _Py_LeaveRecursiveCall();
17289
0
            if (res != 0) goto failed;
17290
0
            Py_CLEAR(tmp);
17291
0
        }
17292
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17293
0
                                     end_col_offset, arena);
17294
0
        if (*out == NULL) goto failed;
17295
0
        return 0;
17296
0
    }
17297
0
    tp = state->MatchSequence_type;
17298
0
    isinstance = PyObject_IsInstance(obj, tp);
17299
0
    if (isinstance == -1) {
17300
0
        return -1;
17301
0
    }
17302
0
    if (isinstance) {
17303
0
        asdl_pattern_seq* patterns;
17304
17305
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17306
0
            return -1;
17307
0
        }
17308
0
        if (tmp == NULL) {
17309
0
            tmp = PyList_New(0);
17310
0
            if (tmp == NULL) {
17311
0
                return -1;
17312
0
            }
17313
0
        }
17314
0
        {
17315
0
            int res;
17316
0
            Py_ssize_t len;
17317
0
            Py_ssize_t i;
17318
0
            if (!PyList_Check(tmp)) {
17319
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17320
0
                goto failed;
17321
0
            }
17322
0
            len = PyList_GET_SIZE(tmp);
17323
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17324
0
            if (patterns == NULL) goto failed;
17325
0
            for (i = 0; i < len; i++) {
17326
0
                pattern_ty val;
17327
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17328
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17329
0
                    goto failed;
17330
0
                }
17331
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17332
0
                _Py_LeaveRecursiveCall();
17333
0
                Py_DECREF(tmp2);
17334
0
                if (res != 0) goto failed;
17335
0
                if (len != PyList_GET_SIZE(tmp)) {
17336
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17337
0
                    goto failed;
17338
0
                }
17339
0
                asdl_seq_SET(patterns, i, val);
17340
0
            }
17341
0
            Py_CLEAR(tmp);
17342
0
        }
17343
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17344
0
                                    end_col_offset, arena);
17345
0
        if (*out == NULL) goto failed;
17346
0
        return 0;
17347
0
    }
17348
0
    tp = state->MatchMapping_type;
17349
0
    isinstance = PyObject_IsInstance(obj, tp);
17350
0
    if (isinstance == -1) {
17351
0
        return -1;
17352
0
    }
17353
0
    if (isinstance) {
17354
0
        asdl_expr_seq* keys;
17355
0
        asdl_pattern_seq* patterns;
17356
0
        identifier rest;
17357
17358
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17359
0
            return -1;
17360
0
        }
17361
0
        if (tmp == NULL) {
17362
0
            tmp = PyList_New(0);
17363
0
            if (tmp == NULL) {
17364
0
                return -1;
17365
0
            }
17366
0
        }
17367
0
        {
17368
0
            int res;
17369
0
            Py_ssize_t len;
17370
0
            Py_ssize_t i;
17371
0
            if (!PyList_Check(tmp)) {
17372
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17373
0
                goto failed;
17374
0
            }
17375
0
            len = PyList_GET_SIZE(tmp);
17376
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17377
0
            if (keys == NULL) goto failed;
17378
0
            for (i = 0; i < len; i++) {
17379
0
                expr_ty val;
17380
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17381
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17382
0
                    goto failed;
17383
0
                }
17384
0
                res = obj2ast_expr(state, tmp2, &val, "keys", arena);
17385
0
                _Py_LeaveRecursiveCall();
17386
0
                Py_DECREF(tmp2);
17387
0
                if (res != 0) goto failed;
17388
0
                if (len != PyList_GET_SIZE(tmp)) {
17389
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17390
0
                    goto failed;
17391
0
                }
17392
0
                asdl_seq_SET(keys, i, val);
17393
0
            }
17394
0
            Py_CLEAR(tmp);
17395
0
        }
17396
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17397
0
            return -1;
17398
0
        }
17399
0
        if (tmp == NULL) {
17400
0
            tmp = PyList_New(0);
17401
0
            if (tmp == NULL) {
17402
0
                return -1;
17403
0
            }
17404
0
        }
17405
0
        {
17406
0
            int res;
17407
0
            Py_ssize_t len;
17408
0
            Py_ssize_t i;
17409
0
            if (!PyList_Check(tmp)) {
17410
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17411
0
                goto failed;
17412
0
            }
17413
0
            len = PyList_GET_SIZE(tmp);
17414
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17415
0
            if (patterns == NULL) goto failed;
17416
0
            for (i = 0; i < len; i++) {
17417
0
                pattern_ty val;
17418
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17419
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17420
0
                    goto failed;
17421
0
                }
17422
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17423
0
                _Py_LeaveRecursiveCall();
17424
0
                Py_DECREF(tmp2);
17425
0
                if (res != 0) goto failed;
17426
0
                if (len != PyList_GET_SIZE(tmp)) {
17427
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17428
0
                    goto failed;
17429
0
                }
17430
0
                asdl_seq_SET(patterns, i, val);
17431
0
            }
17432
0
            Py_CLEAR(tmp);
17433
0
        }
17434
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17435
0
            return -1;
17436
0
        }
17437
0
        if (tmp == NULL || tmp == Py_None) {
17438
0
            Py_CLEAR(tmp);
17439
0
            rest = NULL;
17440
0
        }
17441
0
        else {
17442
0
            int res;
17443
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17444
0
                goto failed;
17445
0
            }
17446
0
            res = obj2ast_identifier(state, tmp, &rest, "rest", arena);
17447
0
            _Py_LeaveRecursiveCall();
17448
0
            if (res != 0) goto failed;
17449
0
            Py_CLEAR(tmp);
17450
0
        }
17451
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17452
0
                                   end_lineno, end_col_offset, arena);
17453
0
        if (*out == NULL) goto failed;
17454
0
        return 0;
17455
0
    }
17456
0
    tp = state->MatchClass_type;
17457
0
    isinstance = PyObject_IsInstance(obj, tp);
17458
0
    if (isinstance == -1) {
17459
0
        return -1;
17460
0
    }
17461
0
    if (isinstance) {
17462
0
        expr_ty cls;
17463
0
        asdl_pattern_seq* patterns;
17464
0
        asdl_identifier_seq* kwd_attrs;
17465
0
        asdl_pattern_seq* kwd_patterns;
17466
17467
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17468
0
            return -1;
17469
0
        }
17470
0
        if (tmp == NULL) {
17471
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17472
0
            return -1;
17473
0
        }
17474
0
        else {
17475
0
            int res;
17476
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17477
0
                goto failed;
17478
0
            }
17479
0
            res = obj2ast_expr(state, tmp, &cls, "cls", arena);
17480
0
            _Py_LeaveRecursiveCall();
17481
0
            if (res != 0) goto failed;
17482
0
            Py_CLEAR(tmp);
17483
0
        }
17484
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17485
0
            return -1;
17486
0
        }
17487
0
        if (tmp == NULL) {
17488
0
            tmp = PyList_New(0);
17489
0
            if (tmp == NULL) {
17490
0
                return -1;
17491
0
            }
17492
0
        }
17493
0
        {
17494
0
            int res;
17495
0
            Py_ssize_t len;
17496
0
            Py_ssize_t i;
17497
0
            if (!PyList_Check(tmp)) {
17498
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17499
0
                goto failed;
17500
0
            }
17501
0
            len = PyList_GET_SIZE(tmp);
17502
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17503
0
            if (patterns == NULL) goto failed;
17504
0
            for (i = 0; i < len; i++) {
17505
0
                pattern_ty val;
17506
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17507
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17508
0
                    goto failed;
17509
0
                }
17510
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17511
0
                _Py_LeaveRecursiveCall();
17512
0
                Py_DECREF(tmp2);
17513
0
                if (res != 0) goto failed;
17514
0
                if (len != PyList_GET_SIZE(tmp)) {
17515
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17516
0
                    goto failed;
17517
0
                }
17518
0
                asdl_seq_SET(patterns, i, val);
17519
0
            }
17520
0
            Py_CLEAR(tmp);
17521
0
        }
17522
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17523
0
            return -1;
17524
0
        }
17525
0
        if (tmp == NULL) {
17526
0
            tmp = PyList_New(0);
17527
0
            if (tmp == NULL) {
17528
0
                return -1;
17529
0
            }
17530
0
        }
17531
0
        {
17532
0
            int res;
17533
0
            Py_ssize_t len;
17534
0
            Py_ssize_t i;
17535
0
            if (!PyList_Check(tmp)) {
17536
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17537
0
                goto failed;
17538
0
            }
17539
0
            len = PyList_GET_SIZE(tmp);
17540
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17541
0
            if (kwd_attrs == NULL) goto failed;
17542
0
            for (i = 0; i < len; i++) {
17543
0
                identifier val;
17544
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17545
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17546
0
                    goto failed;
17547
0
                }
17548
0
                res = obj2ast_identifier(state, tmp2, &val, "kwd_attrs", arena);
17549
0
                _Py_LeaveRecursiveCall();
17550
0
                Py_DECREF(tmp2);
17551
0
                if (res != 0) goto failed;
17552
0
                if (len != PyList_GET_SIZE(tmp)) {
17553
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17554
0
                    goto failed;
17555
0
                }
17556
0
                asdl_seq_SET(kwd_attrs, i, val);
17557
0
            }
17558
0
            Py_CLEAR(tmp);
17559
0
        }
17560
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17561
0
            return -1;
17562
0
        }
17563
0
        if (tmp == NULL) {
17564
0
            tmp = PyList_New(0);
17565
0
            if (tmp == NULL) {
17566
0
                return -1;
17567
0
            }
17568
0
        }
17569
0
        {
17570
0
            int res;
17571
0
            Py_ssize_t len;
17572
0
            Py_ssize_t i;
17573
0
            if (!PyList_Check(tmp)) {
17574
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17575
0
                goto failed;
17576
0
            }
17577
0
            len = PyList_GET_SIZE(tmp);
17578
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17579
0
            if (kwd_patterns == NULL) goto failed;
17580
0
            for (i = 0; i < len; i++) {
17581
0
                pattern_ty val;
17582
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17583
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17584
0
                    goto failed;
17585
0
                }
17586
0
                res = obj2ast_pattern(state, tmp2, &val, "kwd_patterns", arena);
17587
0
                _Py_LeaveRecursiveCall();
17588
0
                Py_DECREF(tmp2);
17589
0
                if (res != 0) goto failed;
17590
0
                if (len != PyList_GET_SIZE(tmp)) {
17591
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17592
0
                    goto failed;
17593
0
                }
17594
0
                asdl_seq_SET(kwd_patterns, i, val);
17595
0
            }
17596
0
            Py_CLEAR(tmp);
17597
0
        }
17598
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17599
0
                                 lineno, col_offset, end_lineno,
17600
0
                                 end_col_offset, arena);
17601
0
        if (*out == NULL) goto failed;
17602
0
        return 0;
17603
0
    }
17604
0
    tp = state->MatchStar_type;
17605
0
    isinstance = PyObject_IsInstance(obj, tp);
17606
0
    if (isinstance == -1) {
17607
0
        return -1;
17608
0
    }
17609
0
    if (isinstance) {
17610
0
        identifier name;
17611
17612
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17613
0
            return -1;
17614
0
        }
17615
0
        if (tmp == NULL || tmp == Py_None) {
17616
0
            Py_CLEAR(tmp);
17617
0
            name = NULL;
17618
0
        }
17619
0
        else {
17620
0
            int res;
17621
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17622
0
                goto failed;
17623
0
            }
17624
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17625
0
            _Py_LeaveRecursiveCall();
17626
0
            if (res != 0) goto failed;
17627
0
            Py_CLEAR(tmp);
17628
0
        }
17629
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17630
0
                                end_col_offset, arena);
17631
0
        if (*out == NULL) goto failed;
17632
0
        return 0;
17633
0
    }
17634
0
    tp = state->MatchAs_type;
17635
0
    isinstance = PyObject_IsInstance(obj, tp);
17636
0
    if (isinstance == -1) {
17637
0
        return -1;
17638
0
    }
17639
0
    if (isinstance) {
17640
0
        pattern_ty pattern;
17641
0
        identifier name;
17642
17643
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17644
0
            return -1;
17645
0
        }
17646
0
        if (tmp == NULL || tmp == Py_None) {
17647
0
            Py_CLEAR(tmp);
17648
0
            pattern = NULL;
17649
0
        }
17650
0
        else {
17651
0
            int res;
17652
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17653
0
                goto failed;
17654
0
            }
17655
0
            res = obj2ast_pattern(state, tmp, &pattern, "pattern", arena);
17656
0
            _Py_LeaveRecursiveCall();
17657
0
            if (res != 0) goto failed;
17658
0
            Py_CLEAR(tmp);
17659
0
        }
17660
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17661
0
            return -1;
17662
0
        }
17663
0
        if (tmp == NULL || tmp == Py_None) {
17664
0
            Py_CLEAR(tmp);
17665
0
            name = NULL;
17666
0
        }
17667
0
        else {
17668
0
            int res;
17669
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17670
0
                goto failed;
17671
0
            }
17672
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17673
0
            _Py_LeaveRecursiveCall();
17674
0
            if (res != 0) goto failed;
17675
0
            Py_CLEAR(tmp);
17676
0
        }
17677
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17678
0
                              end_col_offset, arena);
17679
0
        if (*out == NULL) goto failed;
17680
0
        return 0;
17681
0
    }
17682
0
    tp = state->MatchOr_type;
17683
0
    isinstance = PyObject_IsInstance(obj, tp);
17684
0
    if (isinstance == -1) {
17685
0
        return -1;
17686
0
    }
17687
0
    if (isinstance) {
17688
0
        asdl_pattern_seq* patterns;
17689
17690
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17691
0
            return -1;
17692
0
        }
17693
0
        if (tmp == NULL) {
17694
0
            tmp = PyList_New(0);
17695
0
            if (tmp == NULL) {
17696
0
                return -1;
17697
0
            }
17698
0
        }
17699
0
        {
17700
0
            int res;
17701
0
            Py_ssize_t len;
17702
0
            Py_ssize_t i;
17703
0
            if (!PyList_Check(tmp)) {
17704
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17705
0
                goto failed;
17706
0
            }
17707
0
            len = PyList_GET_SIZE(tmp);
17708
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17709
0
            if (patterns == NULL) goto failed;
17710
0
            for (i = 0; i < len; i++) {
17711
0
                pattern_ty val;
17712
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17713
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17714
0
                    goto failed;
17715
0
                }
17716
0
                res = obj2ast_pattern(state, tmp2, &val, "patterns", arena);
17717
0
                _Py_LeaveRecursiveCall();
17718
0
                Py_DECREF(tmp2);
17719
0
                if (res != 0) goto failed;
17720
0
                if (len != PyList_GET_SIZE(tmp)) {
17721
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17722
0
                    goto failed;
17723
0
                }
17724
0
                asdl_seq_SET(patterns, i, val);
17725
0
            }
17726
0
            Py_CLEAR(tmp);
17727
0
        }
17728
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17729
0
                              end_col_offset, 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 pattern, but got %R", obj);
17735
0
    failed:
17736
0
    Py_XDECREF(tmp);
17737
0
    return -1;
17738
0
}
17739
17740
int
17741
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17742
                    out, const char* field, PyArena* arena)
17743
0
{
17744
0
    int isinstance;
17745
17746
0
    PyObject *tmp = NULL;
17747
0
    PyObject *tp;
17748
17749
0
    if (obj == Py_None) {
17750
0
        *out = NULL;
17751
0
        return 0;
17752
0
    }
17753
0
    tp = state->type_ignore_type;
17754
0
    isinstance = PyObject_IsInstance(obj, tp);
17755
0
    if (isinstance == -1) {
17756
0
        return 1;
17757
0
    }
17758
0
    if (!isinstance && field != NULL) {
17759
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'type_ignore', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
17760
0
        return 1;
17761
0
    }
17762
0
    tp = state->TypeIgnore_type;
17763
0
    isinstance = PyObject_IsInstance(obj, tp);
17764
0
    if (isinstance == -1) {
17765
0
        return -1;
17766
0
    }
17767
0
    if (isinstance) {
17768
0
        int lineno;
17769
0
        string tag;
17770
17771
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17772
0
            return -1;
17773
0
        }
17774
0
        if (tmp == NULL) {
17775
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17776
0
            return -1;
17777
0
        }
17778
0
        else {
17779
0
            int res;
17780
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17781
0
                goto failed;
17782
0
            }
17783
0
            res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
17784
0
            _Py_LeaveRecursiveCall();
17785
0
            if (res != 0) goto failed;
17786
0
            Py_CLEAR(tmp);
17787
0
        }
17788
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17789
0
            return -1;
17790
0
        }
17791
0
        if (tmp == NULL) {
17792
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17793
0
            return -1;
17794
0
        }
17795
0
        else {
17796
0
            int res;
17797
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17798
0
                goto failed;
17799
0
            }
17800
0
            res = obj2ast_string(state, tmp, &tag, "tag", arena);
17801
0
            _Py_LeaveRecursiveCall();
17802
0
            if (res != 0) goto failed;
17803
0
            Py_CLEAR(tmp);
17804
0
        }
17805
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17806
0
        if (*out == NULL) goto failed;
17807
0
        return 0;
17808
0
    }
17809
17810
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17811
0
    failed:
17812
0
    Py_XDECREF(tmp);
17813
0
    return -1;
17814
0
}
17815
17816
int
17817
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17818
                   const char* field, PyArena* arena)
17819
0
{
17820
0
    int isinstance;
17821
17822
0
    PyObject *tmp = NULL;
17823
0
    PyObject *tp;
17824
0
    int lineno;
17825
0
    int col_offset;
17826
0
    int end_lineno;
17827
0
    int end_col_offset;
17828
17829
0
    if (obj == Py_None) {
17830
0
        *out = NULL;
17831
0
        return 0;
17832
0
    }
17833
0
    tp = state->type_param_type;
17834
0
    isinstance = PyObject_IsInstance(obj, tp);
17835
0
    if (isinstance == -1) {
17836
0
        return 1;
17837
0
    }
17838
0
    if (!isinstance && field != NULL) {
17839
0
        PyErr_Format(PyExc_TypeError, "field '%s' was expecting node of type 'type_param', got '%s'", field, _PyType_Name(Py_TYPE(obj)));
17840
0
        return 1;
17841
0
    }
17842
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17843
0
        return -1;
17844
0
    }
17845
0
    if (tmp == NULL) {
17846
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17847
0
        return -1;
17848
0
    }
17849
0
    else {
17850
0
        int res;
17851
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17852
0
            goto failed;
17853
0
        }
17854
0
        res = obj2ast_int(state, tmp, &lineno, "lineno", arena);
17855
0
        _Py_LeaveRecursiveCall();
17856
0
        if (res != 0) goto failed;
17857
0
        Py_CLEAR(tmp);
17858
0
    }
17859
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17860
0
        return -1;
17861
0
    }
17862
0
    if (tmp == NULL) {
17863
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17864
0
        return -1;
17865
0
    }
17866
0
    else {
17867
0
        int res;
17868
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17869
0
            goto failed;
17870
0
        }
17871
0
        res = obj2ast_int(state, tmp, &col_offset, "col_offset", arena);
17872
0
        _Py_LeaveRecursiveCall();
17873
0
        if (res != 0) goto failed;
17874
0
        Py_CLEAR(tmp);
17875
0
    }
17876
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17877
0
        return -1;
17878
0
    }
17879
0
    if (tmp == NULL) {
17880
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17881
0
        return -1;
17882
0
    }
17883
0
    else {
17884
0
        int res;
17885
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17886
0
            goto failed;
17887
0
        }
17888
0
        res = obj2ast_int(state, tmp, &end_lineno, "end_lineno", arena);
17889
0
        _Py_LeaveRecursiveCall();
17890
0
        if (res != 0) goto failed;
17891
0
        Py_CLEAR(tmp);
17892
0
    }
17893
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17894
0
        return -1;
17895
0
    }
17896
0
    if (tmp == NULL) {
17897
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17898
0
        return -1;
17899
0
    }
17900
0
    else {
17901
0
        int res;
17902
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17903
0
            goto failed;
17904
0
        }
17905
0
        res = obj2ast_int(state, tmp, &end_col_offset, "end_col_offset", arena);
17906
0
        _Py_LeaveRecursiveCall();
17907
0
        if (res != 0) goto failed;
17908
0
        Py_CLEAR(tmp);
17909
0
    }
17910
0
    tp = state->TypeVar_type;
17911
0
    isinstance = PyObject_IsInstance(obj, tp);
17912
0
    if (isinstance == -1) {
17913
0
        return -1;
17914
0
    }
17915
0
    if (isinstance) {
17916
0
        identifier name;
17917
0
        expr_ty bound;
17918
0
        expr_ty default_value;
17919
17920
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17921
0
            return -1;
17922
0
        }
17923
0
        if (tmp == NULL) {
17924
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17925
0
            return -1;
17926
0
        }
17927
0
        else {
17928
0
            int res;
17929
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17930
0
                goto failed;
17931
0
            }
17932
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17933
0
            _Py_LeaveRecursiveCall();
17934
0
            if (res != 0) goto failed;
17935
0
            Py_CLEAR(tmp);
17936
0
        }
17937
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17938
0
            return -1;
17939
0
        }
17940
0
        if (tmp == NULL || tmp == Py_None) {
17941
0
            Py_CLEAR(tmp);
17942
0
            bound = NULL;
17943
0
        }
17944
0
        else {
17945
0
            int res;
17946
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17947
0
                goto failed;
17948
0
            }
17949
0
            res = obj2ast_expr(state, tmp, &bound, "bound", arena);
17950
0
            _Py_LeaveRecursiveCall();
17951
0
            if (res != 0) goto failed;
17952
0
            Py_CLEAR(tmp);
17953
0
        }
17954
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17955
0
            return -1;
17956
0
        }
17957
0
        if (tmp == NULL || tmp == Py_None) {
17958
0
            Py_CLEAR(tmp);
17959
0
            default_value = NULL;
17960
0
        }
17961
0
        else {
17962
0
            int res;
17963
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17964
0
                goto failed;
17965
0
            }
17966
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
17967
0
                               arena);
17968
0
            _Py_LeaveRecursiveCall();
17969
0
            if (res != 0) goto failed;
17970
0
            Py_CLEAR(tmp);
17971
0
        }
17972
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17973
0
                              end_lineno, end_col_offset, arena);
17974
0
        if (*out == NULL) goto failed;
17975
0
        return 0;
17976
0
    }
17977
0
    tp = state->ParamSpec_type;
17978
0
    isinstance = PyObject_IsInstance(obj, tp);
17979
0
    if (isinstance == -1) {
17980
0
        return -1;
17981
0
    }
17982
0
    if (isinstance) {
17983
0
        identifier name;
17984
0
        expr_ty default_value;
17985
17986
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17987
0
            return -1;
17988
0
        }
17989
0
        if (tmp == NULL) {
17990
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17991
0
            return -1;
17992
0
        }
17993
0
        else {
17994
0
            int res;
17995
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17996
0
                goto failed;
17997
0
            }
17998
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
17999
0
            _Py_LeaveRecursiveCall();
18000
0
            if (res != 0) goto failed;
18001
0
            Py_CLEAR(tmp);
18002
0
        }
18003
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
18004
0
            return -1;
18005
0
        }
18006
0
        if (tmp == NULL || tmp == Py_None) {
18007
0
            Py_CLEAR(tmp);
18008
0
            default_value = NULL;
18009
0
        }
18010
0
        else {
18011
0
            int res;
18012
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
18013
0
                goto failed;
18014
0
            }
18015
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
18016
0
                               arena);
18017
0
            _Py_LeaveRecursiveCall();
18018
0
            if (res != 0) goto failed;
18019
0
            Py_CLEAR(tmp);
18020
0
        }
18021
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
18022
0
                                end_lineno, end_col_offset, arena);
18023
0
        if (*out == NULL) goto failed;
18024
0
        return 0;
18025
0
    }
18026
0
    tp = state->TypeVarTuple_type;
18027
0
    isinstance = PyObject_IsInstance(obj, tp);
18028
0
    if (isinstance == -1) {
18029
0
        return -1;
18030
0
    }
18031
0
    if (isinstance) {
18032
0
        identifier name;
18033
0
        expr_ty default_value;
18034
18035
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
18036
0
            return -1;
18037
0
        }
18038
0
        if (tmp == NULL) {
18039
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
18040
0
            return -1;
18041
0
        }
18042
0
        else {
18043
0
            int res;
18044
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
18045
0
                goto failed;
18046
0
            }
18047
0
            res = obj2ast_identifier(state, tmp, &name, "name", arena);
18048
0
            _Py_LeaveRecursiveCall();
18049
0
            if (res != 0) goto failed;
18050
0
            Py_CLEAR(tmp);
18051
0
        }
18052
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
18053
0
            return -1;
18054
0
        }
18055
0
        if (tmp == NULL || tmp == Py_None) {
18056
0
            Py_CLEAR(tmp);
18057
0
            default_value = NULL;
18058
0
        }
18059
0
        else {
18060
0
            int res;
18061
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
18062
0
                goto failed;
18063
0
            }
18064
0
            res = obj2ast_expr(state, tmp, &default_value, "default_value",
18065
0
                               arena);
18066
0
            _Py_LeaveRecursiveCall();
18067
0
            if (res != 0) goto failed;
18068
0
            Py_CLEAR(tmp);
18069
0
        }
18070
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
18071
0
                                   end_lineno, end_col_offset, arena);
18072
0
        if (*out == NULL) goto failed;
18073
0
        return 0;
18074
0
    }
18075
18076
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
18077
0
    failed:
18078
0
    Py_XDECREF(tmp);
18079
0
    return -1;
18080
0
}
18081
18082
18083
/* Helper for checking if a node class is abstract in the tests. */
18084
static PyObject *
18085
0
ast_is_abstract(PyObject *Py_UNUSED(module), PyObject *cls) {
18086
0
    struct ast_state *state = get_ast_state();
18087
0
    if (state == NULL) {
18088
0
        return NULL;
18089
0
    }
18090
0
    int contains = PySet_Contains(state->abstract_types, cls);
18091
0
    if (contains == -1) {
18092
0
        return NULL;
18093
0
    }
18094
0
    else if (contains == 1) {
18095
0
        Py_RETURN_TRUE;
18096
0
    }
18097
0
    Py_RETURN_FALSE;
18098
0
}
18099
18100
static struct PyMethodDef astmodule_methods[] = {
18101
    {"_is_abstract", ast_is_abstract, METH_O, NULL},
18102
    {NULL}  /* Sentinel */
18103
};
18104
18105
static int
18106
astmodule_exec(PyObject *m)
18107
9
{
18108
9
    struct ast_state *state = get_ast_state();
18109
9
    if (state == NULL) {
18110
0
        return -1;
18111
0
    }
18112
9
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
18113
0
        return -1;
18114
0
    }
18115
9
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
18116
0
        return -1;
18117
0
    }
18118
9
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
18119
0
        return -1;
18120
0
    }
18121
9
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
18122
0
        return -1;
18123
0
    }
18124
9
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18125
0
        return -1;
18126
0
    }
18127
9
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18128
0
        return -1;
18129
0
    }
18130
9
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18131
0
        return -1;
18132
0
    }
18133
9
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18134
0
        return -1;
18135
0
    }
18136
9
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18137
0
        return -1;
18138
0
    }
18139
9
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18140
0
        {
18141
0
        return -1;
18142
0
    }
18143
9
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18144
0
        return -1;
18145
0
    }
18146
9
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18147
0
        return -1;
18148
0
    }
18149
9
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18150
9
        state->AsyncFunctionDef_type) < 0) {
18151
0
        return -1;
18152
0
    }
18153
9
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18154
0
        return -1;
18155
0
    }
18156
9
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18157
0
        return -1;
18158
0
    }
18159
9
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18160
0
        return -1;
18161
0
    }
18162
9
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18163
0
        return -1;
18164
0
    }
18165
9
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18166
0
        return -1;
18167
0
    }
18168
9
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18169
0
        return -1;
18170
0
    }
18171
9
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18172
0
        return -1;
18173
0
    }
18174
9
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18175
0
        return -1;
18176
0
    }
18177
9
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18178
0
        return -1;
18179
0
    }
18180
9
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18181
0
        return -1;
18182
0
    }
18183
9
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18184
0
        return -1;
18185
0
    }
18186
9
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18187
0
        return -1;
18188
0
    }
18189
9
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18190
0
        return -1;
18191
0
    }
18192
9
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18193
0
        return -1;
18194
0
    }
18195
9
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18196
0
        return -1;
18197
0
    }
18198
9
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18199
0
        return -1;
18200
0
    }
18201
9
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18202
0
        return -1;
18203
0
    }
18204
9
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18205
0
        return -1;
18206
0
    }
18207
9
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18208
0
        return -1;
18209
0
    }
18210
9
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18211
0
        return -1;
18212
0
    }
18213
9
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18214
0
        return -1;
18215
0
    }
18216
9
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18217
0
        return -1;
18218
0
    }
18219
9
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18220
0
        return -1;
18221
0
    }
18222
9
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18223
0
        return -1;
18224
0
    }
18225
9
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18226
0
        return -1;
18227
0
    }
18228
9
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18229
0
        return -1;
18230
0
    }
18231
9
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18232
0
        return -1;
18233
0
    }
18234
9
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18235
0
        return -1;
18236
0
    }
18237
9
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18238
0
        return -1;
18239
0
    }
18240
9
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18241
0
        return -1;
18242
0
    }
18243
9
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18244
0
        return -1;
18245
0
    }
18246
9
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18247
0
        return -1;
18248
0
    }
18249
9
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18250
0
        return -1;
18251
0
    }
18252
9
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18253
0
        return -1;
18254
0
    }
18255
9
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18256
0
        return -1;
18257
0
    }
18258
9
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18259
0
        return -1;
18260
0
    }
18261
9
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18262
0
        return -1;
18263
0
    }
18264
9
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18265
0
        return -1;
18266
0
    }
18267
9
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18268
0
        {
18269
0
        return -1;
18270
0
    }
18271
9
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18272
0
        return -1;
18273
0
    }
18274
9
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18275
0
        return -1;
18276
0
    }
18277
9
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18278
0
        return -1;
18279
0
    }
18280
9
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18281
0
        return -1;
18282
0
    }
18283
9
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18284
0
        return -1;
18285
0
    }
18286
9
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18287
9
        < 0) {
18288
0
        return -1;
18289
0
    }
18290
9
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18291
9
        0) {
18292
0
        return -1;
18293
0
    }
18294
9
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18295
0
        return -1;
18296
0
    }
18297
9
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18298
0
        return -1;
18299
0
    }
18300
9
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18301
0
        return -1;
18302
0
    }
18303
9
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18304
0
        return -1;
18305
0
    }
18306
9
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18307
0
        return -1;
18308
0
    }
18309
9
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18310
0
        return -1;
18311
0
    }
18312
9
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18313
0
        return -1;
18314
0
    }
18315
9
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18316
0
        return -1;
18317
0
    }
18318
9
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18319
0
        return -1;
18320
0
    }
18321
9
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18322
0
        return -1;
18323
0
    }
18324
9
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18325
0
        {
18326
0
        return -1;
18327
0
    }
18328
9
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18329
0
        return -1;
18330
0
    }
18331
9
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18332
0
        return -1;
18333
0
    }
18334
9
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18335
0
        return -1;
18336
0
    }
18337
9
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18338
0
        return -1;
18339
0
    }
18340
9
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18341
0
        return -1;
18342
0
    }
18343
9
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18344
0
        return -1;
18345
0
    }
18346
9
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18347
0
        return -1;
18348
0
    }
18349
9
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18350
0
        return -1;
18351
0
    }
18352
9
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18353
0
        return -1;
18354
0
    }
18355
9
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18356
0
        return -1;
18357
0
    }
18358
9
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18359
0
        return -1;
18360
0
    }
18361
9
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18362
0
        return -1;
18363
0
    }
18364
9
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18365
0
        return -1;
18366
0
    }
18367
9
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18368
0
        return -1;
18369
0
    }
18370
9
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18371
0
        return -1;
18372
0
    }
18373
9
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18374
0
        return -1;
18375
0
    }
18376
9
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18377
0
        return -1;
18378
0
    }
18379
9
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18380
0
        return -1;
18381
0
    }
18382
9
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18383
0
        return -1;
18384
0
    }
18385
9
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18386
0
        return -1;
18387
0
    }
18388
9
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18389
0
        return -1;
18390
0
    }
18391
9
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18392
0
        return -1;
18393
0
    }
18394
9
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18395
0
        return -1;
18396
0
    }
18397
9
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18398
0
        return -1;
18399
0
    }
18400
9
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18401
0
        return -1;
18402
0
    }
18403
9
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18404
0
        return -1;
18405
0
    }
18406
9
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18407
0
        return -1;
18408
0
    }
18409
9
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18410
0
        return -1;
18411
0
    }
18412
9
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18413
0
        return -1;
18414
0
    }
18415
9
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18416
0
        return -1;
18417
0
    }
18418
9
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18419
0
        return -1;
18420
0
    }
18421
9
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18422
0
        return -1;
18423
0
    }
18424
9
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18425
0
        return -1;
18426
0
    }
18427
9
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18428
0
        return -1;
18429
0
    }
18430
9
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18431
0
        return -1;
18432
0
    }
18433
9
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18434
0
        return -1;
18435
0
    }
18436
9
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18437
9
        0) {
18438
0
        return -1;
18439
0
    }
18440
9
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18441
9
        0) {
18442
0
        return -1;
18443
0
    }
18444
9
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18445
9
        0) {
18446
0
        return -1;
18447
0
    }
18448
9
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18449
0
        return -1;
18450
0
    }
18451
9
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18452
0
        return -1;
18453
0
    }
18454
9
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18455
0
        return -1;
18456
0
    }
18457
9
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18458
0
        return -1;
18459
0
    }
18460
9
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18461
0
        return -1;
18462
0
    }
18463
9
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18464
0
        return -1;
18465
0
    }
18466
9
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18467
0
        return -1;
18468
0
    }
18469
9
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18470
0
        return -1;
18471
0
    }
18472
9
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18473
9
        < 0) {
18474
0
        return -1;
18475
0
    }
18476
9
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18477
9
        0) {
18478
0
        return -1;
18479
0
    }
18480
9
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18481
0
        {
18482
0
        return -1;
18483
0
    }
18484
9
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18485
0
        return -1;
18486
0
    }
18487
9
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18488
0
        return -1;
18489
0
    }
18490
9
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18491
0
        return -1;
18492
0
    }
18493
9
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18494
0
        return -1;
18495
0
    }
18496
9
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18497
0
        return -1;
18498
0
    }
18499
9
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18500
0
        return -1;
18501
0
    }
18502
9
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18503
0
        return -1;
18504
0
    }
18505
9
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18506
0
        return -1;
18507
0
    }
18508
9
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18509
0
        return -1;
18510
0
    }
18511
9
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18512
0
        {
18513
0
        return -1;
18514
0
    }
18515
9
    return 0;
18516
9
}
18517
18518
static PyModuleDef_Slot astmodule_slots[] = {
18519
    _Py_ABI_SLOT,
18520
    {Py_mod_exec, astmodule_exec},
18521
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18522
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18523
    {0, NULL}
18524
};
18525
18526
static struct PyModuleDef _astmodule = {
18527
    PyModuleDef_HEAD_INIT,
18528
    .m_name = "_ast",
18529
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18530
    .m_size = 0,
18531
    .m_methods = astmodule_methods,
18532
    .m_slots = astmodule_slots
18533
};
18534
18535
PyMODINIT_FUNC
18536
PyInit__ast(void)
18537
9
{
18538
9
    return PyModuleDef_Init(&_astmodule);
18539
9
}
18540
18541
18542
PyObject* PyAST_mod2obj(mod_ty t)
18543
6.68k
{
18544
6.68k
    struct ast_state *state = get_ast_state();
18545
6.68k
    if (state == NULL) {
18546
0
        return NULL;
18547
0
    }
18548
6.68k
    PyObject *result = ast2obj_mod(state, t);
18549
18550
6.68k
    return result;
18551
6.68k
}
18552
18553
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18554
int PyAst_CheckMode(PyObject *ast, int mode)
18555
0
{
18556
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18557
18558
0
    struct ast_state *state = get_ast_state();
18559
0
    if (state == NULL) {
18560
0
        return -1;
18561
0
    }
18562
18563
0
    PyObject *req_type[3];
18564
0
    req_type[0] = state->Module_type;
18565
0
    req_type[1] = state->Expression_type;
18566
0
    req_type[2] = state->Interactive_type;
18567
18568
0
    assert(0 <= mode && mode <= 2);
18569
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18570
0
    if (isinstance == -1) {
18571
0
        return -1;
18572
0
    }
18573
0
    if (!isinstance) {
18574
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18575
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18576
0
        return -1;
18577
0
    }
18578
0
    return 0;
18579
0
}
18580
18581
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18582
0
{
18583
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18584
0
        return NULL;
18585
0
    }
18586
18587
0
    struct ast_state *state = get_ast_state();
18588
0
    if (state == NULL) {
18589
0
        return NULL;
18590
0
    }
18591
18592
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18593
0
        return NULL;
18594
0
    }
18595
18596
0
    mod_ty res = NULL;
18597
0
    if (obj2ast_mod(state, ast, &res, NULL, arena) != 0)
18598
0
        return NULL;
18599
0
    else
18600
0
        return res;
18601
0
}
18602
18603
int PyAST_Check(PyObject* obj)
18604
109k
{
18605
109k
    struct ast_state *state = get_ast_state();
18606
109k
    if (state == NULL) {
18607
0
        return -1;
18608
0
    }
18609
109k
    return PyObject_IsInstance(obj, state->AST_type);
18610
109k
}
18611
18612