Coverage Report

Created: 2026-02-09 07:07

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
22.7k
{
23
22.7k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
22.7k
    struct ast_state *state = &interp->ast;
25
22.7k
    assert(!state->finalized);
26
22.7k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
22.7k
    return state;
30
22.7k
}
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->alias_type);
182
0
    Py_CLEAR(state->annotation);
183
0
    Py_CLEAR(state->arg);
184
0
    Py_CLEAR(state->arg_type);
185
0
    Py_CLEAR(state->args);
186
0
    Py_CLEAR(state->argtypes);
187
0
    Py_CLEAR(state->arguments_type);
188
0
    Py_CLEAR(state->asname);
189
0
    Py_CLEAR(state->ast);
190
0
    Py_CLEAR(state->attr);
191
0
    Py_CLEAR(state->bases);
192
0
    Py_CLEAR(state->body);
193
0
    Py_CLEAR(state->boolop_type);
194
0
    Py_CLEAR(state->bound);
195
0
    Py_CLEAR(state->cases);
196
0
    Py_CLEAR(state->cause);
197
0
    Py_CLEAR(state->cls);
198
0
    Py_CLEAR(state->cmpop_type);
199
0
    Py_CLEAR(state->col_offset);
200
0
    Py_CLEAR(state->comparators);
201
0
    Py_CLEAR(state->comprehension_type);
202
0
    Py_CLEAR(state->context_expr);
203
0
    Py_CLEAR(state->conversion);
204
0
    Py_CLEAR(state->ctx);
205
0
    Py_CLEAR(state->decorator_list);
206
0
    Py_CLEAR(state->default_value);
207
0
    Py_CLEAR(state->defaults);
208
0
    Py_CLEAR(state->elt);
209
0
    Py_CLEAR(state->elts);
210
0
    Py_CLEAR(state->end_col_offset);
211
0
    Py_CLEAR(state->end_lineno);
212
0
    Py_CLEAR(state->exc);
213
0
    Py_CLEAR(state->excepthandler_type);
214
0
    Py_CLEAR(state->expr_context_type);
215
0
    Py_CLEAR(state->expr_type);
216
0
    Py_CLEAR(state->finalbody);
217
0
    Py_CLEAR(state->format_spec);
218
0
    Py_CLEAR(state->func);
219
0
    Py_CLEAR(state->generators);
220
0
    Py_CLEAR(state->guard);
221
0
    Py_CLEAR(state->handlers);
222
0
    Py_CLEAR(state->id);
223
0
    Py_CLEAR(state->ifs);
224
0
    Py_CLEAR(state->is_async);
225
0
    Py_CLEAR(state->items);
226
0
    Py_CLEAR(state->iter);
227
0
    Py_CLEAR(state->key);
228
0
    Py_CLEAR(state->keys);
229
0
    Py_CLEAR(state->keyword_type);
230
0
    Py_CLEAR(state->keywords);
231
0
    Py_CLEAR(state->kind);
232
0
    Py_CLEAR(state->kw_defaults);
233
0
    Py_CLEAR(state->kwarg);
234
0
    Py_CLEAR(state->kwd_attrs);
235
0
    Py_CLEAR(state->kwd_patterns);
236
0
    Py_CLEAR(state->kwonlyargs);
237
0
    Py_CLEAR(state->left);
238
0
    Py_CLEAR(state->level);
239
0
    Py_CLEAR(state->lineno);
240
0
    Py_CLEAR(state->lower);
241
0
    Py_CLEAR(state->match_case_type);
242
0
    Py_CLEAR(state->mod_type);
243
0
    Py_CLEAR(state->module);
244
0
    Py_CLEAR(state->msg);
245
0
    Py_CLEAR(state->name);
246
0
    Py_CLEAR(state->names);
247
0
    Py_CLEAR(state->op);
248
0
    Py_CLEAR(state->operand);
249
0
    Py_CLEAR(state->operator_type);
250
0
    Py_CLEAR(state->ops);
251
0
    Py_CLEAR(state->optional_vars);
252
0
    Py_CLEAR(state->orelse);
253
0
    Py_CLEAR(state->pattern);
254
0
    Py_CLEAR(state->pattern_type);
255
0
    Py_CLEAR(state->patterns);
256
0
    Py_CLEAR(state->posonlyargs);
257
0
    Py_CLEAR(state->rest);
258
0
    Py_CLEAR(state->returns);
259
0
    Py_CLEAR(state->right);
260
0
    Py_CLEAR(state->simple);
261
0
    Py_CLEAR(state->slice);
262
0
    Py_CLEAR(state->step);
263
0
    Py_CLEAR(state->stmt_type);
264
0
    Py_CLEAR(state->str);
265
0
    Py_CLEAR(state->subject);
266
0
    Py_CLEAR(state->tag);
267
0
    Py_CLEAR(state->target);
268
0
    Py_CLEAR(state->targets);
269
0
    Py_CLEAR(state->test);
270
0
    Py_CLEAR(state->type);
271
0
    Py_CLEAR(state->type_comment);
272
0
    Py_CLEAR(state->type_ignore_type);
273
0
    Py_CLEAR(state->type_ignores);
274
0
    Py_CLEAR(state->type_param_type);
275
0
    Py_CLEAR(state->type_params);
276
0
    Py_CLEAR(state->unaryop_type);
277
0
    Py_CLEAR(state->upper);
278
0
    Py_CLEAR(state->value);
279
0
    Py_CLEAR(state->values);
280
0
    Py_CLEAR(state->vararg);
281
0
    Py_CLEAR(state->withitem_type);
282
283
0
    state->finalized = 1;
284
0
    state->once = (_PyOnceFlag){0};
285
0
}
286
287
static int init_identifiers(struct ast_state *state)
288
12
{
289
12
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
290
12
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
291
12
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
292
12
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
293
12
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
294
12
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
295
12
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
296
12
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
297
12
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
298
12
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
299
12
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
300
12
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
301
12
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
302
12
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
303
12
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
304
12
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
305
12
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
306
12
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
307
12
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
308
12
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
309
12
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
310
12
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
311
12
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
312
12
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
313
12
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
314
12
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
315
12
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
316
12
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
317
12
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
318
12
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
319
12
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
320
12
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
321
12
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
322
12
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
323
12
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
324
12
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
325
12
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
326
12
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
327
12
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
328
12
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
329
12
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
330
12
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
331
12
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
332
12
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
333
12
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
334
12
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
335
12
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
336
12
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
337
12
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
338
12
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
339
12
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
340
12
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
341
12
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
342
12
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
343
12
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
344
12
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
345
12
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
346
12
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
347
12
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
348
12
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
349
12
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
350
12
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
351
12
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
352
12
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
353
12
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
354
12
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
355
12
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
356
12
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
357
12
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
358
12
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
359
12
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
360
12
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
361
12
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
362
12
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
363
12
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
364
12
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
365
12
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
366
12
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
367
12
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
368
12
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
369
12
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
370
12
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
371
12
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
372
12
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
373
12
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
374
12
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
375
12
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
376
12
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
377
12
    return 0;
378
12
};
379
380
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
381
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
382
94.4k
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
384
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
385
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
386
46.0k
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
387
8.13k
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
388
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
389
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
390
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
391
1.04k
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
392
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
393
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
394
395
static PyObject* ast2obj_mod(struct ast_state *state, void*);
396
static const char * const Module_fields[]={
397
    "body",
398
    "type_ignores",
399
};
400
static const char * const Interactive_fields[]={
401
    "body",
402
};
403
static const char * const Expression_fields[]={
404
    "body",
405
};
406
static const char * const FunctionType_fields[]={
407
    "argtypes",
408
    "returns",
409
};
410
static const char * const stmt_attributes[] = {
411
    "lineno",
412
    "col_offset",
413
    "end_lineno",
414
    "end_col_offset",
415
};
416
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
417
static const char * const FunctionDef_fields[]={
418
    "name",
419
    "args",
420
    "body",
421
    "decorator_list",
422
    "returns",
423
    "type_comment",
424
    "type_params",
425
};
426
static const char * const AsyncFunctionDef_fields[]={
427
    "name",
428
    "args",
429
    "body",
430
    "decorator_list",
431
    "returns",
432
    "type_comment",
433
    "type_params",
434
};
435
static const char * const ClassDef_fields[]={
436
    "name",
437
    "bases",
438
    "keywords",
439
    "body",
440
    "decorator_list",
441
    "type_params",
442
};
443
static const char * const Return_fields[]={
444
    "value",
445
};
446
static const char * const Delete_fields[]={
447
    "targets",
448
};
449
static const char * const Assign_fields[]={
450
    "targets",
451
    "value",
452
    "type_comment",
453
};
454
static const char * const TypeAlias_fields[]={
455
    "name",
456
    "type_params",
457
    "value",
458
};
459
static const char * const AugAssign_fields[]={
460
    "target",
461
    "op",
462
    "value",
463
};
464
static const char * const AnnAssign_fields[]={
465
    "target",
466
    "annotation",
467
    "value",
468
    "simple",
469
};
470
static const char * const For_fields[]={
471
    "target",
472
    "iter",
473
    "body",
474
    "orelse",
475
    "type_comment",
476
};
477
static const char * const AsyncFor_fields[]={
478
    "target",
479
    "iter",
480
    "body",
481
    "orelse",
482
    "type_comment",
483
};
484
static const char * const While_fields[]={
485
    "test",
486
    "body",
487
    "orelse",
488
};
489
static const char * const If_fields[]={
490
    "test",
491
    "body",
492
    "orelse",
493
};
494
static const char * const With_fields[]={
495
    "items",
496
    "body",
497
    "type_comment",
498
};
499
static const char * const AsyncWith_fields[]={
500
    "items",
501
    "body",
502
    "type_comment",
503
};
504
static const char * const Match_fields[]={
505
    "subject",
506
    "cases",
507
};
508
static const char * const Raise_fields[]={
509
    "exc",
510
    "cause",
511
};
512
static const char * const Try_fields[]={
513
    "body",
514
    "handlers",
515
    "orelse",
516
    "finalbody",
517
};
518
static const char * const TryStar_fields[]={
519
    "body",
520
    "handlers",
521
    "orelse",
522
    "finalbody",
523
};
524
static const char * const Assert_fields[]={
525
    "test",
526
    "msg",
527
};
528
static const char * const Import_fields[]={
529
    "names",
530
};
531
static const char * const ImportFrom_fields[]={
532
    "module",
533
    "names",
534
    "level",
535
};
536
static const char * const Global_fields[]={
537
    "names",
538
};
539
static const char * const Nonlocal_fields[]={
540
    "names",
541
};
542
static const char * const Expr_fields[]={
543
    "value",
544
};
545
static const char * const expr_attributes[] = {
546
    "lineno",
547
    "col_offset",
548
    "end_lineno",
549
    "end_col_offset",
550
};
551
static PyObject* ast2obj_expr(struct ast_state *state, void*);
552
static const char * const BoolOp_fields[]={
553
    "op",
554
    "values",
555
};
556
static const char * const NamedExpr_fields[]={
557
    "target",
558
    "value",
559
};
560
static const char * const BinOp_fields[]={
561
    "left",
562
    "op",
563
    "right",
564
};
565
static const char * const UnaryOp_fields[]={
566
    "op",
567
    "operand",
568
};
569
static const char * const Lambda_fields[]={
570
    "args",
571
    "body",
572
};
573
static const char * const IfExp_fields[]={
574
    "test",
575
    "body",
576
    "orelse",
577
};
578
static const char * const Dict_fields[]={
579
    "keys",
580
    "values",
581
};
582
static const char * const Set_fields[]={
583
    "elts",
584
};
585
static const char * const ListComp_fields[]={
586
    "elt",
587
    "generators",
588
};
589
static const char * const SetComp_fields[]={
590
    "elt",
591
    "generators",
592
};
593
static const char * const DictComp_fields[]={
594
    "key",
595
    "value",
596
    "generators",
597
};
598
static const char * const GeneratorExp_fields[]={
599
    "elt",
600
    "generators",
601
};
602
static const char * const Await_fields[]={
603
    "value",
604
};
605
static const char * const Yield_fields[]={
606
    "value",
607
};
608
static const char * const YieldFrom_fields[]={
609
    "value",
610
};
611
static const char * const Compare_fields[]={
612
    "left",
613
    "ops",
614
    "comparators",
615
};
616
static const char * const Call_fields[]={
617
    "func",
618
    "args",
619
    "keywords",
620
};
621
static const char * const FormattedValue_fields[]={
622
    "value",
623
    "conversion",
624
    "format_spec",
625
};
626
static const char * const Interpolation_fields[]={
627
    "value",
628
    "str",
629
    "conversion",
630
    "format_spec",
631
};
632
static const char * const JoinedStr_fields[]={
633
    "values",
634
};
635
static const char * const TemplateStr_fields[]={
636
    "values",
637
};
638
static const char * const Constant_fields[]={
639
    "value",
640
    "kind",
641
};
642
static const char * const Attribute_fields[]={
643
    "value",
644
    "attr",
645
    "ctx",
646
};
647
static const char * const Subscript_fields[]={
648
    "value",
649
    "slice",
650
    "ctx",
651
};
652
static const char * const Starred_fields[]={
653
    "value",
654
    "ctx",
655
};
656
static const char * const Name_fields[]={
657
    "id",
658
    "ctx",
659
};
660
static const char * const List_fields[]={
661
    "elts",
662
    "ctx",
663
};
664
static const char * const Tuple_fields[]={
665
    "elts",
666
    "ctx",
667
};
668
static const char * const Slice_fields[]={
669
    "lower",
670
    "upper",
671
    "step",
672
};
673
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
674
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
675
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
676
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
677
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
678
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
679
static const char * const comprehension_fields[]={
680
    "target",
681
    "iter",
682
    "ifs",
683
    "is_async",
684
};
685
static const char * const excepthandler_attributes[] = {
686
    "lineno",
687
    "col_offset",
688
    "end_lineno",
689
    "end_col_offset",
690
};
691
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
692
static const char * const ExceptHandler_fields[]={
693
    "type",
694
    "name",
695
    "body",
696
};
697
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
698
static const char * const arguments_fields[]={
699
    "posonlyargs",
700
    "args",
701
    "vararg",
702
    "kwonlyargs",
703
    "kw_defaults",
704
    "kwarg",
705
    "defaults",
706
};
707
static PyObject* ast2obj_arg(struct ast_state *state, void*);
708
static const char * const arg_attributes[] = {
709
    "lineno",
710
    "col_offset",
711
    "end_lineno",
712
    "end_col_offset",
713
};
714
static const char * const arg_fields[]={
715
    "arg",
716
    "annotation",
717
    "type_comment",
718
};
719
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
720
static const char * const keyword_attributes[] = {
721
    "lineno",
722
    "col_offset",
723
    "end_lineno",
724
    "end_col_offset",
725
};
726
static const char * const keyword_fields[]={
727
    "arg",
728
    "value",
729
};
730
static PyObject* ast2obj_alias(struct ast_state *state, void*);
731
static const char * const alias_attributes[] = {
732
    "lineno",
733
    "col_offset",
734
    "end_lineno",
735
    "end_col_offset",
736
};
737
static const char * const alias_fields[]={
738
    "name",
739
    "asname",
740
};
741
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
742
static const char * const withitem_fields[]={
743
    "context_expr",
744
    "optional_vars",
745
};
746
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
747
static const char * const match_case_fields[]={
748
    "pattern",
749
    "guard",
750
    "body",
751
};
752
static const char * const pattern_attributes[] = {
753
    "lineno",
754
    "col_offset",
755
    "end_lineno",
756
    "end_col_offset",
757
};
758
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
759
static const char * const MatchValue_fields[]={
760
    "value",
761
};
762
static const char * const MatchSingleton_fields[]={
763
    "value",
764
};
765
static const char * const MatchSequence_fields[]={
766
    "patterns",
767
};
768
static const char * const MatchMapping_fields[]={
769
    "keys",
770
    "patterns",
771
    "rest",
772
};
773
static const char * const MatchClass_fields[]={
774
    "cls",
775
    "patterns",
776
    "kwd_attrs",
777
    "kwd_patterns",
778
};
779
static const char * const MatchStar_fields[]={
780
    "name",
781
};
782
static const char * const MatchAs_fields[]={
783
    "pattern",
784
    "name",
785
};
786
static const char * const MatchOr_fields[]={
787
    "patterns",
788
};
789
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
790
static const char * const TypeIgnore_fields[]={
791
    "lineno",
792
    "tag",
793
};
794
static const char * const type_param_attributes[] = {
795
    "lineno",
796
    "col_offset",
797
    "end_lineno",
798
    "end_col_offset",
799
};
800
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
801
static const char * const TypeVar_fields[]={
802
    "name",
803
    "bound",
804
    "default_value",
805
};
806
static const char * const ParamSpec_fields[]={
807
    "name",
808
    "default_value",
809
};
810
static const char * const TypeVarTuple_fields[]={
811
    "name",
812
    "default_value",
813
};
814
815
816
static int
817
add_ast_annotations(struct ast_state *state)
818
12
{
819
12
    bool cond;
820
12
    PyObject *Module_annotations = PyDict_New();
821
12
    if (!Module_annotations) return 0;
822
12
    {
823
12
        PyObject *type = state->stmt_type;
824
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
825
12
        cond = type != NULL;
826
12
        if (!cond) {
827
0
            Py_DECREF(Module_annotations);
828
0
            return 0;
829
0
        }
830
12
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
831
12
        Py_DECREF(type);
832
12
        if (!cond) {
833
0
            Py_DECREF(Module_annotations);
834
0
            return 0;
835
0
        }
836
12
    }
837
12
    {
838
12
        PyObject *type = state->type_ignore_type;
839
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
840
12
        cond = type != NULL;
841
12
        if (!cond) {
842
0
            Py_DECREF(Module_annotations);
843
0
            return 0;
844
0
        }
845
12
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
846
12
                                    == 0;
847
12
        Py_DECREF(type);
848
12
        if (!cond) {
849
0
            Py_DECREF(Module_annotations);
850
0
            return 0;
851
0
        }
852
12
    }
853
12
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
854
12
                                  Module_annotations) == 0;
855
12
    if (!cond) {
856
0
        Py_DECREF(Module_annotations);
857
0
        return 0;
858
0
    }
859
12
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
860
12
                                  Module_annotations) == 0;
861
12
    if (!cond) {
862
0
        Py_DECREF(Module_annotations);
863
0
        return 0;
864
0
    }
865
12
    Py_DECREF(Module_annotations);
866
12
    PyObject *Interactive_annotations = PyDict_New();
867
12
    if (!Interactive_annotations) return 0;
868
12
    {
869
12
        PyObject *type = state->stmt_type;
870
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
871
12
        cond = type != NULL;
872
12
        if (!cond) {
873
0
            Py_DECREF(Interactive_annotations);
874
0
            return 0;
875
0
        }
876
12
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
877
12
        Py_DECREF(type);
878
12
        if (!cond) {
879
0
            Py_DECREF(Interactive_annotations);
880
0
            return 0;
881
0
        }
882
12
    }
883
12
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
884
12
                                  Interactive_annotations) == 0;
885
12
    if (!cond) {
886
0
        Py_DECREF(Interactive_annotations);
887
0
        return 0;
888
0
    }
889
12
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
890
12
                                  Interactive_annotations) == 0;
891
12
    if (!cond) {
892
0
        Py_DECREF(Interactive_annotations);
893
0
        return 0;
894
0
    }
895
12
    Py_DECREF(Interactive_annotations);
896
12
    PyObject *Expression_annotations = PyDict_New();
897
12
    if (!Expression_annotations) return 0;
898
12
    {
899
12
        PyObject *type = state->expr_type;
900
12
        Py_INCREF(type);
901
12
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
902
12
        Py_DECREF(type);
903
12
        if (!cond) {
904
0
            Py_DECREF(Expression_annotations);
905
0
            return 0;
906
0
        }
907
12
    }
908
12
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
909
12
                                  Expression_annotations) == 0;
910
12
    if (!cond) {
911
0
        Py_DECREF(Expression_annotations);
912
0
        return 0;
913
0
    }
914
12
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
915
12
                                  Expression_annotations) == 0;
916
12
    if (!cond) {
917
0
        Py_DECREF(Expression_annotations);
918
0
        return 0;
919
0
    }
920
12
    Py_DECREF(Expression_annotations);
921
12
    PyObject *FunctionType_annotations = PyDict_New();
922
12
    if (!FunctionType_annotations) return 0;
923
12
    {
924
12
        PyObject *type = state->expr_type;
925
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
926
12
        cond = type != NULL;
927
12
        if (!cond) {
928
0
            Py_DECREF(FunctionType_annotations);
929
0
            return 0;
930
0
        }
931
12
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
932
12
                                    == 0;
933
12
        Py_DECREF(type);
934
12
        if (!cond) {
935
0
            Py_DECREF(FunctionType_annotations);
936
0
            return 0;
937
0
        }
938
12
    }
939
12
    {
940
12
        PyObject *type = state->expr_type;
941
12
        Py_INCREF(type);
942
12
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
943
12
                                    == 0;
944
12
        Py_DECREF(type);
945
12
        if (!cond) {
946
0
            Py_DECREF(FunctionType_annotations);
947
0
            return 0;
948
0
        }
949
12
    }
950
12
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
951
12
                                  FunctionType_annotations) == 0;
952
12
    if (!cond) {
953
0
        Py_DECREF(FunctionType_annotations);
954
0
        return 0;
955
0
    }
956
12
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
957
12
                                  FunctionType_annotations) == 0;
958
12
    if (!cond) {
959
0
        Py_DECREF(FunctionType_annotations);
960
0
        return 0;
961
0
    }
962
12
    Py_DECREF(FunctionType_annotations);
963
12
    PyObject *FunctionDef_annotations = PyDict_New();
964
12
    if (!FunctionDef_annotations) return 0;
965
12
    {
966
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
967
12
        Py_INCREF(type);
968
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
969
12
        Py_DECREF(type);
970
12
        if (!cond) {
971
0
            Py_DECREF(FunctionDef_annotations);
972
0
            return 0;
973
0
        }
974
12
    }
975
12
    {
976
12
        PyObject *type = state->arguments_type;
977
12
        Py_INCREF(type);
978
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
979
12
        Py_DECREF(type);
980
12
        if (!cond) {
981
0
            Py_DECREF(FunctionDef_annotations);
982
0
            return 0;
983
0
        }
984
12
    }
985
12
    {
986
12
        PyObject *type = state->stmt_type;
987
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
988
12
        cond = type != NULL;
989
12
        if (!cond) {
990
0
            Py_DECREF(FunctionDef_annotations);
991
0
            return 0;
992
0
        }
993
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
994
12
        Py_DECREF(type);
995
12
        if (!cond) {
996
0
            Py_DECREF(FunctionDef_annotations);
997
0
            return 0;
998
0
        }
999
12
    }
1000
12
    {
1001
12
        PyObject *type = state->expr_type;
1002
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1003
12
        cond = type != NULL;
1004
12
        if (!cond) {
1005
0
            Py_DECREF(FunctionDef_annotations);
1006
0
            return 0;
1007
0
        }
1008
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1009
12
                                    type) == 0;
1010
12
        Py_DECREF(type);
1011
12
        if (!cond) {
1012
0
            Py_DECREF(FunctionDef_annotations);
1013
0
            return 0;
1014
0
        }
1015
12
    }
1016
12
    {
1017
12
        PyObject *type = state->expr_type;
1018
12
        type = _Py_union_type_or(type, Py_None);
1019
12
        cond = type != NULL;
1020
12
        if (!cond) {
1021
0
            Py_DECREF(FunctionDef_annotations);
1022
0
            return 0;
1023
0
        }
1024
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1025
12
                                    == 0;
1026
12
        Py_DECREF(type);
1027
12
        if (!cond) {
1028
0
            Py_DECREF(FunctionDef_annotations);
1029
0
            return 0;
1030
0
        }
1031
12
    }
1032
12
    {
1033
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1034
12
        type = _Py_union_type_or(type, Py_None);
1035
12
        cond = type != NULL;
1036
12
        if (!cond) {
1037
0
            Py_DECREF(FunctionDef_annotations);
1038
0
            return 0;
1039
0
        }
1040
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1041
12
                                    type) == 0;
1042
12
        Py_DECREF(type);
1043
12
        if (!cond) {
1044
0
            Py_DECREF(FunctionDef_annotations);
1045
0
            return 0;
1046
0
        }
1047
12
    }
1048
12
    {
1049
12
        PyObject *type = state->type_param_type;
1050
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1051
12
        cond = type != NULL;
1052
12
        if (!cond) {
1053
0
            Py_DECREF(FunctionDef_annotations);
1054
0
            return 0;
1055
0
        }
1056
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1057
12
                                    type) == 0;
1058
12
        Py_DECREF(type);
1059
12
        if (!cond) {
1060
0
            Py_DECREF(FunctionDef_annotations);
1061
0
            return 0;
1062
0
        }
1063
12
    }
1064
12
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1065
12
                                  FunctionDef_annotations) == 0;
1066
12
    if (!cond) {
1067
0
        Py_DECREF(FunctionDef_annotations);
1068
0
        return 0;
1069
0
    }
1070
12
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1071
12
                                  FunctionDef_annotations) == 0;
1072
12
    if (!cond) {
1073
0
        Py_DECREF(FunctionDef_annotations);
1074
0
        return 0;
1075
0
    }
1076
12
    Py_DECREF(FunctionDef_annotations);
1077
12
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1078
12
    if (!AsyncFunctionDef_annotations) return 0;
1079
12
    {
1080
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1081
12
        Py_INCREF(type);
1082
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1083
12
                                    == 0;
1084
12
        Py_DECREF(type);
1085
12
        if (!cond) {
1086
0
            Py_DECREF(AsyncFunctionDef_annotations);
1087
0
            return 0;
1088
0
        }
1089
12
    }
1090
12
    {
1091
12
        PyObject *type = state->arguments_type;
1092
12
        Py_INCREF(type);
1093
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1094
12
                                    == 0;
1095
12
        Py_DECREF(type);
1096
12
        if (!cond) {
1097
0
            Py_DECREF(AsyncFunctionDef_annotations);
1098
0
            return 0;
1099
0
        }
1100
12
    }
1101
12
    {
1102
12
        PyObject *type = state->stmt_type;
1103
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1104
12
        cond = type != NULL;
1105
12
        if (!cond) {
1106
0
            Py_DECREF(AsyncFunctionDef_annotations);
1107
0
            return 0;
1108
0
        }
1109
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1110
12
                                    == 0;
1111
12
        Py_DECREF(type);
1112
12
        if (!cond) {
1113
0
            Py_DECREF(AsyncFunctionDef_annotations);
1114
0
            return 0;
1115
0
        }
1116
12
    }
1117
12
    {
1118
12
        PyObject *type = state->expr_type;
1119
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1120
12
        cond = type != NULL;
1121
12
        if (!cond) {
1122
0
            Py_DECREF(AsyncFunctionDef_annotations);
1123
0
            return 0;
1124
0
        }
1125
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1126
12
                                    "decorator_list", type) == 0;
1127
12
        Py_DECREF(type);
1128
12
        if (!cond) {
1129
0
            Py_DECREF(AsyncFunctionDef_annotations);
1130
0
            return 0;
1131
0
        }
1132
12
    }
1133
12
    {
1134
12
        PyObject *type = state->expr_type;
1135
12
        type = _Py_union_type_or(type, Py_None);
1136
12
        cond = type != NULL;
1137
12
        if (!cond) {
1138
0
            Py_DECREF(AsyncFunctionDef_annotations);
1139
0
            return 0;
1140
0
        }
1141
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1142
12
                                    type) == 0;
1143
12
        Py_DECREF(type);
1144
12
        if (!cond) {
1145
0
            Py_DECREF(AsyncFunctionDef_annotations);
1146
0
            return 0;
1147
0
        }
1148
12
    }
1149
12
    {
1150
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1151
12
        type = _Py_union_type_or(type, Py_None);
1152
12
        cond = type != NULL;
1153
12
        if (!cond) {
1154
0
            Py_DECREF(AsyncFunctionDef_annotations);
1155
0
            return 0;
1156
0
        }
1157
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1158
12
                                    "type_comment", type) == 0;
1159
12
        Py_DECREF(type);
1160
12
        if (!cond) {
1161
0
            Py_DECREF(AsyncFunctionDef_annotations);
1162
0
            return 0;
1163
0
        }
1164
12
    }
1165
12
    {
1166
12
        PyObject *type = state->type_param_type;
1167
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1168
12
        cond = type != NULL;
1169
12
        if (!cond) {
1170
0
            Py_DECREF(AsyncFunctionDef_annotations);
1171
0
            return 0;
1172
0
        }
1173
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1174
12
                                    "type_params", type) == 0;
1175
12
        Py_DECREF(type);
1176
12
        if (!cond) {
1177
0
            Py_DECREF(AsyncFunctionDef_annotations);
1178
0
            return 0;
1179
0
        }
1180
12
    }
1181
12
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1182
12
                                  AsyncFunctionDef_annotations) == 0;
1183
12
    if (!cond) {
1184
0
        Py_DECREF(AsyncFunctionDef_annotations);
1185
0
        return 0;
1186
0
    }
1187
12
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1188
12
                                  "__annotations__",
1189
12
                                  AsyncFunctionDef_annotations) == 0;
1190
12
    if (!cond) {
1191
0
        Py_DECREF(AsyncFunctionDef_annotations);
1192
0
        return 0;
1193
0
    }
1194
12
    Py_DECREF(AsyncFunctionDef_annotations);
1195
12
    PyObject *ClassDef_annotations = PyDict_New();
1196
12
    if (!ClassDef_annotations) return 0;
1197
12
    {
1198
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1199
12
        Py_INCREF(type);
1200
12
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1201
12
        Py_DECREF(type);
1202
12
        if (!cond) {
1203
0
            Py_DECREF(ClassDef_annotations);
1204
0
            return 0;
1205
0
        }
1206
12
    }
1207
12
    {
1208
12
        PyObject *type = state->expr_type;
1209
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1210
12
        cond = type != NULL;
1211
12
        if (!cond) {
1212
0
            Py_DECREF(ClassDef_annotations);
1213
0
            return 0;
1214
0
        }
1215
12
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1216
12
        Py_DECREF(type);
1217
12
        if (!cond) {
1218
0
            Py_DECREF(ClassDef_annotations);
1219
0
            return 0;
1220
0
        }
1221
12
    }
1222
12
    {
1223
12
        PyObject *type = state->keyword_type;
1224
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1225
12
        cond = type != NULL;
1226
12
        if (!cond) {
1227
0
            Py_DECREF(ClassDef_annotations);
1228
0
            return 0;
1229
0
        }
1230
12
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1231
12
                                    0;
1232
12
        Py_DECREF(type);
1233
12
        if (!cond) {
1234
0
            Py_DECREF(ClassDef_annotations);
1235
0
            return 0;
1236
0
        }
1237
12
    }
1238
12
    {
1239
12
        PyObject *type = state->stmt_type;
1240
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1241
12
        cond = type != NULL;
1242
12
        if (!cond) {
1243
0
            Py_DECREF(ClassDef_annotations);
1244
0
            return 0;
1245
0
        }
1246
12
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1247
12
        Py_DECREF(type);
1248
12
        if (!cond) {
1249
0
            Py_DECREF(ClassDef_annotations);
1250
0
            return 0;
1251
0
        }
1252
12
    }
1253
12
    {
1254
12
        PyObject *type = state->expr_type;
1255
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1256
12
        cond = type != NULL;
1257
12
        if (!cond) {
1258
0
            Py_DECREF(ClassDef_annotations);
1259
0
            return 0;
1260
0
        }
1261
12
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1262
12
                                    type) == 0;
1263
12
        Py_DECREF(type);
1264
12
        if (!cond) {
1265
0
            Py_DECREF(ClassDef_annotations);
1266
0
            return 0;
1267
0
        }
1268
12
    }
1269
12
    {
1270
12
        PyObject *type = state->type_param_type;
1271
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1272
12
        cond = type != NULL;
1273
12
        if (!cond) {
1274
0
            Py_DECREF(ClassDef_annotations);
1275
0
            return 0;
1276
0
        }
1277
12
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1278
12
                                    == 0;
1279
12
        Py_DECREF(type);
1280
12
        if (!cond) {
1281
0
            Py_DECREF(ClassDef_annotations);
1282
0
            return 0;
1283
0
        }
1284
12
    }
1285
12
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1286
12
                                  ClassDef_annotations) == 0;
1287
12
    if (!cond) {
1288
0
        Py_DECREF(ClassDef_annotations);
1289
0
        return 0;
1290
0
    }
1291
12
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1292
12
                                  ClassDef_annotations) == 0;
1293
12
    if (!cond) {
1294
0
        Py_DECREF(ClassDef_annotations);
1295
0
        return 0;
1296
0
    }
1297
12
    Py_DECREF(ClassDef_annotations);
1298
12
    PyObject *Return_annotations = PyDict_New();
1299
12
    if (!Return_annotations) return 0;
1300
12
    {
1301
12
        PyObject *type = state->expr_type;
1302
12
        type = _Py_union_type_or(type, Py_None);
1303
12
        cond = type != NULL;
1304
12
        if (!cond) {
1305
0
            Py_DECREF(Return_annotations);
1306
0
            return 0;
1307
0
        }
1308
12
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1309
12
        Py_DECREF(type);
1310
12
        if (!cond) {
1311
0
            Py_DECREF(Return_annotations);
1312
0
            return 0;
1313
0
        }
1314
12
    }
1315
12
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1316
12
                                  Return_annotations) == 0;
1317
12
    if (!cond) {
1318
0
        Py_DECREF(Return_annotations);
1319
0
        return 0;
1320
0
    }
1321
12
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1322
12
                                  Return_annotations) == 0;
1323
12
    if (!cond) {
1324
0
        Py_DECREF(Return_annotations);
1325
0
        return 0;
1326
0
    }
1327
12
    Py_DECREF(Return_annotations);
1328
12
    PyObject *Delete_annotations = PyDict_New();
1329
12
    if (!Delete_annotations) return 0;
1330
12
    {
1331
12
        PyObject *type = state->expr_type;
1332
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1333
12
        cond = type != NULL;
1334
12
        if (!cond) {
1335
0
            Py_DECREF(Delete_annotations);
1336
0
            return 0;
1337
0
        }
1338
12
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1339
12
        Py_DECREF(type);
1340
12
        if (!cond) {
1341
0
            Py_DECREF(Delete_annotations);
1342
0
            return 0;
1343
0
        }
1344
12
    }
1345
12
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1346
12
                                  Delete_annotations) == 0;
1347
12
    if (!cond) {
1348
0
        Py_DECREF(Delete_annotations);
1349
0
        return 0;
1350
0
    }
1351
12
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1352
12
                                  Delete_annotations) == 0;
1353
12
    if (!cond) {
1354
0
        Py_DECREF(Delete_annotations);
1355
0
        return 0;
1356
0
    }
1357
12
    Py_DECREF(Delete_annotations);
1358
12
    PyObject *Assign_annotations = PyDict_New();
1359
12
    if (!Assign_annotations) return 0;
1360
12
    {
1361
12
        PyObject *type = state->expr_type;
1362
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1363
12
        cond = type != NULL;
1364
12
        if (!cond) {
1365
0
            Py_DECREF(Assign_annotations);
1366
0
            return 0;
1367
0
        }
1368
12
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1369
12
        Py_DECREF(type);
1370
12
        if (!cond) {
1371
0
            Py_DECREF(Assign_annotations);
1372
0
            return 0;
1373
0
        }
1374
12
    }
1375
12
    {
1376
12
        PyObject *type = state->expr_type;
1377
12
        Py_INCREF(type);
1378
12
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1379
12
        Py_DECREF(type);
1380
12
        if (!cond) {
1381
0
            Py_DECREF(Assign_annotations);
1382
0
            return 0;
1383
0
        }
1384
12
    }
1385
12
    {
1386
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1387
12
        type = _Py_union_type_or(type, Py_None);
1388
12
        cond = type != NULL;
1389
12
        if (!cond) {
1390
0
            Py_DECREF(Assign_annotations);
1391
0
            return 0;
1392
0
        }
1393
12
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1394
12
                                    == 0;
1395
12
        Py_DECREF(type);
1396
12
        if (!cond) {
1397
0
            Py_DECREF(Assign_annotations);
1398
0
            return 0;
1399
0
        }
1400
12
    }
1401
12
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1402
12
                                  Assign_annotations) == 0;
1403
12
    if (!cond) {
1404
0
        Py_DECREF(Assign_annotations);
1405
0
        return 0;
1406
0
    }
1407
12
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1408
12
                                  Assign_annotations) == 0;
1409
12
    if (!cond) {
1410
0
        Py_DECREF(Assign_annotations);
1411
0
        return 0;
1412
0
    }
1413
12
    Py_DECREF(Assign_annotations);
1414
12
    PyObject *TypeAlias_annotations = PyDict_New();
1415
12
    if (!TypeAlias_annotations) return 0;
1416
12
    {
1417
12
        PyObject *type = state->expr_type;
1418
12
        Py_INCREF(type);
1419
12
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1420
12
        Py_DECREF(type);
1421
12
        if (!cond) {
1422
0
            Py_DECREF(TypeAlias_annotations);
1423
0
            return 0;
1424
0
        }
1425
12
    }
1426
12
    {
1427
12
        PyObject *type = state->type_param_type;
1428
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1429
12
        cond = type != NULL;
1430
12
        if (!cond) {
1431
0
            Py_DECREF(TypeAlias_annotations);
1432
0
            return 0;
1433
0
        }
1434
12
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1435
12
                                    == 0;
1436
12
        Py_DECREF(type);
1437
12
        if (!cond) {
1438
0
            Py_DECREF(TypeAlias_annotations);
1439
0
            return 0;
1440
0
        }
1441
12
    }
1442
12
    {
1443
12
        PyObject *type = state->expr_type;
1444
12
        Py_INCREF(type);
1445
12
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1446
12
        Py_DECREF(type);
1447
12
        if (!cond) {
1448
0
            Py_DECREF(TypeAlias_annotations);
1449
0
            return 0;
1450
0
        }
1451
12
    }
1452
12
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1453
12
                                  TypeAlias_annotations) == 0;
1454
12
    if (!cond) {
1455
0
        Py_DECREF(TypeAlias_annotations);
1456
0
        return 0;
1457
0
    }
1458
12
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1459
12
                                  TypeAlias_annotations) == 0;
1460
12
    if (!cond) {
1461
0
        Py_DECREF(TypeAlias_annotations);
1462
0
        return 0;
1463
0
    }
1464
12
    Py_DECREF(TypeAlias_annotations);
1465
12
    PyObject *AugAssign_annotations = PyDict_New();
1466
12
    if (!AugAssign_annotations) return 0;
1467
12
    {
1468
12
        PyObject *type = state->expr_type;
1469
12
        Py_INCREF(type);
1470
12
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1471
12
        Py_DECREF(type);
1472
12
        if (!cond) {
1473
0
            Py_DECREF(AugAssign_annotations);
1474
0
            return 0;
1475
0
        }
1476
12
    }
1477
12
    {
1478
12
        PyObject *type = state->operator_type;
1479
12
        Py_INCREF(type);
1480
12
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1481
12
        Py_DECREF(type);
1482
12
        if (!cond) {
1483
0
            Py_DECREF(AugAssign_annotations);
1484
0
            return 0;
1485
0
        }
1486
12
    }
1487
12
    {
1488
12
        PyObject *type = state->expr_type;
1489
12
        Py_INCREF(type);
1490
12
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1491
12
        Py_DECREF(type);
1492
12
        if (!cond) {
1493
0
            Py_DECREF(AugAssign_annotations);
1494
0
            return 0;
1495
0
        }
1496
12
    }
1497
12
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1498
12
                                  AugAssign_annotations) == 0;
1499
12
    if (!cond) {
1500
0
        Py_DECREF(AugAssign_annotations);
1501
0
        return 0;
1502
0
    }
1503
12
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1504
12
                                  AugAssign_annotations) == 0;
1505
12
    if (!cond) {
1506
0
        Py_DECREF(AugAssign_annotations);
1507
0
        return 0;
1508
0
    }
1509
12
    Py_DECREF(AugAssign_annotations);
1510
12
    PyObject *AnnAssign_annotations = PyDict_New();
1511
12
    if (!AnnAssign_annotations) return 0;
1512
12
    {
1513
12
        PyObject *type = state->expr_type;
1514
12
        Py_INCREF(type);
1515
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1516
12
        Py_DECREF(type);
1517
12
        if (!cond) {
1518
0
            Py_DECREF(AnnAssign_annotations);
1519
0
            return 0;
1520
0
        }
1521
12
    }
1522
12
    {
1523
12
        PyObject *type = state->expr_type;
1524
12
        Py_INCREF(type);
1525
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1526
12
                                    == 0;
1527
12
        Py_DECREF(type);
1528
12
        if (!cond) {
1529
0
            Py_DECREF(AnnAssign_annotations);
1530
0
            return 0;
1531
0
        }
1532
12
    }
1533
12
    {
1534
12
        PyObject *type = state->expr_type;
1535
12
        type = _Py_union_type_or(type, Py_None);
1536
12
        cond = type != NULL;
1537
12
        if (!cond) {
1538
0
            Py_DECREF(AnnAssign_annotations);
1539
0
            return 0;
1540
0
        }
1541
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1542
12
        Py_DECREF(type);
1543
12
        if (!cond) {
1544
0
            Py_DECREF(AnnAssign_annotations);
1545
0
            return 0;
1546
0
        }
1547
12
    }
1548
12
    {
1549
12
        PyObject *type = (PyObject *)&PyLong_Type;
1550
12
        Py_INCREF(type);
1551
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1552
12
        Py_DECREF(type);
1553
12
        if (!cond) {
1554
0
            Py_DECREF(AnnAssign_annotations);
1555
0
            return 0;
1556
0
        }
1557
12
    }
1558
12
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1559
12
                                  AnnAssign_annotations) == 0;
1560
12
    if (!cond) {
1561
0
        Py_DECREF(AnnAssign_annotations);
1562
0
        return 0;
1563
0
    }
1564
12
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1565
12
                                  AnnAssign_annotations) == 0;
1566
12
    if (!cond) {
1567
0
        Py_DECREF(AnnAssign_annotations);
1568
0
        return 0;
1569
0
    }
1570
12
    Py_DECREF(AnnAssign_annotations);
1571
12
    PyObject *For_annotations = PyDict_New();
1572
12
    if (!For_annotations) return 0;
1573
12
    {
1574
12
        PyObject *type = state->expr_type;
1575
12
        Py_INCREF(type);
1576
12
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1577
12
        Py_DECREF(type);
1578
12
        if (!cond) {
1579
0
            Py_DECREF(For_annotations);
1580
0
            return 0;
1581
0
        }
1582
12
    }
1583
12
    {
1584
12
        PyObject *type = state->expr_type;
1585
12
        Py_INCREF(type);
1586
12
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1587
12
        Py_DECREF(type);
1588
12
        if (!cond) {
1589
0
            Py_DECREF(For_annotations);
1590
0
            return 0;
1591
0
        }
1592
12
    }
1593
12
    {
1594
12
        PyObject *type = state->stmt_type;
1595
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1596
12
        cond = type != NULL;
1597
12
        if (!cond) {
1598
0
            Py_DECREF(For_annotations);
1599
0
            return 0;
1600
0
        }
1601
12
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1602
12
        Py_DECREF(type);
1603
12
        if (!cond) {
1604
0
            Py_DECREF(For_annotations);
1605
0
            return 0;
1606
0
        }
1607
12
    }
1608
12
    {
1609
12
        PyObject *type = state->stmt_type;
1610
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1611
12
        cond = type != NULL;
1612
12
        if (!cond) {
1613
0
            Py_DECREF(For_annotations);
1614
0
            return 0;
1615
0
        }
1616
12
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1617
12
        Py_DECREF(type);
1618
12
        if (!cond) {
1619
0
            Py_DECREF(For_annotations);
1620
0
            return 0;
1621
0
        }
1622
12
    }
1623
12
    {
1624
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1625
12
        type = _Py_union_type_or(type, Py_None);
1626
12
        cond = type != NULL;
1627
12
        if (!cond) {
1628
0
            Py_DECREF(For_annotations);
1629
0
            return 0;
1630
0
        }
1631
12
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1632
12
        Py_DECREF(type);
1633
12
        if (!cond) {
1634
0
            Py_DECREF(For_annotations);
1635
0
            return 0;
1636
0
        }
1637
12
    }
1638
12
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1639
12
                                  For_annotations) == 0;
1640
12
    if (!cond) {
1641
0
        Py_DECREF(For_annotations);
1642
0
        return 0;
1643
0
    }
1644
12
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1645
12
                                  For_annotations) == 0;
1646
12
    if (!cond) {
1647
0
        Py_DECREF(For_annotations);
1648
0
        return 0;
1649
0
    }
1650
12
    Py_DECREF(For_annotations);
1651
12
    PyObject *AsyncFor_annotations = PyDict_New();
1652
12
    if (!AsyncFor_annotations) return 0;
1653
12
    {
1654
12
        PyObject *type = state->expr_type;
1655
12
        Py_INCREF(type);
1656
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1657
12
        Py_DECREF(type);
1658
12
        if (!cond) {
1659
0
            Py_DECREF(AsyncFor_annotations);
1660
0
            return 0;
1661
0
        }
1662
12
    }
1663
12
    {
1664
12
        PyObject *type = state->expr_type;
1665
12
        Py_INCREF(type);
1666
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1667
12
        Py_DECREF(type);
1668
12
        if (!cond) {
1669
0
            Py_DECREF(AsyncFor_annotations);
1670
0
            return 0;
1671
0
        }
1672
12
    }
1673
12
    {
1674
12
        PyObject *type = state->stmt_type;
1675
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1676
12
        cond = type != NULL;
1677
12
        if (!cond) {
1678
0
            Py_DECREF(AsyncFor_annotations);
1679
0
            return 0;
1680
0
        }
1681
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1682
12
        Py_DECREF(type);
1683
12
        if (!cond) {
1684
0
            Py_DECREF(AsyncFor_annotations);
1685
0
            return 0;
1686
0
        }
1687
12
    }
1688
12
    {
1689
12
        PyObject *type = state->stmt_type;
1690
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1691
12
        cond = type != NULL;
1692
12
        if (!cond) {
1693
0
            Py_DECREF(AsyncFor_annotations);
1694
0
            return 0;
1695
0
        }
1696
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1697
12
        Py_DECREF(type);
1698
12
        if (!cond) {
1699
0
            Py_DECREF(AsyncFor_annotations);
1700
0
            return 0;
1701
0
        }
1702
12
    }
1703
12
    {
1704
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1705
12
        type = _Py_union_type_or(type, Py_None);
1706
12
        cond = type != NULL;
1707
12
        if (!cond) {
1708
0
            Py_DECREF(AsyncFor_annotations);
1709
0
            return 0;
1710
0
        }
1711
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1712
12
                                    == 0;
1713
12
        Py_DECREF(type);
1714
12
        if (!cond) {
1715
0
            Py_DECREF(AsyncFor_annotations);
1716
0
            return 0;
1717
0
        }
1718
12
    }
1719
12
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1720
12
                                  AsyncFor_annotations) == 0;
1721
12
    if (!cond) {
1722
0
        Py_DECREF(AsyncFor_annotations);
1723
0
        return 0;
1724
0
    }
1725
12
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1726
12
                                  AsyncFor_annotations) == 0;
1727
12
    if (!cond) {
1728
0
        Py_DECREF(AsyncFor_annotations);
1729
0
        return 0;
1730
0
    }
1731
12
    Py_DECREF(AsyncFor_annotations);
1732
12
    PyObject *While_annotations = PyDict_New();
1733
12
    if (!While_annotations) return 0;
1734
12
    {
1735
12
        PyObject *type = state->expr_type;
1736
12
        Py_INCREF(type);
1737
12
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1738
12
        Py_DECREF(type);
1739
12
        if (!cond) {
1740
0
            Py_DECREF(While_annotations);
1741
0
            return 0;
1742
0
        }
1743
12
    }
1744
12
    {
1745
12
        PyObject *type = state->stmt_type;
1746
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1747
12
        cond = type != NULL;
1748
12
        if (!cond) {
1749
0
            Py_DECREF(While_annotations);
1750
0
            return 0;
1751
0
        }
1752
12
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1753
12
        Py_DECREF(type);
1754
12
        if (!cond) {
1755
0
            Py_DECREF(While_annotations);
1756
0
            return 0;
1757
0
        }
1758
12
    }
1759
12
    {
1760
12
        PyObject *type = state->stmt_type;
1761
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1762
12
        cond = type != NULL;
1763
12
        if (!cond) {
1764
0
            Py_DECREF(While_annotations);
1765
0
            return 0;
1766
0
        }
1767
12
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1768
12
        Py_DECREF(type);
1769
12
        if (!cond) {
1770
0
            Py_DECREF(While_annotations);
1771
0
            return 0;
1772
0
        }
1773
12
    }
1774
12
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1775
12
                                  While_annotations) == 0;
1776
12
    if (!cond) {
1777
0
        Py_DECREF(While_annotations);
1778
0
        return 0;
1779
0
    }
1780
12
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1781
12
                                  While_annotations) == 0;
1782
12
    if (!cond) {
1783
0
        Py_DECREF(While_annotations);
1784
0
        return 0;
1785
0
    }
1786
12
    Py_DECREF(While_annotations);
1787
12
    PyObject *If_annotations = PyDict_New();
1788
12
    if (!If_annotations) return 0;
1789
12
    {
1790
12
        PyObject *type = state->expr_type;
1791
12
        Py_INCREF(type);
1792
12
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1793
12
        Py_DECREF(type);
1794
12
        if (!cond) {
1795
0
            Py_DECREF(If_annotations);
1796
0
            return 0;
1797
0
        }
1798
12
    }
1799
12
    {
1800
12
        PyObject *type = state->stmt_type;
1801
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1802
12
        cond = type != NULL;
1803
12
        if (!cond) {
1804
0
            Py_DECREF(If_annotations);
1805
0
            return 0;
1806
0
        }
1807
12
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1808
12
        Py_DECREF(type);
1809
12
        if (!cond) {
1810
0
            Py_DECREF(If_annotations);
1811
0
            return 0;
1812
0
        }
1813
12
    }
1814
12
    {
1815
12
        PyObject *type = state->stmt_type;
1816
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1817
12
        cond = type != NULL;
1818
12
        if (!cond) {
1819
0
            Py_DECREF(If_annotations);
1820
0
            return 0;
1821
0
        }
1822
12
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1823
12
        Py_DECREF(type);
1824
12
        if (!cond) {
1825
0
            Py_DECREF(If_annotations);
1826
0
            return 0;
1827
0
        }
1828
12
    }
1829
12
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1830
12
                                  If_annotations) == 0;
1831
12
    if (!cond) {
1832
0
        Py_DECREF(If_annotations);
1833
0
        return 0;
1834
0
    }
1835
12
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1836
12
                                  If_annotations) == 0;
1837
12
    if (!cond) {
1838
0
        Py_DECREF(If_annotations);
1839
0
        return 0;
1840
0
    }
1841
12
    Py_DECREF(If_annotations);
1842
12
    PyObject *With_annotations = PyDict_New();
1843
12
    if (!With_annotations) return 0;
1844
12
    {
1845
12
        PyObject *type = state->withitem_type;
1846
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1847
12
        cond = type != NULL;
1848
12
        if (!cond) {
1849
0
            Py_DECREF(With_annotations);
1850
0
            return 0;
1851
0
        }
1852
12
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1853
12
        Py_DECREF(type);
1854
12
        if (!cond) {
1855
0
            Py_DECREF(With_annotations);
1856
0
            return 0;
1857
0
        }
1858
12
    }
1859
12
    {
1860
12
        PyObject *type = state->stmt_type;
1861
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1862
12
        cond = type != NULL;
1863
12
        if (!cond) {
1864
0
            Py_DECREF(With_annotations);
1865
0
            return 0;
1866
0
        }
1867
12
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1868
12
        Py_DECREF(type);
1869
12
        if (!cond) {
1870
0
            Py_DECREF(With_annotations);
1871
0
            return 0;
1872
0
        }
1873
12
    }
1874
12
    {
1875
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1876
12
        type = _Py_union_type_or(type, Py_None);
1877
12
        cond = type != NULL;
1878
12
        if (!cond) {
1879
0
            Py_DECREF(With_annotations);
1880
0
            return 0;
1881
0
        }
1882
12
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1883
12
                                    0;
1884
12
        Py_DECREF(type);
1885
12
        if (!cond) {
1886
0
            Py_DECREF(With_annotations);
1887
0
            return 0;
1888
0
        }
1889
12
    }
1890
12
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1891
12
                                  With_annotations) == 0;
1892
12
    if (!cond) {
1893
0
        Py_DECREF(With_annotations);
1894
0
        return 0;
1895
0
    }
1896
12
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1897
12
                                  With_annotations) == 0;
1898
12
    if (!cond) {
1899
0
        Py_DECREF(With_annotations);
1900
0
        return 0;
1901
0
    }
1902
12
    Py_DECREF(With_annotations);
1903
12
    PyObject *AsyncWith_annotations = PyDict_New();
1904
12
    if (!AsyncWith_annotations) return 0;
1905
12
    {
1906
12
        PyObject *type = state->withitem_type;
1907
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1908
12
        cond = type != NULL;
1909
12
        if (!cond) {
1910
0
            Py_DECREF(AsyncWith_annotations);
1911
0
            return 0;
1912
0
        }
1913
12
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1914
12
        Py_DECREF(type);
1915
12
        if (!cond) {
1916
0
            Py_DECREF(AsyncWith_annotations);
1917
0
            return 0;
1918
0
        }
1919
12
    }
1920
12
    {
1921
12
        PyObject *type = state->stmt_type;
1922
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1923
12
        cond = type != NULL;
1924
12
        if (!cond) {
1925
0
            Py_DECREF(AsyncWith_annotations);
1926
0
            return 0;
1927
0
        }
1928
12
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1929
12
        Py_DECREF(type);
1930
12
        if (!cond) {
1931
0
            Py_DECREF(AsyncWith_annotations);
1932
0
            return 0;
1933
0
        }
1934
12
    }
1935
12
    {
1936
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1937
12
        type = _Py_union_type_or(type, Py_None);
1938
12
        cond = type != NULL;
1939
12
        if (!cond) {
1940
0
            Py_DECREF(AsyncWith_annotations);
1941
0
            return 0;
1942
0
        }
1943
12
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1944
12
                                    type) == 0;
1945
12
        Py_DECREF(type);
1946
12
        if (!cond) {
1947
0
            Py_DECREF(AsyncWith_annotations);
1948
0
            return 0;
1949
0
        }
1950
12
    }
1951
12
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1952
12
                                  AsyncWith_annotations) == 0;
1953
12
    if (!cond) {
1954
0
        Py_DECREF(AsyncWith_annotations);
1955
0
        return 0;
1956
0
    }
1957
12
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1958
12
                                  AsyncWith_annotations) == 0;
1959
12
    if (!cond) {
1960
0
        Py_DECREF(AsyncWith_annotations);
1961
0
        return 0;
1962
0
    }
1963
12
    Py_DECREF(AsyncWith_annotations);
1964
12
    PyObject *Match_annotations = PyDict_New();
1965
12
    if (!Match_annotations) return 0;
1966
12
    {
1967
12
        PyObject *type = state->expr_type;
1968
12
        Py_INCREF(type);
1969
12
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1970
12
        Py_DECREF(type);
1971
12
        if (!cond) {
1972
0
            Py_DECREF(Match_annotations);
1973
0
            return 0;
1974
0
        }
1975
12
    }
1976
12
    {
1977
12
        PyObject *type = state->match_case_type;
1978
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1979
12
        cond = type != NULL;
1980
12
        if (!cond) {
1981
0
            Py_DECREF(Match_annotations);
1982
0
            return 0;
1983
0
        }
1984
12
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1985
12
        Py_DECREF(type);
1986
12
        if (!cond) {
1987
0
            Py_DECREF(Match_annotations);
1988
0
            return 0;
1989
0
        }
1990
12
    }
1991
12
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1992
12
                                  Match_annotations) == 0;
1993
12
    if (!cond) {
1994
0
        Py_DECREF(Match_annotations);
1995
0
        return 0;
1996
0
    }
1997
12
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
1998
12
                                  Match_annotations) == 0;
1999
12
    if (!cond) {
2000
0
        Py_DECREF(Match_annotations);
2001
0
        return 0;
2002
0
    }
2003
12
    Py_DECREF(Match_annotations);
2004
12
    PyObject *Raise_annotations = PyDict_New();
2005
12
    if (!Raise_annotations) return 0;
2006
12
    {
2007
12
        PyObject *type = state->expr_type;
2008
12
        type = _Py_union_type_or(type, Py_None);
2009
12
        cond = type != NULL;
2010
12
        if (!cond) {
2011
0
            Py_DECREF(Raise_annotations);
2012
0
            return 0;
2013
0
        }
2014
12
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2015
12
        Py_DECREF(type);
2016
12
        if (!cond) {
2017
0
            Py_DECREF(Raise_annotations);
2018
0
            return 0;
2019
0
        }
2020
12
    }
2021
12
    {
2022
12
        PyObject *type = state->expr_type;
2023
12
        type = _Py_union_type_or(type, Py_None);
2024
12
        cond = type != NULL;
2025
12
        if (!cond) {
2026
0
            Py_DECREF(Raise_annotations);
2027
0
            return 0;
2028
0
        }
2029
12
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2030
12
        Py_DECREF(type);
2031
12
        if (!cond) {
2032
0
            Py_DECREF(Raise_annotations);
2033
0
            return 0;
2034
0
        }
2035
12
    }
2036
12
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2037
12
                                  Raise_annotations) == 0;
2038
12
    if (!cond) {
2039
0
        Py_DECREF(Raise_annotations);
2040
0
        return 0;
2041
0
    }
2042
12
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2043
12
                                  Raise_annotations) == 0;
2044
12
    if (!cond) {
2045
0
        Py_DECREF(Raise_annotations);
2046
0
        return 0;
2047
0
    }
2048
12
    Py_DECREF(Raise_annotations);
2049
12
    PyObject *Try_annotations = PyDict_New();
2050
12
    if (!Try_annotations) return 0;
2051
12
    {
2052
12
        PyObject *type = state->stmt_type;
2053
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2054
12
        cond = type != NULL;
2055
12
        if (!cond) {
2056
0
            Py_DECREF(Try_annotations);
2057
0
            return 0;
2058
0
        }
2059
12
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2060
12
        Py_DECREF(type);
2061
12
        if (!cond) {
2062
0
            Py_DECREF(Try_annotations);
2063
0
            return 0;
2064
0
        }
2065
12
    }
2066
12
    {
2067
12
        PyObject *type = state->excepthandler_type;
2068
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2069
12
        cond = type != NULL;
2070
12
        if (!cond) {
2071
0
            Py_DECREF(Try_annotations);
2072
0
            return 0;
2073
0
        }
2074
12
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2075
12
        Py_DECREF(type);
2076
12
        if (!cond) {
2077
0
            Py_DECREF(Try_annotations);
2078
0
            return 0;
2079
0
        }
2080
12
    }
2081
12
    {
2082
12
        PyObject *type = state->stmt_type;
2083
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2084
12
        cond = type != NULL;
2085
12
        if (!cond) {
2086
0
            Py_DECREF(Try_annotations);
2087
0
            return 0;
2088
0
        }
2089
12
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2090
12
        Py_DECREF(type);
2091
12
        if (!cond) {
2092
0
            Py_DECREF(Try_annotations);
2093
0
            return 0;
2094
0
        }
2095
12
    }
2096
12
    {
2097
12
        PyObject *type = state->stmt_type;
2098
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2099
12
        cond = type != NULL;
2100
12
        if (!cond) {
2101
0
            Py_DECREF(Try_annotations);
2102
0
            return 0;
2103
0
        }
2104
12
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2105
12
        Py_DECREF(type);
2106
12
        if (!cond) {
2107
0
            Py_DECREF(Try_annotations);
2108
0
            return 0;
2109
0
        }
2110
12
    }
2111
12
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2112
12
                                  Try_annotations) == 0;
2113
12
    if (!cond) {
2114
0
        Py_DECREF(Try_annotations);
2115
0
        return 0;
2116
0
    }
2117
12
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2118
12
                                  Try_annotations) == 0;
2119
12
    if (!cond) {
2120
0
        Py_DECREF(Try_annotations);
2121
0
        return 0;
2122
0
    }
2123
12
    Py_DECREF(Try_annotations);
2124
12
    PyObject *TryStar_annotations = PyDict_New();
2125
12
    if (!TryStar_annotations) return 0;
2126
12
    {
2127
12
        PyObject *type = state->stmt_type;
2128
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2129
12
        cond = type != NULL;
2130
12
        if (!cond) {
2131
0
            Py_DECREF(TryStar_annotations);
2132
0
            return 0;
2133
0
        }
2134
12
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2135
12
        Py_DECREF(type);
2136
12
        if (!cond) {
2137
0
            Py_DECREF(TryStar_annotations);
2138
0
            return 0;
2139
0
        }
2140
12
    }
2141
12
    {
2142
12
        PyObject *type = state->excepthandler_type;
2143
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2144
12
        cond = type != NULL;
2145
12
        if (!cond) {
2146
0
            Py_DECREF(TryStar_annotations);
2147
0
            return 0;
2148
0
        }
2149
12
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2150
12
        Py_DECREF(type);
2151
12
        if (!cond) {
2152
0
            Py_DECREF(TryStar_annotations);
2153
0
            return 0;
2154
0
        }
2155
12
    }
2156
12
    {
2157
12
        PyObject *type = state->stmt_type;
2158
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2159
12
        cond = type != NULL;
2160
12
        if (!cond) {
2161
0
            Py_DECREF(TryStar_annotations);
2162
0
            return 0;
2163
0
        }
2164
12
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2165
12
        Py_DECREF(type);
2166
12
        if (!cond) {
2167
0
            Py_DECREF(TryStar_annotations);
2168
0
            return 0;
2169
0
        }
2170
12
    }
2171
12
    {
2172
12
        PyObject *type = state->stmt_type;
2173
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2174
12
        cond = type != NULL;
2175
12
        if (!cond) {
2176
0
            Py_DECREF(TryStar_annotations);
2177
0
            return 0;
2178
0
        }
2179
12
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2180
12
                                    0;
2181
12
        Py_DECREF(type);
2182
12
        if (!cond) {
2183
0
            Py_DECREF(TryStar_annotations);
2184
0
            return 0;
2185
0
        }
2186
12
    }
2187
12
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2188
12
                                  TryStar_annotations) == 0;
2189
12
    if (!cond) {
2190
0
        Py_DECREF(TryStar_annotations);
2191
0
        return 0;
2192
0
    }
2193
12
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2194
12
                                  TryStar_annotations) == 0;
2195
12
    if (!cond) {
2196
0
        Py_DECREF(TryStar_annotations);
2197
0
        return 0;
2198
0
    }
2199
12
    Py_DECREF(TryStar_annotations);
2200
12
    PyObject *Assert_annotations = PyDict_New();
2201
12
    if (!Assert_annotations) return 0;
2202
12
    {
2203
12
        PyObject *type = state->expr_type;
2204
12
        Py_INCREF(type);
2205
12
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2206
12
        Py_DECREF(type);
2207
12
        if (!cond) {
2208
0
            Py_DECREF(Assert_annotations);
2209
0
            return 0;
2210
0
        }
2211
12
    }
2212
12
    {
2213
12
        PyObject *type = state->expr_type;
2214
12
        type = _Py_union_type_or(type, Py_None);
2215
12
        cond = type != NULL;
2216
12
        if (!cond) {
2217
0
            Py_DECREF(Assert_annotations);
2218
0
            return 0;
2219
0
        }
2220
12
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2221
12
        Py_DECREF(type);
2222
12
        if (!cond) {
2223
0
            Py_DECREF(Assert_annotations);
2224
0
            return 0;
2225
0
        }
2226
12
    }
2227
12
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2228
12
                                  Assert_annotations) == 0;
2229
12
    if (!cond) {
2230
0
        Py_DECREF(Assert_annotations);
2231
0
        return 0;
2232
0
    }
2233
12
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2234
12
                                  Assert_annotations) == 0;
2235
12
    if (!cond) {
2236
0
        Py_DECREF(Assert_annotations);
2237
0
        return 0;
2238
0
    }
2239
12
    Py_DECREF(Assert_annotations);
2240
12
    PyObject *Import_annotations = PyDict_New();
2241
12
    if (!Import_annotations) return 0;
2242
12
    {
2243
12
        PyObject *type = state->alias_type;
2244
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2245
12
        cond = type != NULL;
2246
12
        if (!cond) {
2247
0
            Py_DECREF(Import_annotations);
2248
0
            return 0;
2249
0
        }
2250
12
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2251
12
        Py_DECREF(type);
2252
12
        if (!cond) {
2253
0
            Py_DECREF(Import_annotations);
2254
0
            return 0;
2255
0
        }
2256
12
    }
2257
12
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2258
12
                                  Import_annotations) == 0;
2259
12
    if (!cond) {
2260
0
        Py_DECREF(Import_annotations);
2261
0
        return 0;
2262
0
    }
2263
12
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2264
12
                                  Import_annotations) == 0;
2265
12
    if (!cond) {
2266
0
        Py_DECREF(Import_annotations);
2267
0
        return 0;
2268
0
    }
2269
12
    Py_DECREF(Import_annotations);
2270
12
    PyObject *ImportFrom_annotations = PyDict_New();
2271
12
    if (!ImportFrom_annotations) return 0;
2272
12
    {
2273
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
2274
12
        type = _Py_union_type_or(type, Py_None);
2275
12
        cond = type != NULL;
2276
12
        if (!cond) {
2277
0
            Py_DECREF(ImportFrom_annotations);
2278
0
            return 0;
2279
0
        }
2280
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2281
12
                                    0;
2282
12
        Py_DECREF(type);
2283
12
        if (!cond) {
2284
0
            Py_DECREF(ImportFrom_annotations);
2285
0
            return 0;
2286
0
        }
2287
12
    }
2288
12
    {
2289
12
        PyObject *type = state->alias_type;
2290
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2291
12
        cond = type != NULL;
2292
12
        if (!cond) {
2293
0
            Py_DECREF(ImportFrom_annotations);
2294
0
            return 0;
2295
0
        }
2296
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2297
12
        Py_DECREF(type);
2298
12
        if (!cond) {
2299
0
            Py_DECREF(ImportFrom_annotations);
2300
0
            return 0;
2301
0
        }
2302
12
    }
2303
12
    {
2304
12
        PyObject *type = (PyObject *)&PyLong_Type;
2305
12
        type = _Py_union_type_or(type, Py_None);
2306
12
        cond = type != NULL;
2307
12
        if (!cond) {
2308
0
            Py_DECREF(ImportFrom_annotations);
2309
0
            return 0;
2310
0
        }
2311
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2312
12
        Py_DECREF(type);
2313
12
        if (!cond) {
2314
0
            Py_DECREF(ImportFrom_annotations);
2315
0
            return 0;
2316
0
        }
2317
12
    }
2318
12
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2319
12
                                  ImportFrom_annotations) == 0;
2320
12
    if (!cond) {
2321
0
        Py_DECREF(ImportFrom_annotations);
2322
0
        return 0;
2323
0
    }
2324
12
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2325
12
                                  ImportFrom_annotations) == 0;
2326
12
    if (!cond) {
2327
0
        Py_DECREF(ImportFrom_annotations);
2328
0
        return 0;
2329
0
    }
2330
12
    Py_DECREF(ImportFrom_annotations);
2331
12
    PyObject *Global_annotations = PyDict_New();
2332
12
    if (!Global_annotations) return 0;
2333
12
    {
2334
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
2335
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2336
12
        cond = type != NULL;
2337
12
        if (!cond) {
2338
0
            Py_DECREF(Global_annotations);
2339
0
            return 0;
2340
0
        }
2341
12
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2342
12
        Py_DECREF(type);
2343
12
        if (!cond) {
2344
0
            Py_DECREF(Global_annotations);
2345
0
            return 0;
2346
0
        }
2347
12
    }
2348
12
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2349
12
                                  Global_annotations) == 0;
2350
12
    if (!cond) {
2351
0
        Py_DECREF(Global_annotations);
2352
0
        return 0;
2353
0
    }
2354
12
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2355
12
                                  Global_annotations) == 0;
2356
12
    if (!cond) {
2357
0
        Py_DECREF(Global_annotations);
2358
0
        return 0;
2359
0
    }
2360
12
    Py_DECREF(Global_annotations);
2361
12
    PyObject *Nonlocal_annotations = PyDict_New();
2362
12
    if (!Nonlocal_annotations) return 0;
2363
12
    {
2364
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
2365
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2366
12
        cond = type != NULL;
2367
12
        if (!cond) {
2368
0
            Py_DECREF(Nonlocal_annotations);
2369
0
            return 0;
2370
0
        }
2371
12
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2372
12
        Py_DECREF(type);
2373
12
        if (!cond) {
2374
0
            Py_DECREF(Nonlocal_annotations);
2375
0
            return 0;
2376
0
        }
2377
12
    }
2378
12
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2379
12
                                  Nonlocal_annotations) == 0;
2380
12
    if (!cond) {
2381
0
        Py_DECREF(Nonlocal_annotations);
2382
0
        return 0;
2383
0
    }
2384
12
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2385
12
                                  Nonlocal_annotations) == 0;
2386
12
    if (!cond) {
2387
0
        Py_DECREF(Nonlocal_annotations);
2388
0
        return 0;
2389
0
    }
2390
12
    Py_DECREF(Nonlocal_annotations);
2391
12
    PyObject *Expr_annotations = PyDict_New();
2392
12
    if (!Expr_annotations) return 0;
2393
12
    {
2394
12
        PyObject *type = state->expr_type;
2395
12
        Py_INCREF(type);
2396
12
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2397
12
        Py_DECREF(type);
2398
12
        if (!cond) {
2399
0
            Py_DECREF(Expr_annotations);
2400
0
            return 0;
2401
0
        }
2402
12
    }
2403
12
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2404
12
                                  Expr_annotations) == 0;
2405
12
    if (!cond) {
2406
0
        Py_DECREF(Expr_annotations);
2407
0
        return 0;
2408
0
    }
2409
12
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2410
12
                                  Expr_annotations) == 0;
2411
12
    if (!cond) {
2412
0
        Py_DECREF(Expr_annotations);
2413
0
        return 0;
2414
0
    }
2415
12
    Py_DECREF(Expr_annotations);
2416
12
    PyObject *Pass_annotations = PyDict_New();
2417
12
    if (!Pass_annotations) return 0;
2418
12
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2419
12
                                  Pass_annotations) == 0;
2420
12
    if (!cond) {
2421
0
        Py_DECREF(Pass_annotations);
2422
0
        return 0;
2423
0
    }
2424
12
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2425
12
                                  Pass_annotations) == 0;
2426
12
    if (!cond) {
2427
0
        Py_DECREF(Pass_annotations);
2428
0
        return 0;
2429
0
    }
2430
12
    Py_DECREF(Pass_annotations);
2431
12
    PyObject *Break_annotations = PyDict_New();
2432
12
    if (!Break_annotations) return 0;
2433
12
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2434
12
                                  Break_annotations) == 0;
2435
12
    if (!cond) {
2436
0
        Py_DECREF(Break_annotations);
2437
0
        return 0;
2438
0
    }
2439
12
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2440
12
                                  Break_annotations) == 0;
2441
12
    if (!cond) {
2442
0
        Py_DECREF(Break_annotations);
2443
0
        return 0;
2444
0
    }
2445
12
    Py_DECREF(Break_annotations);
2446
12
    PyObject *Continue_annotations = PyDict_New();
2447
12
    if (!Continue_annotations) return 0;
2448
12
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2449
12
                                  Continue_annotations) == 0;
2450
12
    if (!cond) {
2451
0
        Py_DECREF(Continue_annotations);
2452
0
        return 0;
2453
0
    }
2454
12
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2455
12
                                  Continue_annotations) == 0;
2456
12
    if (!cond) {
2457
0
        Py_DECREF(Continue_annotations);
2458
0
        return 0;
2459
0
    }
2460
12
    Py_DECREF(Continue_annotations);
2461
12
    PyObject *BoolOp_annotations = PyDict_New();
2462
12
    if (!BoolOp_annotations) return 0;
2463
12
    {
2464
12
        PyObject *type = state->boolop_type;
2465
12
        Py_INCREF(type);
2466
12
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2467
12
        Py_DECREF(type);
2468
12
        if (!cond) {
2469
0
            Py_DECREF(BoolOp_annotations);
2470
0
            return 0;
2471
0
        }
2472
12
    }
2473
12
    {
2474
12
        PyObject *type = state->expr_type;
2475
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2476
12
        cond = type != NULL;
2477
12
        if (!cond) {
2478
0
            Py_DECREF(BoolOp_annotations);
2479
0
            return 0;
2480
0
        }
2481
12
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2482
12
        Py_DECREF(type);
2483
12
        if (!cond) {
2484
0
            Py_DECREF(BoolOp_annotations);
2485
0
            return 0;
2486
0
        }
2487
12
    }
2488
12
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2489
12
                                  BoolOp_annotations) == 0;
2490
12
    if (!cond) {
2491
0
        Py_DECREF(BoolOp_annotations);
2492
0
        return 0;
2493
0
    }
2494
12
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2495
12
                                  BoolOp_annotations) == 0;
2496
12
    if (!cond) {
2497
0
        Py_DECREF(BoolOp_annotations);
2498
0
        return 0;
2499
0
    }
2500
12
    Py_DECREF(BoolOp_annotations);
2501
12
    PyObject *NamedExpr_annotations = PyDict_New();
2502
12
    if (!NamedExpr_annotations) return 0;
2503
12
    {
2504
12
        PyObject *type = state->expr_type;
2505
12
        Py_INCREF(type);
2506
12
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2507
12
        Py_DECREF(type);
2508
12
        if (!cond) {
2509
0
            Py_DECREF(NamedExpr_annotations);
2510
0
            return 0;
2511
0
        }
2512
12
    }
2513
12
    {
2514
12
        PyObject *type = state->expr_type;
2515
12
        Py_INCREF(type);
2516
12
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2517
12
        Py_DECREF(type);
2518
12
        if (!cond) {
2519
0
            Py_DECREF(NamedExpr_annotations);
2520
0
            return 0;
2521
0
        }
2522
12
    }
2523
12
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2524
12
                                  NamedExpr_annotations) == 0;
2525
12
    if (!cond) {
2526
0
        Py_DECREF(NamedExpr_annotations);
2527
0
        return 0;
2528
0
    }
2529
12
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2530
12
                                  NamedExpr_annotations) == 0;
2531
12
    if (!cond) {
2532
0
        Py_DECREF(NamedExpr_annotations);
2533
0
        return 0;
2534
0
    }
2535
12
    Py_DECREF(NamedExpr_annotations);
2536
12
    PyObject *BinOp_annotations = PyDict_New();
2537
12
    if (!BinOp_annotations) return 0;
2538
12
    {
2539
12
        PyObject *type = state->expr_type;
2540
12
        Py_INCREF(type);
2541
12
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2542
12
        Py_DECREF(type);
2543
12
        if (!cond) {
2544
0
            Py_DECREF(BinOp_annotations);
2545
0
            return 0;
2546
0
        }
2547
12
    }
2548
12
    {
2549
12
        PyObject *type = state->operator_type;
2550
12
        Py_INCREF(type);
2551
12
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2552
12
        Py_DECREF(type);
2553
12
        if (!cond) {
2554
0
            Py_DECREF(BinOp_annotations);
2555
0
            return 0;
2556
0
        }
2557
12
    }
2558
12
    {
2559
12
        PyObject *type = state->expr_type;
2560
12
        Py_INCREF(type);
2561
12
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2562
12
        Py_DECREF(type);
2563
12
        if (!cond) {
2564
0
            Py_DECREF(BinOp_annotations);
2565
0
            return 0;
2566
0
        }
2567
12
    }
2568
12
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2569
12
                                  BinOp_annotations) == 0;
2570
12
    if (!cond) {
2571
0
        Py_DECREF(BinOp_annotations);
2572
0
        return 0;
2573
0
    }
2574
12
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2575
12
                                  BinOp_annotations) == 0;
2576
12
    if (!cond) {
2577
0
        Py_DECREF(BinOp_annotations);
2578
0
        return 0;
2579
0
    }
2580
12
    Py_DECREF(BinOp_annotations);
2581
12
    PyObject *UnaryOp_annotations = PyDict_New();
2582
12
    if (!UnaryOp_annotations) return 0;
2583
12
    {
2584
12
        PyObject *type = state->unaryop_type;
2585
12
        Py_INCREF(type);
2586
12
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2587
12
        Py_DECREF(type);
2588
12
        if (!cond) {
2589
0
            Py_DECREF(UnaryOp_annotations);
2590
0
            return 0;
2591
0
        }
2592
12
    }
2593
12
    {
2594
12
        PyObject *type = state->expr_type;
2595
12
        Py_INCREF(type);
2596
12
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2597
12
        Py_DECREF(type);
2598
12
        if (!cond) {
2599
0
            Py_DECREF(UnaryOp_annotations);
2600
0
            return 0;
2601
0
        }
2602
12
    }
2603
12
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2604
12
                                  UnaryOp_annotations) == 0;
2605
12
    if (!cond) {
2606
0
        Py_DECREF(UnaryOp_annotations);
2607
0
        return 0;
2608
0
    }
2609
12
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2610
12
                                  UnaryOp_annotations) == 0;
2611
12
    if (!cond) {
2612
0
        Py_DECREF(UnaryOp_annotations);
2613
0
        return 0;
2614
0
    }
2615
12
    Py_DECREF(UnaryOp_annotations);
2616
12
    PyObject *Lambda_annotations = PyDict_New();
2617
12
    if (!Lambda_annotations) return 0;
2618
12
    {
2619
12
        PyObject *type = state->arguments_type;
2620
12
        Py_INCREF(type);
2621
12
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2622
12
        Py_DECREF(type);
2623
12
        if (!cond) {
2624
0
            Py_DECREF(Lambda_annotations);
2625
0
            return 0;
2626
0
        }
2627
12
    }
2628
12
    {
2629
12
        PyObject *type = state->expr_type;
2630
12
        Py_INCREF(type);
2631
12
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2632
12
        Py_DECREF(type);
2633
12
        if (!cond) {
2634
0
            Py_DECREF(Lambda_annotations);
2635
0
            return 0;
2636
0
        }
2637
12
    }
2638
12
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2639
12
                                  Lambda_annotations) == 0;
2640
12
    if (!cond) {
2641
0
        Py_DECREF(Lambda_annotations);
2642
0
        return 0;
2643
0
    }
2644
12
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2645
12
                                  Lambda_annotations) == 0;
2646
12
    if (!cond) {
2647
0
        Py_DECREF(Lambda_annotations);
2648
0
        return 0;
2649
0
    }
2650
12
    Py_DECREF(Lambda_annotations);
2651
12
    PyObject *IfExp_annotations = PyDict_New();
2652
12
    if (!IfExp_annotations) return 0;
2653
12
    {
2654
12
        PyObject *type = state->expr_type;
2655
12
        Py_INCREF(type);
2656
12
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2657
12
        Py_DECREF(type);
2658
12
        if (!cond) {
2659
0
            Py_DECREF(IfExp_annotations);
2660
0
            return 0;
2661
0
        }
2662
12
    }
2663
12
    {
2664
12
        PyObject *type = state->expr_type;
2665
12
        Py_INCREF(type);
2666
12
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2667
12
        Py_DECREF(type);
2668
12
        if (!cond) {
2669
0
            Py_DECREF(IfExp_annotations);
2670
0
            return 0;
2671
0
        }
2672
12
    }
2673
12
    {
2674
12
        PyObject *type = state->expr_type;
2675
12
        Py_INCREF(type);
2676
12
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2677
12
        Py_DECREF(type);
2678
12
        if (!cond) {
2679
0
            Py_DECREF(IfExp_annotations);
2680
0
            return 0;
2681
0
        }
2682
12
    }
2683
12
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2684
12
                                  IfExp_annotations) == 0;
2685
12
    if (!cond) {
2686
0
        Py_DECREF(IfExp_annotations);
2687
0
        return 0;
2688
0
    }
2689
12
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2690
12
                                  IfExp_annotations) == 0;
2691
12
    if (!cond) {
2692
0
        Py_DECREF(IfExp_annotations);
2693
0
        return 0;
2694
0
    }
2695
12
    Py_DECREF(IfExp_annotations);
2696
12
    PyObject *Dict_annotations = PyDict_New();
2697
12
    if (!Dict_annotations) return 0;
2698
12
    {
2699
12
        PyObject *type = state->expr_type;
2700
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2701
12
        cond = type != NULL;
2702
12
        if (!cond) {
2703
0
            Py_DECREF(Dict_annotations);
2704
0
            return 0;
2705
0
        }
2706
12
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2707
12
        Py_DECREF(type);
2708
12
        if (!cond) {
2709
0
            Py_DECREF(Dict_annotations);
2710
0
            return 0;
2711
0
        }
2712
12
    }
2713
12
    {
2714
12
        PyObject *type = state->expr_type;
2715
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2716
12
        cond = type != NULL;
2717
12
        if (!cond) {
2718
0
            Py_DECREF(Dict_annotations);
2719
0
            return 0;
2720
0
        }
2721
12
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2722
12
        Py_DECREF(type);
2723
12
        if (!cond) {
2724
0
            Py_DECREF(Dict_annotations);
2725
0
            return 0;
2726
0
        }
2727
12
    }
2728
12
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2729
12
                                  Dict_annotations) == 0;
2730
12
    if (!cond) {
2731
0
        Py_DECREF(Dict_annotations);
2732
0
        return 0;
2733
0
    }
2734
12
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2735
12
                                  Dict_annotations) == 0;
2736
12
    if (!cond) {
2737
0
        Py_DECREF(Dict_annotations);
2738
0
        return 0;
2739
0
    }
2740
12
    Py_DECREF(Dict_annotations);
2741
12
    PyObject *Set_annotations = PyDict_New();
2742
12
    if (!Set_annotations) return 0;
2743
12
    {
2744
12
        PyObject *type = state->expr_type;
2745
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2746
12
        cond = type != NULL;
2747
12
        if (!cond) {
2748
0
            Py_DECREF(Set_annotations);
2749
0
            return 0;
2750
0
        }
2751
12
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2752
12
        Py_DECREF(type);
2753
12
        if (!cond) {
2754
0
            Py_DECREF(Set_annotations);
2755
0
            return 0;
2756
0
        }
2757
12
    }
2758
12
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2759
12
                                  Set_annotations) == 0;
2760
12
    if (!cond) {
2761
0
        Py_DECREF(Set_annotations);
2762
0
        return 0;
2763
0
    }
2764
12
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2765
12
                                  Set_annotations) == 0;
2766
12
    if (!cond) {
2767
0
        Py_DECREF(Set_annotations);
2768
0
        return 0;
2769
0
    }
2770
12
    Py_DECREF(Set_annotations);
2771
12
    PyObject *ListComp_annotations = PyDict_New();
2772
12
    if (!ListComp_annotations) return 0;
2773
12
    {
2774
12
        PyObject *type = state->expr_type;
2775
12
        Py_INCREF(type);
2776
12
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2777
12
        Py_DECREF(type);
2778
12
        if (!cond) {
2779
0
            Py_DECREF(ListComp_annotations);
2780
0
            return 0;
2781
0
        }
2782
12
    }
2783
12
    {
2784
12
        PyObject *type = state->comprehension_type;
2785
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2786
12
        cond = type != NULL;
2787
12
        if (!cond) {
2788
0
            Py_DECREF(ListComp_annotations);
2789
0
            return 0;
2790
0
        }
2791
12
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2792
12
                                    == 0;
2793
12
        Py_DECREF(type);
2794
12
        if (!cond) {
2795
0
            Py_DECREF(ListComp_annotations);
2796
0
            return 0;
2797
0
        }
2798
12
    }
2799
12
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2800
12
                                  ListComp_annotations) == 0;
2801
12
    if (!cond) {
2802
0
        Py_DECREF(ListComp_annotations);
2803
0
        return 0;
2804
0
    }
2805
12
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2806
12
                                  ListComp_annotations) == 0;
2807
12
    if (!cond) {
2808
0
        Py_DECREF(ListComp_annotations);
2809
0
        return 0;
2810
0
    }
2811
12
    Py_DECREF(ListComp_annotations);
2812
12
    PyObject *SetComp_annotations = PyDict_New();
2813
12
    if (!SetComp_annotations) return 0;
2814
12
    {
2815
12
        PyObject *type = state->expr_type;
2816
12
        Py_INCREF(type);
2817
12
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2818
12
        Py_DECREF(type);
2819
12
        if (!cond) {
2820
0
            Py_DECREF(SetComp_annotations);
2821
0
            return 0;
2822
0
        }
2823
12
    }
2824
12
    {
2825
12
        PyObject *type = state->comprehension_type;
2826
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2827
12
        cond = type != NULL;
2828
12
        if (!cond) {
2829
0
            Py_DECREF(SetComp_annotations);
2830
0
            return 0;
2831
0
        }
2832
12
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2833
12
                                    0;
2834
12
        Py_DECREF(type);
2835
12
        if (!cond) {
2836
0
            Py_DECREF(SetComp_annotations);
2837
0
            return 0;
2838
0
        }
2839
12
    }
2840
12
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2841
12
                                  SetComp_annotations) == 0;
2842
12
    if (!cond) {
2843
0
        Py_DECREF(SetComp_annotations);
2844
0
        return 0;
2845
0
    }
2846
12
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2847
12
                                  SetComp_annotations) == 0;
2848
12
    if (!cond) {
2849
0
        Py_DECREF(SetComp_annotations);
2850
0
        return 0;
2851
0
    }
2852
12
    Py_DECREF(SetComp_annotations);
2853
12
    PyObject *DictComp_annotations = PyDict_New();
2854
12
    if (!DictComp_annotations) return 0;
2855
12
    {
2856
12
        PyObject *type = state->expr_type;
2857
12
        Py_INCREF(type);
2858
12
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2859
12
        Py_DECREF(type);
2860
12
        if (!cond) {
2861
0
            Py_DECREF(DictComp_annotations);
2862
0
            return 0;
2863
0
        }
2864
12
    }
2865
12
    {
2866
12
        PyObject *type = state->expr_type;
2867
12
        type = _Py_union_type_or(type, Py_None);
2868
12
        cond = type != NULL;
2869
12
        if (!cond) {
2870
0
            Py_DECREF(DictComp_annotations);
2871
0
            return 0;
2872
0
        }
2873
12
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2874
12
        Py_DECREF(type);
2875
12
        if (!cond) {
2876
0
            Py_DECREF(DictComp_annotations);
2877
0
            return 0;
2878
0
        }
2879
12
    }
2880
12
    {
2881
12
        PyObject *type = state->comprehension_type;
2882
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2883
12
        cond = type != NULL;
2884
12
        if (!cond) {
2885
0
            Py_DECREF(DictComp_annotations);
2886
0
            return 0;
2887
0
        }
2888
12
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2889
12
                                    == 0;
2890
12
        Py_DECREF(type);
2891
12
        if (!cond) {
2892
0
            Py_DECREF(DictComp_annotations);
2893
0
            return 0;
2894
0
        }
2895
12
    }
2896
12
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2897
12
                                  DictComp_annotations) == 0;
2898
12
    if (!cond) {
2899
0
        Py_DECREF(DictComp_annotations);
2900
0
        return 0;
2901
0
    }
2902
12
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2903
12
                                  DictComp_annotations) == 0;
2904
12
    if (!cond) {
2905
0
        Py_DECREF(DictComp_annotations);
2906
0
        return 0;
2907
0
    }
2908
12
    Py_DECREF(DictComp_annotations);
2909
12
    PyObject *GeneratorExp_annotations = PyDict_New();
2910
12
    if (!GeneratorExp_annotations) return 0;
2911
12
    {
2912
12
        PyObject *type = state->expr_type;
2913
12
        Py_INCREF(type);
2914
12
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2915
12
        Py_DECREF(type);
2916
12
        if (!cond) {
2917
0
            Py_DECREF(GeneratorExp_annotations);
2918
0
            return 0;
2919
0
        }
2920
12
    }
2921
12
    {
2922
12
        PyObject *type = state->comprehension_type;
2923
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2924
12
        cond = type != NULL;
2925
12
        if (!cond) {
2926
0
            Py_DECREF(GeneratorExp_annotations);
2927
0
            return 0;
2928
0
        }
2929
12
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2930
12
                                    type) == 0;
2931
12
        Py_DECREF(type);
2932
12
        if (!cond) {
2933
0
            Py_DECREF(GeneratorExp_annotations);
2934
0
            return 0;
2935
0
        }
2936
12
    }
2937
12
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2938
12
                                  GeneratorExp_annotations) == 0;
2939
12
    if (!cond) {
2940
0
        Py_DECREF(GeneratorExp_annotations);
2941
0
        return 0;
2942
0
    }
2943
12
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2944
12
                                  GeneratorExp_annotations) == 0;
2945
12
    if (!cond) {
2946
0
        Py_DECREF(GeneratorExp_annotations);
2947
0
        return 0;
2948
0
    }
2949
12
    Py_DECREF(GeneratorExp_annotations);
2950
12
    PyObject *Await_annotations = PyDict_New();
2951
12
    if (!Await_annotations) return 0;
2952
12
    {
2953
12
        PyObject *type = state->expr_type;
2954
12
        Py_INCREF(type);
2955
12
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2956
12
        Py_DECREF(type);
2957
12
        if (!cond) {
2958
0
            Py_DECREF(Await_annotations);
2959
0
            return 0;
2960
0
        }
2961
12
    }
2962
12
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2963
12
                                  Await_annotations) == 0;
2964
12
    if (!cond) {
2965
0
        Py_DECREF(Await_annotations);
2966
0
        return 0;
2967
0
    }
2968
12
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
2969
12
                                  Await_annotations) == 0;
2970
12
    if (!cond) {
2971
0
        Py_DECREF(Await_annotations);
2972
0
        return 0;
2973
0
    }
2974
12
    Py_DECREF(Await_annotations);
2975
12
    PyObject *Yield_annotations = PyDict_New();
2976
12
    if (!Yield_annotations) return 0;
2977
12
    {
2978
12
        PyObject *type = state->expr_type;
2979
12
        type = _Py_union_type_or(type, Py_None);
2980
12
        cond = type != NULL;
2981
12
        if (!cond) {
2982
0
            Py_DECREF(Yield_annotations);
2983
0
            return 0;
2984
0
        }
2985
12
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
2986
12
        Py_DECREF(type);
2987
12
        if (!cond) {
2988
0
            Py_DECREF(Yield_annotations);
2989
0
            return 0;
2990
0
        }
2991
12
    }
2992
12
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
2993
12
                                  Yield_annotations) == 0;
2994
12
    if (!cond) {
2995
0
        Py_DECREF(Yield_annotations);
2996
0
        return 0;
2997
0
    }
2998
12
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
2999
12
                                  Yield_annotations) == 0;
3000
12
    if (!cond) {
3001
0
        Py_DECREF(Yield_annotations);
3002
0
        return 0;
3003
0
    }
3004
12
    Py_DECREF(Yield_annotations);
3005
12
    PyObject *YieldFrom_annotations = PyDict_New();
3006
12
    if (!YieldFrom_annotations) return 0;
3007
12
    {
3008
12
        PyObject *type = state->expr_type;
3009
12
        Py_INCREF(type);
3010
12
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3011
12
        Py_DECREF(type);
3012
12
        if (!cond) {
3013
0
            Py_DECREF(YieldFrom_annotations);
3014
0
            return 0;
3015
0
        }
3016
12
    }
3017
12
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3018
12
                                  YieldFrom_annotations) == 0;
3019
12
    if (!cond) {
3020
0
        Py_DECREF(YieldFrom_annotations);
3021
0
        return 0;
3022
0
    }
3023
12
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3024
12
                                  YieldFrom_annotations) == 0;
3025
12
    if (!cond) {
3026
0
        Py_DECREF(YieldFrom_annotations);
3027
0
        return 0;
3028
0
    }
3029
12
    Py_DECREF(YieldFrom_annotations);
3030
12
    PyObject *Compare_annotations = PyDict_New();
3031
12
    if (!Compare_annotations) return 0;
3032
12
    {
3033
12
        PyObject *type = state->expr_type;
3034
12
        Py_INCREF(type);
3035
12
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3036
12
        Py_DECREF(type);
3037
12
        if (!cond) {
3038
0
            Py_DECREF(Compare_annotations);
3039
0
            return 0;
3040
0
        }
3041
12
    }
3042
12
    {
3043
12
        PyObject *type = state->cmpop_type;
3044
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3045
12
        cond = type != NULL;
3046
12
        if (!cond) {
3047
0
            Py_DECREF(Compare_annotations);
3048
0
            return 0;
3049
0
        }
3050
12
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3051
12
        Py_DECREF(type);
3052
12
        if (!cond) {
3053
0
            Py_DECREF(Compare_annotations);
3054
0
            return 0;
3055
0
        }
3056
12
    }
3057
12
    {
3058
12
        PyObject *type = state->expr_type;
3059
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3060
12
        cond = type != NULL;
3061
12
        if (!cond) {
3062
0
            Py_DECREF(Compare_annotations);
3063
0
            return 0;
3064
0
        }
3065
12
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3066
12
                                    == 0;
3067
12
        Py_DECREF(type);
3068
12
        if (!cond) {
3069
0
            Py_DECREF(Compare_annotations);
3070
0
            return 0;
3071
0
        }
3072
12
    }
3073
12
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3074
12
                                  Compare_annotations) == 0;
3075
12
    if (!cond) {
3076
0
        Py_DECREF(Compare_annotations);
3077
0
        return 0;
3078
0
    }
3079
12
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3080
12
                                  Compare_annotations) == 0;
3081
12
    if (!cond) {
3082
0
        Py_DECREF(Compare_annotations);
3083
0
        return 0;
3084
0
    }
3085
12
    Py_DECREF(Compare_annotations);
3086
12
    PyObject *Call_annotations = PyDict_New();
3087
12
    if (!Call_annotations) return 0;
3088
12
    {
3089
12
        PyObject *type = state->expr_type;
3090
12
        Py_INCREF(type);
3091
12
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3092
12
        Py_DECREF(type);
3093
12
        if (!cond) {
3094
0
            Py_DECREF(Call_annotations);
3095
0
            return 0;
3096
0
        }
3097
12
    }
3098
12
    {
3099
12
        PyObject *type = state->expr_type;
3100
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3101
12
        cond = type != NULL;
3102
12
        if (!cond) {
3103
0
            Py_DECREF(Call_annotations);
3104
0
            return 0;
3105
0
        }
3106
12
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3107
12
        Py_DECREF(type);
3108
12
        if (!cond) {
3109
0
            Py_DECREF(Call_annotations);
3110
0
            return 0;
3111
0
        }
3112
12
    }
3113
12
    {
3114
12
        PyObject *type = state->keyword_type;
3115
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3116
12
        cond = type != NULL;
3117
12
        if (!cond) {
3118
0
            Py_DECREF(Call_annotations);
3119
0
            return 0;
3120
0
        }
3121
12
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3122
12
        Py_DECREF(type);
3123
12
        if (!cond) {
3124
0
            Py_DECREF(Call_annotations);
3125
0
            return 0;
3126
0
        }
3127
12
    }
3128
12
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3129
12
                                  Call_annotations) == 0;
3130
12
    if (!cond) {
3131
0
        Py_DECREF(Call_annotations);
3132
0
        return 0;
3133
0
    }
3134
12
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3135
12
                                  Call_annotations) == 0;
3136
12
    if (!cond) {
3137
0
        Py_DECREF(Call_annotations);
3138
0
        return 0;
3139
0
    }
3140
12
    Py_DECREF(Call_annotations);
3141
12
    PyObject *FormattedValue_annotations = PyDict_New();
3142
12
    if (!FormattedValue_annotations) return 0;
3143
12
    {
3144
12
        PyObject *type = state->expr_type;
3145
12
        Py_INCREF(type);
3146
12
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3147
12
                                    == 0;
3148
12
        Py_DECREF(type);
3149
12
        if (!cond) {
3150
0
            Py_DECREF(FormattedValue_annotations);
3151
0
            return 0;
3152
0
        }
3153
12
    }
3154
12
    {
3155
12
        PyObject *type = (PyObject *)&PyLong_Type;
3156
12
        Py_INCREF(type);
3157
12
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3158
12
                                    type) == 0;
3159
12
        Py_DECREF(type);
3160
12
        if (!cond) {
3161
0
            Py_DECREF(FormattedValue_annotations);
3162
0
            return 0;
3163
0
        }
3164
12
    }
3165
12
    {
3166
12
        PyObject *type = state->expr_type;
3167
12
        type = _Py_union_type_or(type, Py_None);
3168
12
        cond = type != NULL;
3169
12
        if (!cond) {
3170
0
            Py_DECREF(FormattedValue_annotations);
3171
0
            return 0;
3172
0
        }
3173
12
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3174
12
                                    type) == 0;
3175
12
        Py_DECREF(type);
3176
12
        if (!cond) {
3177
0
            Py_DECREF(FormattedValue_annotations);
3178
0
            return 0;
3179
0
        }
3180
12
    }
3181
12
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3182
12
                                  FormattedValue_annotations) == 0;
3183
12
    if (!cond) {
3184
0
        Py_DECREF(FormattedValue_annotations);
3185
0
        return 0;
3186
0
    }
3187
12
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3188
12
                                  "__annotations__",
3189
12
                                  FormattedValue_annotations) == 0;
3190
12
    if (!cond) {
3191
0
        Py_DECREF(FormattedValue_annotations);
3192
0
        return 0;
3193
0
    }
3194
12
    Py_DECREF(FormattedValue_annotations);
3195
12
    PyObject *Interpolation_annotations = PyDict_New();
3196
12
    if (!Interpolation_annotations) return 0;
3197
12
    {
3198
12
        PyObject *type = state->expr_type;
3199
12
        Py_INCREF(type);
3200
12
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3201
12
                                    == 0;
3202
12
        Py_DECREF(type);
3203
12
        if (!cond) {
3204
0
            Py_DECREF(Interpolation_annotations);
3205
0
            return 0;
3206
0
        }
3207
12
    }
3208
12
    {
3209
12
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3210
12
        Py_INCREF(type);
3211
12
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3212
12
                                    0;
3213
12
        Py_DECREF(type);
3214
12
        if (!cond) {
3215
0
            Py_DECREF(Interpolation_annotations);
3216
0
            return 0;
3217
0
        }
3218
12
    }
3219
12
    {
3220
12
        PyObject *type = (PyObject *)&PyLong_Type;
3221
12
        Py_INCREF(type);
3222
12
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3223
12
                                    type) == 0;
3224
12
        Py_DECREF(type);
3225
12
        if (!cond) {
3226
0
            Py_DECREF(Interpolation_annotations);
3227
0
            return 0;
3228
0
        }
3229
12
    }
3230
12
    {
3231
12
        PyObject *type = state->expr_type;
3232
12
        type = _Py_union_type_or(type, Py_None);
3233
12
        cond = type != NULL;
3234
12
        if (!cond) {
3235
0
            Py_DECREF(Interpolation_annotations);
3236
0
            return 0;
3237
0
        }
3238
12
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3239
12
                                    type) == 0;
3240
12
        Py_DECREF(type);
3241
12
        if (!cond) {
3242
0
            Py_DECREF(Interpolation_annotations);
3243
0
            return 0;
3244
0
        }
3245
12
    }
3246
12
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3247
12
                                  Interpolation_annotations) == 0;
3248
12
    if (!cond) {
3249
0
        Py_DECREF(Interpolation_annotations);
3250
0
        return 0;
3251
0
    }
3252
12
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3253
12
                                  Interpolation_annotations) == 0;
3254
12
    if (!cond) {
3255
0
        Py_DECREF(Interpolation_annotations);
3256
0
        return 0;
3257
0
    }
3258
12
    Py_DECREF(Interpolation_annotations);
3259
12
    PyObject *JoinedStr_annotations = PyDict_New();
3260
12
    if (!JoinedStr_annotations) return 0;
3261
12
    {
3262
12
        PyObject *type = state->expr_type;
3263
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3264
12
        cond = type != NULL;
3265
12
        if (!cond) {
3266
0
            Py_DECREF(JoinedStr_annotations);
3267
0
            return 0;
3268
0
        }
3269
12
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3270
12
        Py_DECREF(type);
3271
12
        if (!cond) {
3272
0
            Py_DECREF(JoinedStr_annotations);
3273
0
            return 0;
3274
0
        }
3275
12
    }
3276
12
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3277
12
                                  JoinedStr_annotations) == 0;
3278
12
    if (!cond) {
3279
0
        Py_DECREF(JoinedStr_annotations);
3280
0
        return 0;
3281
0
    }
3282
12
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3283
12
                                  JoinedStr_annotations) == 0;
3284
12
    if (!cond) {
3285
0
        Py_DECREF(JoinedStr_annotations);
3286
0
        return 0;
3287
0
    }
3288
12
    Py_DECREF(JoinedStr_annotations);
3289
12
    PyObject *TemplateStr_annotations = PyDict_New();
3290
12
    if (!TemplateStr_annotations) return 0;
3291
12
    {
3292
12
        PyObject *type = state->expr_type;
3293
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3294
12
        cond = type != NULL;
3295
12
        if (!cond) {
3296
0
            Py_DECREF(TemplateStr_annotations);
3297
0
            return 0;
3298
0
        }
3299
12
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3300
12
                                    0;
3301
12
        Py_DECREF(type);
3302
12
        if (!cond) {
3303
0
            Py_DECREF(TemplateStr_annotations);
3304
0
            return 0;
3305
0
        }
3306
12
    }
3307
12
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3308
12
                                  TemplateStr_annotations) == 0;
3309
12
    if (!cond) {
3310
0
        Py_DECREF(TemplateStr_annotations);
3311
0
        return 0;
3312
0
    }
3313
12
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3314
12
                                  TemplateStr_annotations) == 0;
3315
12
    if (!cond) {
3316
0
        Py_DECREF(TemplateStr_annotations);
3317
0
        return 0;
3318
0
    }
3319
12
    Py_DECREF(TemplateStr_annotations);
3320
12
    PyObject *Constant_annotations = PyDict_New();
3321
12
    if (!Constant_annotations) return 0;
3322
12
    {
3323
12
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3324
12
        Py_INCREF(type);
3325
12
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3326
12
        Py_DECREF(type);
3327
12
        if (!cond) {
3328
0
            Py_DECREF(Constant_annotations);
3329
0
            return 0;
3330
0
        }
3331
12
    }
3332
12
    {
3333
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
3334
12
        type = _Py_union_type_or(type, Py_None);
3335
12
        cond = type != NULL;
3336
12
        if (!cond) {
3337
0
            Py_DECREF(Constant_annotations);
3338
0
            return 0;
3339
0
        }
3340
12
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3341
12
        Py_DECREF(type);
3342
12
        if (!cond) {
3343
0
            Py_DECREF(Constant_annotations);
3344
0
            return 0;
3345
0
        }
3346
12
    }
3347
12
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3348
12
                                  Constant_annotations) == 0;
3349
12
    if (!cond) {
3350
0
        Py_DECREF(Constant_annotations);
3351
0
        return 0;
3352
0
    }
3353
12
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3354
12
                                  Constant_annotations) == 0;
3355
12
    if (!cond) {
3356
0
        Py_DECREF(Constant_annotations);
3357
0
        return 0;
3358
0
    }
3359
12
    Py_DECREF(Constant_annotations);
3360
12
    PyObject *Attribute_annotations = PyDict_New();
3361
12
    if (!Attribute_annotations) return 0;
3362
12
    {
3363
12
        PyObject *type = state->expr_type;
3364
12
        Py_INCREF(type);
3365
12
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3366
12
        Py_DECREF(type);
3367
12
        if (!cond) {
3368
0
            Py_DECREF(Attribute_annotations);
3369
0
            return 0;
3370
0
        }
3371
12
    }
3372
12
    {
3373
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
3374
12
        Py_INCREF(type);
3375
12
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3376
12
        Py_DECREF(type);
3377
12
        if (!cond) {
3378
0
            Py_DECREF(Attribute_annotations);
3379
0
            return 0;
3380
0
        }
3381
12
    }
3382
12
    {
3383
12
        PyObject *type = state->expr_context_type;
3384
12
        Py_INCREF(type);
3385
12
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3386
12
        Py_DECREF(type);
3387
12
        if (!cond) {
3388
0
            Py_DECREF(Attribute_annotations);
3389
0
            return 0;
3390
0
        }
3391
12
    }
3392
12
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3393
12
                                  Attribute_annotations) == 0;
3394
12
    if (!cond) {
3395
0
        Py_DECREF(Attribute_annotations);
3396
0
        return 0;
3397
0
    }
3398
12
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3399
12
                                  Attribute_annotations) == 0;
3400
12
    if (!cond) {
3401
0
        Py_DECREF(Attribute_annotations);
3402
0
        return 0;
3403
0
    }
3404
12
    Py_DECREF(Attribute_annotations);
3405
12
    PyObject *Subscript_annotations = PyDict_New();
3406
12
    if (!Subscript_annotations) return 0;
3407
12
    {
3408
12
        PyObject *type = state->expr_type;
3409
12
        Py_INCREF(type);
3410
12
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3411
12
        Py_DECREF(type);
3412
12
        if (!cond) {
3413
0
            Py_DECREF(Subscript_annotations);
3414
0
            return 0;
3415
0
        }
3416
12
    }
3417
12
    {
3418
12
        PyObject *type = state->expr_type;
3419
12
        Py_INCREF(type);
3420
12
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3421
12
        Py_DECREF(type);
3422
12
        if (!cond) {
3423
0
            Py_DECREF(Subscript_annotations);
3424
0
            return 0;
3425
0
        }
3426
12
    }
3427
12
    {
3428
12
        PyObject *type = state->expr_context_type;
3429
12
        Py_INCREF(type);
3430
12
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3431
12
        Py_DECREF(type);
3432
12
        if (!cond) {
3433
0
            Py_DECREF(Subscript_annotations);
3434
0
            return 0;
3435
0
        }
3436
12
    }
3437
12
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3438
12
                                  Subscript_annotations) == 0;
3439
12
    if (!cond) {
3440
0
        Py_DECREF(Subscript_annotations);
3441
0
        return 0;
3442
0
    }
3443
12
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3444
12
                                  Subscript_annotations) == 0;
3445
12
    if (!cond) {
3446
0
        Py_DECREF(Subscript_annotations);
3447
0
        return 0;
3448
0
    }
3449
12
    Py_DECREF(Subscript_annotations);
3450
12
    PyObject *Starred_annotations = PyDict_New();
3451
12
    if (!Starred_annotations) return 0;
3452
12
    {
3453
12
        PyObject *type = state->expr_type;
3454
12
        Py_INCREF(type);
3455
12
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3456
12
        Py_DECREF(type);
3457
12
        if (!cond) {
3458
0
            Py_DECREF(Starred_annotations);
3459
0
            return 0;
3460
0
        }
3461
12
    }
3462
12
    {
3463
12
        PyObject *type = state->expr_context_type;
3464
12
        Py_INCREF(type);
3465
12
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3466
12
        Py_DECREF(type);
3467
12
        if (!cond) {
3468
0
            Py_DECREF(Starred_annotations);
3469
0
            return 0;
3470
0
        }
3471
12
    }
3472
12
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3473
12
                                  Starred_annotations) == 0;
3474
12
    if (!cond) {
3475
0
        Py_DECREF(Starred_annotations);
3476
0
        return 0;
3477
0
    }
3478
12
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3479
12
                                  Starred_annotations) == 0;
3480
12
    if (!cond) {
3481
0
        Py_DECREF(Starred_annotations);
3482
0
        return 0;
3483
0
    }
3484
12
    Py_DECREF(Starred_annotations);
3485
12
    PyObject *Name_annotations = PyDict_New();
3486
12
    if (!Name_annotations) return 0;
3487
12
    {
3488
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
3489
12
        Py_INCREF(type);
3490
12
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3491
12
        Py_DECREF(type);
3492
12
        if (!cond) {
3493
0
            Py_DECREF(Name_annotations);
3494
0
            return 0;
3495
0
        }
3496
12
    }
3497
12
    {
3498
12
        PyObject *type = state->expr_context_type;
3499
12
        Py_INCREF(type);
3500
12
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3501
12
        Py_DECREF(type);
3502
12
        if (!cond) {
3503
0
            Py_DECREF(Name_annotations);
3504
0
            return 0;
3505
0
        }
3506
12
    }
3507
12
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3508
12
                                  Name_annotations) == 0;
3509
12
    if (!cond) {
3510
0
        Py_DECREF(Name_annotations);
3511
0
        return 0;
3512
0
    }
3513
12
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3514
12
                                  Name_annotations) == 0;
3515
12
    if (!cond) {
3516
0
        Py_DECREF(Name_annotations);
3517
0
        return 0;
3518
0
    }
3519
12
    Py_DECREF(Name_annotations);
3520
12
    PyObject *List_annotations = PyDict_New();
3521
12
    if (!List_annotations) return 0;
3522
12
    {
3523
12
        PyObject *type = state->expr_type;
3524
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3525
12
        cond = type != NULL;
3526
12
        if (!cond) {
3527
0
            Py_DECREF(List_annotations);
3528
0
            return 0;
3529
0
        }
3530
12
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3531
12
        Py_DECREF(type);
3532
12
        if (!cond) {
3533
0
            Py_DECREF(List_annotations);
3534
0
            return 0;
3535
0
        }
3536
12
    }
3537
12
    {
3538
12
        PyObject *type = state->expr_context_type;
3539
12
        Py_INCREF(type);
3540
12
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3541
12
        Py_DECREF(type);
3542
12
        if (!cond) {
3543
0
            Py_DECREF(List_annotations);
3544
0
            return 0;
3545
0
        }
3546
12
    }
3547
12
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3548
12
                                  List_annotations) == 0;
3549
12
    if (!cond) {
3550
0
        Py_DECREF(List_annotations);
3551
0
        return 0;
3552
0
    }
3553
12
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3554
12
                                  List_annotations) == 0;
3555
12
    if (!cond) {
3556
0
        Py_DECREF(List_annotations);
3557
0
        return 0;
3558
0
    }
3559
12
    Py_DECREF(List_annotations);
3560
12
    PyObject *Tuple_annotations = PyDict_New();
3561
12
    if (!Tuple_annotations) return 0;
3562
12
    {
3563
12
        PyObject *type = state->expr_type;
3564
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3565
12
        cond = type != NULL;
3566
12
        if (!cond) {
3567
0
            Py_DECREF(Tuple_annotations);
3568
0
            return 0;
3569
0
        }
3570
12
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3571
12
        Py_DECREF(type);
3572
12
        if (!cond) {
3573
0
            Py_DECREF(Tuple_annotations);
3574
0
            return 0;
3575
0
        }
3576
12
    }
3577
12
    {
3578
12
        PyObject *type = state->expr_context_type;
3579
12
        Py_INCREF(type);
3580
12
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3581
12
        Py_DECREF(type);
3582
12
        if (!cond) {
3583
0
            Py_DECREF(Tuple_annotations);
3584
0
            return 0;
3585
0
        }
3586
12
    }
3587
12
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3588
12
                                  Tuple_annotations) == 0;
3589
12
    if (!cond) {
3590
0
        Py_DECREF(Tuple_annotations);
3591
0
        return 0;
3592
0
    }
3593
12
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3594
12
                                  Tuple_annotations) == 0;
3595
12
    if (!cond) {
3596
0
        Py_DECREF(Tuple_annotations);
3597
0
        return 0;
3598
0
    }
3599
12
    Py_DECREF(Tuple_annotations);
3600
12
    PyObject *Slice_annotations = PyDict_New();
3601
12
    if (!Slice_annotations) return 0;
3602
12
    {
3603
12
        PyObject *type = state->expr_type;
3604
12
        type = _Py_union_type_or(type, Py_None);
3605
12
        cond = type != NULL;
3606
12
        if (!cond) {
3607
0
            Py_DECREF(Slice_annotations);
3608
0
            return 0;
3609
0
        }
3610
12
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3611
12
        Py_DECREF(type);
3612
12
        if (!cond) {
3613
0
            Py_DECREF(Slice_annotations);
3614
0
            return 0;
3615
0
        }
3616
12
    }
3617
12
    {
3618
12
        PyObject *type = state->expr_type;
3619
12
        type = _Py_union_type_or(type, Py_None);
3620
12
        cond = type != NULL;
3621
12
        if (!cond) {
3622
0
            Py_DECREF(Slice_annotations);
3623
0
            return 0;
3624
0
        }
3625
12
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3626
12
        Py_DECREF(type);
3627
12
        if (!cond) {
3628
0
            Py_DECREF(Slice_annotations);
3629
0
            return 0;
3630
0
        }
3631
12
    }
3632
12
    {
3633
12
        PyObject *type = state->expr_type;
3634
12
        type = _Py_union_type_or(type, Py_None);
3635
12
        cond = type != NULL;
3636
12
        if (!cond) {
3637
0
            Py_DECREF(Slice_annotations);
3638
0
            return 0;
3639
0
        }
3640
12
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3641
12
        Py_DECREF(type);
3642
12
        if (!cond) {
3643
0
            Py_DECREF(Slice_annotations);
3644
0
            return 0;
3645
0
        }
3646
12
    }
3647
12
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3648
12
                                  Slice_annotations) == 0;
3649
12
    if (!cond) {
3650
0
        Py_DECREF(Slice_annotations);
3651
0
        return 0;
3652
0
    }
3653
12
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3654
12
                                  Slice_annotations) == 0;
3655
12
    if (!cond) {
3656
0
        Py_DECREF(Slice_annotations);
3657
0
        return 0;
3658
0
    }
3659
12
    Py_DECREF(Slice_annotations);
3660
12
    PyObject *Load_annotations = PyDict_New();
3661
12
    if (!Load_annotations) return 0;
3662
12
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3663
12
                                  Load_annotations) == 0;
3664
12
    if (!cond) {
3665
0
        Py_DECREF(Load_annotations);
3666
0
        return 0;
3667
0
    }
3668
12
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3669
12
                                  Load_annotations) == 0;
3670
12
    if (!cond) {
3671
0
        Py_DECREF(Load_annotations);
3672
0
        return 0;
3673
0
    }
3674
12
    Py_DECREF(Load_annotations);
3675
12
    PyObject *Store_annotations = PyDict_New();
3676
12
    if (!Store_annotations) return 0;
3677
12
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3678
12
                                  Store_annotations) == 0;
3679
12
    if (!cond) {
3680
0
        Py_DECREF(Store_annotations);
3681
0
        return 0;
3682
0
    }
3683
12
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3684
12
                                  Store_annotations) == 0;
3685
12
    if (!cond) {
3686
0
        Py_DECREF(Store_annotations);
3687
0
        return 0;
3688
0
    }
3689
12
    Py_DECREF(Store_annotations);
3690
12
    PyObject *Del_annotations = PyDict_New();
3691
12
    if (!Del_annotations) return 0;
3692
12
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3693
12
                                  Del_annotations) == 0;
3694
12
    if (!cond) {
3695
0
        Py_DECREF(Del_annotations);
3696
0
        return 0;
3697
0
    }
3698
12
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3699
12
                                  Del_annotations) == 0;
3700
12
    if (!cond) {
3701
0
        Py_DECREF(Del_annotations);
3702
0
        return 0;
3703
0
    }
3704
12
    Py_DECREF(Del_annotations);
3705
12
    PyObject *And_annotations = PyDict_New();
3706
12
    if (!And_annotations) return 0;
3707
12
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3708
12
                                  And_annotations) == 0;
3709
12
    if (!cond) {
3710
0
        Py_DECREF(And_annotations);
3711
0
        return 0;
3712
0
    }
3713
12
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3714
12
                                  And_annotations) == 0;
3715
12
    if (!cond) {
3716
0
        Py_DECREF(And_annotations);
3717
0
        return 0;
3718
0
    }
3719
12
    Py_DECREF(And_annotations);
3720
12
    PyObject *Or_annotations = PyDict_New();
3721
12
    if (!Or_annotations) return 0;
3722
12
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3723
12
                                  Or_annotations) == 0;
3724
12
    if (!cond) {
3725
0
        Py_DECREF(Or_annotations);
3726
0
        return 0;
3727
0
    }
3728
12
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3729
12
                                  Or_annotations) == 0;
3730
12
    if (!cond) {
3731
0
        Py_DECREF(Or_annotations);
3732
0
        return 0;
3733
0
    }
3734
12
    Py_DECREF(Or_annotations);
3735
12
    PyObject *Add_annotations = PyDict_New();
3736
12
    if (!Add_annotations) return 0;
3737
12
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3738
12
                                  Add_annotations) == 0;
3739
12
    if (!cond) {
3740
0
        Py_DECREF(Add_annotations);
3741
0
        return 0;
3742
0
    }
3743
12
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3744
12
                                  Add_annotations) == 0;
3745
12
    if (!cond) {
3746
0
        Py_DECREF(Add_annotations);
3747
0
        return 0;
3748
0
    }
3749
12
    Py_DECREF(Add_annotations);
3750
12
    PyObject *Sub_annotations = PyDict_New();
3751
12
    if (!Sub_annotations) return 0;
3752
12
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3753
12
                                  Sub_annotations) == 0;
3754
12
    if (!cond) {
3755
0
        Py_DECREF(Sub_annotations);
3756
0
        return 0;
3757
0
    }
3758
12
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3759
12
                                  Sub_annotations) == 0;
3760
12
    if (!cond) {
3761
0
        Py_DECREF(Sub_annotations);
3762
0
        return 0;
3763
0
    }
3764
12
    Py_DECREF(Sub_annotations);
3765
12
    PyObject *Mult_annotations = PyDict_New();
3766
12
    if (!Mult_annotations) return 0;
3767
12
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3768
12
                                  Mult_annotations) == 0;
3769
12
    if (!cond) {
3770
0
        Py_DECREF(Mult_annotations);
3771
0
        return 0;
3772
0
    }
3773
12
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3774
12
                                  Mult_annotations) == 0;
3775
12
    if (!cond) {
3776
0
        Py_DECREF(Mult_annotations);
3777
0
        return 0;
3778
0
    }
3779
12
    Py_DECREF(Mult_annotations);
3780
12
    PyObject *MatMult_annotations = PyDict_New();
3781
12
    if (!MatMult_annotations) return 0;
3782
12
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3783
12
                                  MatMult_annotations) == 0;
3784
12
    if (!cond) {
3785
0
        Py_DECREF(MatMult_annotations);
3786
0
        return 0;
3787
0
    }
3788
12
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3789
12
                                  MatMult_annotations) == 0;
3790
12
    if (!cond) {
3791
0
        Py_DECREF(MatMult_annotations);
3792
0
        return 0;
3793
0
    }
3794
12
    Py_DECREF(MatMult_annotations);
3795
12
    PyObject *Div_annotations = PyDict_New();
3796
12
    if (!Div_annotations) return 0;
3797
12
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3798
12
                                  Div_annotations) == 0;
3799
12
    if (!cond) {
3800
0
        Py_DECREF(Div_annotations);
3801
0
        return 0;
3802
0
    }
3803
12
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3804
12
                                  Div_annotations) == 0;
3805
12
    if (!cond) {
3806
0
        Py_DECREF(Div_annotations);
3807
0
        return 0;
3808
0
    }
3809
12
    Py_DECREF(Div_annotations);
3810
12
    PyObject *Mod_annotations = PyDict_New();
3811
12
    if (!Mod_annotations) return 0;
3812
12
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3813
12
                                  Mod_annotations) == 0;
3814
12
    if (!cond) {
3815
0
        Py_DECREF(Mod_annotations);
3816
0
        return 0;
3817
0
    }
3818
12
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3819
12
                                  Mod_annotations) == 0;
3820
12
    if (!cond) {
3821
0
        Py_DECREF(Mod_annotations);
3822
0
        return 0;
3823
0
    }
3824
12
    Py_DECREF(Mod_annotations);
3825
12
    PyObject *Pow_annotations = PyDict_New();
3826
12
    if (!Pow_annotations) return 0;
3827
12
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3828
12
                                  Pow_annotations) == 0;
3829
12
    if (!cond) {
3830
0
        Py_DECREF(Pow_annotations);
3831
0
        return 0;
3832
0
    }
3833
12
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3834
12
                                  Pow_annotations) == 0;
3835
12
    if (!cond) {
3836
0
        Py_DECREF(Pow_annotations);
3837
0
        return 0;
3838
0
    }
3839
12
    Py_DECREF(Pow_annotations);
3840
12
    PyObject *LShift_annotations = PyDict_New();
3841
12
    if (!LShift_annotations) return 0;
3842
12
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3843
12
                                  LShift_annotations) == 0;
3844
12
    if (!cond) {
3845
0
        Py_DECREF(LShift_annotations);
3846
0
        return 0;
3847
0
    }
3848
12
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3849
12
                                  LShift_annotations) == 0;
3850
12
    if (!cond) {
3851
0
        Py_DECREF(LShift_annotations);
3852
0
        return 0;
3853
0
    }
3854
12
    Py_DECREF(LShift_annotations);
3855
12
    PyObject *RShift_annotations = PyDict_New();
3856
12
    if (!RShift_annotations) return 0;
3857
12
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3858
12
                                  RShift_annotations) == 0;
3859
12
    if (!cond) {
3860
0
        Py_DECREF(RShift_annotations);
3861
0
        return 0;
3862
0
    }
3863
12
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3864
12
                                  RShift_annotations) == 0;
3865
12
    if (!cond) {
3866
0
        Py_DECREF(RShift_annotations);
3867
0
        return 0;
3868
0
    }
3869
12
    Py_DECREF(RShift_annotations);
3870
12
    PyObject *BitOr_annotations = PyDict_New();
3871
12
    if (!BitOr_annotations) return 0;
3872
12
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3873
12
                                  BitOr_annotations) == 0;
3874
12
    if (!cond) {
3875
0
        Py_DECREF(BitOr_annotations);
3876
0
        return 0;
3877
0
    }
3878
12
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3879
12
                                  BitOr_annotations) == 0;
3880
12
    if (!cond) {
3881
0
        Py_DECREF(BitOr_annotations);
3882
0
        return 0;
3883
0
    }
3884
12
    Py_DECREF(BitOr_annotations);
3885
12
    PyObject *BitXor_annotations = PyDict_New();
3886
12
    if (!BitXor_annotations) return 0;
3887
12
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3888
12
                                  BitXor_annotations) == 0;
3889
12
    if (!cond) {
3890
0
        Py_DECREF(BitXor_annotations);
3891
0
        return 0;
3892
0
    }
3893
12
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3894
12
                                  BitXor_annotations) == 0;
3895
12
    if (!cond) {
3896
0
        Py_DECREF(BitXor_annotations);
3897
0
        return 0;
3898
0
    }
3899
12
    Py_DECREF(BitXor_annotations);
3900
12
    PyObject *BitAnd_annotations = PyDict_New();
3901
12
    if (!BitAnd_annotations) return 0;
3902
12
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3903
12
                                  BitAnd_annotations) == 0;
3904
12
    if (!cond) {
3905
0
        Py_DECREF(BitAnd_annotations);
3906
0
        return 0;
3907
0
    }
3908
12
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3909
12
                                  BitAnd_annotations) == 0;
3910
12
    if (!cond) {
3911
0
        Py_DECREF(BitAnd_annotations);
3912
0
        return 0;
3913
0
    }
3914
12
    Py_DECREF(BitAnd_annotations);
3915
12
    PyObject *FloorDiv_annotations = PyDict_New();
3916
12
    if (!FloorDiv_annotations) return 0;
3917
12
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3918
12
                                  FloorDiv_annotations) == 0;
3919
12
    if (!cond) {
3920
0
        Py_DECREF(FloorDiv_annotations);
3921
0
        return 0;
3922
0
    }
3923
12
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3924
12
                                  FloorDiv_annotations) == 0;
3925
12
    if (!cond) {
3926
0
        Py_DECREF(FloorDiv_annotations);
3927
0
        return 0;
3928
0
    }
3929
12
    Py_DECREF(FloorDiv_annotations);
3930
12
    PyObject *Invert_annotations = PyDict_New();
3931
12
    if (!Invert_annotations) return 0;
3932
12
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3933
12
                                  Invert_annotations) == 0;
3934
12
    if (!cond) {
3935
0
        Py_DECREF(Invert_annotations);
3936
0
        return 0;
3937
0
    }
3938
12
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3939
12
                                  Invert_annotations) == 0;
3940
12
    if (!cond) {
3941
0
        Py_DECREF(Invert_annotations);
3942
0
        return 0;
3943
0
    }
3944
12
    Py_DECREF(Invert_annotations);
3945
12
    PyObject *Not_annotations = PyDict_New();
3946
12
    if (!Not_annotations) return 0;
3947
12
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3948
12
                                  Not_annotations) == 0;
3949
12
    if (!cond) {
3950
0
        Py_DECREF(Not_annotations);
3951
0
        return 0;
3952
0
    }
3953
12
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3954
12
                                  Not_annotations) == 0;
3955
12
    if (!cond) {
3956
0
        Py_DECREF(Not_annotations);
3957
0
        return 0;
3958
0
    }
3959
12
    Py_DECREF(Not_annotations);
3960
12
    PyObject *UAdd_annotations = PyDict_New();
3961
12
    if (!UAdd_annotations) return 0;
3962
12
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3963
12
                                  UAdd_annotations) == 0;
3964
12
    if (!cond) {
3965
0
        Py_DECREF(UAdd_annotations);
3966
0
        return 0;
3967
0
    }
3968
12
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
3969
12
                                  UAdd_annotations) == 0;
3970
12
    if (!cond) {
3971
0
        Py_DECREF(UAdd_annotations);
3972
0
        return 0;
3973
0
    }
3974
12
    Py_DECREF(UAdd_annotations);
3975
12
    PyObject *USub_annotations = PyDict_New();
3976
12
    if (!USub_annotations) return 0;
3977
12
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
3978
12
                                  USub_annotations) == 0;
3979
12
    if (!cond) {
3980
0
        Py_DECREF(USub_annotations);
3981
0
        return 0;
3982
0
    }
3983
12
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
3984
12
                                  USub_annotations) == 0;
3985
12
    if (!cond) {
3986
0
        Py_DECREF(USub_annotations);
3987
0
        return 0;
3988
0
    }
3989
12
    Py_DECREF(USub_annotations);
3990
12
    PyObject *Eq_annotations = PyDict_New();
3991
12
    if (!Eq_annotations) return 0;
3992
12
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
3993
12
                                  Eq_annotations) == 0;
3994
12
    if (!cond) {
3995
0
        Py_DECREF(Eq_annotations);
3996
0
        return 0;
3997
0
    }
3998
12
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
3999
12
                                  Eq_annotations) == 0;
4000
12
    if (!cond) {
4001
0
        Py_DECREF(Eq_annotations);
4002
0
        return 0;
4003
0
    }
4004
12
    Py_DECREF(Eq_annotations);
4005
12
    PyObject *NotEq_annotations = PyDict_New();
4006
12
    if (!NotEq_annotations) return 0;
4007
12
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4008
12
                                  NotEq_annotations) == 0;
4009
12
    if (!cond) {
4010
0
        Py_DECREF(NotEq_annotations);
4011
0
        return 0;
4012
0
    }
4013
12
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4014
12
                                  NotEq_annotations) == 0;
4015
12
    if (!cond) {
4016
0
        Py_DECREF(NotEq_annotations);
4017
0
        return 0;
4018
0
    }
4019
12
    Py_DECREF(NotEq_annotations);
4020
12
    PyObject *Lt_annotations = PyDict_New();
4021
12
    if (!Lt_annotations) return 0;
4022
12
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4023
12
                                  Lt_annotations) == 0;
4024
12
    if (!cond) {
4025
0
        Py_DECREF(Lt_annotations);
4026
0
        return 0;
4027
0
    }
4028
12
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4029
12
                                  Lt_annotations) == 0;
4030
12
    if (!cond) {
4031
0
        Py_DECREF(Lt_annotations);
4032
0
        return 0;
4033
0
    }
4034
12
    Py_DECREF(Lt_annotations);
4035
12
    PyObject *LtE_annotations = PyDict_New();
4036
12
    if (!LtE_annotations) return 0;
4037
12
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4038
12
                                  LtE_annotations) == 0;
4039
12
    if (!cond) {
4040
0
        Py_DECREF(LtE_annotations);
4041
0
        return 0;
4042
0
    }
4043
12
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4044
12
                                  LtE_annotations) == 0;
4045
12
    if (!cond) {
4046
0
        Py_DECREF(LtE_annotations);
4047
0
        return 0;
4048
0
    }
4049
12
    Py_DECREF(LtE_annotations);
4050
12
    PyObject *Gt_annotations = PyDict_New();
4051
12
    if (!Gt_annotations) return 0;
4052
12
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4053
12
                                  Gt_annotations) == 0;
4054
12
    if (!cond) {
4055
0
        Py_DECREF(Gt_annotations);
4056
0
        return 0;
4057
0
    }
4058
12
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4059
12
                                  Gt_annotations) == 0;
4060
12
    if (!cond) {
4061
0
        Py_DECREF(Gt_annotations);
4062
0
        return 0;
4063
0
    }
4064
12
    Py_DECREF(Gt_annotations);
4065
12
    PyObject *GtE_annotations = PyDict_New();
4066
12
    if (!GtE_annotations) return 0;
4067
12
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4068
12
                                  GtE_annotations) == 0;
4069
12
    if (!cond) {
4070
0
        Py_DECREF(GtE_annotations);
4071
0
        return 0;
4072
0
    }
4073
12
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4074
12
                                  GtE_annotations) == 0;
4075
12
    if (!cond) {
4076
0
        Py_DECREF(GtE_annotations);
4077
0
        return 0;
4078
0
    }
4079
12
    Py_DECREF(GtE_annotations);
4080
12
    PyObject *Is_annotations = PyDict_New();
4081
12
    if (!Is_annotations) return 0;
4082
12
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4083
12
                                  Is_annotations) == 0;
4084
12
    if (!cond) {
4085
0
        Py_DECREF(Is_annotations);
4086
0
        return 0;
4087
0
    }
4088
12
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4089
12
                                  Is_annotations) == 0;
4090
12
    if (!cond) {
4091
0
        Py_DECREF(Is_annotations);
4092
0
        return 0;
4093
0
    }
4094
12
    Py_DECREF(Is_annotations);
4095
12
    PyObject *IsNot_annotations = PyDict_New();
4096
12
    if (!IsNot_annotations) return 0;
4097
12
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4098
12
                                  IsNot_annotations) == 0;
4099
12
    if (!cond) {
4100
0
        Py_DECREF(IsNot_annotations);
4101
0
        return 0;
4102
0
    }
4103
12
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4104
12
                                  IsNot_annotations) == 0;
4105
12
    if (!cond) {
4106
0
        Py_DECREF(IsNot_annotations);
4107
0
        return 0;
4108
0
    }
4109
12
    Py_DECREF(IsNot_annotations);
4110
12
    PyObject *In_annotations = PyDict_New();
4111
12
    if (!In_annotations) return 0;
4112
12
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4113
12
                                  In_annotations) == 0;
4114
12
    if (!cond) {
4115
0
        Py_DECREF(In_annotations);
4116
0
        return 0;
4117
0
    }
4118
12
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4119
12
                                  In_annotations) == 0;
4120
12
    if (!cond) {
4121
0
        Py_DECREF(In_annotations);
4122
0
        return 0;
4123
0
    }
4124
12
    Py_DECREF(In_annotations);
4125
12
    PyObject *NotIn_annotations = PyDict_New();
4126
12
    if (!NotIn_annotations) return 0;
4127
12
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4128
12
                                  NotIn_annotations) == 0;
4129
12
    if (!cond) {
4130
0
        Py_DECREF(NotIn_annotations);
4131
0
        return 0;
4132
0
    }
4133
12
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4134
12
                                  NotIn_annotations) == 0;
4135
12
    if (!cond) {
4136
0
        Py_DECREF(NotIn_annotations);
4137
0
        return 0;
4138
0
    }
4139
12
    Py_DECREF(NotIn_annotations);
4140
12
    PyObject *comprehension_annotations = PyDict_New();
4141
12
    if (!comprehension_annotations) return 0;
4142
12
    {
4143
12
        PyObject *type = state->expr_type;
4144
12
        Py_INCREF(type);
4145
12
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4146
12
                                    == 0;
4147
12
        Py_DECREF(type);
4148
12
        if (!cond) {
4149
0
            Py_DECREF(comprehension_annotations);
4150
0
            return 0;
4151
0
        }
4152
12
    }
4153
12
    {
4154
12
        PyObject *type = state->expr_type;
4155
12
        Py_INCREF(type);
4156
12
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4157
12
                                    0;
4158
12
        Py_DECREF(type);
4159
12
        if (!cond) {
4160
0
            Py_DECREF(comprehension_annotations);
4161
0
            return 0;
4162
0
        }
4163
12
    }
4164
12
    {
4165
12
        PyObject *type = state->expr_type;
4166
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4167
12
        cond = type != NULL;
4168
12
        if (!cond) {
4169
0
            Py_DECREF(comprehension_annotations);
4170
0
            return 0;
4171
0
        }
4172
12
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4173
12
                                    0;
4174
12
        Py_DECREF(type);
4175
12
        if (!cond) {
4176
0
            Py_DECREF(comprehension_annotations);
4177
0
            return 0;
4178
0
        }
4179
12
    }
4180
12
    {
4181
12
        PyObject *type = (PyObject *)&PyLong_Type;
4182
12
        Py_INCREF(type);
4183
12
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4184
12
                                    type) == 0;
4185
12
        Py_DECREF(type);
4186
12
        if (!cond) {
4187
0
            Py_DECREF(comprehension_annotations);
4188
0
            return 0;
4189
0
        }
4190
12
    }
4191
12
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4192
12
                                  comprehension_annotations) == 0;
4193
12
    if (!cond) {
4194
0
        Py_DECREF(comprehension_annotations);
4195
0
        return 0;
4196
0
    }
4197
12
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4198
12
                                  comprehension_annotations) == 0;
4199
12
    if (!cond) {
4200
0
        Py_DECREF(comprehension_annotations);
4201
0
        return 0;
4202
0
    }
4203
12
    Py_DECREF(comprehension_annotations);
4204
12
    PyObject *ExceptHandler_annotations = PyDict_New();
4205
12
    if (!ExceptHandler_annotations) return 0;
4206
12
    {
4207
12
        PyObject *type = state->expr_type;
4208
12
        type = _Py_union_type_or(type, Py_None);
4209
12
        cond = type != NULL;
4210
12
        if (!cond) {
4211
0
            Py_DECREF(ExceptHandler_annotations);
4212
0
            return 0;
4213
0
        }
4214
12
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4215
12
                                    0;
4216
12
        Py_DECREF(type);
4217
12
        if (!cond) {
4218
0
            Py_DECREF(ExceptHandler_annotations);
4219
0
            return 0;
4220
0
        }
4221
12
    }
4222
12
    {
4223
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4224
12
        type = _Py_union_type_or(type, Py_None);
4225
12
        cond = type != NULL;
4226
12
        if (!cond) {
4227
0
            Py_DECREF(ExceptHandler_annotations);
4228
0
            return 0;
4229
0
        }
4230
12
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4231
12
                                    0;
4232
12
        Py_DECREF(type);
4233
12
        if (!cond) {
4234
0
            Py_DECREF(ExceptHandler_annotations);
4235
0
            return 0;
4236
0
        }
4237
12
    }
4238
12
    {
4239
12
        PyObject *type = state->stmt_type;
4240
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4241
12
        cond = type != NULL;
4242
12
        if (!cond) {
4243
0
            Py_DECREF(ExceptHandler_annotations);
4244
0
            return 0;
4245
0
        }
4246
12
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4247
12
                                    0;
4248
12
        Py_DECREF(type);
4249
12
        if (!cond) {
4250
0
            Py_DECREF(ExceptHandler_annotations);
4251
0
            return 0;
4252
0
        }
4253
12
    }
4254
12
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4255
12
                                  ExceptHandler_annotations) == 0;
4256
12
    if (!cond) {
4257
0
        Py_DECREF(ExceptHandler_annotations);
4258
0
        return 0;
4259
0
    }
4260
12
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4261
12
                                  ExceptHandler_annotations) == 0;
4262
12
    if (!cond) {
4263
0
        Py_DECREF(ExceptHandler_annotations);
4264
0
        return 0;
4265
0
    }
4266
12
    Py_DECREF(ExceptHandler_annotations);
4267
12
    PyObject *arguments_annotations = PyDict_New();
4268
12
    if (!arguments_annotations) return 0;
4269
12
    {
4270
12
        PyObject *type = state->arg_type;
4271
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4272
12
        cond = type != NULL;
4273
12
        if (!cond) {
4274
0
            Py_DECREF(arguments_annotations);
4275
0
            return 0;
4276
0
        }
4277
12
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4278
12
                                    == 0;
4279
12
        Py_DECREF(type);
4280
12
        if (!cond) {
4281
0
            Py_DECREF(arguments_annotations);
4282
0
            return 0;
4283
0
        }
4284
12
    }
4285
12
    {
4286
12
        PyObject *type = state->arg_type;
4287
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4288
12
        cond = type != NULL;
4289
12
        if (!cond) {
4290
0
            Py_DECREF(arguments_annotations);
4291
0
            return 0;
4292
0
        }
4293
12
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4294
12
        Py_DECREF(type);
4295
12
        if (!cond) {
4296
0
            Py_DECREF(arguments_annotations);
4297
0
            return 0;
4298
0
        }
4299
12
    }
4300
12
    {
4301
12
        PyObject *type = state->arg_type;
4302
12
        type = _Py_union_type_or(type, Py_None);
4303
12
        cond = type != NULL;
4304
12
        if (!cond) {
4305
0
            Py_DECREF(arguments_annotations);
4306
0
            return 0;
4307
0
        }
4308
12
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4309
12
        Py_DECREF(type);
4310
12
        if (!cond) {
4311
0
            Py_DECREF(arguments_annotations);
4312
0
            return 0;
4313
0
        }
4314
12
    }
4315
12
    {
4316
12
        PyObject *type = state->arg_type;
4317
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4318
12
        cond = type != NULL;
4319
12
        if (!cond) {
4320
0
            Py_DECREF(arguments_annotations);
4321
0
            return 0;
4322
0
        }
4323
12
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4324
12
                                    == 0;
4325
12
        Py_DECREF(type);
4326
12
        if (!cond) {
4327
0
            Py_DECREF(arguments_annotations);
4328
0
            return 0;
4329
0
        }
4330
12
    }
4331
12
    {
4332
12
        PyObject *type = state->expr_type;
4333
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4334
12
        cond = type != NULL;
4335
12
        if (!cond) {
4336
0
            Py_DECREF(arguments_annotations);
4337
0
            return 0;
4338
0
        }
4339
12
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4340
12
                                    == 0;
4341
12
        Py_DECREF(type);
4342
12
        if (!cond) {
4343
0
            Py_DECREF(arguments_annotations);
4344
0
            return 0;
4345
0
        }
4346
12
    }
4347
12
    {
4348
12
        PyObject *type = state->arg_type;
4349
12
        type = _Py_union_type_or(type, Py_None);
4350
12
        cond = type != NULL;
4351
12
        if (!cond) {
4352
0
            Py_DECREF(arguments_annotations);
4353
0
            return 0;
4354
0
        }
4355
12
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4356
12
        Py_DECREF(type);
4357
12
        if (!cond) {
4358
0
            Py_DECREF(arguments_annotations);
4359
0
            return 0;
4360
0
        }
4361
12
    }
4362
12
    {
4363
12
        PyObject *type = state->expr_type;
4364
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4365
12
        cond = type != NULL;
4366
12
        if (!cond) {
4367
0
            Py_DECREF(arguments_annotations);
4368
0
            return 0;
4369
0
        }
4370
12
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4371
12
                                    0;
4372
12
        Py_DECREF(type);
4373
12
        if (!cond) {
4374
0
            Py_DECREF(arguments_annotations);
4375
0
            return 0;
4376
0
        }
4377
12
    }
4378
12
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4379
12
                                  arguments_annotations) == 0;
4380
12
    if (!cond) {
4381
0
        Py_DECREF(arguments_annotations);
4382
0
        return 0;
4383
0
    }
4384
12
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4385
12
                                  arguments_annotations) == 0;
4386
12
    if (!cond) {
4387
0
        Py_DECREF(arguments_annotations);
4388
0
        return 0;
4389
0
    }
4390
12
    Py_DECREF(arguments_annotations);
4391
12
    PyObject *arg_annotations = PyDict_New();
4392
12
    if (!arg_annotations) return 0;
4393
12
    {
4394
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4395
12
        Py_INCREF(type);
4396
12
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4397
12
        Py_DECREF(type);
4398
12
        if (!cond) {
4399
0
            Py_DECREF(arg_annotations);
4400
0
            return 0;
4401
0
        }
4402
12
    }
4403
12
    {
4404
12
        PyObject *type = state->expr_type;
4405
12
        type = _Py_union_type_or(type, Py_None);
4406
12
        cond = type != NULL;
4407
12
        if (!cond) {
4408
0
            Py_DECREF(arg_annotations);
4409
0
            return 0;
4410
0
        }
4411
12
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4412
12
        Py_DECREF(type);
4413
12
        if (!cond) {
4414
0
            Py_DECREF(arg_annotations);
4415
0
            return 0;
4416
0
        }
4417
12
    }
4418
12
    {
4419
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4420
12
        type = _Py_union_type_or(type, Py_None);
4421
12
        cond = type != NULL;
4422
12
        if (!cond) {
4423
0
            Py_DECREF(arg_annotations);
4424
0
            return 0;
4425
0
        }
4426
12
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4427
12
        Py_DECREF(type);
4428
12
        if (!cond) {
4429
0
            Py_DECREF(arg_annotations);
4430
0
            return 0;
4431
0
        }
4432
12
    }
4433
12
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4434
12
                                  arg_annotations) == 0;
4435
12
    if (!cond) {
4436
0
        Py_DECREF(arg_annotations);
4437
0
        return 0;
4438
0
    }
4439
12
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4440
12
                                  arg_annotations) == 0;
4441
12
    if (!cond) {
4442
0
        Py_DECREF(arg_annotations);
4443
0
        return 0;
4444
0
    }
4445
12
    Py_DECREF(arg_annotations);
4446
12
    PyObject *keyword_annotations = PyDict_New();
4447
12
    if (!keyword_annotations) return 0;
4448
12
    {
4449
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4450
12
        type = _Py_union_type_or(type, Py_None);
4451
12
        cond = type != NULL;
4452
12
        if (!cond) {
4453
0
            Py_DECREF(keyword_annotations);
4454
0
            return 0;
4455
0
        }
4456
12
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4457
12
        Py_DECREF(type);
4458
12
        if (!cond) {
4459
0
            Py_DECREF(keyword_annotations);
4460
0
            return 0;
4461
0
        }
4462
12
    }
4463
12
    {
4464
12
        PyObject *type = state->expr_type;
4465
12
        Py_INCREF(type);
4466
12
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4467
12
        Py_DECREF(type);
4468
12
        if (!cond) {
4469
0
            Py_DECREF(keyword_annotations);
4470
0
            return 0;
4471
0
        }
4472
12
    }
4473
12
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4474
12
                                  keyword_annotations) == 0;
4475
12
    if (!cond) {
4476
0
        Py_DECREF(keyword_annotations);
4477
0
        return 0;
4478
0
    }
4479
12
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4480
12
                                  keyword_annotations) == 0;
4481
12
    if (!cond) {
4482
0
        Py_DECREF(keyword_annotations);
4483
0
        return 0;
4484
0
    }
4485
12
    Py_DECREF(keyword_annotations);
4486
12
    PyObject *alias_annotations = PyDict_New();
4487
12
    if (!alias_annotations) return 0;
4488
12
    {
4489
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4490
12
        Py_INCREF(type);
4491
12
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4492
12
        Py_DECREF(type);
4493
12
        if (!cond) {
4494
0
            Py_DECREF(alias_annotations);
4495
0
            return 0;
4496
0
        }
4497
12
    }
4498
12
    {
4499
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4500
12
        type = _Py_union_type_or(type, Py_None);
4501
12
        cond = type != NULL;
4502
12
        if (!cond) {
4503
0
            Py_DECREF(alias_annotations);
4504
0
            return 0;
4505
0
        }
4506
12
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4507
12
        Py_DECREF(type);
4508
12
        if (!cond) {
4509
0
            Py_DECREF(alias_annotations);
4510
0
            return 0;
4511
0
        }
4512
12
    }
4513
12
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4514
12
                                  alias_annotations) == 0;
4515
12
    if (!cond) {
4516
0
        Py_DECREF(alias_annotations);
4517
0
        return 0;
4518
0
    }
4519
12
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4520
12
                                  alias_annotations) == 0;
4521
12
    if (!cond) {
4522
0
        Py_DECREF(alias_annotations);
4523
0
        return 0;
4524
0
    }
4525
12
    Py_DECREF(alias_annotations);
4526
12
    PyObject *withitem_annotations = PyDict_New();
4527
12
    if (!withitem_annotations) return 0;
4528
12
    {
4529
12
        PyObject *type = state->expr_type;
4530
12
        Py_INCREF(type);
4531
12
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4532
12
                                    == 0;
4533
12
        Py_DECREF(type);
4534
12
        if (!cond) {
4535
0
            Py_DECREF(withitem_annotations);
4536
0
            return 0;
4537
0
        }
4538
12
    }
4539
12
    {
4540
12
        PyObject *type = state->expr_type;
4541
12
        type = _Py_union_type_or(type, Py_None);
4542
12
        cond = type != NULL;
4543
12
        if (!cond) {
4544
0
            Py_DECREF(withitem_annotations);
4545
0
            return 0;
4546
0
        }
4547
12
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4548
12
                                    type) == 0;
4549
12
        Py_DECREF(type);
4550
12
        if (!cond) {
4551
0
            Py_DECREF(withitem_annotations);
4552
0
            return 0;
4553
0
        }
4554
12
    }
4555
12
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4556
12
                                  withitem_annotations) == 0;
4557
12
    if (!cond) {
4558
0
        Py_DECREF(withitem_annotations);
4559
0
        return 0;
4560
0
    }
4561
12
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4562
12
                                  withitem_annotations) == 0;
4563
12
    if (!cond) {
4564
0
        Py_DECREF(withitem_annotations);
4565
0
        return 0;
4566
0
    }
4567
12
    Py_DECREF(withitem_annotations);
4568
12
    PyObject *match_case_annotations = PyDict_New();
4569
12
    if (!match_case_annotations) return 0;
4570
12
    {
4571
12
        PyObject *type = state->pattern_type;
4572
12
        Py_INCREF(type);
4573
12
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4574
12
                                    0;
4575
12
        Py_DECREF(type);
4576
12
        if (!cond) {
4577
0
            Py_DECREF(match_case_annotations);
4578
0
            return 0;
4579
0
        }
4580
12
    }
4581
12
    {
4582
12
        PyObject *type = state->expr_type;
4583
12
        type = _Py_union_type_or(type, Py_None);
4584
12
        cond = type != NULL;
4585
12
        if (!cond) {
4586
0
            Py_DECREF(match_case_annotations);
4587
0
            return 0;
4588
0
        }
4589
12
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4590
12
        Py_DECREF(type);
4591
12
        if (!cond) {
4592
0
            Py_DECREF(match_case_annotations);
4593
0
            return 0;
4594
0
        }
4595
12
    }
4596
12
    {
4597
12
        PyObject *type = state->stmt_type;
4598
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4599
12
        cond = type != NULL;
4600
12
        if (!cond) {
4601
0
            Py_DECREF(match_case_annotations);
4602
0
            return 0;
4603
0
        }
4604
12
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4605
12
        Py_DECREF(type);
4606
12
        if (!cond) {
4607
0
            Py_DECREF(match_case_annotations);
4608
0
            return 0;
4609
0
        }
4610
12
    }
4611
12
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4612
12
                                  match_case_annotations) == 0;
4613
12
    if (!cond) {
4614
0
        Py_DECREF(match_case_annotations);
4615
0
        return 0;
4616
0
    }
4617
12
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4618
12
                                  match_case_annotations) == 0;
4619
12
    if (!cond) {
4620
0
        Py_DECREF(match_case_annotations);
4621
0
        return 0;
4622
0
    }
4623
12
    Py_DECREF(match_case_annotations);
4624
12
    PyObject *MatchValue_annotations = PyDict_New();
4625
12
    if (!MatchValue_annotations) return 0;
4626
12
    {
4627
12
        PyObject *type = state->expr_type;
4628
12
        Py_INCREF(type);
4629
12
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4630
12
        Py_DECREF(type);
4631
12
        if (!cond) {
4632
0
            Py_DECREF(MatchValue_annotations);
4633
0
            return 0;
4634
0
        }
4635
12
    }
4636
12
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4637
12
                                  MatchValue_annotations) == 0;
4638
12
    if (!cond) {
4639
0
        Py_DECREF(MatchValue_annotations);
4640
0
        return 0;
4641
0
    }
4642
12
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4643
12
                                  MatchValue_annotations) == 0;
4644
12
    if (!cond) {
4645
0
        Py_DECREF(MatchValue_annotations);
4646
0
        return 0;
4647
0
    }
4648
12
    Py_DECREF(MatchValue_annotations);
4649
12
    PyObject *MatchSingleton_annotations = PyDict_New();
4650
12
    if (!MatchSingleton_annotations) return 0;
4651
12
    {
4652
12
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4653
12
        Py_INCREF(type);
4654
12
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4655
12
                                    == 0;
4656
12
        Py_DECREF(type);
4657
12
        if (!cond) {
4658
0
            Py_DECREF(MatchSingleton_annotations);
4659
0
            return 0;
4660
0
        }
4661
12
    }
4662
12
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4663
12
                                  MatchSingleton_annotations) == 0;
4664
12
    if (!cond) {
4665
0
        Py_DECREF(MatchSingleton_annotations);
4666
0
        return 0;
4667
0
    }
4668
12
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4669
12
                                  "__annotations__",
4670
12
                                  MatchSingleton_annotations) == 0;
4671
12
    if (!cond) {
4672
0
        Py_DECREF(MatchSingleton_annotations);
4673
0
        return 0;
4674
0
    }
4675
12
    Py_DECREF(MatchSingleton_annotations);
4676
12
    PyObject *MatchSequence_annotations = PyDict_New();
4677
12
    if (!MatchSequence_annotations) return 0;
4678
12
    {
4679
12
        PyObject *type = state->pattern_type;
4680
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4681
12
        cond = type != NULL;
4682
12
        if (!cond) {
4683
0
            Py_DECREF(MatchSequence_annotations);
4684
0
            return 0;
4685
0
        }
4686
12
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4687
12
                                    type) == 0;
4688
12
        Py_DECREF(type);
4689
12
        if (!cond) {
4690
0
            Py_DECREF(MatchSequence_annotations);
4691
0
            return 0;
4692
0
        }
4693
12
    }
4694
12
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4695
12
                                  MatchSequence_annotations) == 0;
4696
12
    if (!cond) {
4697
0
        Py_DECREF(MatchSequence_annotations);
4698
0
        return 0;
4699
0
    }
4700
12
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4701
12
                                  MatchSequence_annotations) == 0;
4702
12
    if (!cond) {
4703
0
        Py_DECREF(MatchSequence_annotations);
4704
0
        return 0;
4705
0
    }
4706
12
    Py_DECREF(MatchSequence_annotations);
4707
12
    PyObject *MatchMapping_annotations = PyDict_New();
4708
12
    if (!MatchMapping_annotations) return 0;
4709
12
    {
4710
12
        PyObject *type = state->expr_type;
4711
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4712
12
        cond = type != NULL;
4713
12
        if (!cond) {
4714
0
            Py_DECREF(MatchMapping_annotations);
4715
0
            return 0;
4716
0
        }
4717
12
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4718
12
                                    0;
4719
12
        Py_DECREF(type);
4720
12
        if (!cond) {
4721
0
            Py_DECREF(MatchMapping_annotations);
4722
0
            return 0;
4723
0
        }
4724
12
    }
4725
12
    {
4726
12
        PyObject *type = state->pattern_type;
4727
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4728
12
        cond = type != NULL;
4729
12
        if (!cond) {
4730
0
            Py_DECREF(MatchMapping_annotations);
4731
0
            return 0;
4732
0
        }
4733
12
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4734
12
                                    == 0;
4735
12
        Py_DECREF(type);
4736
12
        if (!cond) {
4737
0
            Py_DECREF(MatchMapping_annotations);
4738
0
            return 0;
4739
0
        }
4740
12
    }
4741
12
    {
4742
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4743
12
        type = _Py_union_type_or(type, Py_None);
4744
12
        cond = type != NULL;
4745
12
        if (!cond) {
4746
0
            Py_DECREF(MatchMapping_annotations);
4747
0
            return 0;
4748
0
        }
4749
12
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4750
12
                                    0;
4751
12
        Py_DECREF(type);
4752
12
        if (!cond) {
4753
0
            Py_DECREF(MatchMapping_annotations);
4754
0
            return 0;
4755
0
        }
4756
12
    }
4757
12
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4758
12
                                  MatchMapping_annotations) == 0;
4759
12
    if (!cond) {
4760
0
        Py_DECREF(MatchMapping_annotations);
4761
0
        return 0;
4762
0
    }
4763
12
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4764
12
                                  MatchMapping_annotations) == 0;
4765
12
    if (!cond) {
4766
0
        Py_DECREF(MatchMapping_annotations);
4767
0
        return 0;
4768
0
    }
4769
12
    Py_DECREF(MatchMapping_annotations);
4770
12
    PyObject *MatchClass_annotations = PyDict_New();
4771
12
    if (!MatchClass_annotations) return 0;
4772
12
    {
4773
12
        PyObject *type = state->expr_type;
4774
12
        Py_INCREF(type);
4775
12
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4776
12
        Py_DECREF(type);
4777
12
        if (!cond) {
4778
0
            Py_DECREF(MatchClass_annotations);
4779
0
            return 0;
4780
0
        }
4781
12
    }
4782
12
    {
4783
12
        PyObject *type = state->pattern_type;
4784
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4785
12
        cond = type != NULL;
4786
12
        if (!cond) {
4787
0
            Py_DECREF(MatchClass_annotations);
4788
0
            return 0;
4789
0
        }
4790
12
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4791
12
                                    == 0;
4792
12
        Py_DECREF(type);
4793
12
        if (!cond) {
4794
0
            Py_DECREF(MatchClass_annotations);
4795
0
            return 0;
4796
0
        }
4797
12
    }
4798
12
    {
4799
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4800
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4801
12
        cond = type != NULL;
4802
12
        if (!cond) {
4803
0
            Py_DECREF(MatchClass_annotations);
4804
0
            return 0;
4805
0
        }
4806
12
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4807
12
                                    == 0;
4808
12
        Py_DECREF(type);
4809
12
        if (!cond) {
4810
0
            Py_DECREF(MatchClass_annotations);
4811
0
            return 0;
4812
0
        }
4813
12
    }
4814
12
    {
4815
12
        PyObject *type = state->pattern_type;
4816
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4817
12
        cond = type != NULL;
4818
12
        if (!cond) {
4819
0
            Py_DECREF(MatchClass_annotations);
4820
0
            return 0;
4821
0
        }
4822
12
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4823
12
                                    type) == 0;
4824
12
        Py_DECREF(type);
4825
12
        if (!cond) {
4826
0
            Py_DECREF(MatchClass_annotations);
4827
0
            return 0;
4828
0
        }
4829
12
    }
4830
12
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4831
12
                                  MatchClass_annotations) == 0;
4832
12
    if (!cond) {
4833
0
        Py_DECREF(MatchClass_annotations);
4834
0
        return 0;
4835
0
    }
4836
12
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4837
12
                                  MatchClass_annotations) == 0;
4838
12
    if (!cond) {
4839
0
        Py_DECREF(MatchClass_annotations);
4840
0
        return 0;
4841
0
    }
4842
12
    Py_DECREF(MatchClass_annotations);
4843
12
    PyObject *MatchStar_annotations = PyDict_New();
4844
12
    if (!MatchStar_annotations) return 0;
4845
12
    {
4846
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4847
12
        type = _Py_union_type_or(type, Py_None);
4848
12
        cond = type != NULL;
4849
12
        if (!cond) {
4850
0
            Py_DECREF(MatchStar_annotations);
4851
0
            return 0;
4852
0
        }
4853
12
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4854
12
        Py_DECREF(type);
4855
12
        if (!cond) {
4856
0
            Py_DECREF(MatchStar_annotations);
4857
0
            return 0;
4858
0
        }
4859
12
    }
4860
12
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4861
12
                                  MatchStar_annotations) == 0;
4862
12
    if (!cond) {
4863
0
        Py_DECREF(MatchStar_annotations);
4864
0
        return 0;
4865
0
    }
4866
12
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4867
12
                                  MatchStar_annotations) == 0;
4868
12
    if (!cond) {
4869
0
        Py_DECREF(MatchStar_annotations);
4870
0
        return 0;
4871
0
    }
4872
12
    Py_DECREF(MatchStar_annotations);
4873
12
    PyObject *MatchAs_annotations = PyDict_New();
4874
12
    if (!MatchAs_annotations) return 0;
4875
12
    {
4876
12
        PyObject *type = state->pattern_type;
4877
12
        type = _Py_union_type_or(type, Py_None);
4878
12
        cond = type != NULL;
4879
12
        if (!cond) {
4880
0
            Py_DECREF(MatchAs_annotations);
4881
0
            return 0;
4882
0
        }
4883
12
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4884
12
        Py_DECREF(type);
4885
12
        if (!cond) {
4886
0
            Py_DECREF(MatchAs_annotations);
4887
0
            return 0;
4888
0
        }
4889
12
    }
4890
12
    {
4891
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4892
12
        type = _Py_union_type_or(type, Py_None);
4893
12
        cond = type != NULL;
4894
12
        if (!cond) {
4895
0
            Py_DECREF(MatchAs_annotations);
4896
0
            return 0;
4897
0
        }
4898
12
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4899
12
        Py_DECREF(type);
4900
12
        if (!cond) {
4901
0
            Py_DECREF(MatchAs_annotations);
4902
0
            return 0;
4903
0
        }
4904
12
    }
4905
12
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4906
12
                                  MatchAs_annotations) == 0;
4907
12
    if (!cond) {
4908
0
        Py_DECREF(MatchAs_annotations);
4909
0
        return 0;
4910
0
    }
4911
12
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4912
12
                                  MatchAs_annotations) == 0;
4913
12
    if (!cond) {
4914
0
        Py_DECREF(MatchAs_annotations);
4915
0
        return 0;
4916
0
    }
4917
12
    Py_DECREF(MatchAs_annotations);
4918
12
    PyObject *MatchOr_annotations = PyDict_New();
4919
12
    if (!MatchOr_annotations) return 0;
4920
12
    {
4921
12
        PyObject *type = state->pattern_type;
4922
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4923
12
        cond = type != NULL;
4924
12
        if (!cond) {
4925
0
            Py_DECREF(MatchOr_annotations);
4926
0
            return 0;
4927
0
        }
4928
12
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4929
12
        Py_DECREF(type);
4930
12
        if (!cond) {
4931
0
            Py_DECREF(MatchOr_annotations);
4932
0
            return 0;
4933
0
        }
4934
12
    }
4935
12
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4936
12
                                  MatchOr_annotations) == 0;
4937
12
    if (!cond) {
4938
0
        Py_DECREF(MatchOr_annotations);
4939
0
        return 0;
4940
0
    }
4941
12
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4942
12
                                  MatchOr_annotations) == 0;
4943
12
    if (!cond) {
4944
0
        Py_DECREF(MatchOr_annotations);
4945
0
        return 0;
4946
0
    }
4947
12
    Py_DECREF(MatchOr_annotations);
4948
12
    PyObject *TypeIgnore_annotations = PyDict_New();
4949
12
    if (!TypeIgnore_annotations) return 0;
4950
12
    {
4951
12
        PyObject *type = (PyObject *)&PyLong_Type;
4952
12
        Py_INCREF(type);
4953
12
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4954
12
                                    0;
4955
12
        Py_DECREF(type);
4956
12
        if (!cond) {
4957
0
            Py_DECREF(TypeIgnore_annotations);
4958
0
            return 0;
4959
0
        }
4960
12
    }
4961
12
    {
4962
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4963
12
        Py_INCREF(type);
4964
12
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
4965
12
        Py_DECREF(type);
4966
12
        if (!cond) {
4967
0
            Py_DECREF(TypeIgnore_annotations);
4968
0
            return 0;
4969
0
        }
4970
12
    }
4971
12
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
4972
12
                                  TypeIgnore_annotations) == 0;
4973
12
    if (!cond) {
4974
0
        Py_DECREF(TypeIgnore_annotations);
4975
0
        return 0;
4976
0
    }
4977
12
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
4978
12
                                  TypeIgnore_annotations) == 0;
4979
12
    if (!cond) {
4980
0
        Py_DECREF(TypeIgnore_annotations);
4981
0
        return 0;
4982
0
    }
4983
12
    Py_DECREF(TypeIgnore_annotations);
4984
12
    PyObject *TypeVar_annotations = PyDict_New();
4985
12
    if (!TypeVar_annotations) return 0;
4986
12
    {
4987
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4988
12
        Py_INCREF(type);
4989
12
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
4990
12
        Py_DECREF(type);
4991
12
        if (!cond) {
4992
0
            Py_DECREF(TypeVar_annotations);
4993
0
            return 0;
4994
0
        }
4995
12
    }
4996
12
    {
4997
12
        PyObject *type = state->expr_type;
4998
12
        type = _Py_union_type_or(type, Py_None);
4999
12
        cond = type != NULL;
5000
12
        if (!cond) {
5001
0
            Py_DECREF(TypeVar_annotations);
5002
0
            return 0;
5003
0
        }
5004
12
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5005
12
        Py_DECREF(type);
5006
12
        if (!cond) {
5007
0
            Py_DECREF(TypeVar_annotations);
5008
0
            return 0;
5009
0
        }
5010
12
    }
5011
12
    {
5012
12
        PyObject *type = state->expr_type;
5013
12
        type = _Py_union_type_or(type, Py_None);
5014
12
        cond = type != NULL;
5015
12
        if (!cond) {
5016
0
            Py_DECREF(TypeVar_annotations);
5017
0
            return 0;
5018
0
        }
5019
12
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5020
12
                                    == 0;
5021
12
        Py_DECREF(type);
5022
12
        if (!cond) {
5023
0
            Py_DECREF(TypeVar_annotations);
5024
0
            return 0;
5025
0
        }
5026
12
    }
5027
12
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5028
12
                                  TypeVar_annotations) == 0;
5029
12
    if (!cond) {
5030
0
        Py_DECREF(TypeVar_annotations);
5031
0
        return 0;
5032
0
    }
5033
12
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5034
12
                                  TypeVar_annotations) == 0;
5035
12
    if (!cond) {
5036
0
        Py_DECREF(TypeVar_annotations);
5037
0
        return 0;
5038
0
    }
5039
12
    Py_DECREF(TypeVar_annotations);
5040
12
    PyObject *ParamSpec_annotations = PyDict_New();
5041
12
    if (!ParamSpec_annotations) return 0;
5042
12
    {
5043
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
5044
12
        Py_INCREF(type);
5045
12
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5046
12
        Py_DECREF(type);
5047
12
        if (!cond) {
5048
0
            Py_DECREF(ParamSpec_annotations);
5049
0
            return 0;
5050
0
        }
5051
12
    }
5052
12
    {
5053
12
        PyObject *type = state->expr_type;
5054
12
        type = _Py_union_type_or(type, Py_None);
5055
12
        cond = type != NULL;
5056
12
        if (!cond) {
5057
0
            Py_DECREF(ParamSpec_annotations);
5058
0
            return 0;
5059
0
        }
5060
12
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5061
12
                                    type) == 0;
5062
12
        Py_DECREF(type);
5063
12
        if (!cond) {
5064
0
            Py_DECREF(ParamSpec_annotations);
5065
0
            return 0;
5066
0
        }
5067
12
    }
5068
12
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5069
12
                                  ParamSpec_annotations) == 0;
5070
12
    if (!cond) {
5071
0
        Py_DECREF(ParamSpec_annotations);
5072
0
        return 0;
5073
0
    }
5074
12
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5075
12
                                  ParamSpec_annotations) == 0;
5076
12
    if (!cond) {
5077
0
        Py_DECREF(ParamSpec_annotations);
5078
0
        return 0;
5079
0
    }
5080
12
    Py_DECREF(ParamSpec_annotations);
5081
12
    PyObject *TypeVarTuple_annotations = PyDict_New();
5082
12
    if (!TypeVarTuple_annotations) return 0;
5083
12
    {
5084
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
5085
12
        Py_INCREF(type);
5086
12
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5087
12
                                    0;
5088
12
        Py_DECREF(type);
5089
12
        if (!cond) {
5090
0
            Py_DECREF(TypeVarTuple_annotations);
5091
0
            return 0;
5092
0
        }
5093
12
    }
5094
12
    {
5095
12
        PyObject *type = state->expr_type;
5096
12
        type = _Py_union_type_or(type, Py_None);
5097
12
        cond = type != NULL;
5098
12
        if (!cond) {
5099
0
            Py_DECREF(TypeVarTuple_annotations);
5100
0
            return 0;
5101
0
        }
5102
12
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5103
12
                                    type) == 0;
5104
12
        Py_DECREF(type);
5105
12
        if (!cond) {
5106
0
            Py_DECREF(TypeVarTuple_annotations);
5107
0
            return 0;
5108
0
        }
5109
12
    }
5110
12
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5111
12
                                  TypeVarTuple_annotations) == 0;
5112
12
    if (!cond) {
5113
0
        Py_DECREF(TypeVarTuple_annotations);
5114
0
        return 0;
5115
0
    }
5116
12
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5117
12
                                  TypeVarTuple_annotations) == 0;
5118
12
    if (!cond) {
5119
0
        Py_DECREF(TypeVarTuple_annotations);
5120
0
        return 0;
5121
0
    }
5122
12
    Py_DECREF(TypeVarTuple_annotations);
5123
5124
12
    return 1;
5125
12
}
5126
5127
5128
5129
typedef struct {
5130
    PyObject_HEAD
5131
    PyObject *dict;
5132
} AST_object;
5133
5134
static void
5135
ast_dealloc(PyObject *op)
5136
282k
{
5137
282k
    AST_object *self = (AST_object*)op;
5138
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5139
282k
    PyTypeObject *tp = Py_TYPE(self);
5140
282k
    PyObject_GC_UnTrack(self);
5141
282k
    Py_CLEAR(self->dict);
5142
282k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5143
282k
    assert(free_func != NULL);
5144
282k
    free_func(self);
5145
282k
    Py_DECREF(tp);
5146
282k
}
5147
5148
static int
5149
ast_traverse(PyObject *op, visitproc visit, void *arg)
5150
70.1k
{
5151
70.1k
    AST_object *self = (AST_object*)op;
5152
70.1k
    Py_VISIT(Py_TYPE(self));
5153
70.1k
    Py_VISIT(self->dict);
5154
70.1k
    return 0;
5155
70.1k
}
5156
5157
static int
5158
ast_clear(PyObject *op)
5159
0
{
5160
0
    AST_object *self = (AST_object*)op;
5161
0
    Py_CLEAR(self->dict);
5162
0
    return 0;
5163
0
}
5164
5165
static int
5166
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
5167
208
{
5168
208
    struct ast_state *state = get_ast_state();
5169
208
    if (state == NULL) {
5170
0
        return -1;
5171
0
    }
5172
5173
208
    Py_ssize_t i, numfields = 0;
5174
208
    int res = -1;
5175
208
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5176
5177
208
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5178
208
    if (fields == NULL) {
5179
0
        goto cleanup;
5180
0
    }
5181
5182
208
    numfields = PySequence_Size(fields);
5183
208
    if (numfields == -1) {
5184
0
        goto cleanup;
5185
0
    }
5186
208
    remaining_fields = PySet_New(fields);
5187
208
    if (remaining_fields == NULL) {
5188
0
        goto cleanup;
5189
0
    }
5190
5191
208
    res = 0; /* if no error occurs, this stays 0 to the end */
5192
208
    if (numfields < PyTuple_GET_SIZE(args)) {
5193
0
        PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
5194
0
                     "%zd positional argument%s",
5195
0
                     _PyType_Name(Py_TYPE(self)),
5196
0
                     numfields, numfields == 1 ? "" : "s");
5197
0
        res = -1;
5198
0
        goto cleanup;
5199
0
    }
5200
252
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5201
        /* cannot be reached when fields is NULL */
5202
44
        PyObject *name = PySequence_GetItem(fields, i);
5203
44
        if (!name) {
5204
0
            res = -1;
5205
0
            goto cleanup;
5206
0
        }
5207
44
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5208
44
        if (PySet_Discard(remaining_fields, name) < 0) {
5209
0
            res = -1;
5210
0
            Py_DECREF(name);
5211
0
            goto cleanup;
5212
0
        }
5213
44
        Py_DECREF(name);
5214
44
        if (res < 0) {
5215
0
            goto cleanup;
5216
0
        }
5217
44
    }
5218
208
    if (kw) {
5219
44
        i = 0;  /* needed by PyDict_Next */
5220
88
        while (PyDict_Next(kw, &i, &key, &value)) {
5221
44
            int contains = PySequence_Contains(fields, key);
5222
44
            if (contains == -1) {
5223
0
                res = -1;
5224
0
                goto cleanup;
5225
0
            }
5226
44
            else if (contains == 1) {
5227
44
                int p = PySet_Discard(remaining_fields, key);
5228
44
                if (p == -1) {
5229
0
                    res = -1;
5230
0
                    goto cleanup;
5231
0
                }
5232
44
                if (p == 0) {
5233
0
                    PyErr_Format(PyExc_TypeError,
5234
0
                        "%.400s got multiple values for argument %R",
5235
0
                        Py_TYPE(self)->tp_name, key);
5236
0
                    res = -1;
5237
0
                    goto cleanup;
5238
0
                }
5239
44
            }
5240
0
            else {
5241
                // Lazily initialize "attributes"
5242
0
                if (attributes == NULL) {
5243
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5244
0
                    if (attributes == NULL) {
5245
0
                        res = -1;
5246
0
                        goto cleanup;
5247
0
                    }
5248
0
                }
5249
0
                int contains = PySequence_Contains(attributes, key);
5250
0
                if (contains == -1) {
5251
0
                    res = -1;
5252
0
                    goto cleanup;
5253
0
                }
5254
0
                else if (contains == 0) {
5255
0
                    if (PyErr_WarnFormat(
5256
0
                        PyExc_DeprecationWarning, 1,
5257
0
                        "%.400s.__init__ got an unexpected keyword argument %R. "
5258
0
                        "Support for arbitrary keyword arguments is deprecated "
5259
0
                        "and will be removed in Python 3.15.",
5260
0
                        Py_TYPE(self)->tp_name, key
5261
0
                    ) < 0) {
5262
0
                        res = -1;
5263
0
                        goto cleanup;
5264
0
                    }
5265
0
                }
5266
0
            }
5267
44
            res = PyObject_SetAttr(self, key, value);
5268
44
            if (res < 0) {
5269
0
                goto cleanup;
5270
0
            }
5271
44
        }
5272
44
    }
5273
208
    Py_ssize_t size = PySet_Size(remaining_fields);
5274
208
    PyObject *field_types = NULL, *remaining_list = NULL;
5275
208
    if (size > 0) {
5276
68
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5277
68
                                     &field_types) < 0) {
5278
0
            res = -1;
5279
0
            goto cleanup;
5280
0
        }
5281
68
        if (field_types == NULL) {
5282
            // Probably a user-defined subclass of AST that lacks _field_types.
5283
            // This will continue to work as it did before 3.13; i.e., attributes
5284
            // that are not passed in simply do not exist on the instance.
5285
0
            goto cleanup;
5286
0
        }
5287
68
        remaining_list = PySequence_List(remaining_fields);
5288
68
        if (!remaining_list) {
5289
0
            goto set_remaining_cleanup;
5290
0
        }
5291
136
        for (Py_ssize_t i = 0; i < size; i++) {
5292
68
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5293
68
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5294
68
            if (!type) {
5295
0
                if (PyErr_Occurred()) {
5296
0
                    goto set_remaining_cleanup;
5297
0
                }
5298
0
                else {
5299
0
                    if (PyErr_WarnFormat(
5300
0
                        PyExc_DeprecationWarning, 1,
5301
0
                        "Field %R is missing from %.400s._field_types. "
5302
0
                        "This will become an error in Python 3.15.",
5303
0
                        name, Py_TYPE(self)->tp_name
5304
0
                    ) < 0) {
5305
0
                        goto set_remaining_cleanup;
5306
0
                    }
5307
0
                }
5308
0
            }
5309
68
            else if (_PyUnion_Check(type)) {
5310
                // optional field
5311
                // do nothing, we'll have set a None default on the class
5312
8
            }
5313
60
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5314
                // list field
5315
0
                PyObject *empty = PyList_New(0);
5316
0
                if (!empty) {
5317
0
                    goto set_remaining_cleanup;
5318
0
                }
5319
0
                res = PyObject_SetAttr(self, name, empty);
5320
0
                Py_DECREF(empty);
5321
0
                if (res < 0) {
5322
0
                    goto set_remaining_cleanup;
5323
0
                }
5324
0
            }
5325
60
            else if (type == state->expr_context_type) {
5326
                // special case for expr_context: default to Load()
5327
60
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5328
60
                if (res < 0) {
5329
0
                    goto set_remaining_cleanup;
5330
0
                }
5331
60
            }
5332
0
            else {
5333
                // simple field (e.g., identifier)
5334
0
                if (PyErr_WarnFormat(
5335
0
                    PyExc_DeprecationWarning, 1,
5336
0
                    "%.400s.__init__ missing 1 required positional argument: %R. "
5337
0
                    "This will become an error in Python 3.15.",
5338
0
                    Py_TYPE(self)->tp_name, name
5339
0
                ) < 0) {
5340
0
                    goto set_remaining_cleanup;
5341
0
                }
5342
0
            }
5343
68
        }
5344
68
        Py_DECREF(remaining_list);
5345
68
        Py_DECREF(field_types);
5346
68
    }
5347
208
  cleanup:
5348
208
    Py_XDECREF(attributes);
5349
208
    Py_XDECREF(fields);
5350
208
    Py_XDECREF(remaining_fields);
5351
208
    return res;
5352
0
  set_remaining_cleanup:
5353
0
    Py_XDECREF(remaining_list);
5354
0
    Py_XDECREF(field_types);
5355
0
    res = -1;
5356
0
    goto cleanup;
5357
208
}
5358
5359
/* Pickling support */
5360
static PyObject *
5361
ast_type_reduce(PyObject *self, PyObject *unused)
5362
0
{
5363
0
    struct ast_state *state = get_ast_state();
5364
0
    if (state == NULL) {
5365
0
        return NULL;
5366
0
    }
5367
5368
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5369
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5370
0
        return NULL;
5371
0
    }
5372
0
    PyObject *result = NULL;
5373
0
    if (dict) {
5374
        // Unpickling (or copying) works as follows:
5375
        // - Construct the object with only positional arguments
5376
        // - Set the fields from the dict
5377
        // We have two constraints:
5378
        // - We must set all the required fields in the initial constructor call,
5379
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5380
        // - We must not include child nodes in the positional args, because
5381
        //   that may trigger runaway recursion during copying (gh-120108).
5382
        // To satisfy both constraints, we set all the fields to None in the
5383
        // initial list of positional args, and then set the fields from the dict.
5384
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5385
0
            goto cleanup;
5386
0
        }
5387
0
        if (fields) {
5388
0
            Py_ssize_t numfields = PySequence_Size(fields);
5389
0
            if (numfields == -1) {
5390
0
                Py_DECREF(dict);
5391
0
                goto cleanup;
5392
0
            }
5393
0
            positional_args = PyList_New(0);
5394
0
            if (!positional_args) {
5395
0
                goto cleanup;
5396
0
            }
5397
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5398
0
                PyObject *name = PySequence_GetItem(fields, i);
5399
0
                if (!name) {
5400
0
                    goto cleanup;
5401
0
                }
5402
0
                PyObject *value;
5403
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5404
0
                Py_DECREF(name);
5405
0
                if (rc < 0) {
5406
0
                    goto cleanup;
5407
0
                }
5408
0
                if (!value) {
5409
0
                    break;
5410
0
                }
5411
0
                rc = PyList_Append(positional_args, Py_None);
5412
0
                Py_DECREF(value);
5413
0
                if (rc < 0) {
5414
0
                    goto cleanup;
5415
0
                }
5416
0
            }
5417
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5418
0
            if (!args_tuple) {
5419
0
                goto cleanup;
5420
0
            }
5421
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5422
0
        }
5423
0
        else {
5424
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5425
0
        }
5426
0
    }
5427
0
    else {
5428
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5429
0
    }
5430
0
cleanup:
5431
0
    Py_XDECREF(fields);
5432
0
    Py_XDECREF(positional_args);
5433
0
    return result;
5434
0
}
5435
5436
/*
5437
 * Perform the following validations:
5438
 *
5439
 *   - All keyword arguments are known 'fields' or 'attributes'.
5440
 *   - No field or attribute would be left unfilled after copy.replace().
5441
 *
5442
 * On success, this returns 1. Otherwise, set a TypeError
5443
 * exception and returns -1 (no exception is set if some
5444
 * other internal errors occur).
5445
 *
5446
 * Parameters
5447
 *
5448
 *      self          The AST node instance.
5449
 *      dict          The AST node instance dictionary (self.__dict__).
5450
 *      fields        The list of fields (self._fields).
5451
 *      attributes    The list of attributes (self._attributes).
5452
 *      kwargs        Keyword arguments passed to ast_type_replace().
5453
 *
5454
 * The 'dict', 'fields', 'attributes' and 'kwargs' arguments can be NULL.
5455
 *
5456
 * Note: this function can be removed in 3.15 since the verification
5457
 *       will be done inside the constructor.
5458
 */
5459
static inline int
5460
ast_type_replace_check(PyObject *self,
5461
                       PyObject *dict,
5462
                       PyObject *fields,
5463
                       PyObject *attributes,
5464
                       PyObject *kwargs)
5465
0
{
5466
    // While it is possible to make some fast paths that would avoid
5467
    // allocating objects on the stack, this would cost us readability.
5468
    // For instance, if 'fields' and 'attributes' are both empty, and
5469
    // 'kwargs' is not empty, we could raise a TypeError immediately.
5470
0
    PyObject *expecting = PySet_New(fields);
5471
0
    if (expecting == NULL) {
5472
0
        return -1;
5473
0
    }
5474
0
    if (attributes) {
5475
0
        if (_PySet_Update(expecting, attributes) < 0) {
5476
0
            Py_DECREF(expecting);
5477
0
            return -1;
5478
0
        }
5479
0
    }
5480
    // Any keyword argument that is neither a field nor attribute is rejected.
5481
    // We first need to check whether a keyword argument is accepted or not.
5482
    // If all keyword arguments are accepted, we compute the required fields
5483
    // and attributes. A field or attribute is not needed if:
5484
    //
5485
    //  1) it is given in 'kwargs', or
5486
    //  2) it already exists on 'self'.
5487
0
    if (kwargs) {
5488
0
        Py_ssize_t pos = 0;
5489
0
        PyObject *key, *value;
5490
0
        while (PyDict_Next(kwargs, &pos, &key, &value)) {
5491
0
            int rc = PySet_Discard(expecting, key);
5492
0
            if (rc < 0) {
5493
0
                Py_DECREF(expecting);
5494
0
                return -1;
5495
0
            }
5496
0
            if (rc == 0) {
5497
0
                PyErr_Format(PyExc_TypeError,
5498
0
                             "%.400s.__replace__ got an unexpected keyword "
5499
0
                             "argument %R.", Py_TYPE(self)->tp_name, key);
5500
0
                Py_DECREF(expecting);
5501
0
                return -1;
5502
0
            }
5503
0
        }
5504
0
    }
5505
    // check that the remaining fields or attributes would be filled
5506
0
    if (dict) {
5507
0
        Py_ssize_t pos = 0;
5508
0
        PyObject *key, *value;
5509
0
        while (PyDict_Next(dict, &pos, &key, &value)) {
5510
            // Mark fields or attributes that are found on the instance
5511
            // as non-mandatory. If they are not given in 'kwargs', they
5512
            // will be shallow-coied; otherwise, they would be replaced
5513
            // (not in this function).
5514
0
            if (PySet_Discard(expecting, key) < 0) {
5515
0
                Py_DECREF(expecting);
5516
0
                return -1;
5517
0
            }
5518
0
        }
5519
0
        if (attributes) {
5520
            // Some attributes may or may not be present at runtime.
5521
            // In particular, now that we checked whether 'kwargs'
5522
            // is correct or not, we allow any attribute to be missing.
5523
            //
5524
            // Note that fields must still be entirely determined when
5525
            // calling the constructor later.
5526
0
            PyObject *unused = PyObject_CallMethodOneArg(expecting,
5527
0
                                                         &_Py_ID(difference_update),
5528
0
                                                         attributes);
5529
0
            if (unused == NULL) {
5530
0
                Py_DECREF(expecting);
5531
0
                return -1;
5532
0
            }
5533
0
            Py_DECREF(unused);
5534
0
        }
5535
0
    }
5536
5537
    // Discard fields from 'expecting' that default to None
5538
0
    PyObject *field_types = NULL;
5539
0
    if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self),
5540
0
                                 &_Py_ID(_field_types),
5541
0
                                 &field_types) < 0)
5542
0
    {
5543
0
        Py_DECREF(expecting);
5544
0
        return -1;
5545
0
    }
5546
0
    if (field_types != NULL) {
5547
0
        Py_ssize_t pos = 0;
5548
0
        PyObject *field_name, *field_type;
5549
0
        while (PyDict_Next(field_types, &pos, &field_name, &field_type)) {
5550
0
            if (_PyUnion_Check(field_type)) {
5551
                // optional field
5552
0
                if (PySet_Discard(expecting, field_name) < 0) {
5553
0
                    Py_DECREF(expecting);
5554
0
                    Py_DECREF(field_types);
5555
0
                    return -1;
5556
0
                }
5557
0
            }
5558
0
        }
5559
0
        Py_DECREF(field_types);
5560
0
    }
5561
5562
    // Now 'expecting' contains the fields or attributes
5563
    // that would not be filled inside ast_type_replace().
5564
0
    Py_ssize_t m = PySet_GET_SIZE(expecting);
5565
0
    if (m > 0) {
5566
0
        PyObject *names = PyList_New(m);
5567
0
        if (names == NULL) {
5568
0
            Py_DECREF(expecting);
5569
0
            return -1;
5570
0
        }
5571
0
        Py_ssize_t i = 0, pos = 0;
5572
0
        PyObject *item;
5573
0
        Py_hash_t hash;
5574
0
        while (_PySet_NextEntry(expecting, &pos, &item, &hash)) {
5575
0
            PyObject *name = PyObject_Repr(item);
5576
0
            if (name == NULL) {
5577
0
                Py_DECREF(expecting);
5578
0
                Py_DECREF(names);
5579
0
                return -1;
5580
0
            }
5581
            // steal the reference 'name'
5582
0
            PyList_SET_ITEM(names, i++, name);
5583
0
        }
5584
0
        Py_DECREF(expecting);
5585
0
        if (PyList_Sort(names) < 0) {
5586
0
            Py_DECREF(names);
5587
0
            return -1;
5588
0
        }
5589
0
        PyObject *sep = PyUnicode_FromString(", ");
5590
0
        if (sep == NULL) {
5591
0
            Py_DECREF(names);
5592
0
            return -1;
5593
0
        }
5594
0
        PyObject *str_names = PyUnicode_Join(sep, names);
5595
0
        Py_DECREF(sep);
5596
0
        Py_DECREF(names);
5597
0
        if (str_names == NULL) {
5598
0
            return -1;
5599
0
        }
5600
0
        PyErr_Format(PyExc_TypeError,
5601
0
                     "%.400s.__replace__ missing %ld keyword argument%s: %U.",
5602
0
                     Py_TYPE(self)->tp_name, m, m == 1 ? "" : "s", str_names);
5603
0
        Py_DECREF(str_names);
5604
0
        return -1;
5605
0
    }
5606
0
    else {
5607
0
        Py_DECREF(expecting);
5608
0
        return 1;
5609
0
    }
5610
0
}
5611
5612
/*
5613
 * Python equivalent:
5614
 *
5615
 *   for key in keys:
5616
 *       if hasattr(self, key):
5617
 *           payload[key] = getattr(self, key)
5618
 *
5619
 * The 'keys' argument is a sequence corresponding to
5620
 * the '_fields' or the '_attributes' of an AST node.
5621
 *
5622
 * This returns -1 if an error occurs and 0 otherwise.
5623
 *
5624
 * Parameters
5625
 *
5626
 *      payload   A dictionary to fill.
5627
 *      keys      A sequence of keys or NULL for an empty sequence.
5628
 *      dict      The AST node instance dictionary (must not be NULL).
5629
 */
5630
static inline int
5631
ast_type_replace_update_payload(PyObject *payload,
5632
                                PyObject *keys,
5633
                                PyObject *dict)
5634
0
{
5635
0
    assert(dict != NULL);
5636
0
    if (keys == NULL) {
5637
0
        return 0;
5638
0
    }
5639
0
    Py_ssize_t n = PySequence_Size(keys);
5640
0
    if (n == -1) {
5641
0
        return -1;
5642
0
    }
5643
0
    for (Py_ssize_t i = 0; i < n; i++) {
5644
0
        PyObject *key = PySequence_GetItem(keys, i);
5645
0
        if (key == NULL) {
5646
0
            return -1;
5647
0
        }
5648
0
        PyObject *value;
5649
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5650
0
            Py_DECREF(key);
5651
0
            return -1;
5652
0
        }
5653
0
        if (value == NULL) {
5654
0
            Py_DECREF(key);
5655
            // If a field or attribute is not present at runtime, it should
5656
            // be explicitly given in 'kwargs'. If not, the constructor will
5657
            // issue a warning (which becomes an error in 3.15).
5658
0
            continue;
5659
0
        }
5660
0
        int rc = PyDict_SetItem(payload, key, value);
5661
0
        Py_DECREF(key);
5662
0
        Py_DECREF(value);
5663
0
        if (rc < 0) {
5664
0
            return -1;
5665
0
        }
5666
0
    }
5667
0
    return 0;
5668
0
}
5669
5670
/* copy.replace() support (shallow copy) */
5671
static PyObject *
5672
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5673
0
{
5674
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5675
0
        return NULL;
5676
0
    }
5677
5678
0
    struct ast_state *state = get_ast_state();
5679
0
    if (state == NULL) {
5680
0
        return NULL;
5681
0
    }
5682
5683
0
    PyObject *result = NULL;
5684
    // known AST class fields and attributes
5685
0
    PyObject *fields = NULL, *attributes = NULL;
5686
    // current instance dictionary
5687
0
    PyObject *dict = NULL;
5688
    // constructor positional and keyword arguments
5689
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5690
5691
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5692
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5693
0
        goto cleanup;
5694
0
    }
5695
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5696
0
        goto cleanup;
5697
0
    }
5698
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5699
0
        goto cleanup;
5700
0
    }
5701
0
    if (ast_type_replace_check(self, dict, fields, attributes, kwargs) < 0) {
5702
0
        goto cleanup;
5703
0
    }
5704
0
    empty_tuple = PyTuple_New(0);
5705
0
    if (empty_tuple == NULL) {
5706
0
        goto cleanup;
5707
0
    }
5708
0
    payload = PyDict_New();
5709
0
    if (payload == NULL) {
5710
0
        goto cleanup;
5711
0
    }
5712
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5713
        // copy the instance's fields (possibly NULL)
5714
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5715
0
            goto cleanup;
5716
0
        }
5717
        // copy the instance's attributes (possibly NULL)
5718
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5719
0
            goto cleanup;
5720
0
        }
5721
0
    }
5722
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5723
0
        goto cleanup;
5724
0
    }
5725
0
    result = PyObject_Call(type, empty_tuple, payload);
5726
0
cleanup:
5727
0
    Py_XDECREF(payload);
5728
0
    Py_XDECREF(empty_tuple);
5729
0
    Py_XDECREF(dict);
5730
0
    Py_XDECREF(attributes);
5731
0
    Py_XDECREF(fields);
5732
0
    return result;
5733
0
}
5734
5735
static PyMemberDef ast_type_members[] = {
5736
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5737
    {NULL}  /* Sentinel */
5738
};
5739
5740
static PyMethodDef ast_type_methods[] = {
5741
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5742
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5743
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5744
               "Return a copy of the AST node with new values "
5745
               "for the specified fields.")},
5746
    {NULL}
5747
};
5748
5749
static PyGetSetDef ast_type_getsets[] = {
5750
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5751
    {NULL}
5752
};
5753
5754
static PyObject *
5755
ast_repr_max_depth(AST_object *self, int depth);
5756
5757
/* Format list and tuple properties of AST nodes.
5758
   Note that, only the first and last elements are shown.
5759
   Anything in between is represented with an ellipsis ('...').
5760
   For example, the list [1, 2, 3] is formatted as
5761
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5762
static PyObject *
5763
ast_repr_list(PyObject *list, int depth)
5764
0
{
5765
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5766
5767
0
    struct ast_state *state = get_ast_state();
5768
0
    if (state == NULL) {
5769
0
        return NULL;
5770
0
    }
5771
5772
0
    Py_ssize_t length = PySequence_Size(list);
5773
0
    if (length < 0) {
5774
0
        return NULL;
5775
0
    }
5776
0
    else if (length == 0) {
5777
0
        return PyObject_Repr(list);
5778
0
    }
5779
5780
0
    PyObject *items[2] = {NULL, NULL};
5781
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5782
0
    if (writer == NULL) {
5783
0
        goto error;
5784
0
    }
5785
5786
0
    items[0] = PySequence_GetItem(list, 0);
5787
0
    if (!items[0]) {
5788
0
        goto error;
5789
0
    }
5790
0
    if (length > 1) {
5791
0
        items[1] = PySequence_GetItem(list, length - 1);
5792
0
        if (!items[1]) {
5793
0
            goto error;
5794
0
        }
5795
0
    }
5796
5797
0
    bool is_list = PyList_Check(list);
5798
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5799
0
        goto error;
5800
0
    }
5801
5802
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5803
0
        if (i > 0) {
5804
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5805
0
                goto error;
5806
0
            }
5807
0
        }
5808
5809
0
        PyObject *item = items[i];
5810
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5811
0
            PyObject *item_repr;
5812
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5813
0
            if (!item_repr) {
5814
0
                goto error;
5815
0
            }
5816
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5817
0
                Py_DECREF(item_repr);
5818
0
                goto error;
5819
0
            }
5820
0
            Py_DECREF(item_repr);
5821
0
        } else {
5822
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5823
0
                goto error;
5824
0
            }
5825
0
        }
5826
5827
0
        if (i == 0 && length > 2) {
5828
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5829
0
                goto error;
5830
0
            }
5831
0
        }
5832
0
    }
5833
5834
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5835
0
        goto error;
5836
0
    }
5837
5838
0
    Py_XDECREF(items[0]);
5839
0
    Py_XDECREF(items[1]);
5840
0
    return PyUnicodeWriter_Finish(writer);
5841
5842
0
error:
5843
0
    Py_XDECREF(items[0]);
5844
0
    Py_XDECREF(items[1]);
5845
0
    PyUnicodeWriter_Discard(writer);
5846
0
    return NULL;
5847
0
}
5848
5849
static PyObject *
5850
ast_repr_max_depth(AST_object *self, int depth)
5851
0
{
5852
0
    struct ast_state *state = get_ast_state();
5853
0
    if (state == NULL) {
5854
0
        return NULL;
5855
0
    }
5856
5857
0
    if (depth <= 0) {
5858
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5859
0
    }
5860
5861
0
    int status = Py_ReprEnter((PyObject *)self);
5862
0
    if (status != 0) {
5863
0
        if (status < 0) {
5864
0
            return NULL;
5865
0
        }
5866
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5867
0
    }
5868
5869
0
    PyObject *fields;
5870
0
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5871
0
        Py_ReprLeave((PyObject *)self);
5872
0
        return NULL;
5873
0
    }
5874
5875
0
    Py_ssize_t numfields = PySequence_Size(fields);
5876
0
    if (numfields < 0) {
5877
0
        Py_ReprLeave((PyObject *)self);
5878
0
        Py_DECREF(fields);
5879
0
        return NULL;
5880
0
    }
5881
5882
0
    if (numfields == 0) {
5883
0
        Py_ReprLeave((PyObject *)self);
5884
0
        Py_DECREF(fields);
5885
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5886
0
    }
5887
5888
0
    const char* tp_name = Py_TYPE(self)->tp_name;
5889
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5890
0
    if (writer == NULL) {
5891
0
        goto error;
5892
0
    }
5893
5894
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5895
0
        goto error;
5896
0
    }
5897
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5898
0
        goto error;
5899
0
    }
5900
5901
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
5902
0
        PyObject *name = PySequence_GetItem(fields, i);
5903
0
        if (!name) {
5904
0
            goto error;
5905
0
        }
5906
5907
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5908
0
        if (!value) {
5909
0
            Py_DECREF(name);
5910
0
            goto error;
5911
0
        }
5912
5913
0
        PyObject *value_repr;
5914
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
5915
0
            value_repr = ast_repr_list(value, depth);
5916
0
        }
5917
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5918
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5919
0
        }
5920
0
        else {
5921
0
            value_repr = PyObject_Repr(value);
5922
0
        }
5923
5924
0
        Py_DECREF(value);
5925
5926
0
        if (!value_repr) {
5927
0
            Py_DECREF(name);
5928
0
            goto error;
5929
0
        }
5930
5931
0
        if (i > 0) {
5932
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5933
0
                Py_DECREF(name);
5934
0
                Py_DECREF(value_repr);
5935
0
                goto error;
5936
0
            }
5937
0
        }
5938
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5939
0
            Py_DECREF(name);
5940
0
            Py_DECREF(value_repr);
5941
0
            goto error;
5942
0
        }
5943
5944
0
        Py_DECREF(name);
5945
5946
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5947
0
            Py_DECREF(value_repr);
5948
0
            goto error;
5949
0
        }
5950
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5951
0
            Py_DECREF(value_repr);
5952
0
            goto error;
5953
0
        }
5954
5955
0
        Py_DECREF(value_repr);
5956
0
    }
5957
5958
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5959
0
        goto error;
5960
0
    }
5961
0
    Py_ReprLeave((PyObject *)self);
5962
0
    Py_DECREF(fields);
5963
0
    return PyUnicodeWriter_Finish(writer);
5964
5965
0
error:
5966
0
    Py_ReprLeave((PyObject *)self);
5967
0
    Py_DECREF(fields);
5968
0
    PyUnicodeWriter_Discard(writer);
5969
0
    return NULL;
5970
0
}
5971
5972
static PyObject *
5973
ast_repr(PyObject *self)
5974
0
{
5975
0
    return ast_repr_max_depth((AST_object*)self, 3);
5976
0
}
5977
5978
static PyType_Slot AST_type_slots[] = {
5979
    {Py_tp_dealloc, ast_dealloc},
5980
    {Py_tp_repr, ast_repr},
5981
    {Py_tp_getattro, PyObject_GenericGetAttr},
5982
    {Py_tp_setattro, PyObject_GenericSetAttr},
5983
    {Py_tp_traverse, ast_traverse},
5984
    {Py_tp_clear, ast_clear},
5985
    {Py_tp_members, ast_type_members},
5986
    {Py_tp_methods, ast_type_methods},
5987
    {Py_tp_getset, ast_type_getsets},
5988
    {Py_tp_init, ast_type_init},
5989
    {Py_tp_alloc, PyType_GenericAlloc},
5990
    {Py_tp_new, PyType_GenericNew},
5991
    {Py_tp_free, PyObject_GC_Del},
5992
    {0, 0},
5993
};
5994
5995
static PyType_Spec AST_type_spec = {
5996
    "ast.AST",
5997
    sizeof(AST_object),
5998
    0,
5999
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
6000
    AST_type_slots
6001
};
6002
6003
static PyObject *
6004
make_type(struct ast_state *state, const char *type, PyObject* base,
6005
          const char* const* fields, int num_fields, const char *doc)
6006
1.50k
{
6007
1.50k
    PyObject *fnames, *result;
6008
1.50k
    int i;
6009
1.50k
    fnames = PyTuple_New(num_fields);
6010
1.50k
    if (!fnames) return NULL;
6011
3.85k
    for (i = 0; i < num_fields; i++) {
6012
2.35k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
6013
2.35k
        if (!field) {
6014
0
            Py_DECREF(fnames);
6015
0
            return NULL;
6016
0
        }
6017
2.35k
        PyTuple_SET_ITEM(fnames, i, field);
6018
2.35k
    }
6019
1.50k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
6020
1.50k
                    type, base,
6021
1.50k
                    state->_fields, fnames,
6022
1.50k
                    state->__match_args__, fnames,
6023
1.50k
                    state->__module__,
6024
1.50k
                    state->ast,
6025
1.50k
                    state->__doc__, doc);
6026
1.50k
    Py_DECREF(fnames);
6027
1.50k
    return result;
6028
1.50k
}
6029
6030
static int
6031
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
6032
228
{
6033
228
    int i, result;
6034
228
    PyObject *s, *l = PyTuple_New(num_fields);
6035
228
    if (!l)
6036
0
        return -1;
6037
612
    for (i = 0; i < num_fields; i++) {
6038
384
        s = PyUnicode_InternFromString(attrs[i]);
6039
384
        if (!s) {
6040
0
            Py_DECREF(l);
6041
0
            return -1;
6042
0
        }
6043
384
        PyTuple_SET_ITEM(l, i, s);
6044
384
    }
6045
228
    result = PyObject_SetAttr(type, state->_attributes, l);
6046
228
    Py_DECREF(l);
6047
228
    return result;
6048
228
}
6049
6050
/* Conversion AST -> Python */
6051
6052
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
6053
                              PyObject* (*func)(struct ast_state *state, void*))
6054
76.8k
{
6055
76.8k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
6056
76.8k
    PyObject *result = PyList_New(n);
6057
76.8k
    PyObject *value;
6058
76.8k
    if (!result)
6059
0
        return NULL;
6060
200k
    for (i = 0; i < n; i++) {
6061
123k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6062
123k
        if (!value) {
6063
0
            Py_DECREF(result);
6064
0
            return NULL;
6065
0
        }
6066
123k
        PyList_SET_ITEM(result, i, value);
6067
123k
    }
6068
76.8k
    return result;
6069
76.8k
}
6070
6071
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6072
198k
{
6073
198k
    PyObject *op = (PyObject*)o;
6074
198k
    if (!op) {
6075
66.9k
        op = Py_None;
6076
66.9k
    }
6077
198k
    return Py_NewRef(op);
6078
198k
}
6079
48.3k
#define ast2obj_constant ast2obj_object
6080
89.6k
#define ast2obj_identifier ast2obj_object
6081
59.3k
#define ast2obj_string ast2obj_object
6082
6083
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6084
1.10M
{
6085
1.10M
    return PyLong_FromLong(b);
6086
1.10M
}
6087
6088
/* Conversion Python -> AST */
6089
6090
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6091
0
{
6092
0
    if (obj == Py_None)
6093
0
        obj = NULL;
6094
0
    if (obj) {
6095
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6096
0
            *out = NULL;
6097
0
            return -1;
6098
0
        }
6099
0
        *out = Py_NewRef(obj);
6100
0
    }
6101
0
    else {
6102
0
        *out = NULL;
6103
0
    }
6104
0
    return 0;
6105
0
}
6106
6107
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6108
0
{
6109
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6110
0
        *out = NULL;
6111
0
        return -1;
6112
0
    }
6113
0
    *out = Py_NewRef(obj);
6114
0
    return 0;
6115
0
}
6116
6117
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6118
0
{
6119
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6120
0
        PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
6121
0
        return -1;
6122
0
    }
6123
0
    return obj2ast_object(state, obj, out, arena);
6124
0
}
6125
6126
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6127
0
{
6128
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6129
0
        PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
6130
0
        return -1;
6131
0
    }
6132
0
    return obj2ast_object(state, obj, out, arena);
6133
0
}
6134
6135
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
6136
0
{
6137
0
    int i;
6138
0
    if (!PyLong_Check(obj)) {
6139
0
        PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
6140
0
        return -1;
6141
0
    }
6142
6143
0
    i = PyLong_AsInt(obj);
6144
0
    if (i == -1 && PyErr_Occurred())
6145
0
        return -1;
6146
0
    *out = i;
6147
0
    return 0;
6148
0
}
6149
6150
static int add_ast_fields(struct ast_state *state)
6151
12
{
6152
12
    PyObject *empty_tuple;
6153
12
    empty_tuple = PyTuple_New(0);
6154
12
    if (!empty_tuple ||
6155
12
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6156
12
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6157
12
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6158
0
        Py_XDECREF(empty_tuple);
6159
0
        return -1;
6160
0
    }
6161
12
    Py_DECREF(empty_tuple);
6162
12
    return 0;
6163
12
}
6164
6165
6166
6167
static int
6168
init_types(void *arg)
6169
12
{
6170
12
    struct ast_state *state = arg;
6171
12
    if (init_identifiers(state) < 0) {
6172
0
        return -1;
6173
0
    }
6174
12
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6175
12
    if (!state->AST_type) {
6176
0
        return -1;
6177
0
    }
6178
12
    if (add_ast_fields(state) < 0) {
6179
0
        return -1;
6180
0
    }
6181
12
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6182
12
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6183
12
        "    | Interactive(stmt* body)\n"
6184
12
        "    | Expression(expr body)\n"
6185
12
        "    | FunctionType(expr* argtypes, expr returns)");
6186
12
    if (!state->mod_type) return -1;
6187
12
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6188
12
    state->Module_type = make_type(state, "Module", state->mod_type,
6189
12
                                   Module_fields, 2,
6190
12
        "Module(stmt* body, type_ignore* type_ignores)");
6191
12
    if (!state->Module_type) return -1;
6192
12
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6193
12
                                        Interactive_fields, 1,
6194
12
        "Interactive(stmt* body)");
6195
12
    if (!state->Interactive_type) return -1;
6196
12
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6197
12
                                       Expression_fields, 1,
6198
12
        "Expression(expr body)");
6199
12
    if (!state->Expression_type) return -1;
6200
12
    state->FunctionType_type = make_type(state, "FunctionType",
6201
12
                                         state->mod_type, FunctionType_fields,
6202
12
                                         2,
6203
12
        "FunctionType(expr* argtypes, expr returns)");
6204
12
    if (!state->FunctionType_type) return -1;
6205
12
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6206
12
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6207
12
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6208
12
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6209
12
        "     | Return(expr? value)\n"
6210
12
        "     | Delete(expr* targets)\n"
6211
12
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6212
12
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6213
12
        "     | AugAssign(expr target, operator op, expr value)\n"
6214
12
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6215
12
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6216
12
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6217
12
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6218
12
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6219
12
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6220
12
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6221
12
        "     | Match(expr subject, match_case* cases)\n"
6222
12
        "     | Raise(expr? exc, expr? cause)\n"
6223
12
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6224
12
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6225
12
        "     | Assert(expr test, expr? msg)\n"
6226
12
        "     | Import(alias* names)\n"
6227
12
        "     | ImportFrom(identifier? module, alias* names, int? level)\n"
6228
12
        "     | Global(identifier* names)\n"
6229
12
        "     | Nonlocal(identifier* names)\n"
6230
12
        "     | Expr(expr value)\n"
6231
12
        "     | Pass\n"
6232
12
        "     | Break\n"
6233
12
        "     | Continue");
6234
12
    if (!state->stmt_type) return -1;
6235
12
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6236
0
        -1;
6237
12
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6238
0
        return -1;
6239
12
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6240
12
        -1)
6241
0
        return -1;
6242
12
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6243
12
                                        FunctionDef_fields, 7,
6244
12
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6245
12
    if (!state->FunctionDef_type) return -1;
6246
12
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6247
12
        -1)
6248
0
        return -1;
6249
12
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6250
12
        == -1)
6251
0
        return -1;
6252
12
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6253
12
                                             state->stmt_type,
6254
12
                                             AsyncFunctionDef_fields, 7,
6255
12
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6256
12
    if (!state->AsyncFunctionDef_type) return -1;
6257
12
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6258
12
        == -1)
6259
0
        return -1;
6260
12
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6261
12
        Py_None) == -1)
6262
0
        return -1;
6263
12
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6264
12
                                     ClassDef_fields, 6,
6265
12
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6266
12
    if (!state->ClassDef_type) return -1;
6267
12
    state->Return_type = make_type(state, "Return", state->stmt_type,
6268
12
                                   Return_fields, 1,
6269
12
        "Return(expr? value)");
6270
12
    if (!state->Return_type) return -1;
6271
12
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6272
0
        return -1;
6273
12
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6274
12
                                   Delete_fields, 1,
6275
12
        "Delete(expr* targets)");
6276
12
    if (!state->Delete_type) return -1;
6277
12
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6278
12
                                   Assign_fields, 3,
6279
12
        "Assign(expr* targets, expr value, string? type_comment)");
6280
12
    if (!state->Assign_type) return -1;
6281
12
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6282
12
        -1)
6283
0
        return -1;
6284
12
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6285
12
                                      TypeAlias_fields, 3,
6286
12
        "TypeAlias(expr name, type_param* type_params, expr value)");
6287
12
    if (!state->TypeAlias_type) return -1;
6288
12
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6289
12
                                      AugAssign_fields, 3,
6290
12
        "AugAssign(expr target, operator op, expr value)");
6291
12
    if (!state->AugAssign_type) return -1;
6292
12
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6293
12
                                      AnnAssign_fields, 4,
6294
12
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6295
12
    if (!state->AnnAssign_type) return -1;
6296
12
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6297
0
        return -1;
6298
12
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6299
12
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6300
12
    if (!state->For_type) return -1;
6301
12
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6302
0
        return -1;
6303
12
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6304
12
                                     AsyncFor_fields, 5,
6305
12
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6306
12
    if (!state->AsyncFor_type) return -1;
6307
12
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6308
12
        -1)
6309
0
        return -1;
6310
12
    state->While_type = make_type(state, "While", state->stmt_type,
6311
12
                                  While_fields, 3,
6312
12
        "While(expr test, stmt* body, stmt* orelse)");
6313
12
    if (!state->While_type) return -1;
6314
12
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6315
12
        "If(expr test, stmt* body, stmt* orelse)");
6316
12
    if (!state->If_type) return -1;
6317
12
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6318
12
                                 3,
6319
12
        "With(withitem* items, stmt* body, string? type_comment)");
6320
12
    if (!state->With_type) return -1;
6321
12
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6322
0
        return -1;
6323
12
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6324
12
                                      AsyncWith_fields, 3,
6325
12
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6326
12
    if (!state->AsyncWith_type) return -1;
6327
12
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6328
12
        == -1)
6329
0
        return -1;
6330
12
    state->Match_type = make_type(state, "Match", state->stmt_type,
6331
12
                                  Match_fields, 2,
6332
12
        "Match(expr subject, match_case* cases)");
6333
12
    if (!state->Match_type) return -1;
6334
12
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6335
12
                                  Raise_fields, 2,
6336
12
        "Raise(expr? exc, expr? cause)");
6337
12
    if (!state->Raise_type) return -1;
6338
12
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6339
0
        return -1;
6340
12
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6341
0
        return -1;
6342
12
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6343
12
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6344
12
    if (!state->Try_type) return -1;
6345
12
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6346
12
                                    TryStar_fields, 4,
6347
12
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6348
12
    if (!state->TryStar_type) return -1;
6349
12
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6350
12
                                   Assert_fields, 2,
6351
12
        "Assert(expr test, expr? msg)");
6352
12
    if (!state->Assert_type) return -1;
6353
12
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6354
0
        return -1;
6355
12
    state->Import_type = make_type(state, "Import", state->stmt_type,
6356
12
                                   Import_fields, 1,
6357
12
        "Import(alias* names)");
6358
12
    if (!state->Import_type) return -1;
6359
12
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6360
12
                                       ImportFrom_fields, 3,
6361
12
        "ImportFrom(identifier? module, alias* names, int? level)");
6362
12
    if (!state->ImportFrom_type) return -1;
6363
12
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6364
0
        return -1;
6365
12
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6366
0
        return -1;
6367
12
    state->Global_type = make_type(state, "Global", state->stmt_type,
6368
12
                                   Global_fields, 1,
6369
12
        "Global(identifier* names)");
6370
12
    if (!state->Global_type) return -1;
6371
12
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6372
12
                                     Nonlocal_fields, 1,
6373
12
        "Nonlocal(identifier* names)");
6374
12
    if (!state->Nonlocal_type) return -1;
6375
12
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6376
12
                                 1,
6377
12
        "Expr(expr value)");
6378
12
    if (!state->Expr_type) return -1;
6379
12
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6380
12
        "Pass");
6381
12
    if (!state->Pass_type) return -1;
6382
12
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6383
12
        "Break");
6384
12
    if (!state->Break_type) return -1;
6385
12
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6386
12
                                     0,
6387
12
        "Continue");
6388
12
    if (!state->Continue_type) return -1;
6389
12
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6390
12
        "expr = BoolOp(boolop op, expr* values)\n"
6391
12
        "     | NamedExpr(expr target, expr value)\n"
6392
12
        "     | BinOp(expr left, operator op, expr right)\n"
6393
12
        "     | UnaryOp(unaryop op, expr operand)\n"
6394
12
        "     | Lambda(arguments args, expr body)\n"
6395
12
        "     | IfExp(expr test, expr body, expr orelse)\n"
6396
12
        "     | Dict(expr?* keys, expr* values)\n"
6397
12
        "     | Set(expr* elts)\n"
6398
12
        "     | ListComp(expr elt, comprehension* generators)\n"
6399
12
        "     | SetComp(expr elt, comprehension* generators)\n"
6400
12
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6401
12
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6402
12
        "     | Await(expr value)\n"
6403
12
        "     | Yield(expr? value)\n"
6404
12
        "     | YieldFrom(expr value)\n"
6405
12
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6406
12
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6407
12
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6408
12
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6409
12
        "     | JoinedStr(expr* values)\n"
6410
12
        "     | TemplateStr(expr* values)\n"
6411
12
        "     | Constant(constant value, string? kind)\n"
6412
12
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6413
12
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6414
12
        "     | Starred(expr value, expr_context ctx)\n"
6415
12
        "     | Name(identifier id, expr_context ctx)\n"
6416
12
        "     | List(expr* elts, expr_context ctx)\n"
6417
12
        "     | Tuple(expr* elts, expr_context ctx)\n"
6418
12
        "     | Slice(expr? lower, expr? upper, expr? step)");
6419
12
    if (!state->expr_type) return -1;
6420
12
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6421
0
        -1;
6422
12
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6423
0
        return -1;
6424
12
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6425
12
        -1)
6426
0
        return -1;
6427
12
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6428
12
                                   BoolOp_fields, 2,
6429
12
        "BoolOp(boolop op, expr* values)");
6430
12
    if (!state->BoolOp_type) return -1;
6431
12
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6432
12
                                      NamedExpr_fields, 2,
6433
12
        "NamedExpr(expr target, expr value)");
6434
12
    if (!state->NamedExpr_type) return -1;
6435
12
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6436
12
                                  BinOp_fields, 3,
6437
12
        "BinOp(expr left, operator op, expr right)");
6438
12
    if (!state->BinOp_type) return -1;
6439
12
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6440
12
                                    UnaryOp_fields, 2,
6441
12
        "UnaryOp(unaryop op, expr operand)");
6442
12
    if (!state->UnaryOp_type) return -1;
6443
12
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6444
12
                                   Lambda_fields, 2,
6445
12
        "Lambda(arguments args, expr body)");
6446
12
    if (!state->Lambda_type) return -1;
6447
12
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6448
12
                                  IfExp_fields, 3,
6449
12
        "IfExp(expr test, expr body, expr orelse)");
6450
12
    if (!state->IfExp_type) return -1;
6451
12
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6452
12
                                 2,
6453
12
        "Dict(expr?* keys, expr* values)");
6454
12
    if (!state->Dict_type) return -1;
6455
12
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6456
12
        "Set(expr* elts)");
6457
12
    if (!state->Set_type) return -1;
6458
12
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6459
12
                                     ListComp_fields, 2,
6460
12
        "ListComp(expr elt, comprehension* generators)");
6461
12
    if (!state->ListComp_type) return -1;
6462
12
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6463
12
                                    SetComp_fields, 2,
6464
12
        "SetComp(expr elt, comprehension* generators)");
6465
12
    if (!state->SetComp_type) return -1;
6466
12
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6467
12
                                     DictComp_fields, 3,
6468
12
        "DictComp(expr key, expr? value, comprehension* generators)");
6469
12
    if (!state->DictComp_type) return -1;
6470
12
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6471
0
        return -1;
6472
12
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6473
12
                                         state->expr_type, GeneratorExp_fields,
6474
12
                                         2,
6475
12
        "GeneratorExp(expr elt, comprehension* generators)");
6476
12
    if (!state->GeneratorExp_type) return -1;
6477
12
    state->Await_type = make_type(state, "Await", state->expr_type,
6478
12
                                  Await_fields, 1,
6479
12
        "Await(expr value)");
6480
12
    if (!state->Await_type) return -1;
6481
12
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6482
12
                                  Yield_fields, 1,
6483
12
        "Yield(expr? value)");
6484
12
    if (!state->Yield_type) return -1;
6485
12
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6486
0
        return -1;
6487
12
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6488
12
                                      YieldFrom_fields, 1,
6489
12
        "YieldFrom(expr value)");
6490
12
    if (!state->YieldFrom_type) return -1;
6491
12
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6492
12
                                    Compare_fields, 3,
6493
12
        "Compare(expr left, cmpop* ops, expr* comparators)");
6494
12
    if (!state->Compare_type) return -1;
6495
12
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6496
12
                                 3,
6497
12
        "Call(expr func, expr* args, keyword* keywords)");
6498
12
    if (!state->Call_type) return -1;
6499
12
    state->FormattedValue_type = make_type(state, "FormattedValue",
6500
12
                                           state->expr_type,
6501
12
                                           FormattedValue_fields, 3,
6502
12
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6503
12
    if (!state->FormattedValue_type) return -1;
6504
12
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6505
12
        Py_None) == -1)
6506
0
        return -1;
6507
12
    state->Interpolation_type = make_type(state, "Interpolation",
6508
12
                                          state->expr_type,
6509
12
                                          Interpolation_fields, 4,
6510
12
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6511
12
    if (!state->Interpolation_type) return -1;
6512
12
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6513
12
        Py_None) == -1)
6514
0
        return -1;
6515
12
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6516
12
                                      JoinedStr_fields, 1,
6517
12
        "JoinedStr(expr* values)");
6518
12
    if (!state->JoinedStr_type) return -1;
6519
12
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6520
12
                                        TemplateStr_fields, 1,
6521
12
        "TemplateStr(expr* values)");
6522
12
    if (!state->TemplateStr_type) return -1;
6523
12
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6524
12
                                     Constant_fields, 2,
6525
12
        "Constant(constant value, string? kind)");
6526
12
    if (!state->Constant_type) return -1;
6527
12
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6528
0
        return -1;
6529
12
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6530
12
                                      Attribute_fields, 3,
6531
12
        "Attribute(expr value, identifier attr, expr_context ctx)");
6532
12
    if (!state->Attribute_type) return -1;
6533
12
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6534
12
                                      Subscript_fields, 3,
6535
12
        "Subscript(expr value, expr slice, expr_context ctx)");
6536
12
    if (!state->Subscript_type) return -1;
6537
12
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6538
12
                                    Starred_fields, 2,
6539
12
        "Starred(expr value, expr_context ctx)");
6540
12
    if (!state->Starred_type) return -1;
6541
12
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6542
12
                                 2,
6543
12
        "Name(identifier id, expr_context ctx)");
6544
12
    if (!state->Name_type) return -1;
6545
12
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6546
12
                                 2,
6547
12
        "List(expr* elts, expr_context ctx)");
6548
12
    if (!state->List_type) return -1;
6549
12
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6550
12
                                  Tuple_fields, 2,
6551
12
        "Tuple(expr* elts, expr_context ctx)");
6552
12
    if (!state->Tuple_type) return -1;
6553
12
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6554
12
                                  Slice_fields, 3,
6555
12
        "Slice(expr? lower, expr? upper, expr? step)");
6556
12
    if (!state->Slice_type) return -1;
6557
12
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6558
0
        return -1;
6559
12
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6560
0
        return -1;
6561
12
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6562
0
        return -1;
6563
12
    state->expr_context_type = make_type(state, "expr_context",
6564
12
                                         state->AST_type, NULL, 0,
6565
12
        "expr_context = Load | Store | Del");
6566
12
    if (!state->expr_context_type) return -1;
6567
12
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6568
12
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6569
12
                                 0,
6570
12
        "Load");
6571
12
    if (!state->Load_type) return -1;
6572
12
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6573
12
                                              NULL, NULL);
6574
12
    if (!state->Load_singleton) return -1;
6575
12
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6576
12
                                  NULL, 0,
6577
12
        "Store");
6578
12
    if (!state->Store_type) return -1;
6579
12
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6580
12
                                               *)state->Store_type, NULL, NULL);
6581
12
    if (!state->Store_singleton) return -1;
6582
12
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6583
12
        "Del");
6584
12
    if (!state->Del_type) return -1;
6585
12
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6586
12
                                             NULL, NULL);
6587
12
    if (!state->Del_singleton) return -1;
6588
12
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6589
12
        "boolop = And | Or");
6590
12
    if (!state->boolop_type) return -1;
6591
12
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6592
12
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6593
12
        "And");
6594
12
    if (!state->And_type) return -1;
6595
12
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6596
12
                                             NULL, NULL);
6597
12
    if (!state->And_singleton) return -1;
6598
12
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6599
12
        "Or");
6600
12
    if (!state->Or_type) return -1;
6601
12
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6602
12
                                            NULL, NULL);
6603
12
    if (!state->Or_singleton) return -1;
6604
12
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6605
12
                                     0,
6606
12
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6607
12
    if (!state->operator_type) return -1;
6608
12
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6609
12
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6610
12
        "Add");
6611
12
    if (!state->Add_type) return -1;
6612
12
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6613
12
                                             NULL, NULL);
6614
12
    if (!state->Add_singleton) return -1;
6615
12
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6616
12
        "Sub");
6617
12
    if (!state->Sub_type) return -1;
6618
12
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6619
12
                                             NULL, NULL);
6620
12
    if (!state->Sub_singleton) return -1;
6621
12
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6622
12
        "Mult");
6623
12
    if (!state->Mult_type) return -1;
6624
12
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6625
12
                                              NULL, NULL);
6626
12
    if (!state->Mult_singleton) return -1;
6627
12
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6628
12
                                    NULL, 0,
6629
12
        "MatMult");
6630
12
    if (!state->MatMult_type) return -1;
6631
12
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6632
12
                                                 *)state->MatMult_type, NULL,
6633
12
                                                 NULL);
6634
12
    if (!state->MatMult_singleton) return -1;
6635
12
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6636
12
        "Div");
6637
12
    if (!state->Div_type) return -1;
6638
12
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6639
12
                                             NULL, NULL);
6640
12
    if (!state->Div_singleton) return -1;
6641
12
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6642
12
        "Mod");
6643
12
    if (!state->Mod_type) return -1;
6644
12
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6645
12
                                             NULL, NULL);
6646
12
    if (!state->Mod_singleton) return -1;
6647
12
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6648
12
        "Pow");
6649
12
    if (!state->Pow_type) return -1;
6650
12
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6651
12
                                             NULL, NULL);
6652
12
    if (!state->Pow_singleton) return -1;
6653
12
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6654
12
                                   0,
6655
12
        "LShift");
6656
12
    if (!state->LShift_type) return -1;
6657
12
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6658
12
                                                *)state->LShift_type, NULL,
6659
12
                                                NULL);
6660
12
    if (!state->LShift_singleton) return -1;
6661
12
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6662
12
                                   0,
6663
12
        "RShift");
6664
12
    if (!state->RShift_type) return -1;
6665
12
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6666
12
                                                *)state->RShift_type, NULL,
6667
12
                                                NULL);
6668
12
    if (!state->RShift_singleton) return -1;
6669
12
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6670
12
        "BitOr");
6671
12
    if (!state->BitOr_type) return -1;
6672
12
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6673
12
                                               *)state->BitOr_type, NULL, NULL);
6674
12
    if (!state->BitOr_singleton) return -1;
6675
12
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6676
12
                                   0,
6677
12
        "BitXor");
6678
12
    if (!state->BitXor_type) return -1;
6679
12
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6680
12
                                                *)state->BitXor_type, NULL,
6681
12
                                                NULL);
6682
12
    if (!state->BitXor_singleton) return -1;
6683
12
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6684
12
                                   0,
6685
12
        "BitAnd");
6686
12
    if (!state->BitAnd_type) return -1;
6687
12
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6688
12
                                                *)state->BitAnd_type, NULL,
6689
12
                                                NULL);
6690
12
    if (!state->BitAnd_singleton) return -1;
6691
12
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6692
12
                                     NULL, 0,
6693
12
        "FloorDiv");
6694
12
    if (!state->FloorDiv_type) return -1;
6695
12
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6696
12
                                                  *)state->FloorDiv_type, NULL,
6697
12
                                                  NULL);
6698
12
    if (!state->FloorDiv_singleton) return -1;
6699
12
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6700
12
        "unaryop = Invert | Not | UAdd | USub");
6701
12
    if (!state->unaryop_type) return -1;
6702
12
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6703
12
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6704
12
                                   0,
6705
12
        "Invert");
6706
12
    if (!state->Invert_type) return -1;
6707
12
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6708
12
                                                *)state->Invert_type, NULL,
6709
12
                                                NULL);
6710
12
    if (!state->Invert_singleton) return -1;
6711
12
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6712
12
        "Not");
6713
12
    if (!state->Not_type) return -1;
6714
12
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6715
12
                                             NULL, NULL);
6716
12
    if (!state->Not_singleton) return -1;
6717
12
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6718
12
        "UAdd");
6719
12
    if (!state->UAdd_type) return -1;
6720
12
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6721
12
                                              NULL, NULL);
6722
12
    if (!state->UAdd_singleton) return -1;
6723
12
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6724
12
        "USub");
6725
12
    if (!state->USub_type) return -1;
6726
12
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6727
12
                                              NULL, NULL);
6728
12
    if (!state->USub_singleton) return -1;
6729
12
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6730
12
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6731
12
    if (!state->cmpop_type) return -1;
6732
12
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6733
12
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6734
12
        "Eq");
6735
12
    if (!state->Eq_type) return -1;
6736
12
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6737
12
                                            NULL, NULL);
6738
12
    if (!state->Eq_singleton) return -1;
6739
12
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6740
12
        "NotEq");
6741
12
    if (!state->NotEq_type) return -1;
6742
12
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6743
12
                                               *)state->NotEq_type, NULL, NULL);
6744
12
    if (!state->NotEq_singleton) return -1;
6745
12
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6746
12
        "Lt");
6747
12
    if (!state->Lt_type) return -1;
6748
12
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6749
12
                                            NULL, NULL);
6750
12
    if (!state->Lt_singleton) return -1;
6751
12
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6752
12
        "LtE");
6753
12
    if (!state->LtE_type) return -1;
6754
12
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6755
12
                                             NULL, NULL);
6756
12
    if (!state->LtE_singleton) return -1;
6757
12
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6758
12
        "Gt");
6759
12
    if (!state->Gt_type) return -1;
6760
12
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6761
12
                                            NULL, NULL);
6762
12
    if (!state->Gt_singleton) return -1;
6763
12
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6764
12
        "GtE");
6765
12
    if (!state->GtE_type) return -1;
6766
12
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6767
12
                                             NULL, NULL);
6768
12
    if (!state->GtE_singleton) return -1;
6769
12
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6770
12
        "Is");
6771
12
    if (!state->Is_type) return -1;
6772
12
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6773
12
                                            NULL, NULL);
6774
12
    if (!state->Is_singleton) return -1;
6775
12
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6776
12
        "IsNot");
6777
12
    if (!state->IsNot_type) return -1;
6778
12
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6779
12
                                               *)state->IsNot_type, NULL, NULL);
6780
12
    if (!state->IsNot_singleton) return -1;
6781
12
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6782
12
        "In");
6783
12
    if (!state->In_type) return -1;
6784
12
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6785
12
                                            NULL, NULL);
6786
12
    if (!state->In_singleton) return -1;
6787
12
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6788
12
        "NotIn");
6789
12
    if (!state->NotIn_type) return -1;
6790
12
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6791
12
                                               *)state->NotIn_type, NULL, NULL);
6792
12
    if (!state->NotIn_singleton) return -1;
6793
12
    state->comprehension_type = make_type(state, "comprehension",
6794
12
                                          state->AST_type,
6795
12
                                          comprehension_fields, 4,
6796
12
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6797
12
    if (!state->comprehension_type) return -1;
6798
12
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6799
0
        -1;
6800
12
    state->excepthandler_type = make_type(state, "excepthandler",
6801
12
                                          state->AST_type, NULL, 0,
6802
12
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6803
12
    if (!state->excepthandler_type) return -1;
6804
12
    if (add_attributes(state, state->excepthandler_type,
6805
12
        excepthandler_attributes, 4) < 0) return -1;
6806
12
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6807
12
        == -1)
6808
0
        return -1;
6809
12
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6810
12
        Py_None) == -1)
6811
0
        return -1;
6812
12
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6813
12
                                          state->excepthandler_type,
6814
12
                                          ExceptHandler_fields, 3,
6815
12
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6816
12
    if (!state->ExceptHandler_type) return -1;
6817
12
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6818
0
        return -1;
6819
12
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6820
0
        return -1;
6821
12
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6822
12
                                      arguments_fields, 7,
6823
12
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6824
12
    if (!state->arguments_type) return -1;
6825
12
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6826
12
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6827
0
        return -1;
6828
12
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6829
0
        return -1;
6830
12
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6831
12
        "arg(identifier arg, expr? annotation, string? type_comment)");
6832
12
    if (!state->arg_type) return -1;
6833
12
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6834
0
        -1;
6835
12
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6836
0
        return -1;
6837
12
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6838
0
        return -1;
6839
12
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6840
0
        return -1;
6841
12
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6842
0
        return -1;
6843
12
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6844
12
                                    keyword_fields, 2,
6845
12
        "keyword(identifier? arg, expr value)");
6846
12
    if (!state->keyword_type) return -1;
6847
12
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6848
0
        return -1;
6849
12
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6850
0
        return -1;
6851
12
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6852
0
        return -1;
6853
12
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6854
12
        == -1)
6855
0
        return -1;
6856
12
    state->alias_type = make_type(state, "alias", state->AST_type,
6857
12
                                  alias_fields, 2,
6858
12
        "alias(identifier name, identifier? asname)");
6859
12
    if (!state->alias_type) return -1;
6860
12
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6861
0
        return -1;
6862
12
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6863
0
        return -1;
6864
12
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6865
0
        return -1;
6866
12
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6867
12
        -1)
6868
0
        return -1;
6869
12
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6870
12
                                     withitem_fields, 2,
6871
12
        "withitem(expr context_expr, expr? optional_vars)");
6872
12
    if (!state->withitem_type) return -1;
6873
12
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6874
12
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6875
12
        == -1)
6876
0
        return -1;
6877
12
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6878
12
                                       match_case_fields, 3,
6879
12
        "match_case(pattern pattern, expr? guard, stmt* body)");
6880
12
    if (!state->match_case_type) return -1;
6881
12
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6882
12
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6883
0
        return -1;
6884
12
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6885
12
        "pattern = MatchValue(expr value)\n"
6886
12
        "        | MatchSingleton(constant value)\n"
6887
12
        "        | MatchSequence(pattern* patterns)\n"
6888
12
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6889
12
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6890
12
        "        | MatchStar(identifier? name)\n"
6891
12
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6892
12
        "        | MatchOr(pattern* patterns)");
6893
12
    if (!state->pattern_type) return -1;
6894
12
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6895
0
        return -1;
6896
12
    state->MatchValue_type = make_type(state, "MatchValue",
6897
12
                                       state->pattern_type, MatchValue_fields,
6898
12
                                       1,
6899
12
        "MatchValue(expr value)");
6900
12
    if (!state->MatchValue_type) return -1;
6901
12
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6902
12
                                           state->pattern_type,
6903
12
                                           MatchSingleton_fields, 1,
6904
12
        "MatchSingleton(constant value)");
6905
12
    if (!state->MatchSingleton_type) return -1;
6906
12
    state->MatchSequence_type = make_type(state, "MatchSequence",
6907
12
                                          state->pattern_type,
6908
12
                                          MatchSequence_fields, 1,
6909
12
        "MatchSequence(pattern* patterns)");
6910
12
    if (!state->MatchSequence_type) return -1;
6911
12
    state->MatchMapping_type = make_type(state, "MatchMapping",
6912
12
                                         state->pattern_type,
6913
12
                                         MatchMapping_fields, 3,
6914
12
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6915
12
    if (!state->MatchMapping_type) return -1;
6916
12
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6917
0
        return -1;
6918
12
    state->MatchClass_type = make_type(state, "MatchClass",
6919
12
                                       state->pattern_type, MatchClass_fields,
6920
12
                                       4,
6921
12
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6922
12
    if (!state->MatchClass_type) return -1;
6923
12
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6924
12
                                      MatchStar_fields, 1,
6925
12
        "MatchStar(identifier? name)");
6926
12
    if (!state->MatchStar_type) return -1;
6927
12
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6928
0
        return -1;
6929
12
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6930
12
                                    MatchAs_fields, 2,
6931
12
        "MatchAs(pattern? pattern, identifier? name)");
6932
12
    if (!state->MatchAs_type) return -1;
6933
12
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6934
0
        return -1;
6935
12
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6936
0
        return -1;
6937
12
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6938
12
                                    MatchOr_fields, 1,
6939
12
        "MatchOr(pattern* patterns)");
6940
12
    if (!state->MatchOr_type) return -1;
6941
12
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6942
12
                                        NULL, 0,
6943
12
        "type_ignore = TypeIgnore(int lineno, string tag)");
6944
12
    if (!state->type_ignore_type) return -1;
6945
12
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6946
12
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6947
12
                                       state->type_ignore_type,
6948
12
                                       TypeIgnore_fields, 2,
6949
12
        "TypeIgnore(int lineno, string tag)");
6950
12
    if (!state->TypeIgnore_type) return -1;
6951
12
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6952
12
                                       NULL, 0,
6953
12
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6954
12
        "           | ParamSpec(identifier name, expr? default_value)\n"
6955
12
        "           | TypeVarTuple(identifier name, expr? default_value)");
6956
12
    if (!state->type_param_type) return -1;
6957
12
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6958
12
        < 0) return -1;
6959
12
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6960
12
                                    TypeVar_fields, 3,
6961
12
        "TypeVar(identifier name, expr? bound, expr? default_value)");
6962
12
    if (!state->TypeVar_type) return -1;
6963
12
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
6964
0
        return -1;
6965
12
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
6966
12
        -1)
6967
0
        return -1;
6968
12
    state->ParamSpec_type = make_type(state, "ParamSpec",
6969
12
                                      state->type_param_type, ParamSpec_fields,
6970
12
                                      2,
6971
12
        "ParamSpec(identifier name, expr? default_value)");
6972
12
    if (!state->ParamSpec_type) return -1;
6973
12
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
6974
12
        == -1)
6975
0
        return -1;
6976
12
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
6977
12
                                         state->type_param_type,
6978
12
                                         TypeVarTuple_fields, 2,
6979
12
        "TypeVarTuple(identifier name, expr? default_value)");
6980
12
    if (!state->TypeVarTuple_type) return -1;
6981
12
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
6982
12
        Py_None) == -1)
6983
0
        return -1;
6984
6985
12
    if (!add_ast_annotations(state)) {
6986
0
        return -1;
6987
0
    }
6988
12
    return 0;
6989
12
}
6990
6991
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
6992
                       PyArena* arena);
6993
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
6994
                        PyArena* arena);
6995
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
6996
                        PyArena* arena);
6997
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
6998
                                expr_context_ty* out, PyArena* arena);
6999
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
7000
                          out, PyArena* arena);
7001
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
7002
                            operator_ty* out, PyArena* arena);
7003
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
7004
                           out, PyArena* arena);
7005
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
7006
                         PyArena* arena);
7007
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
7008
                                 comprehension_ty* out, PyArena* arena);
7009
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
7010
                                 excepthandler_ty* out, PyArena* arena);
7011
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
7012
                             arguments_ty* out, PyArena* arena);
7013
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
7014
                       PyArena* arena);
7015
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
7016
                           out, PyArena* arena);
7017
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
7018
                         PyArena* arena);
7019
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
7020
                            withitem_ty* out, PyArena* arena);
7021
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
7022
                              match_case_ty* out, PyArena* arena);
7023
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
7024
                           out, PyArena* arena);
7025
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
7026
                               type_ignore_ty* out, PyArena* arena);
7027
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
7028
                              type_param_ty* out, PyArena* arena);
7029
7030
mod_ty
7031
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
7032
              PyArena *arena)
7033
5.50k
{
7034
5.50k
    mod_ty p;
7035
5.50k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7036
5.50k
    if (!p)
7037
0
        return NULL;
7038
5.50k
    p->kind = Module_kind;
7039
5.50k
    p->v.Module.body = body;
7040
5.50k
    p->v.Module.type_ignores = type_ignores;
7041
5.50k
    return p;
7042
5.50k
}
7043
7044
mod_ty
7045
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7046
0
{
7047
0
    mod_ty p;
7048
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7049
0
    if (!p)
7050
0
        return NULL;
7051
0
    p->kind = Interactive_kind;
7052
0
    p->v.Interactive.body = body;
7053
0
    return p;
7054
0
}
7055
7056
mod_ty
7057
_PyAST_Expression(expr_ty body, PyArena *arena)
7058
166
{
7059
166
    mod_ty p;
7060
166
    if (!body) {
7061
0
        PyErr_SetString(PyExc_ValueError,
7062
0
                        "field 'body' is required for Expression");
7063
0
        return NULL;
7064
0
    }
7065
166
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7066
166
    if (!p)
7067
0
        return NULL;
7068
166
    p->kind = Expression_kind;
7069
166
    p->v.Expression.body = body;
7070
166
    return p;
7071
166
}
7072
7073
mod_ty
7074
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7075
0
{
7076
0
    mod_ty p;
7077
0
    if (!returns) {
7078
0
        PyErr_SetString(PyExc_ValueError,
7079
0
                        "field 'returns' is required for FunctionType");
7080
0
        return NULL;
7081
0
    }
7082
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7083
0
    if (!p)
7084
0
        return NULL;
7085
0
    p->kind = FunctionType_kind;
7086
0
    p->v.FunctionType.argtypes = argtypes;
7087
0
    p->v.FunctionType.returns = returns;
7088
0
    return p;
7089
0
}
7090
7091
stmt_ty
7092
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7093
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7094
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7095
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7096
                   *arena)
7097
6.31k
{
7098
6.31k
    stmt_ty p;
7099
6.31k
    if (!name) {
7100
0
        PyErr_SetString(PyExc_ValueError,
7101
0
                        "field 'name' is required for FunctionDef");
7102
0
        return NULL;
7103
0
    }
7104
6.31k
    if (!args) {
7105
0
        PyErr_SetString(PyExc_ValueError,
7106
0
                        "field 'args' is required for FunctionDef");
7107
0
        return NULL;
7108
0
    }
7109
6.31k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7110
6.31k
    if (!p)
7111
0
        return NULL;
7112
6.31k
    p->kind = FunctionDef_kind;
7113
6.31k
    p->v.FunctionDef.name = name;
7114
6.31k
    p->v.FunctionDef.args = args;
7115
6.31k
    p->v.FunctionDef.body = body;
7116
6.31k
    p->v.FunctionDef.decorator_list = decorator_list;
7117
6.31k
    p->v.FunctionDef.returns = returns;
7118
6.31k
    p->v.FunctionDef.type_comment = type_comment;
7119
6.31k
    p->v.FunctionDef.type_params = type_params;
7120
6.31k
    p->lineno = lineno;
7121
6.31k
    p->col_offset = col_offset;
7122
6.31k
    p->end_lineno = end_lineno;
7123
6.31k
    p->end_col_offset = end_col_offset;
7124
6.31k
    return p;
7125
6.31k
}
7126
7127
stmt_ty
7128
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7129
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7130
                        string type_comment, asdl_type_param_seq * type_params,
7131
                        int lineno, int col_offset, int end_lineno, int
7132
                        end_col_offset, PyArena *arena)
7133
366
{
7134
366
    stmt_ty p;
7135
366
    if (!name) {
7136
0
        PyErr_SetString(PyExc_ValueError,
7137
0
                        "field 'name' is required for AsyncFunctionDef");
7138
0
        return NULL;
7139
0
    }
7140
366
    if (!args) {
7141
0
        PyErr_SetString(PyExc_ValueError,
7142
0
                        "field 'args' is required for AsyncFunctionDef");
7143
0
        return NULL;
7144
0
    }
7145
366
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7146
366
    if (!p)
7147
0
        return NULL;
7148
366
    p->kind = AsyncFunctionDef_kind;
7149
366
    p->v.AsyncFunctionDef.name = name;
7150
366
    p->v.AsyncFunctionDef.args = args;
7151
366
    p->v.AsyncFunctionDef.body = body;
7152
366
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7153
366
    p->v.AsyncFunctionDef.returns = returns;
7154
366
    p->v.AsyncFunctionDef.type_comment = type_comment;
7155
366
    p->v.AsyncFunctionDef.type_params = type_params;
7156
366
    p->lineno = lineno;
7157
366
    p->col_offset = col_offset;
7158
366
    p->end_lineno = end_lineno;
7159
366
    p->end_col_offset = end_col_offset;
7160
366
    return p;
7161
366
}
7162
7163
stmt_ty
7164
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7165
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7166
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7167
                int end_lineno, int end_col_offset, PyArena *arena)
7168
3.64k
{
7169
3.64k
    stmt_ty p;
7170
3.64k
    if (!name) {
7171
0
        PyErr_SetString(PyExc_ValueError,
7172
0
                        "field 'name' is required for ClassDef");
7173
0
        return NULL;
7174
0
    }
7175
3.64k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7176
3.64k
    if (!p)
7177
0
        return NULL;
7178
3.64k
    p->kind = ClassDef_kind;
7179
3.64k
    p->v.ClassDef.name = name;
7180
3.64k
    p->v.ClassDef.bases = bases;
7181
3.64k
    p->v.ClassDef.keywords = keywords;
7182
3.64k
    p->v.ClassDef.body = body;
7183
3.64k
    p->v.ClassDef.decorator_list = decorator_list;
7184
3.64k
    p->v.ClassDef.type_params = type_params;
7185
3.64k
    p->lineno = lineno;
7186
3.64k
    p->col_offset = col_offset;
7187
3.64k
    p->end_lineno = end_lineno;
7188
3.64k
    p->end_col_offset = end_col_offset;
7189
3.64k
    return p;
7190
3.64k
}
7191
7192
stmt_ty
7193
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7194
              end_col_offset, PyArena *arena)
7195
3.16k
{
7196
3.16k
    stmt_ty p;
7197
3.16k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7198
3.16k
    if (!p)
7199
0
        return NULL;
7200
3.16k
    p->kind = Return_kind;
7201
3.16k
    p->v.Return.value = value;
7202
3.16k
    p->lineno = lineno;
7203
3.16k
    p->col_offset = col_offset;
7204
3.16k
    p->end_lineno = end_lineno;
7205
3.16k
    p->end_col_offset = end_col_offset;
7206
3.16k
    return p;
7207
3.16k
}
7208
7209
stmt_ty
7210
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7211
              end_lineno, int end_col_offset, PyArena *arena)
7212
501
{
7213
501
    stmt_ty p;
7214
501
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7215
501
    if (!p)
7216
0
        return NULL;
7217
501
    p->kind = Delete_kind;
7218
501
    p->v.Delete.targets = targets;
7219
501
    p->lineno = lineno;
7220
501
    p->col_offset = col_offset;
7221
501
    p->end_lineno = end_lineno;
7222
501
    p->end_col_offset = end_col_offset;
7223
501
    return p;
7224
501
}
7225
7226
stmt_ty
7227
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7228
              lineno, int col_offset, int end_lineno, int end_col_offset,
7229
              PyArena *arena)
7230
6.44k
{
7231
6.44k
    stmt_ty p;
7232
6.44k
    if (!value) {
7233
0
        PyErr_SetString(PyExc_ValueError,
7234
0
                        "field 'value' is required for Assign");
7235
0
        return NULL;
7236
0
    }
7237
6.44k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7238
6.44k
    if (!p)
7239
0
        return NULL;
7240
6.44k
    p->kind = Assign_kind;
7241
6.44k
    p->v.Assign.targets = targets;
7242
6.44k
    p->v.Assign.value = value;
7243
6.44k
    p->v.Assign.type_comment = type_comment;
7244
6.44k
    p->lineno = lineno;
7245
6.44k
    p->col_offset = col_offset;
7246
6.44k
    p->end_lineno = end_lineno;
7247
6.44k
    p->end_col_offset = end_col_offset;
7248
6.44k
    return p;
7249
6.44k
}
7250
7251
stmt_ty
7252
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7253
                 value, int lineno, int col_offset, int end_lineno, int
7254
                 end_col_offset, PyArena *arena)
7255
229
{
7256
229
    stmt_ty p;
7257
229
    if (!name) {
7258
0
        PyErr_SetString(PyExc_ValueError,
7259
0
                        "field 'name' is required for TypeAlias");
7260
0
        return NULL;
7261
0
    }
7262
229
    if (!value) {
7263
0
        PyErr_SetString(PyExc_ValueError,
7264
0
                        "field 'value' is required for TypeAlias");
7265
0
        return NULL;
7266
0
    }
7267
229
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7268
229
    if (!p)
7269
0
        return NULL;
7270
229
    p->kind = TypeAlias_kind;
7271
229
    p->v.TypeAlias.name = name;
7272
229
    p->v.TypeAlias.type_params = type_params;
7273
229
    p->v.TypeAlias.value = value;
7274
229
    p->lineno = lineno;
7275
229
    p->col_offset = col_offset;
7276
229
    p->end_lineno = end_lineno;
7277
229
    p->end_col_offset = end_col_offset;
7278
229
    return p;
7279
229
}
7280
7281
stmt_ty
7282
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7283
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7284
2.60k
{
7285
2.60k
    stmt_ty p;
7286
2.60k
    if (!target) {
7287
0
        PyErr_SetString(PyExc_ValueError,
7288
0
                        "field 'target' is required for AugAssign");
7289
0
        return NULL;
7290
0
    }
7291
2.60k
    if (!op) {
7292
0
        PyErr_SetString(PyExc_ValueError,
7293
0
                        "field 'op' is required for AugAssign");
7294
0
        return NULL;
7295
0
    }
7296
2.60k
    if (!value) {
7297
0
        PyErr_SetString(PyExc_ValueError,
7298
0
                        "field 'value' is required for AugAssign");
7299
0
        return NULL;
7300
0
    }
7301
2.60k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7302
2.60k
    if (!p)
7303
0
        return NULL;
7304
2.60k
    p->kind = AugAssign_kind;
7305
2.60k
    p->v.AugAssign.target = target;
7306
2.60k
    p->v.AugAssign.op = op;
7307
2.60k
    p->v.AugAssign.value = value;
7308
2.60k
    p->lineno = lineno;
7309
2.60k
    p->col_offset = col_offset;
7310
2.60k
    p->end_lineno = end_lineno;
7311
2.60k
    p->end_col_offset = end_col_offset;
7312
2.60k
    return p;
7313
2.60k
}
7314
7315
stmt_ty
7316
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7317
                 int lineno, int col_offset, int end_lineno, int
7318
                 end_col_offset, PyArena *arena)
7319
2.51k
{
7320
2.51k
    stmt_ty p;
7321
2.51k
    if (!target) {
7322
0
        PyErr_SetString(PyExc_ValueError,
7323
0
                        "field 'target' is required for AnnAssign");
7324
0
        return NULL;
7325
0
    }
7326
2.51k
    if (!annotation) {
7327
0
        PyErr_SetString(PyExc_ValueError,
7328
0
                        "field 'annotation' is required for AnnAssign");
7329
0
        return NULL;
7330
0
    }
7331
2.51k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7332
2.51k
    if (!p)
7333
0
        return NULL;
7334
2.51k
    p->kind = AnnAssign_kind;
7335
2.51k
    p->v.AnnAssign.target = target;
7336
2.51k
    p->v.AnnAssign.annotation = annotation;
7337
2.51k
    p->v.AnnAssign.value = value;
7338
2.51k
    p->v.AnnAssign.simple = simple;
7339
2.51k
    p->lineno = lineno;
7340
2.51k
    p->col_offset = col_offset;
7341
2.51k
    p->end_lineno = end_lineno;
7342
2.51k
    p->end_col_offset = end_col_offset;
7343
2.51k
    return p;
7344
2.51k
}
7345
7346
stmt_ty
7347
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7348
           orelse, string type_comment, int lineno, int col_offset, int
7349
           end_lineno, int end_col_offset, PyArena *arena)
7350
1.14k
{
7351
1.14k
    stmt_ty p;
7352
1.14k
    if (!target) {
7353
0
        PyErr_SetString(PyExc_ValueError,
7354
0
                        "field 'target' is required for For");
7355
0
        return NULL;
7356
0
    }
7357
1.14k
    if (!iter) {
7358
0
        PyErr_SetString(PyExc_ValueError,
7359
0
                        "field 'iter' is required for For");
7360
0
        return NULL;
7361
0
    }
7362
1.14k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7363
1.14k
    if (!p)
7364
0
        return NULL;
7365
1.14k
    p->kind = For_kind;
7366
1.14k
    p->v.For.target = target;
7367
1.14k
    p->v.For.iter = iter;
7368
1.14k
    p->v.For.body = body;
7369
1.14k
    p->v.For.orelse = orelse;
7370
1.14k
    p->v.For.type_comment = type_comment;
7371
1.14k
    p->lineno = lineno;
7372
1.14k
    p->col_offset = col_offset;
7373
1.14k
    p->end_lineno = end_lineno;
7374
1.14k
    p->end_col_offset = end_col_offset;
7375
1.14k
    return p;
7376
1.14k
}
7377
7378
stmt_ty
7379
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7380
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7381
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7382
318
{
7383
318
    stmt_ty p;
7384
318
    if (!target) {
7385
0
        PyErr_SetString(PyExc_ValueError,
7386
0
                        "field 'target' is required for AsyncFor");
7387
0
        return NULL;
7388
0
    }
7389
318
    if (!iter) {
7390
0
        PyErr_SetString(PyExc_ValueError,
7391
0
                        "field 'iter' is required for AsyncFor");
7392
0
        return NULL;
7393
0
    }
7394
318
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7395
318
    if (!p)
7396
0
        return NULL;
7397
318
    p->kind = AsyncFor_kind;
7398
318
    p->v.AsyncFor.target = target;
7399
318
    p->v.AsyncFor.iter = iter;
7400
318
    p->v.AsyncFor.body = body;
7401
318
    p->v.AsyncFor.orelse = orelse;
7402
318
    p->v.AsyncFor.type_comment = type_comment;
7403
318
    p->lineno = lineno;
7404
318
    p->col_offset = col_offset;
7405
318
    p->end_lineno = end_lineno;
7406
318
    p->end_col_offset = end_col_offset;
7407
318
    return p;
7408
318
}
7409
7410
stmt_ty
7411
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7412
             lineno, int col_offset, int end_lineno, int end_col_offset,
7413
             PyArena *arena)
7414
461
{
7415
461
    stmt_ty p;
7416
461
    if (!test) {
7417
0
        PyErr_SetString(PyExc_ValueError,
7418
0
                        "field 'test' is required for While");
7419
0
        return NULL;
7420
0
    }
7421
461
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7422
461
    if (!p)
7423
0
        return NULL;
7424
461
    p->kind = While_kind;
7425
461
    p->v.While.test = test;
7426
461
    p->v.While.body = body;
7427
461
    p->v.While.orelse = orelse;
7428
461
    p->lineno = lineno;
7429
461
    p->col_offset = col_offset;
7430
461
    p->end_lineno = end_lineno;
7431
461
    p->end_col_offset = end_col_offset;
7432
461
    return p;
7433
461
}
7434
7435
stmt_ty
7436
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7437
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7438
          *arena)
7439
4.54k
{
7440
4.54k
    stmt_ty p;
7441
4.54k
    if (!test) {
7442
0
        PyErr_SetString(PyExc_ValueError,
7443
0
                        "field 'test' is required for If");
7444
0
        return NULL;
7445
0
    }
7446
4.54k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7447
4.54k
    if (!p)
7448
0
        return NULL;
7449
4.54k
    p->kind = If_kind;
7450
4.54k
    p->v.If.test = test;
7451
4.54k
    p->v.If.body = body;
7452
4.54k
    p->v.If.orelse = orelse;
7453
4.54k
    p->lineno = lineno;
7454
4.54k
    p->col_offset = col_offset;
7455
4.54k
    p->end_lineno = end_lineno;
7456
4.54k
    p->end_col_offset = end_col_offset;
7457
4.54k
    return p;
7458
4.54k
}
7459
7460
stmt_ty
7461
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7462
            type_comment, int lineno, int col_offset, int end_lineno, int
7463
            end_col_offset, PyArena *arena)
7464
1.25k
{
7465
1.25k
    stmt_ty p;
7466
1.25k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7467
1.25k
    if (!p)
7468
0
        return NULL;
7469
1.25k
    p->kind = With_kind;
7470
1.25k
    p->v.With.items = items;
7471
1.25k
    p->v.With.body = body;
7472
1.25k
    p->v.With.type_comment = type_comment;
7473
1.25k
    p->lineno = lineno;
7474
1.25k
    p->col_offset = col_offset;
7475
1.25k
    p->end_lineno = end_lineno;
7476
1.25k
    p->end_col_offset = end_col_offset;
7477
1.25k
    return p;
7478
1.25k
}
7479
7480
stmt_ty
7481
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7482
                 type_comment, int lineno, int col_offset, int end_lineno, int
7483
                 end_col_offset, PyArena *arena)
7484
977
{
7485
977
    stmt_ty p;
7486
977
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7487
977
    if (!p)
7488
0
        return NULL;
7489
977
    p->kind = AsyncWith_kind;
7490
977
    p->v.AsyncWith.items = items;
7491
977
    p->v.AsyncWith.body = body;
7492
977
    p->v.AsyncWith.type_comment = type_comment;
7493
977
    p->lineno = lineno;
7494
977
    p->col_offset = col_offset;
7495
977
    p->end_lineno = end_lineno;
7496
977
    p->end_col_offset = end_col_offset;
7497
977
    return p;
7498
977
}
7499
7500
stmt_ty
7501
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7502
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7503
327
{
7504
327
    stmt_ty p;
7505
327
    if (!subject) {
7506
0
        PyErr_SetString(PyExc_ValueError,
7507
0
                        "field 'subject' is required for Match");
7508
0
        return NULL;
7509
0
    }
7510
327
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7511
327
    if (!p)
7512
0
        return NULL;
7513
327
    p->kind = Match_kind;
7514
327
    p->v.Match.subject = subject;
7515
327
    p->v.Match.cases = cases;
7516
327
    p->lineno = lineno;
7517
327
    p->col_offset = col_offset;
7518
327
    p->end_lineno = end_lineno;
7519
327
    p->end_col_offset = end_col_offset;
7520
327
    return p;
7521
327
}
7522
7523
stmt_ty
7524
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7525
             end_lineno, int end_col_offset, PyArena *arena)
7526
2.38k
{
7527
2.38k
    stmt_ty p;
7528
2.38k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7529
2.38k
    if (!p)
7530
0
        return NULL;
7531
2.38k
    p->kind = Raise_kind;
7532
2.38k
    p->v.Raise.exc = exc;
7533
2.38k
    p->v.Raise.cause = cause;
7534
2.38k
    p->lineno = lineno;
7535
2.38k
    p->col_offset = col_offset;
7536
2.38k
    p->end_lineno = end_lineno;
7537
2.38k
    p->end_col_offset = end_col_offset;
7538
2.38k
    return p;
7539
2.38k
}
7540
7541
stmt_ty
7542
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7543
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7544
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7545
3.04k
{
7546
3.04k
    stmt_ty p;
7547
3.04k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7548
3.04k
    if (!p)
7549
0
        return NULL;
7550
3.04k
    p->kind = Try_kind;
7551
3.04k
    p->v.Try.body = body;
7552
3.04k
    p->v.Try.handlers = handlers;
7553
3.04k
    p->v.Try.orelse = orelse;
7554
3.04k
    p->v.Try.finalbody = finalbody;
7555
3.04k
    p->lineno = lineno;
7556
3.04k
    p->col_offset = col_offset;
7557
3.04k
    p->end_lineno = end_lineno;
7558
3.04k
    p->end_col_offset = end_col_offset;
7559
3.04k
    return p;
7560
3.04k
}
7561
7562
stmt_ty
7563
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7564
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7565
               int col_offset, int end_lineno, int end_col_offset, PyArena
7566
               *arena)
7567
1.20k
{
7568
1.20k
    stmt_ty p;
7569
1.20k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7570
1.20k
    if (!p)
7571
0
        return NULL;
7572
1.20k
    p->kind = TryStar_kind;
7573
1.20k
    p->v.TryStar.body = body;
7574
1.20k
    p->v.TryStar.handlers = handlers;
7575
1.20k
    p->v.TryStar.orelse = orelse;
7576
1.20k
    p->v.TryStar.finalbody = finalbody;
7577
1.20k
    p->lineno = lineno;
7578
1.20k
    p->col_offset = col_offset;
7579
1.20k
    p->end_lineno = end_lineno;
7580
1.20k
    p->end_col_offset = end_col_offset;
7581
1.20k
    return p;
7582
1.20k
}
7583
7584
stmt_ty
7585
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7586
              end_lineno, int end_col_offset, PyArena *arena)
7587
1.20k
{
7588
1.20k
    stmt_ty p;
7589
1.20k
    if (!test) {
7590
0
        PyErr_SetString(PyExc_ValueError,
7591
0
                        "field 'test' is required for Assert");
7592
0
        return NULL;
7593
0
    }
7594
1.20k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7595
1.20k
    if (!p)
7596
0
        return NULL;
7597
1.20k
    p->kind = Assert_kind;
7598
1.20k
    p->v.Assert.test = test;
7599
1.20k
    p->v.Assert.msg = msg;
7600
1.20k
    p->lineno = lineno;
7601
1.20k
    p->col_offset = col_offset;
7602
1.20k
    p->end_lineno = end_lineno;
7603
1.20k
    p->end_col_offset = end_col_offset;
7604
1.20k
    return p;
7605
1.20k
}
7606
7607
stmt_ty
7608
_PyAST_Import(asdl_alias_seq * names, int lineno, int col_offset, int
7609
              end_lineno, int end_col_offset, PyArena *arena)
7610
2.14k
{
7611
2.14k
    stmt_ty p;
7612
2.14k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7613
2.14k
    if (!p)
7614
0
        return NULL;
7615
2.14k
    p->kind = Import_kind;
7616
2.14k
    p->v.Import.names = names;
7617
2.14k
    p->lineno = lineno;
7618
2.14k
    p->col_offset = col_offset;
7619
2.14k
    p->end_lineno = end_lineno;
7620
2.14k
    p->end_col_offset = end_col_offset;
7621
2.14k
    return p;
7622
2.14k
}
7623
7624
stmt_ty
7625
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7626
                  lineno, int col_offset, int end_lineno, int end_col_offset,
7627
                  PyArena *arena)
7628
2.83k
{
7629
2.83k
    stmt_ty p;
7630
2.83k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7631
2.83k
    if (!p)
7632
0
        return NULL;
7633
2.83k
    p->kind = ImportFrom_kind;
7634
2.83k
    p->v.ImportFrom.module = module;
7635
2.83k
    p->v.ImportFrom.names = names;
7636
2.83k
    p->v.ImportFrom.level = level;
7637
2.83k
    p->lineno = lineno;
7638
2.83k
    p->col_offset = col_offset;
7639
2.83k
    p->end_lineno = end_lineno;
7640
2.83k
    p->end_col_offset = end_col_offset;
7641
2.83k
    return p;
7642
2.83k
}
7643
7644
stmt_ty
7645
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7646
              end_lineno, int end_col_offset, PyArena *arena)
7647
699
{
7648
699
    stmt_ty p;
7649
699
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7650
699
    if (!p)
7651
0
        return NULL;
7652
699
    p->kind = Global_kind;
7653
699
    p->v.Global.names = names;
7654
699
    p->lineno = lineno;
7655
699
    p->col_offset = col_offset;
7656
699
    p->end_lineno = end_lineno;
7657
699
    p->end_col_offset = end_col_offset;
7658
699
    return p;
7659
699
}
7660
7661
stmt_ty
7662
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7663
                end_lineno, int end_col_offset, PyArena *arena)
7664
87
{
7665
87
    stmt_ty p;
7666
87
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7667
87
    if (!p)
7668
0
        return NULL;
7669
87
    p->kind = Nonlocal_kind;
7670
87
    p->v.Nonlocal.names = names;
7671
87
    p->lineno = lineno;
7672
87
    p->col_offset = col_offset;
7673
87
    p->end_lineno = end_lineno;
7674
87
    p->end_col_offset = end_col_offset;
7675
87
    return p;
7676
87
}
7677
7678
stmt_ty
7679
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7680
            end_col_offset, PyArena *arena)
7681
72.3k
{
7682
72.3k
    stmt_ty p;
7683
72.3k
    if (!value) {
7684
0
        PyErr_SetString(PyExc_ValueError,
7685
0
                        "field 'value' is required for Expr");
7686
0
        return NULL;
7687
0
    }
7688
72.3k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7689
72.3k
    if (!p)
7690
0
        return NULL;
7691
72.3k
    p->kind = Expr_kind;
7692
72.3k
    p->v.Expr.value = value;
7693
72.3k
    p->lineno = lineno;
7694
72.3k
    p->col_offset = col_offset;
7695
72.3k
    p->end_lineno = end_lineno;
7696
72.3k
    p->end_col_offset = end_col_offset;
7697
72.3k
    return p;
7698
72.3k
}
7699
7700
stmt_ty
7701
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7702
            PyArena *arena)
7703
1.06k
{
7704
1.06k
    stmt_ty p;
7705
1.06k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7706
1.06k
    if (!p)
7707
0
        return NULL;
7708
1.06k
    p->kind = Pass_kind;
7709
1.06k
    p->lineno = lineno;
7710
1.06k
    p->col_offset = col_offset;
7711
1.06k
    p->end_lineno = end_lineno;
7712
1.06k
    p->end_col_offset = end_col_offset;
7713
1.06k
    return p;
7714
1.06k
}
7715
7716
stmt_ty
7717
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7718
             PyArena *arena)
7719
1.69k
{
7720
1.69k
    stmt_ty p;
7721
1.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7722
1.69k
    if (!p)
7723
0
        return NULL;
7724
1.69k
    p->kind = Break_kind;
7725
1.69k
    p->lineno = lineno;
7726
1.69k
    p->col_offset = col_offset;
7727
1.69k
    p->end_lineno = end_lineno;
7728
1.69k
    p->end_col_offset = end_col_offset;
7729
1.69k
    return p;
7730
1.69k
}
7731
7732
stmt_ty
7733
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7734
                PyArena *arena)
7735
1.41k
{
7736
1.41k
    stmt_ty p;
7737
1.41k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7738
1.41k
    if (!p)
7739
0
        return NULL;
7740
1.41k
    p->kind = Continue_kind;
7741
1.41k
    p->lineno = lineno;
7742
1.41k
    p->col_offset = col_offset;
7743
1.41k
    p->end_lineno = end_lineno;
7744
1.41k
    p->end_col_offset = end_col_offset;
7745
1.41k
    return p;
7746
1.41k
}
7747
7748
expr_ty
7749
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7750
              int end_lineno, int end_col_offset, PyArena *arena)
7751
1.64k
{
7752
1.64k
    expr_ty p;
7753
1.64k
    if (!op) {
7754
0
        PyErr_SetString(PyExc_ValueError,
7755
0
                        "field 'op' is required for BoolOp");
7756
0
        return NULL;
7757
0
    }
7758
1.64k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7759
1.64k
    if (!p)
7760
0
        return NULL;
7761
1.64k
    p->kind = BoolOp_kind;
7762
1.64k
    p->v.BoolOp.op = op;
7763
1.64k
    p->v.BoolOp.values = values;
7764
1.64k
    p->lineno = lineno;
7765
1.64k
    p->col_offset = col_offset;
7766
1.64k
    p->end_lineno = end_lineno;
7767
1.64k
    p->end_col_offset = end_col_offset;
7768
1.64k
    return p;
7769
1.64k
}
7770
7771
expr_ty
7772
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7773
                 end_lineno, int end_col_offset, PyArena *arena)
7774
1.59k
{
7775
1.59k
    expr_ty p;
7776
1.59k
    if (!target) {
7777
0
        PyErr_SetString(PyExc_ValueError,
7778
0
                        "field 'target' is required for NamedExpr");
7779
0
        return NULL;
7780
0
    }
7781
1.59k
    if (!value) {
7782
0
        PyErr_SetString(PyExc_ValueError,
7783
0
                        "field 'value' is required for NamedExpr");
7784
0
        return NULL;
7785
0
    }
7786
1.59k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7787
1.59k
    if (!p)
7788
0
        return NULL;
7789
1.59k
    p->kind = NamedExpr_kind;
7790
1.59k
    p->v.NamedExpr.target = target;
7791
1.59k
    p->v.NamedExpr.value = value;
7792
1.59k
    p->lineno = lineno;
7793
1.59k
    p->col_offset = col_offset;
7794
1.59k
    p->end_lineno = end_lineno;
7795
1.59k
    p->end_col_offset = end_col_offset;
7796
1.59k
    return p;
7797
1.59k
}
7798
7799
expr_ty
7800
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7801
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7802
34.3k
{
7803
34.3k
    expr_ty p;
7804
34.3k
    if (!left) {
7805
0
        PyErr_SetString(PyExc_ValueError,
7806
0
                        "field 'left' is required for BinOp");
7807
0
        return NULL;
7808
0
    }
7809
34.3k
    if (!op) {
7810
0
        PyErr_SetString(PyExc_ValueError,
7811
0
                        "field 'op' is required for BinOp");
7812
0
        return NULL;
7813
0
    }
7814
34.3k
    if (!right) {
7815
0
        PyErr_SetString(PyExc_ValueError,
7816
0
                        "field 'right' is required for BinOp");
7817
0
        return NULL;
7818
0
    }
7819
34.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7820
34.3k
    if (!p)
7821
0
        return NULL;
7822
34.3k
    p->kind = BinOp_kind;
7823
34.3k
    p->v.BinOp.left = left;
7824
34.3k
    p->v.BinOp.op = op;
7825
34.3k
    p->v.BinOp.right = right;
7826
34.3k
    p->lineno = lineno;
7827
34.3k
    p->col_offset = col_offset;
7828
34.3k
    p->end_lineno = end_lineno;
7829
34.3k
    p->end_col_offset = end_col_offset;
7830
34.3k
    return p;
7831
34.3k
}
7832
7833
expr_ty
7834
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7835
               end_lineno, int end_col_offset, PyArena *arena)
7836
57.3k
{
7837
57.3k
    expr_ty p;
7838
57.3k
    if (!op) {
7839
0
        PyErr_SetString(PyExc_ValueError,
7840
0
                        "field 'op' is required for UnaryOp");
7841
0
        return NULL;
7842
0
    }
7843
57.3k
    if (!operand) {
7844
0
        PyErr_SetString(PyExc_ValueError,
7845
0
                        "field 'operand' is required for UnaryOp");
7846
0
        return NULL;
7847
0
    }
7848
57.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7849
57.3k
    if (!p)
7850
0
        return NULL;
7851
57.3k
    p->kind = UnaryOp_kind;
7852
57.3k
    p->v.UnaryOp.op = op;
7853
57.3k
    p->v.UnaryOp.operand = operand;
7854
57.3k
    p->lineno = lineno;
7855
57.3k
    p->col_offset = col_offset;
7856
57.3k
    p->end_lineno = end_lineno;
7857
57.3k
    p->end_col_offset = end_col_offset;
7858
57.3k
    return p;
7859
57.3k
}
7860
7861
expr_ty
7862
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7863
              end_lineno, int end_col_offset, PyArena *arena)
7864
2.50k
{
7865
2.50k
    expr_ty p;
7866
2.50k
    if (!args) {
7867
0
        PyErr_SetString(PyExc_ValueError,
7868
0
                        "field 'args' is required for Lambda");
7869
0
        return NULL;
7870
0
    }
7871
2.50k
    if (!body) {
7872
0
        PyErr_SetString(PyExc_ValueError,
7873
0
                        "field 'body' is required for Lambda");
7874
0
        return NULL;
7875
0
    }
7876
2.50k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7877
2.50k
    if (!p)
7878
0
        return NULL;
7879
2.50k
    p->kind = Lambda_kind;
7880
2.50k
    p->v.Lambda.args = args;
7881
2.50k
    p->v.Lambda.body = body;
7882
2.50k
    p->lineno = lineno;
7883
2.50k
    p->col_offset = col_offset;
7884
2.50k
    p->end_lineno = end_lineno;
7885
2.50k
    p->end_col_offset = end_col_offset;
7886
2.50k
    return p;
7887
2.50k
}
7888
7889
expr_ty
7890
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7891
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7892
1.27k
{
7893
1.27k
    expr_ty p;
7894
1.27k
    if (!test) {
7895
0
        PyErr_SetString(PyExc_ValueError,
7896
0
                        "field 'test' is required for IfExp");
7897
0
        return NULL;
7898
0
    }
7899
1.27k
    if (!body) {
7900
0
        PyErr_SetString(PyExc_ValueError,
7901
0
                        "field 'body' is required for IfExp");
7902
0
        return NULL;
7903
0
    }
7904
1.27k
    if (!orelse) {
7905
0
        PyErr_SetString(PyExc_ValueError,
7906
0
                        "field 'orelse' is required for IfExp");
7907
0
        return NULL;
7908
0
    }
7909
1.27k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7910
1.27k
    if (!p)
7911
0
        return NULL;
7912
1.27k
    p->kind = IfExp_kind;
7913
1.27k
    p->v.IfExp.test = test;
7914
1.27k
    p->v.IfExp.body = body;
7915
1.27k
    p->v.IfExp.orelse = orelse;
7916
1.27k
    p->lineno = lineno;
7917
1.27k
    p->col_offset = col_offset;
7918
1.27k
    p->end_lineno = end_lineno;
7919
1.27k
    p->end_col_offset = end_col_offset;
7920
1.27k
    return p;
7921
1.27k
}
7922
7923
expr_ty
7924
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7925
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7926
3.25k
{
7927
3.25k
    expr_ty p;
7928
3.25k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7929
3.25k
    if (!p)
7930
0
        return NULL;
7931
3.25k
    p->kind = Dict_kind;
7932
3.25k
    p->v.Dict.keys = keys;
7933
3.25k
    p->v.Dict.values = values;
7934
3.25k
    p->lineno = lineno;
7935
3.25k
    p->col_offset = col_offset;
7936
3.25k
    p->end_lineno = end_lineno;
7937
3.25k
    p->end_col_offset = end_col_offset;
7938
3.25k
    return p;
7939
3.25k
}
7940
7941
expr_ty
7942
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7943
           int end_col_offset, PyArena *arena)
7944
1.69k
{
7945
1.69k
    expr_ty p;
7946
1.69k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7947
1.69k
    if (!p)
7948
0
        return NULL;
7949
1.69k
    p->kind = Set_kind;
7950
1.69k
    p->v.Set.elts = elts;
7951
1.69k
    p->lineno = lineno;
7952
1.69k
    p->col_offset = col_offset;
7953
1.69k
    p->end_lineno = end_lineno;
7954
1.69k
    p->end_col_offset = end_col_offset;
7955
1.69k
    return p;
7956
1.69k
}
7957
7958
expr_ty
7959
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7960
                int col_offset, int end_lineno, int end_col_offset, PyArena
7961
                *arena)
7962
1.05k
{
7963
1.05k
    expr_ty p;
7964
1.05k
    if (!elt) {
7965
0
        PyErr_SetString(PyExc_ValueError,
7966
0
                        "field 'elt' is required for ListComp");
7967
0
        return NULL;
7968
0
    }
7969
1.05k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7970
1.05k
    if (!p)
7971
0
        return NULL;
7972
1.05k
    p->kind = ListComp_kind;
7973
1.05k
    p->v.ListComp.elt = elt;
7974
1.05k
    p->v.ListComp.generators = generators;
7975
1.05k
    p->lineno = lineno;
7976
1.05k
    p->col_offset = col_offset;
7977
1.05k
    p->end_lineno = end_lineno;
7978
1.05k
    p->end_col_offset = end_col_offset;
7979
1.05k
    return p;
7980
1.05k
}
7981
7982
expr_ty
7983
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
7984
               int col_offset, int end_lineno, int end_col_offset, PyArena
7985
               *arena)
7986
861
{
7987
861
    expr_ty p;
7988
861
    if (!elt) {
7989
0
        PyErr_SetString(PyExc_ValueError,
7990
0
                        "field 'elt' is required for SetComp");
7991
0
        return NULL;
7992
0
    }
7993
861
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7994
861
    if (!p)
7995
0
        return NULL;
7996
861
    p->kind = SetComp_kind;
7997
861
    p->v.SetComp.elt = elt;
7998
861
    p->v.SetComp.generators = generators;
7999
861
    p->lineno = lineno;
8000
861
    p->col_offset = col_offset;
8001
861
    p->end_lineno = end_lineno;
8002
861
    p->end_col_offset = end_col_offset;
8003
861
    return p;
8004
861
}
8005
8006
expr_ty
8007
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
8008
                generators, int lineno, int col_offset, int end_lineno, int
8009
                end_col_offset, PyArena *arena)
8010
594
{
8011
594
    expr_ty p;
8012
594
    if (!key) {
8013
0
        PyErr_SetString(PyExc_ValueError,
8014
0
                        "field 'key' is required for DictComp");
8015
0
        return NULL;
8016
0
    }
8017
594
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8018
594
    if (!p)
8019
0
        return NULL;
8020
594
    p->kind = DictComp_kind;
8021
594
    p->v.DictComp.key = key;
8022
594
    p->v.DictComp.value = value;
8023
594
    p->v.DictComp.generators = generators;
8024
594
    p->lineno = lineno;
8025
594
    p->col_offset = col_offset;
8026
594
    p->end_lineno = end_lineno;
8027
594
    p->end_col_offset = end_col_offset;
8028
594
    return p;
8029
594
}
8030
8031
expr_ty
8032
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8033
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8034
                    PyArena *arena)
8035
3.29k
{
8036
3.29k
    expr_ty p;
8037
3.29k
    if (!elt) {
8038
0
        PyErr_SetString(PyExc_ValueError,
8039
0
                        "field 'elt' is required for GeneratorExp");
8040
0
        return NULL;
8041
0
    }
8042
3.29k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8043
3.29k
    if (!p)
8044
0
        return NULL;
8045
3.29k
    p->kind = GeneratorExp_kind;
8046
3.29k
    p->v.GeneratorExp.elt = elt;
8047
3.29k
    p->v.GeneratorExp.generators = generators;
8048
3.29k
    p->lineno = lineno;
8049
3.29k
    p->col_offset = col_offset;
8050
3.29k
    p->end_lineno = end_lineno;
8051
3.29k
    p->end_col_offset = end_col_offset;
8052
3.29k
    return p;
8053
3.29k
}
8054
8055
expr_ty
8056
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8057
             end_col_offset, PyArena *arena)
8058
423
{
8059
423
    expr_ty p;
8060
423
    if (!value) {
8061
0
        PyErr_SetString(PyExc_ValueError,
8062
0
                        "field 'value' is required for Await");
8063
0
        return NULL;
8064
0
    }
8065
423
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8066
423
    if (!p)
8067
0
        return NULL;
8068
423
    p->kind = Await_kind;
8069
423
    p->v.Await.value = value;
8070
423
    p->lineno = lineno;
8071
423
    p->col_offset = col_offset;
8072
423
    p->end_lineno = end_lineno;
8073
423
    p->end_col_offset = end_col_offset;
8074
423
    return p;
8075
423
}
8076
8077
expr_ty
8078
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8079
             end_col_offset, PyArena *arena)
8080
2.02k
{
8081
2.02k
    expr_ty p;
8082
2.02k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8083
2.02k
    if (!p)
8084
0
        return NULL;
8085
2.02k
    p->kind = Yield_kind;
8086
2.02k
    p->v.Yield.value = value;
8087
2.02k
    p->lineno = lineno;
8088
2.02k
    p->col_offset = col_offset;
8089
2.02k
    p->end_lineno = end_lineno;
8090
2.02k
    p->end_col_offset = end_col_offset;
8091
2.02k
    return p;
8092
2.02k
}
8093
8094
expr_ty
8095
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8096
                 end_col_offset, PyArena *arena)
8097
279
{
8098
279
    expr_ty p;
8099
279
    if (!value) {
8100
0
        PyErr_SetString(PyExc_ValueError,
8101
0
                        "field 'value' is required for YieldFrom");
8102
0
        return NULL;
8103
0
    }
8104
279
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8105
279
    if (!p)
8106
0
        return NULL;
8107
279
    p->kind = YieldFrom_kind;
8108
279
    p->v.YieldFrom.value = value;
8109
279
    p->lineno = lineno;
8110
279
    p->col_offset = col_offset;
8111
279
    p->end_lineno = end_lineno;
8112
279
    p->end_col_offset = end_col_offset;
8113
279
    return p;
8114
279
}
8115
8116
expr_ty
8117
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8118
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8119
               PyArena *arena)
8120
4.68k
{
8121
4.68k
    expr_ty p;
8122
4.68k
    if (!left) {
8123
0
        PyErr_SetString(PyExc_ValueError,
8124
0
                        "field 'left' is required for Compare");
8125
0
        return NULL;
8126
0
    }
8127
4.68k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8128
4.68k
    if (!p)
8129
0
        return NULL;
8130
4.68k
    p->kind = Compare_kind;
8131
4.68k
    p->v.Compare.left = left;
8132
4.68k
    p->v.Compare.ops = ops;
8133
4.68k
    p->v.Compare.comparators = comparators;
8134
4.68k
    p->lineno = lineno;
8135
4.68k
    p->col_offset = col_offset;
8136
4.68k
    p->end_lineno = end_lineno;
8137
4.68k
    p->end_col_offset = end_col_offset;
8138
4.68k
    return p;
8139
4.68k
}
8140
8141
expr_ty
8142
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8143
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8144
            PyArena *arena)
8145
47.3k
{
8146
47.3k
    expr_ty p;
8147
47.3k
    if (!func) {
8148
0
        PyErr_SetString(PyExc_ValueError,
8149
0
                        "field 'func' is required for Call");
8150
0
        return NULL;
8151
0
    }
8152
47.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8153
47.3k
    if (!p)
8154
0
        return NULL;
8155
47.3k
    p->kind = Call_kind;
8156
47.3k
    p->v.Call.func = func;
8157
47.3k
    p->v.Call.args = args;
8158
47.3k
    p->v.Call.keywords = keywords;
8159
47.3k
    p->lineno = lineno;
8160
47.3k
    p->col_offset = col_offset;
8161
47.3k
    p->end_lineno = end_lineno;
8162
47.3k
    p->end_col_offset = end_col_offset;
8163
47.3k
    return p;
8164
47.3k
}
8165
8166
expr_ty
8167
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8168
                      lineno, int col_offset, int end_lineno, int
8169
                      end_col_offset, PyArena *arena)
8170
18.1k
{
8171
18.1k
    expr_ty p;
8172
18.1k
    if (!value) {
8173
0
        PyErr_SetString(PyExc_ValueError,
8174
0
                        "field 'value' is required for FormattedValue");
8175
0
        return NULL;
8176
0
    }
8177
18.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8178
18.1k
    if (!p)
8179
0
        return NULL;
8180
18.1k
    p->kind = FormattedValue_kind;
8181
18.1k
    p->v.FormattedValue.value = value;
8182
18.1k
    p->v.FormattedValue.conversion = conversion;
8183
18.1k
    p->v.FormattedValue.format_spec = format_spec;
8184
18.1k
    p->lineno = lineno;
8185
18.1k
    p->col_offset = col_offset;
8186
18.1k
    p->end_lineno = end_lineno;
8187
18.1k
    p->end_col_offset = end_col_offset;
8188
18.1k
    return p;
8189
18.1k
}
8190
8191
expr_ty
8192
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8193
                     format_spec, int lineno, int col_offset, int end_lineno,
8194
                     int end_col_offset, PyArena *arena)
8195
4.35k
{
8196
4.35k
    expr_ty p;
8197
4.35k
    if (!value) {
8198
0
        PyErr_SetString(PyExc_ValueError,
8199
0
                        "field 'value' is required for Interpolation");
8200
0
        return NULL;
8201
0
    }
8202
4.35k
    if (!str) {
8203
0
        PyErr_SetString(PyExc_ValueError,
8204
0
                        "field 'str' is required for Interpolation");
8205
0
        return NULL;
8206
0
    }
8207
4.35k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8208
4.35k
    if (!p)
8209
0
        return NULL;
8210
4.35k
    p->kind = Interpolation_kind;
8211
4.35k
    p->v.Interpolation.value = value;
8212
4.35k
    p->v.Interpolation.str = str;
8213
4.35k
    p->v.Interpolation.conversion = conversion;
8214
4.35k
    p->v.Interpolation.format_spec = format_spec;
8215
4.35k
    p->lineno = lineno;
8216
4.35k
    p->col_offset = col_offset;
8217
4.35k
    p->end_lineno = end_lineno;
8218
4.35k
    p->end_col_offset = end_col_offset;
8219
4.35k
    return p;
8220
4.35k
}
8221
8222
expr_ty
8223
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8224
                 end_lineno, int end_col_offset, PyArena *arena)
8225
29.7k
{
8226
29.7k
    expr_ty p;
8227
29.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8228
29.7k
    if (!p)
8229
0
        return NULL;
8230
29.7k
    p->kind = JoinedStr_kind;
8231
29.7k
    p->v.JoinedStr.values = values;
8232
29.7k
    p->lineno = lineno;
8233
29.7k
    p->col_offset = col_offset;
8234
29.7k
    p->end_lineno = end_lineno;
8235
29.7k
    p->end_col_offset = end_col_offset;
8236
29.7k
    return p;
8237
29.7k
}
8238
8239
expr_ty
8240
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8241
                   end_lineno, int end_col_offset, PyArena *arena)
8242
6.22k
{
8243
6.22k
    expr_ty p;
8244
6.22k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8245
6.22k
    if (!p)
8246
0
        return NULL;
8247
6.22k
    p->kind = TemplateStr_kind;
8248
6.22k
    p->v.TemplateStr.values = values;
8249
6.22k
    p->lineno = lineno;
8250
6.22k
    p->col_offset = col_offset;
8251
6.22k
    p->end_lineno = end_lineno;
8252
6.22k
    p->end_col_offset = end_col_offset;
8253
6.22k
    return p;
8254
6.22k
}
8255
8256
expr_ty
8257
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8258
                end_lineno, int end_col_offset, PyArena *arena)
8259
301k
{
8260
301k
    expr_ty p;
8261
301k
    if (!value) {
8262
2
        PyErr_SetString(PyExc_ValueError,
8263
2
                        "field 'value' is required for Constant");
8264
2
        return NULL;
8265
2
    }
8266
301k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8267
301k
    if (!p)
8268
0
        return NULL;
8269
301k
    p->kind = Constant_kind;
8270
301k
    p->v.Constant.value = value;
8271
301k
    p->v.Constant.kind = kind;
8272
301k
    p->lineno = lineno;
8273
301k
    p->col_offset = col_offset;
8274
301k
    p->end_lineno = end_lineno;
8275
301k
    p->end_col_offset = end_col_offset;
8276
301k
    return p;
8277
301k
}
8278
8279
expr_ty
8280
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8281
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8282
                 PyArena *arena)
8283
32.4k
{
8284
32.4k
    expr_ty p;
8285
32.4k
    if (!value) {
8286
0
        PyErr_SetString(PyExc_ValueError,
8287
0
                        "field 'value' is required for Attribute");
8288
0
        return NULL;
8289
0
    }
8290
32.4k
    if (!attr) {
8291
0
        PyErr_SetString(PyExc_ValueError,
8292
0
                        "field 'attr' is required for Attribute");
8293
0
        return NULL;
8294
0
    }
8295
32.4k
    if (!ctx) {
8296
0
        PyErr_SetString(PyExc_ValueError,
8297
0
                        "field 'ctx' is required for Attribute");
8298
0
        return NULL;
8299
0
    }
8300
32.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8301
32.4k
    if (!p)
8302
0
        return NULL;
8303
32.4k
    p->kind = Attribute_kind;
8304
32.4k
    p->v.Attribute.value = value;
8305
32.4k
    p->v.Attribute.attr = attr;
8306
32.4k
    p->v.Attribute.ctx = ctx;
8307
32.4k
    p->lineno = lineno;
8308
32.4k
    p->col_offset = col_offset;
8309
32.4k
    p->end_lineno = end_lineno;
8310
32.4k
    p->end_col_offset = end_col_offset;
8311
32.4k
    return p;
8312
32.4k
}
8313
8314
expr_ty
8315
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8316
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8317
                 *arena)
8318
4.21k
{
8319
4.21k
    expr_ty p;
8320
4.21k
    if (!value) {
8321
0
        PyErr_SetString(PyExc_ValueError,
8322
0
                        "field 'value' is required for Subscript");
8323
0
        return NULL;
8324
0
    }
8325
4.21k
    if (!slice) {
8326
0
        PyErr_SetString(PyExc_ValueError,
8327
0
                        "field 'slice' is required for Subscript");
8328
0
        return NULL;
8329
0
    }
8330
4.21k
    if (!ctx) {
8331
0
        PyErr_SetString(PyExc_ValueError,
8332
0
                        "field 'ctx' is required for Subscript");
8333
0
        return NULL;
8334
0
    }
8335
4.21k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8336
4.21k
    if (!p)
8337
0
        return NULL;
8338
4.21k
    p->kind = Subscript_kind;
8339
4.21k
    p->v.Subscript.value = value;
8340
4.21k
    p->v.Subscript.slice = slice;
8341
4.21k
    p->v.Subscript.ctx = ctx;
8342
4.21k
    p->lineno = lineno;
8343
4.21k
    p->col_offset = col_offset;
8344
4.21k
    p->end_lineno = end_lineno;
8345
4.21k
    p->end_col_offset = end_col_offset;
8346
4.21k
    return p;
8347
4.21k
}
8348
8349
expr_ty
8350
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8351
               int end_lineno, int end_col_offset, PyArena *arena)
8352
17.2k
{
8353
17.2k
    expr_ty p;
8354
17.2k
    if (!value) {
8355
0
        PyErr_SetString(PyExc_ValueError,
8356
0
                        "field 'value' is required for Starred");
8357
0
        return NULL;
8358
0
    }
8359
17.2k
    if (!ctx) {
8360
0
        PyErr_SetString(PyExc_ValueError,
8361
0
                        "field 'ctx' is required for Starred");
8362
0
        return NULL;
8363
0
    }
8364
17.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8365
17.2k
    if (!p)
8366
0
        return NULL;
8367
17.2k
    p->kind = Starred_kind;
8368
17.2k
    p->v.Starred.value = value;
8369
17.2k
    p->v.Starred.ctx = ctx;
8370
17.2k
    p->lineno = lineno;
8371
17.2k
    p->col_offset = col_offset;
8372
17.2k
    p->end_lineno = end_lineno;
8373
17.2k
    p->end_col_offset = end_col_offset;
8374
17.2k
    return p;
8375
17.2k
}
8376
8377
expr_ty
8378
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8379
            end_lineno, int end_col_offset, PyArena *arena)
8380
1.85M
{
8381
1.85M
    expr_ty p;
8382
1.85M
    if (!id) {
8383
0
        PyErr_SetString(PyExc_ValueError,
8384
0
                        "field 'id' is required for Name");
8385
0
        return NULL;
8386
0
    }
8387
1.85M
    if (!ctx) {
8388
0
        PyErr_SetString(PyExc_ValueError,
8389
0
                        "field 'ctx' is required for Name");
8390
0
        return NULL;
8391
0
    }
8392
1.85M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8393
1.85M
    if (!p)
8394
0
        return NULL;
8395
1.85M
    p->kind = Name_kind;
8396
1.85M
    p->v.Name.id = id;
8397
1.85M
    p->v.Name.ctx = ctx;
8398
1.85M
    p->lineno = lineno;
8399
1.85M
    p->col_offset = col_offset;
8400
1.85M
    p->end_lineno = end_lineno;
8401
1.85M
    p->end_col_offset = end_col_offset;
8402
1.85M
    return p;
8403
1.85M
}
8404
8405
expr_ty
8406
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8407
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8408
14.4k
{
8409
14.4k
    expr_ty p;
8410
14.4k
    if (!ctx) {
8411
0
        PyErr_SetString(PyExc_ValueError,
8412
0
                        "field 'ctx' is required for List");
8413
0
        return NULL;
8414
0
    }
8415
14.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8416
14.4k
    if (!p)
8417
0
        return NULL;
8418
14.4k
    p->kind = List_kind;
8419
14.4k
    p->v.List.elts = elts;
8420
14.4k
    p->v.List.ctx = ctx;
8421
14.4k
    p->lineno = lineno;
8422
14.4k
    p->col_offset = col_offset;
8423
14.4k
    p->end_lineno = end_lineno;
8424
14.4k
    p->end_col_offset = end_col_offset;
8425
14.4k
    return p;
8426
14.4k
}
8427
8428
expr_ty
8429
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8430
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8431
62.1k
{
8432
62.1k
    expr_ty p;
8433
62.1k
    if (!ctx) {
8434
0
        PyErr_SetString(PyExc_ValueError,
8435
0
                        "field 'ctx' is required for Tuple");
8436
0
        return NULL;
8437
0
    }
8438
62.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8439
62.1k
    if (!p)
8440
0
        return NULL;
8441
62.1k
    p->kind = Tuple_kind;
8442
62.1k
    p->v.Tuple.elts = elts;
8443
62.1k
    p->v.Tuple.ctx = ctx;
8444
62.1k
    p->lineno = lineno;
8445
62.1k
    p->col_offset = col_offset;
8446
62.1k
    p->end_lineno = end_lineno;
8447
62.1k
    p->end_col_offset = end_col_offset;
8448
62.1k
    return p;
8449
62.1k
}
8450
8451
expr_ty
8452
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8453
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8454
11.4k
{
8455
11.4k
    expr_ty p;
8456
11.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8457
11.4k
    if (!p)
8458
0
        return NULL;
8459
11.4k
    p->kind = Slice_kind;
8460
11.4k
    p->v.Slice.lower = lower;
8461
11.4k
    p->v.Slice.upper = upper;
8462
11.4k
    p->v.Slice.step = step;
8463
11.4k
    p->lineno = lineno;
8464
11.4k
    p->col_offset = col_offset;
8465
11.4k
    p->end_lineno = end_lineno;
8466
11.4k
    p->end_col_offset = end_col_offset;
8467
11.4k
    return p;
8468
11.4k
}
8469
8470
comprehension_ty
8471
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8472
                     is_async, PyArena *arena)
8473
7.95k
{
8474
7.95k
    comprehension_ty p;
8475
7.95k
    if (!target) {
8476
0
        PyErr_SetString(PyExc_ValueError,
8477
0
                        "field 'target' is required for comprehension");
8478
0
        return NULL;
8479
0
    }
8480
7.95k
    if (!iter) {
8481
0
        PyErr_SetString(PyExc_ValueError,
8482
0
                        "field 'iter' is required for comprehension");
8483
0
        return NULL;
8484
0
    }
8485
7.95k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8486
7.95k
    if (!p)
8487
0
        return NULL;
8488
7.95k
    p->target = target;
8489
7.95k
    p->iter = iter;
8490
7.95k
    p->ifs = ifs;
8491
7.95k
    p->is_async = is_async;
8492
7.95k
    return p;
8493
7.95k
}
8494
8495
excepthandler_ty
8496
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8497
                     lineno, int col_offset, int end_lineno, int
8498
                     end_col_offset, PyArena *arena)
8499
7.39k
{
8500
7.39k
    excepthandler_ty p;
8501
7.39k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8502
7.39k
    if (!p)
8503
0
        return NULL;
8504
7.39k
    p->kind = ExceptHandler_kind;
8505
7.39k
    p->v.ExceptHandler.type = type;
8506
7.39k
    p->v.ExceptHandler.name = name;
8507
7.39k
    p->v.ExceptHandler.body = body;
8508
7.39k
    p->lineno = lineno;
8509
7.39k
    p->col_offset = col_offset;
8510
7.39k
    p->end_lineno = end_lineno;
8511
7.39k
    p->end_col_offset = end_col_offset;
8512
7.39k
    return p;
8513
7.39k
}
8514
8515
arguments_ty
8516
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8517
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8518
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8519
                 *arena)
8520
15.7k
{
8521
15.7k
    arguments_ty p;
8522
15.7k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8523
15.7k
    if (!p)
8524
0
        return NULL;
8525
15.7k
    p->posonlyargs = posonlyargs;
8526
15.7k
    p->args = args;
8527
15.7k
    p->vararg = vararg;
8528
15.7k
    p->kwonlyargs = kwonlyargs;
8529
15.7k
    p->kw_defaults = kw_defaults;
8530
15.7k
    p->kwarg = kwarg;
8531
15.7k
    p->defaults = defaults;
8532
15.7k
    return p;
8533
15.7k
}
8534
8535
arg_ty
8536
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8537
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8538
435k
{
8539
435k
    arg_ty p;
8540
435k
    if (!arg) {
8541
0
        PyErr_SetString(PyExc_ValueError,
8542
0
                        "field 'arg' is required for arg");
8543
0
        return NULL;
8544
0
    }
8545
435k
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8546
435k
    if (!p)
8547
0
        return NULL;
8548
435k
    p->arg = arg;
8549
435k
    p->annotation = annotation;
8550
435k
    p->type_comment = type_comment;
8551
435k
    p->lineno = lineno;
8552
435k
    p->col_offset = col_offset;
8553
435k
    p->end_lineno = end_lineno;
8554
435k
    p->end_col_offset = end_col_offset;
8555
435k
    return p;
8556
435k
}
8557
8558
keyword_ty
8559
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8560
               end_lineno, int end_col_offset, PyArena *arena)
8561
28.5k
{
8562
28.5k
    keyword_ty p;
8563
28.5k
    if (!value) {
8564
0
        PyErr_SetString(PyExc_ValueError,
8565
0
                        "field 'value' is required for keyword");
8566
0
        return NULL;
8567
0
    }
8568
28.5k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8569
28.5k
    if (!p)
8570
0
        return NULL;
8571
28.5k
    p->arg = arg;
8572
28.5k
    p->value = value;
8573
28.5k
    p->lineno = lineno;
8574
28.5k
    p->col_offset = col_offset;
8575
28.5k
    p->end_lineno = end_lineno;
8576
28.5k
    p->end_col_offset = end_col_offset;
8577
28.5k
    return p;
8578
28.5k
}
8579
8580
alias_ty
8581
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8582
             int end_lineno, int end_col_offset, PyArena *arena)
8583
11.8k
{
8584
11.8k
    alias_ty p;
8585
11.8k
    if (!name) {
8586
0
        PyErr_SetString(PyExc_ValueError,
8587
0
                        "field 'name' is required for alias");
8588
0
        return NULL;
8589
0
    }
8590
11.8k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8591
11.8k
    if (!p)
8592
0
        return NULL;
8593
11.8k
    p->name = name;
8594
11.8k
    p->asname = asname;
8595
11.8k
    p->lineno = lineno;
8596
11.8k
    p->col_offset = col_offset;
8597
11.8k
    p->end_lineno = end_lineno;
8598
11.8k
    p->end_col_offset = end_col_offset;
8599
11.8k
    return p;
8600
11.8k
}
8601
8602
withitem_ty
8603
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8604
6.84k
{
8605
6.84k
    withitem_ty p;
8606
6.84k
    if (!context_expr) {
8607
0
        PyErr_SetString(PyExc_ValueError,
8608
0
                        "field 'context_expr' is required for withitem");
8609
0
        return NULL;
8610
0
    }
8611
6.84k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8612
6.84k
    if (!p)
8613
0
        return NULL;
8614
6.84k
    p->context_expr = context_expr;
8615
6.84k
    p->optional_vars = optional_vars;
8616
6.84k
    return p;
8617
6.84k
}
8618
8619
match_case_ty
8620
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8621
                  PyArena *arena)
8622
2.34k
{
8623
2.34k
    match_case_ty p;
8624
2.34k
    if (!pattern) {
8625
0
        PyErr_SetString(PyExc_ValueError,
8626
0
                        "field 'pattern' is required for match_case");
8627
0
        return NULL;
8628
0
    }
8629
2.34k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8630
2.34k
    if (!p)
8631
0
        return NULL;
8632
2.34k
    p->pattern = pattern;
8633
2.34k
    p->guard = guard;
8634
2.34k
    p->body = body;
8635
2.34k
    return p;
8636
2.34k
}
8637
8638
pattern_ty
8639
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8640
                  int end_col_offset, PyArena *arena)
8641
1.88k
{
8642
1.88k
    pattern_ty p;
8643
1.88k
    if (!value) {
8644
0
        PyErr_SetString(PyExc_ValueError,
8645
0
                        "field 'value' is required for MatchValue");
8646
0
        return NULL;
8647
0
    }
8648
1.88k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8649
1.88k
    if (!p)
8650
0
        return NULL;
8651
1.88k
    p->kind = MatchValue_kind;
8652
1.88k
    p->v.MatchValue.value = value;
8653
1.88k
    p->lineno = lineno;
8654
1.88k
    p->col_offset = col_offset;
8655
1.88k
    p->end_lineno = end_lineno;
8656
1.88k
    p->end_col_offset = end_col_offset;
8657
1.88k
    return p;
8658
1.88k
}
8659
8660
pattern_ty
8661
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8662
                      end_lineno, int end_col_offset, PyArena *arena)
8663
615
{
8664
615
    pattern_ty p;
8665
615
    if (!value) {
8666
0
        PyErr_SetString(PyExc_ValueError,
8667
0
                        "field 'value' is required for MatchSingleton");
8668
0
        return NULL;
8669
0
    }
8670
615
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8671
615
    if (!p)
8672
0
        return NULL;
8673
615
    p->kind = MatchSingleton_kind;
8674
615
    p->v.MatchSingleton.value = value;
8675
615
    p->lineno = lineno;
8676
615
    p->col_offset = col_offset;
8677
615
    p->end_lineno = end_lineno;
8678
615
    p->end_col_offset = end_col_offset;
8679
615
    return p;
8680
615
}
8681
8682
pattern_ty
8683
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8684
                     int end_lineno, int end_col_offset, PyArena *arena)
8685
2.73k
{
8686
2.73k
    pattern_ty p;
8687
2.73k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8688
2.73k
    if (!p)
8689
0
        return NULL;
8690
2.73k
    p->kind = MatchSequence_kind;
8691
2.73k
    p->v.MatchSequence.patterns = patterns;
8692
2.73k
    p->lineno = lineno;
8693
2.73k
    p->col_offset = col_offset;
8694
2.73k
    p->end_lineno = end_lineno;
8695
2.73k
    p->end_col_offset = end_col_offset;
8696
2.73k
    return p;
8697
2.73k
}
8698
8699
pattern_ty
8700
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8701
                    identifier rest, int lineno, int col_offset, int
8702
                    end_lineno, int end_col_offset, PyArena *arena)
8703
782
{
8704
782
    pattern_ty p;
8705
782
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8706
782
    if (!p)
8707
0
        return NULL;
8708
782
    p->kind = MatchMapping_kind;
8709
782
    p->v.MatchMapping.keys = keys;
8710
782
    p->v.MatchMapping.patterns = patterns;
8711
782
    p->v.MatchMapping.rest = rest;
8712
782
    p->lineno = lineno;
8713
782
    p->col_offset = col_offset;
8714
782
    p->end_lineno = end_lineno;
8715
782
    p->end_col_offset = end_col_offset;
8716
782
    return p;
8717
782
}
8718
8719
pattern_ty
8720
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8721
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8722
                  col_offset, int end_lineno, int end_col_offset, PyArena
8723
                  *arena)
8724
1.67k
{
8725
1.67k
    pattern_ty p;
8726
1.67k
    if (!cls) {
8727
0
        PyErr_SetString(PyExc_ValueError,
8728
0
                        "field 'cls' is required for MatchClass");
8729
0
        return NULL;
8730
0
    }
8731
1.67k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8732
1.67k
    if (!p)
8733
0
        return NULL;
8734
1.67k
    p->kind = MatchClass_kind;
8735
1.67k
    p->v.MatchClass.cls = cls;
8736
1.67k
    p->v.MatchClass.patterns = patterns;
8737
1.67k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8738
1.67k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8739
1.67k
    p->lineno = lineno;
8740
1.67k
    p->col_offset = col_offset;
8741
1.67k
    p->end_lineno = end_lineno;
8742
1.67k
    p->end_col_offset = end_col_offset;
8743
1.67k
    return p;
8744
1.67k
}
8745
8746
pattern_ty
8747
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8748
                 int end_col_offset, PyArena *arena)
8749
1.23k
{
8750
1.23k
    pattern_ty p;
8751
1.23k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8752
1.23k
    if (!p)
8753
0
        return NULL;
8754
1.23k
    p->kind = MatchStar_kind;
8755
1.23k
    p->v.MatchStar.name = name;
8756
1.23k
    p->lineno = lineno;
8757
1.23k
    p->col_offset = col_offset;
8758
1.23k
    p->end_lineno = end_lineno;
8759
1.23k
    p->end_col_offset = end_col_offset;
8760
1.23k
    return p;
8761
1.23k
}
8762
8763
pattern_ty
8764
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8765
               int end_lineno, int end_col_offset, PyArena *arena)
8766
18.1k
{
8767
18.1k
    pattern_ty p;
8768
18.1k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8769
18.1k
    if (!p)
8770
0
        return NULL;
8771
18.1k
    p->kind = MatchAs_kind;
8772
18.1k
    p->v.MatchAs.pattern = pattern;
8773
18.1k
    p->v.MatchAs.name = name;
8774
18.1k
    p->lineno = lineno;
8775
18.1k
    p->col_offset = col_offset;
8776
18.1k
    p->end_lineno = end_lineno;
8777
18.1k
    p->end_col_offset = end_col_offset;
8778
18.1k
    return p;
8779
18.1k
}
8780
8781
pattern_ty
8782
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8783
               end_lineno, int end_col_offset, PyArena *arena)
8784
5.54k
{
8785
5.54k
    pattern_ty p;
8786
5.54k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8787
5.54k
    if (!p)
8788
0
        return NULL;
8789
5.54k
    p->kind = MatchOr_kind;
8790
5.54k
    p->v.MatchOr.patterns = patterns;
8791
5.54k
    p->lineno = lineno;
8792
5.54k
    p->col_offset = col_offset;
8793
5.54k
    p->end_lineno = end_lineno;
8794
5.54k
    p->end_col_offset = end_col_offset;
8795
5.54k
    return p;
8796
5.54k
}
8797
8798
type_ignore_ty
8799
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8800
0
{
8801
0
    type_ignore_ty p;
8802
0
    if (!tag) {
8803
0
        PyErr_SetString(PyExc_ValueError,
8804
0
                        "field 'tag' is required for TypeIgnore");
8805
0
        return NULL;
8806
0
    }
8807
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8808
0
    if (!p)
8809
0
        return NULL;
8810
0
    p->kind = TypeIgnore_kind;
8811
0
    p->v.TypeIgnore.lineno = lineno;
8812
0
    p->v.TypeIgnore.tag = tag;
8813
0
    return p;
8814
0
}
8815
8816
type_param_ty
8817
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8818
               lineno, int col_offset, int end_lineno, int end_col_offset,
8819
               PyArena *arena)
8820
5.81k
{
8821
5.81k
    type_param_ty p;
8822
5.81k
    if (!name) {
8823
0
        PyErr_SetString(PyExc_ValueError,
8824
0
                        "field 'name' is required for TypeVar");
8825
0
        return NULL;
8826
0
    }
8827
5.81k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8828
5.81k
    if (!p)
8829
0
        return NULL;
8830
5.81k
    p->kind = TypeVar_kind;
8831
5.81k
    p->v.TypeVar.name = name;
8832
5.81k
    p->v.TypeVar.bound = bound;
8833
5.81k
    p->v.TypeVar.default_value = default_value;
8834
5.81k
    p->lineno = lineno;
8835
5.81k
    p->col_offset = col_offset;
8836
5.81k
    p->end_lineno = end_lineno;
8837
5.81k
    p->end_col_offset = end_col_offset;
8838
5.81k
    return p;
8839
5.81k
}
8840
8841
type_param_ty
8842
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8843
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8844
989
{
8845
989
    type_param_ty p;
8846
989
    if (!name) {
8847
0
        PyErr_SetString(PyExc_ValueError,
8848
0
                        "field 'name' is required for ParamSpec");
8849
0
        return NULL;
8850
0
    }
8851
989
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8852
989
    if (!p)
8853
0
        return NULL;
8854
989
    p->kind = ParamSpec_kind;
8855
989
    p->v.ParamSpec.name = name;
8856
989
    p->v.ParamSpec.default_value = default_value;
8857
989
    p->lineno = lineno;
8858
989
    p->col_offset = col_offset;
8859
989
    p->end_lineno = end_lineno;
8860
989
    p->end_col_offset = end_col_offset;
8861
989
    return p;
8862
989
}
8863
8864
type_param_ty
8865
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8866
                    col_offset, int end_lineno, int end_col_offset, PyArena
8867
                    *arena)
8868
1.52k
{
8869
1.52k
    type_param_ty p;
8870
1.52k
    if (!name) {
8871
0
        PyErr_SetString(PyExc_ValueError,
8872
0
                        "field 'name' is required for TypeVarTuple");
8873
0
        return NULL;
8874
0
    }
8875
1.52k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8876
1.52k
    if (!p)
8877
0
        return NULL;
8878
1.52k
    p->kind = TypeVarTuple_kind;
8879
1.52k
    p->v.TypeVarTuple.name = name;
8880
1.52k
    p->v.TypeVarTuple.default_value = default_value;
8881
1.52k
    p->lineno = lineno;
8882
1.52k
    p->col_offset = col_offset;
8883
1.52k
    p->end_lineno = end_lineno;
8884
1.52k
    p->end_col_offset = end_col_offset;
8885
1.52k
    return p;
8886
1.52k
}
8887
8888
8889
PyObject*
8890
ast2obj_mod(struct ast_state *state, void* _o)
8891
5.07k
{
8892
5.07k
    mod_ty o = (mod_ty)_o;
8893
5.07k
    PyObject *result = NULL, *value = NULL;
8894
5.07k
    PyTypeObject *tp;
8895
5.07k
    if (!o) {
8896
0
        Py_RETURN_NONE;
8897
0
    }
8898
5.07k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8899
0
        return NULL;
8900
0
    }
8901
5.07k
    switch (o->kind) {
8902
5.07k
    case Module_kind:
8903
5.07k
        tp = (PyTypeObject *)state->Module_type;
8904
5.07k
        result = PyType_GenericNew(tp, NULL, NULL);
8905
5.07k
        if (!result) goto failed;
8906
5.07k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8907
5.07k
        if (!value) goto failed;
8908
5.07k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8909
0
            goto failed;
8910
5.07k
        Py_DECREF(value);
8911
5.07k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8912
5.07k
                             ast2obj_type_ignore);
8913
5.07k
        if (!value) goto failed;
8914
5.07k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8915
0
            goto failed;
8916
5.07k
        Py_DECREF(value);
8917
5.07k
        break;
8918
0
    case Interactive_kind:
8919
0
        tp = (PyTypeObject *)state->Interactive_type;
8920
0
        result = PyType_GenericNew(tp, NULL, NULL);
8921
0
        if (!result) goto failed;
8922
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8923
0
                             ast2obj_stmt);
8924
0
        if (!value) goto failed;
8925
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8926
0
            goto failed;
8927
0
        Py_DECREF(value);
8928
0
        break;
8929
0
    case Expression_kind:
8930
0
        tp = (PyTypeObject *)state->Expression_type;
8931
0
        result = PyType_GenericNew(tp, NULL, NULL);
8932
0
        if (!result) goto failed;
8933
0
        value = ast2obj_expr(state, o->v.Expression.body);
8934
0
        if (!value) goto failed;
8935
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8936
0
            goto failed;
8937
0
        Py_DECREF(value);
8938
0
        break;
8939
0
    case FunctionType_kind:
8940
0
        tp = (PyTypeObject *)state->FunctionType_type;
8941
0
        result = PyType_GenericNew(tp, NULL, NULL);
8942
0
        if (!result) goto failed;
8943
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8944
0
                             ast2obj_expr);
8945
0
        if (!value) goto failed;
8946
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8947
0
            goto failed;
8948
0
        Py_DECREF(value);
8949
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8950
0
        if (!value) goto failed;
8951
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8952
0
            goto failed;
8953
0
        Py_DECREF(value);
8954
0
        break;
8955
5.07k
    }
8956
5.07k
    Py_LeaveRecursiveCall();
8957
5.07k
    return result;
8958
0
failed:
8959
0
    Py_LeaveRecursiveCall();
8960
0
    Py_XDECREF(value);
8961
0
    Py_XDECREF(result);
8962
0
    return NULL;
8963
5.07k
}
8964
8965
PyObject*
8966
ast2obj_stmt(struct ast_state *state, void* _o)
8967
35.7k
{
8968
35.7k
    stmt_ty o = (stmt_ty)_o;
8969
35.7k
    PyObject *result = NULL, *value = NULL;
8970
35.7k
    PyTypeObject *tp;
8971
35.7k
    if (!o) {
8972
0
        Py_RETURN_NONE;
8973
0
    }
8974
35.7k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8975
0
        return NULL;
8976
0
    }
8977
35.7k
    switch (o->kind) {
8978
1.52k
    case FunctionDef_kind:
8979
1.52k
        tp = (PyTypeObject *)state->FunctionDef_type;
8980
1.52k
        result = PyType_GenericNew(tp, NULL, NULL);
8981
1.52k
        if (!result) goto failed;
8982
1.52k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
8983
1.52k
        if (!value) goto failed;
8984
1.52k
        if (PyObject_SetAttr(result, state->name, value) == -1)
8985
0
            goto failed;
8986
1.52k
        Py_DECREF(value);
8987
1.52k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
8988
1.52k
        if (!value) goto failed;
8989
1.52k
        if (PyObject_SetAttr(result, state->args, value) == -1)
8990
0
            goto failed;
8991
1.52k
        Py_DECREF(value);
8992
1.52k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
8993
1.52k
                             ast2obj_stmt);
8994
1.52k
        if (!value) goto failed;
8995
1.52k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8996
0
            goto failed;
8997
1.52k
        Py_DECREF(value);
8998
1.52k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
8999
1.52k
                             ast2obj_expr);
9000
1.52k
        if (!value) goto failed;
9001
1.52k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9002
0
            goto failed;
9003
1.52k
        Py_DECREF(value);
9004
1.52k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
9005
1.52k
        if (!value) goto failed;
9006
1.52k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9007
0
            goto failed;
9008
1.52k
        Py_DECREF(value);
9009
1.52k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
9010
1.52k
        if (!value) goto failed;
9011
1.52k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9012
0
            goto failed;
9013
1.52k
        Py_DECREF(value);
9014
1.52k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
9015
1.52k
                             ast2obj_type_param);
9016
1.52k
        if (!value) goto failed;
9017
1.52k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9018
0
            goto failed;
9019
1.52k
        Py_DECREF(value);
9020
1.52k
        break;
9021
99
    case AsyncFunctionDef_kind:
9022
99
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9023
99
        result = PyType_GenericNew(tp, NULL, NULL);
9024
99
        if (!result) goto failed;
9025
99
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9026
99
        if (!value) goto failed;
9027
99
        if (PyObject_SetAttr(result, state->name, value) == -1)
9028
0
            goto failed;
9029
99
        Py_DECREF(value);
9030
99
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9031
99
        if (!value) goto failed;
9032
99
        if (PyObject_SetAttr(result, state->args, value) == -1)
9033
0
            goto failed;
9034
99
        Py_DECREF(value);
9035
99
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9036
99
                             ast2obj_stmt);
9037
99
        if (!value) goto failed;
9038
99
        if (PyObject_SetAttr(result, state->body, value) == -1)
9039
0
            goto failed;
9040
99
        Py_DECREF(value);
9041
99
        value = ast2obj_list(state,
9042
99
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9043
99
                             ast2obj_expr);
9044
99
        if (!value) goto failed;
9045
99
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9046
0
            goto failed;
9047
99
        Py_DECREF(value);
9048
99
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9049
99
        if (!value) goto failed;
9050
99
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9051
0
            goto failed;
9052
99
        Py_DECREF(value);
9053
99
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9054
99
        if (!value) goto failed;
9055
99
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9056
0
            goto failed;
9057
99
        Py_DECREF(value);
9058
99
        value = ast2obj_list(state,
9059
99
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9060
99
                             ast2obj_type_param);
9061
99
        if (!value) goto failed;
9062
99
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9063
0
            goto failed;
9064
99
        Py_DECREF(value);
9065
99
        break;
9066
609
    case ClassDef_kind:
9067
609
        tp = (PyTypeObject *)state->ClassDef_type;
9068
609
        result = PyType_GenericNew(tp, NULL, NULL);
9069
609
        if (!result) goto failed;
9070
609
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9071
609
        if (!value) goto failed;
9072
609
        if (PyObject_SetAttr(result, state->name, value) == -1)
9073
0
            goto failed;
9074
609
        Py_DECREF(value);
9075
609
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9076
609
                             ast2obj_expr);
9077
609
        if (!value) goto failed;
9078
609
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9079
0
            goto failed;
9080
609
        Py_DECREF(value);
9081
609
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9082
609
                             ast2obj_keyword);
9083
609
        if (!value) goto failed;
9084
609
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9085
0
            goto failed;
9086
609
        Py_DECREF(value);
9087
609
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9088
609
                             ast2obj_stmt);
9089
609
        if (!value) goto failed;
9090
609
        if (PyObject_SetAttr(result, state->body, value) == -1)
9091
0
            goto failed;
9092
609
        Py_DECREF(value);
9093
609
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9094
609
                             ast2obj_expr);
9095
609
        if (!value) goto failed;
9096
609
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9097
0
            goto failed;
9098
609
        Py_DECREF(value);
9099
609
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9100
609
                             ast2obj_type_param);
9101
609
        if (!value) goto failed;
9102
609
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9103
0
            goto failed;
9104
609
        Py_DECREF(value);
9105
609
        break;
9106
610
    case Return_kind:
9107
610
        tp = (PyTypeObject *)state->Return_type;
9108
610
        result = PyType_GenericNew(tp, NULL, NULL);
9109
610
        if (!result) goto failed;
9110
610
        value = ast2obj_expr(state, o->v.Return.value);
9111
610
        if (!value) goto failed;
9112
610
        if (PyObject_SetAttr(result, state->value, value) == -1)
9113
0
            goto failed;
9114
610
        Py_DECREF(value);
9115
610
        break;
9116
160
    case Delete_kind:
9117
160
        tp = (PyTypeObject *)state->Delete_type;
9118
160
        result = PyType_GenericNew(tp, NULL, NULL);
9119
160
        if (!result) goto failed;
9120
160
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9121
160
                             ast2obj_expr);
9122
160
        if (!value) goto failed;
9123
160
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9124
0
            goto failed;
9125
160
        Py_DECREF(value);
9126
160
        break;
9127
1.25k
    case Assign_kind:
9128
1.25k
        tp = (PyTypeObject *)state->Assign_type;
9129
1.25k
        result = PyType_GenericNew(tp, NULL, NULL);
9130
1.25k
        if (!result) goto failed;
9131
1.25k
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9132
1.25k
                             ast2obj_expr);
9133
1.25k
        if (!value) goto failed;
9134
1.25k
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9135
0
            goto failed;
9136
1.25k
        Py_DECREF(value);
9137
1.25k
        value = ast2obj_expr(state, o->v.Assign.value);
9138
1.25k
        if (!value) goto failed;
9139
1.25k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9140
0
            goto failed;
9141
1.25k
        Py_DECREF(value);
9142
1.25k
        value = ast2obj_string(state, o->v.Assign.type_comment);
9143
1.25k
        if (!value) goto failed;
9144
1.25k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9145
0
            goto failed;
9146
1.25k
        Py_DECREF(value);
9147
1.25k
        break;
9148
39
    case TypeAlias_kind:
9149
39
        tp = (PyTypeObject *)state->TypeAlias_type;
9150
39
        result = PyType_GenericNew(tp, NULL, NULL);
9151
39
        if (!result) goto failed;
9152
39
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9153
39
        if (!value) goto failed;
9154
39
        if (PyObject_SetAttr(result, state->name, value) == -1)
9155
0
            goto failed;
9156
39
        Py_DECREF(value);
9157
39
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9158
39
                             ast2obj_type_param);
9159
39
        if (!value) goto failed;
9160
39
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9161
0
            goto failed;
9162
39
        Py_DECREF(value);
9163
39
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9164
39
        if (!value) goto failed;
9165
39
        if (PyObject_SetAttr(result, state->value, value) == -1)
9166
0
            goto failed;
9167
39
        Py_DECREF(value);
9168
39
        break;
9169
328
    case AugAssign_kind:
9170
328
        tp = (PyTypeObject *)state->AugAssign_type;
9171
328
        result = PyType_GenericNew(tp, NULL, NULL);
9172
328
        if (!result) goto failed;
9173
328
        value = ast2obj_expr(state, o->v.AugAssign.target);
9174
328
        if (!value) goto failed;
9175
328
        if (PyObject_SetAttr(result, state->target, value) == -1)
9176
0
            goto failed;
9177
328
        Py_DECREF(value);
9178
328
        value = ast2obj_operator(state, o->v.AugAssign.op);
9179
328
        if (!value) goto failed;
9180
328
        if (PyObject_SetAttr(result, state->op, value) == -1)
9181
0
            goto failed;
9182
328
        Py_DECREF(value);
9183
328
        value = ast2obj_expr(state, o->v.AugAssign.value);
9184
328
        if (!value) goto failed;
9185
328
        if (PyObject_SetAttr(result, state->value, value) == -1)
9186
0
            goto failed;
9187
328
        Py_DECREF(value);
9188
328
        break;
9189
1.21k
    case AnnAssign_kind:
9190
1.21k
        tp = (PyTypeObject *)state->AnnAssign_type;
9191
1.21k
        result = PyType_GenericNew(tp, NULL, NULL);
9192
1.21k
        if (!result) goto failed;
9193
1.21k
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9194
1.21k
        if (!value) goto failed;
9195
1.21k
        if (PyObject_SetAttr(result, state->target, value) == -1)
9196
0
            goto failed;
9197
1.21k
        Py_DECREF(value);
9198
1.21k
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9199
1.21k
        if (!value) goto failed;
9200
1.21k
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9201
0
            goto failed;
9202
1.21k
        Py_DECREF(value);
9203
1.21k
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9204
1.21k
        if (!value) goto failed;
9205
1.21k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9206
0
            goto failed;
9207
1.21k
        Py_DECREF(value);
9208
1.21k
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9209
1.21k
        if (!value) goto failed;
9210
1.21k
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9211
0
            goto failed;
9212
1.21k
        Py_DECREF(value);
9213
1.21k
        break;
9214
342
    case For_kind:
9215
342
        tp = (PyTypeObject *)state->For_type;
9216
342
        result = PyType_GenericNew(tp, NULL, NULL);
9217
342
        if (!result) goto failed;
9218
342
        value = ast2obj_expr(state, o->v.For.target);
9219
342
        if (!value) goto failed;
9220
342
        if (PyObject_SetAttr(result, state->target, value) == -1)
9221
0
            goto failed;
9222
342
        Py_DECREF(value);
9223
342
        value = ast2obj_expr(state, o->v.For.iter);
9224
342
        if (!value) goto failed;
9225
342
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9226
0
            goto failed;
9227
342
        Py_DECREF(value);
9228
342
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9229
342
        if (!value) goto failed;
9230
342
        if (PyObject_SetAttr(result, state->body, value) == -1)
9231
0
            goto failed;
9232
342
        Py_DECREF(value);
9233
342
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9234
342
        if (!value) goto failed;
9235
342
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9236
0
            goto failed;
9237
342
        Py_DECREF(value);
9238
342
        value = ast2obj_string(state, o->v.For.type_comment);
9239
342
        if (!value) goto failed;
9240
342
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9241
0
            goto failed;
9242
342
        Py_DECREF(value);
9243
342
        break;
9244
144
    case AsyncFor_kind:
9245
144
        tp = (PyTypeObject *)state->AsyncFor_type;
9246
144
        result = PyType_GenericNew(tp, NULL, NULL);
9247
144
        if (!result) goto failed;
9248
144
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9249
144
        if (!value) goto failed;
9250
144
        if (PyObject_SetAttr(result, state->target, value) == -1)
9251
0
            goto failed;
9252
144
        Py_DECREF(value);
9253
144
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9254
144
        if (!value) goto failed;
9255
144
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9256
0
            goto failed;
9257
144
        Py_DECREF(value);
9258
144
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9259
144
                             ast2obj_stmt);
9260
144
        if (!value) goto failed;
9261
144
        if (PyObject_SetAttr(result, state->body, value) == -1)
9262
0
            goto failed;
9263
144
        Py_DECREF(value);
9264
144
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9265
144
                             ast2obj_stmt);
9266
144
        if (!value) goto failed;
9267
144
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9268
0
            goto failed;
9269
144
        Py_DECREF(value);
9270
144
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9271
144
        if (!value) goto failed;
9272
144
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9273
0
            goto failed;
9274
144
        Py_DECREF(value);
9275
144
        break;
9276
167
    case While_kind:
9277
167
        tp = (PyTypeObject *)state->While_type;
9278
167
        result = PyType_GenericNew(tp, NULL, NULL);
9279
167
        if (!result) goto failed;
9280
167
        value = ast2obj_expr(state, o->v.While.test);
9281
167
        if (!value) goto failed;
9282
167
        if (PyObject_SetAttr(result, state->test, value) == -1)
9283
0
            goto failed;
9284
167
        Py_DECREF(value);
9285
167
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9286
167
        if (!value) goto failed;
9287
167
        if (PyObject_SetAttr(result, state->body, value) == -1)
9288
0
            goto failed;
9289
167
        Py_DECREF(value);
9290
167
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9291
167
        if (!value) goto failed;
9292
167
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9293
0
            goto failed;
9294
167
        Py_DECREF(value);
9295
167
        break;
9296
521
    case If_kind:
9297
521
        tp = (PyTypeObject *)state->If_type;
9298
521
        result = PyType_GenericNew(tp, NULL, NULL);
9299
521
        if (!result) goto failed;
9300
521
        value = ast2obj_expr(state, o->v.If.test);
9301
521
        if (!value) goto failed;
9302
521
        if (PyObject_SetAttr(result, state->test, value) == -1)
9303
0
            goto failed;
9304
521
        Py_DECREF(value);
9305
521
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9306
521
        if (!value) goto failed;
9307
521
        if (PyObject_SetAttr(result, state->body, value) == -1)
9308
0
            goto failed;
9309
521
        Py_DECREF(value);
9310
521
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9311
521
        if (!value) goto failed;
9312
521
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9313
0
            goto failed;
9314
521
        Py_DECREF(value);
9315
521
        break;
9316
143
    case With_kind:
9317
143
        tp = (PyTypeObject *)state->With_type;
9318
143
        result = PyType_GenericNew(tp, NULL, NULL);
9319
143
        if (!result) goto failed;
9320
143
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9321
143
                             ast2obj_withitem);
9322
143
        if (!value) goto failed;
9323
143
        if (PyObject_SetAttr(result, state->items, value) == -1)
9324
0
            goto failed;
9325
143
        Py_DECREF(value);
9326
143
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9327
143
        if (!value) goto failed;
9328
143
        if (PyObject_SetAttr(result, state->body, value) == -1)
9329
0
            goto failed;
9330
143
        Py_DECREF(value);
9331
143
        value = ast2obj_string(state, o->v.With.type_comment);
9332
143
        if (!value) goto failed;
9333
143
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9334
0
            goto failed;
9335
143
        Py_DECREF(value);
9336
143
        break;
9337
212
    case AsyncWith_kind:
9338
212
        tp = (PyTypeObject *)state->AsyncWith_type;
9339
212
        result = PyType_GenericNew(tp, NULL, NULL);
9340
212
        if (!result) goto failed;
9341
212
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9342
212
                             ast2obj_withitem);
9343
212
        if (!value) goto failed;
9344
212
        if (PyObject_SetAttr(result, state->items, value) == -1)
9345
0
            goto failed;
9346
212
        Py_DECREF(value);
9347
212
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9348
212
                             ast2obj_stmt);
9349
212
        if (!value) goto failed;
9350
212
        if (PyObject_SetAttr(result, state->body, value) == -1)
9351
0
            goto failed;
9352
212
        Py_DECREF(value);
9353
212
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9354
212
        if (!value) goto failed;
9355
212
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9356
0
            goto failed;
9357
212
        Py_DECREF(value);
9358
212
        break;
9359
164
    case Match_kind:
9360
164
        tp = (PyTypeObject *)state->Match_type;
9361
164
        result = PyType_GenericNew(tp, NULL, NULL);
9362
164
        if (!result) goto failed;
9363
164
        value = ast2obj_expr(state, o->v.Match.subject);
9364
164
        if (!value) goto failed;
9365
164
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9366
0
            goto failed;
9367
164
        Py_DECREF(value);
9368
164
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9369
164
                             ast2obj_match_case);
9370
164
        if (!value) goto failed;
9371
164
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9372
0
            goto failed;
9373
164
        Py_DECREF(value);
9374
164
        break;
9375
345
    case Raise_kind:
9376
345
        tp = (PyTypeObject *)state->Raise_type;
9377
345
        result = PyType_GenericNew(tp, NULL, NULL);
9378
345
        if (!result) goto failed;
9379
345
        value = ast2obj_expr(state, o->v.Raise.exc);
9380
345
        if (!value) goto failed;
9381
345
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9382
0
            goto failed;
9383
345
        Py_DECREF(value);
9384
345
        value = ast2obj_expr(state, o->v.Raise.cause);
9385
345
        if (!value) goto failed;
9386
345
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9387
0
            goto failed;
9388
345
        Py_DECREF(value);
9389
345
        break;
9390
363
    case Try_kind:
9391
363
        tp = (PyTypeObject *)state->Try_type;
9392
363
        result = PyType_GenericNew(tp, NULL, NULL);
9393
363
        if (!result) goto failed;
9394
363
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9395
363
        if (!value) goto failed;
9396
363
        if (PyObject_SetAttr(result, state->body, value) == -1)
9397
0
            goto failed;
9398
363
        Py_DECREF(value);
9399
363
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9400
363
                             ast2obj_excepthandler);
9401
363
        if (!value) goto failed;
9402
363
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9403
0
            goto failed;
9404
363
        Py_DECREF(value);
9405
363
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9406
363
        if (!value) goto failed;
9407
363
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9408
0
            goto failed;
9409
363
        Py_DECREF(value);
9410
363
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9411
363
                             ast2obj_stmt);
9412
363
        if (!value) goto failed;
9413
363
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9414
0
            goto failed;
9415
363
        Py_DECREF(value);
9416
363
        break;
9417
323
    case TryStar_kind:
9418
323
        tp = (PyTypeObject *)state->TryStar_type;
9419
323
        result = PyType_GenericNew(tp, NULL, NULL);
9420
323
        if (!result) goto failed;
9421
323
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9422
323
        if (!value) goto failed;
9423
323
        if (PyObject_SetAttr(result, state->body, value) == -1)
9424
0
            goto failed;
9425
323
        Py_DECREF(value);
9426
323
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9427
323
                             ast2obj_excepthandler);
9428
323
        if (!value) goto failed;
9429
323
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9430
0
            goto failed;
9431
323
        Py_DECREF(value);
9432
323
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9433
323
                             ast2obj_stmt);
9434
323
        if (!value) goto failed;
9435
323
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9436
0
            goto failed;
9437
323
        Py_DECREF(value);
9438
323
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9439
323
                             ast2obj_stmt);
9440
323
        if (!value) goto failed;
9441
323
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9442
0
            goto failed;
9443
323
        Py_DECREF(value);
9444
323
        break;
9445
279
    case Assert_kind:
9446
279
        tp = (PyTypeObject *)state->Assert_type;
9447
279
        result = PyType_GenericNew(tp, NULL, NULL);
9448
279
        if (!result) goto failed;
9449
279
        value = ast2obj_expr(state, o->v.Assert.test);
9450
279
        if (!value) goto failed;
9451
279
        if (PyObject_SetAttr(result, state->test, value) == -1)
9452
0
            goto failed;
9453
279
        Py_DECREF(value);
9454
279
        value = ast2obj_expr(state, o->v.Assert.msg);
9455
279
        if (!value) goto failed;
9456
279
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9457
0
            goto failed;
9458
279
        Py_DECREF(value);
9459
279
        break;
9460
604
    case Import_kind:
9461
604
        tp = (PyTypeObject *)state->Import_type;
9462
604
        result = PyType_GenericNew(tp, NULL, NULL);
9463
604
        if (!result) goto failed;
9464
604
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9465
604
                             ast2obj_alias);
9466
604
        if (!value) goto failed;
9467
604
        if (PyObject_SetAttr(result, state->names, value) == -1)
9468
0
            goto failed;
9469
604
        Py_DECREF(value);
9470
604
        break;
9471
956
    case ImportFrom_kind:
9472
956
        tp = (PyTypeObject *)state->ImportFrom_type;
9473
956
        result = PyType_GenericNew(tp, NULL, NULL);
9474
956
        if (!result) goto failed;
9475
956
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9476
956
        if (!value) goto failed;
9477
956
        if (PyObject_SetAttr(result, state->module, value) == -1)
9478
0
            goto failed;
9479
956
        Py_DECREF(value);
9480
956
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9481
956
                             ast2obj_alias);
9482
956
        if (!value) goto failed;
9483
956
        if (PyObject_SetAttr(result, state->names, value) == -1)
9484
0
            goto failed;
9485
956
        Py_DECREF(value);
9486
956
        value = ast2obj_int(state, o->v.ImportFrom.level);
9487
956
        if (!value) goto failed;
9488
956
        if (PyObject_SetAttr(result, state->level, value) == -1)
9489
0
            goto failed;
9490
956
        Py_DECREF(value);
9491
956
        break;
9492
136
    case Global_kind:
9493
136
        tp = (PyTypeObject *)state->Global_type;
9494
136
        result = PyType_GenericNew(tp, NULL, NULL);
9495
136
        if (!result) goto failed;
9496
136
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9497
136
                             ast2obj_identifier);
9498
136
        if (!value) goto failed;
9499
136
        if (PyObject_SetAttr(result, state->names, value) == -1)
9500
0
            goto failed;
9501
136
        Py_DECREF(value);
9502
136
        break;
9503
57
    case Nonlocal_kind:
9504
57
        tp = (PyTypeObject *)state->Nonlocal_type;
9505
57
        result = PyType_GenericNew(tp, NULL, NULL);
9506
57
        if (!result) goto failed;
9507
57
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9508
57
                             ast2obj_identifier);
9509
57
        if (!value) goto failed;
9510
57
        if (PyObject_SetAttr(result, state->names, value) == -1)
9511
0
            goto failed;
9512
57
        Py_DECREF(value);
9513
57
        break;
9514
24.6k
    case Expr_kind:
9515
24.6k
        tp = (PyTypeObject *)state->Expr_type;
9516
24.6k
        result = PyType_GenericNew(tp, NULL, NULL);
9517
24.6k
        if (!result) goto failed;
9518
24.6k
        value = ast2obj_expr(state, o->v.Expr.value);
9519
24.6k
        if (!value) goto failed;
9520
24.6k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9521
0
            goto failed;
9522
24.6k
        Py_DECREF(value);
9523
24.6k
        break;
9524
143
    case Pass_kind:
9525
143
        tp = (PyTypeObject *)state->Pass_type;
9526
143
        result = PyType_GenericNew(tp, NULL, NULL);
9527
143
        if (!result) goto failed;
9528
143
        break;
9529
297
    case Break_kind:
9530
297
        tp = (PyTypeObject *)state->Break_type;
9531
297
        result = PyType_GenericNew(tp, NULL, NULL);
9532
297
        if (!result) goto failed;
9533
297
        break;
9534
297
    case Continue_kind:
9535
84
        tp = (PyTypeObject *)state->Continue_type;
9536
84
        result = PyType_GenericNew(tp, NULL, NULL);
9537
84
        if (!result) goto failed;
9538
84
        break;
9539
35.7k
    }
9540
35.7k
    value = ast2obj_int(state, o->lineno);
9541
35.7k
    if (!value) goto failed;
9542
35.7k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9543
0
        goto failed;
9544
35.7k
    Py_DECREF(value);
9545
35.7k
    value = ast2obj_int(state, o->col_offset);
9546
35.7k
    if (!value) goto failed;
9547
35.7k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9548
0
        goto failed;
9549
35.7k
    Py_DECREF(value);
9550
35.7k
    value = ast2obj_int(state, o->end_lineno);
9551
35.7k
    if (!value) goto failed;
9552
35.7k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9553
0
        goto failed;
9554
35.7k
    Py_DECREF(value);
9555
35.7k
    value = ast2obj_int(state, o->end_col_offset);
9556
35.7k
    if (!value) goto failed;
9557
35.7k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9558
0
        goto failed;
9559
35.7k
    Py_DECREF(value);
9560
35.7k
    Py_LeaveRecursiveCall();
9561
35.7k
    return result;
9562
0
failed:
9563
0
    Py_LeaveRecursiveCall();
9564
0
    Py_XDECREF(value);
9565
0
    Py_XDECREF(result);
9566
0
    return NULL;
9567
35.7k
}
9568
9569
PyObject*
9570
ast2obj_expr(struct ast_state *state, void* _o)
9571
242k
{
9572
242k
    expr_ty o = (expr_ty)_o;
9573
242k
    PyObject *result = NULL, *value = NULL;
9574
242k
    PyTypeObject *tp;
9575
242k
    if (!o) {
9576
36.6k
        Py_RETURN_NONE;
9577
36.6k
    }
9578
205k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9579
0
        return NULL;
9580
0
    }
9581
205k
    switch (o->kind) {
9582
343
    case BoolOp_kind:
9583
343
        tp = (PyTypeObject *)state->BoolOp_type;
9584
343
        result = PyType_GenericNew(tp, NULL, NULL);
9585
343
        if (!result) goto failed;
9586
343
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9587
343
        if (!value) goto failed;
9588
343
        if (PyObject_SetAttr(result, state->op, value) == -1)
9589
0
            goto failed;
9590
343
        Py_DECREF(value);
9591
343
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9592
343
                             ast2obj_expr);
9593
343
        if (!value) goto failed;
9594
343
        if (PyObject_SetAttr(result, state->values, value) == -1)
9595
0
            goto failed;
9596
343
        Py_DECREF(value);
9597
343
        break;
9598
37
    case NamedExpr_kind:
9599
37
        tp = (PyTypeObject *)state->NamedExpr_type;
9600
37
        result = PyType_GenericNew(tp, NULL, NULL);
9601
37
        if (!result) goto failed;
9602
37
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9603
37
        if (!value) goto failed;
9604
37
        if (PyObject_SetAttr(result, state->target, value) == -1)
9605
0
            goto failed;
9606
37
        Py_DECREF(value);
9607
37
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9608
37
        if (!value) goto failed;
9609
37
        if (PyObject_SetAttr(result, state->value, value) == -1)
9610
0
            goto failed;
9611
37
        Py_DECREF(value);
9612
37
        break;
9613
18.0k
    case BinOp_kind:
9614
18.0k
        tp = (PyTypeObject *)state->BinOp_type;
9615
18.0k
        result = PyType_GenericNew(tp, NULL, NULL);
9616
18.0k
        if (!result) goto failed;
9617
18.0k
        value = ast2obj_expr(state, o->v.BinOp.left);
9618
18.0k
        if (!value) goto failed;
9619
18.0k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9620
0
            goto failed;
9621
18.0k
        Py_DECREF(value);
9622
18.0k
        value = ast2obj_operator(state, o->v.BinOp.op);
9623
18.0k
        if (!value) goto failed;
9624
18.0k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9625
0
            goto failed;
9626
18.0k
        Py_DECREF(value);
9627
18.0k
        value = ast2obj_expr(state, o->v.BinOp.right);
9628
18.0k
        if (!value) goto failed;
9629
18.0k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9630
0
            goto failed;
9631
18.0k
        Py_DECREF(value);
9632
18.0k
        break;
9633
46.0k
    case UnaryOp_kind:
9634
46.0k
        tp = (PyTypeObject *)state->UnaryOp_type;
9635
46.0k
        result = PyType_GenericNew(tp, NULL, NULL);
9636
46.0k
        if (!result) goto failed;
9637
46.0k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9638
46.0k
        if (!value) goto failed;
9639
46.0k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9640
0
            goto failed;
9641
46.0k
        Py_DECREF(value);
9642
46.0k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9643
46.0k
        if (!value) goto failed;
9644
46.0k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9645
0
            goto failed;
9646
46.0k
        Py_DECREF(value);
9647
46.0k
        break;
9648
836
    case Lambda_kind:
9649
836
        tp = (PyTypeObject *)state->Lambda_type;
9650
836
        result = PyType_GenericNew(tp, NULL, NULL);
9651
836
        if (!result) goto failed;
9652
836
        value = ast2obj_arguments(state, o->v.Lambda.args);
9653
836
        if (!value) goto failed;
9654
836
        if (PyObject_SetAttr(result, state->args, value) == -1)
9655
0
            goto failed;
9656
836
        Py_DECREF(value);
9657
836
        value = ast2obj_expr(state, o->v.Lambda.body);
9658
836
        if (!value) goto failed;
9659
836
        if (PyObject_SetAttr(result, state->body, value) == -1)
9660
0
            goto failed;
9661
836
        Py_DECREF(value);
9662
836
        break;
9663
175
    case IfExp_kind:
9664
175
        tp = (PyTypeObject *)state->IfExp_type;
9665
175
        result = PyType_GenericNew(tp, NULL, NULL);
9666
175
        if (!result) goto failed;
9667
175
        value = ast2obj_expr(state, o->v.IfExp.test);
9668
175
        if (!value) goto failed;
9669
175
        if (PyObject_SetAttr(result, state->test, value) == -1)
9670
0
            goto failed;
9671
175
        Py_DECREF(value);
9672
175
        value = ast2obj_expr(state, o->v.IfExp.body);
9673
175
        if (!value) goto failed;
9674
175
        if (PyObject_SetAttr(result, state->body, value) == -1)
9675
0
            goto failed;
9676
175
        Py_DECREF(value);
9677
175
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9678
175
        if (!value) goto failed;
9679
175
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9680
0
            goto failed;
9681
175
        Py_DECREF(value);
9682
175
        break;
9683
1.10k
    case Dict_kind:
9684
1.10k
        tp = (PyTypeObject *)state->Dict_type;
9685
1.10k
        result = PyType_GenericNew(tp, NULL, NULL);
9686
1.10k
        if (!result) goto failed;
9687
1.10k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9688
1.10k
        if (!value) goto failed;
9689
1.10k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9690
0
            goto failed;
9691
1.10k
        Py_DECREF(value);
9692
1.10k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9693
1.10k
        if (!value) goto failed;
9694
1.10k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9695
0
            goto failed;
9696
1.10k
        Py_DECREF(value);
9697
1.10k
        break;
9698
528
    case Set_kind:
9699
528
        tp = (PyTypeObject *)state->Set_type;
9700
528
        result = PyType_GenericNew(tp, NULL, NULL);
9701
528
        if (!result) goto failed;
9702
528
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9703
528
        if (!value) goto failed;
9704
528
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9705
0
            goto failed;
9706
528
        Py_DECREF(value);
9707
528
        break;
9708
376
    case ListComp_kind:
9709
376
        tp = (PyTypeObject *)state->ListComp_type;
9710
376
        result = PyType_GenericNew(tp, NULL, NULL);
9711
376
        if (!result) goto failed;
9712
376
        value = ast2obj_expr(state, o->v.ListComp.elt);
9713
376
        if (!value) goto failed;
9714
376
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9715
0
            goto failed;
9716
376
        Py_DECREF(value);
9717
376
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9718
376
                             ast2obj_comprehension);
9719
376
        if (!value) goto failed;
9720
376
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9721
0
            goto failed;
9722
376
        Py_DECREF(value);
9723
376
        break;
9724
315
    case SetComp_kind:
9725
315
        tp = (PyTypeObject *)state->SetComp_type;
9726
315
        result = PyType_GenericNew(tp, NULL, NULL);
9727
315
        if (!result) goto failed;
9728
315
        value = ast2obj_expr(state, o->v.SetComp.elt);
9729
315
        if (!value) goto failed;
9730
315
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9731
0
            goto failed;
9732
315
        Py_DECREF(value);
9733
315
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9734
315
                             ast2obj_comprehension);
9735
315
        if (!value) goto failed;
9736
315
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9737
0
            goto failed;
9738
315
        Py_DECREF(value);
9739
315
        break;
9740
247
    case DictComp_kind:
9741
247
        tp = (PyTypeObject *)state->DictComp_type;
9742
247
        result = PyType_GenericNew(tp, NULL, NULL);
9743
247
        if (!result) goto failed;
9744
247
        value = ast2obj_expr(state, o->v.DictComp.key);
9745
247
        if (!value) goto failed;
9746
247
        if (PyObject_SetAttr(result, state->key, value) == -1)
9747
0
            goto failed;
9748
247
        Py_DECREF(value);
9749
247
        value = ast2obj_expr(state, o->v.DictComp.value);
9750
247
        if (!value) goto failed;
9751
247
        if (PyObject_SetAttr(result, state->value, value) == -1)
9752
0
            goto failed;
9753
247
        Py_DECREF(value);
9754
247
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9755
247
                             ast2obj_comprehension);
9756
247
        if (!value) goto failed;
9757
247
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9758
0
            goto failed;
9759
247
        Py_DECREF(value);
9760
247
        break;
9761
393
    case GeneratorExp_kind:
9762
393
        tp = (PyTypeObject *)state->GeneratorExp_type;
9763
393
        result = PyType_GenericNew(tp, NULL, NULL);
9764
393
        if (!result) goto failed;
9765
393
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9766
393
        if (!value) goto failed;
9767
393
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9768
0
            goto failed;
9769
393
        Py_DECREF(value);
9770
393
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9771
393
                             ast2obj_comprehension);
9772
393
        if (!value) goto failed;
9773
393
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9774
0
            goto failed;
9775
393
        Py_DECREF(value);
9776
393
        break;
9777
92
    case Await_kind:
9778
92
        tp = (PyTypeObject *)state->Await_type;
9779
92
        result = PyType_GenericNew(tp, NULL, NULL);
9780
92
        if (!result) goto failed;
9781
92
        value = ast2obj_expr(state, o->v.Await.value);
9782
92
        if (!value) goto failed;
9783
92
        if (PyObject_SetAttr(result, state->value, value) == -1)
9784
0
            goto failed;
9785
92
        Py_DECREF(value);
9786
92
        break;
9787
639
    case Yield_kind:
9788
639
        tp = (PyTypeObject *)state->Yield_type;
9789
639
        result = PyType_GenericNew(tp, NULL, NULL);
9790
639
        if (!result) goto failed;
9791
639
        value = ast2obj_expr(state, o->v.Yield.value);
9792
639
        if (!value) goto failed;
9793
639
        if (PyObject_SetAttr(result, state->value, value) == -1)
9794
0
            goto failed;
9795
639
        Py_DECREF(value);
9796
639
        break;
9797
45
    case YieldFrom_kind:
9798
45
        tp = (PyTypeObject *)state->YieldFrom_type;
9799
45
        result = PyType_GenericNew(tp, NULL, NULL);
9800
45
        if (!result) goto failed;
9801
45
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9802
45
        if (!value) goto failed;
9803
45
        if (PyObject_SetAttr(result, state->value, value) == -1)
9804
0
            goto failed;
9805
45
        Py_DECREF(value);
9806
45
        break;
9807
1.10k
    case Compare_kind:
9808
1.10k
        tp = (PyTypeObject *)state->Compare_type;
9809
1.10k
        result = PyType_GenericNew(tp, NULL, NULL);
9810
1.10k
        if (!result) goto failed;
9811
1.10k
        value = ast2obj_expr(state, o->v.Compare.left);
9812
1.10k
        if (!value) goto failed;
9813
1.10k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9814
0
            goto failed;
9815
1.10k
        Py_DECREF(value);
9816
1.10k
        {
9817
1.10k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9818
1.10k
            value = PyList_New(n);
9819
1.10k
            if (!value) goto failed;
9820
5.76k
            for(i = 0; i < n; i++)
9821
4.66k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9822
1.10k
        }
9823
1.10k
        if (!value) goto failed;
9824
1.10k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9825
0
            goto failed;
9826
1.10k
        Py_DECREF(value);
9827
1.10k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9828
1.10k
                             ast2obj_expr);
9829
1.10k
        if (!value) goto failed;
9830
1.10k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9831
0
            goto failed;
9832
1.10k
        Py_DECREF(value);
9833
1.10k
        break;
9834
5.38k
    case Call_kind:
9835
5.38k
        tp = (PyTypeObject *)state->Call_type;
9836
5.38k
        result = PyType_GenericNew(tp, NULL, NULL);
9837
5.38k
        if (!result) goto failed;
9838
5.38k
        value = ast2obj_expr(state, o->v.Call.func);
9839
5.38k
        if (!value) goto failed;
9840
5.38k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9841
0
            goto failed;
9842
5.38k
        Py_DECREF(value);
9843
5.38k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9844
5.38k
        if (!value) goto failed;
9845
5.38k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9846
0
            goto failed;
9847
5.38k
        Py_DECREF(value);
9848
5.38k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9849
5.38k
                             ast2obj_keyword);
9850
5.38k
        if (!value) goto failed;
9851
5.38k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9852
0
            goto failed;
9853
5.38k
        Py_DECREF(value);
9854
5.38k
        break;
9855
10.4k
    case FormattedValue_kind:
9856
10.4k
        tp = (PyTypeObject *)state->FormattedValue_type;
9857
10.4k
        result = PyType_GenericNew(tp, NULL, NULL);
9858
10.4k
        if (!result) goto failed;
9859
10.4k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9860
10.4k
        if (!value) goto failed;
9861
10.4k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9862
0
            goto failed;
9863
10.4k
        Py_DECREF(value);
9864
10.4k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9865
10.4k
        if (!value) goto failed;
9866
10.4k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9867
0
            goto failed;
9868
10.4k
        Py_DECREF(value);
9869
10.4k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9870
10.4k
        if (!value) goto failed;
9871
10.4k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9872
0
            goto failed;
9873
10.4k
        Py_DECREF(value);
9874
10.4k
        break;
9875
1.25k
    case Interpolation_kind:
9876
1.25k
        tp = (PyTypeObject *)state->Interpolation_type;
9877
1.25k
        result = PyType_GenericNew(tp, NULL, NULL);
9878
1.25k
        if (!result) goto failed;
9879
1.25k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9880
1.25k
        if (!value) goto failed;
9881
1.25k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9882
0
            goto failed;
9883
1.25k
        Py_DECREF(value);
9884
1.25k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9885
1.25k
        if (!value) goto failed;
9886
1.25k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9887
0
            goto failed;
9888
1.25k
        Py_DECREF(value);
9889
1.25k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9890
1.25k
        if (!value) goto failed;
9891
1.25k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9892
0
            goto failed;
9893
1.25k
        Py_DECREF(value);
9894
1.25k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9895
1.25k
        if (!value) goto failed;
9896
1.25k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9897
0
            goto failed;
9898
1.25k
        Py_DECREF(value);
9899
1.25k
        break;
9900
5.60k
    case JoinedStr_kind:
9901
5.60k
        tp = (PyTypeObject *)state->JoinedStr_type;
9902
5.60k
        result = PyType_GenericNew(tp, NULL, NULL);
9903
5.60k
        if (!result) goto failed;
9904
5.60k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9905
5.60k
                             ast2obj_expr);
9906
5.60k
        if (!value) goto failed;
9907
5.60k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9908
0
            goto failed;
9909
5.60k
        Py_DECREF(value);
9910
5.60k
        break;
9911
249
    case TemplateStr_kind:
9912
249
        tp = (PyTypeObject *)state->TemplateStr_type;
9913
249
        result = PyType_GenericNew(tp, NULL, NULL);
9914
249
        if (!result) goto failed;
9915
249
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9916
249
                             ast2obj_expr);
9917
249
        if (!value) goto failed;
9918
249
        if (PyObject_SetAttr(result, state->values, value) == -1)
9919
0
            goto failed;
9920
249
        Py_DECREF(value);
9921
249
        break;
9922
46.9k
    case Constant_kind:
9923
46.9k
        tp = (PyTypeObject *)state->Constant_type;
9924
46.9k
        result = PyType_GenericNew(tp, NULL, NULL);
9925
46.9k
        if (!result) goto failed;
9926
46.9k
        value = ast2obj_constant(state, o->v.Constant.value);
9927
46.9k
        if (!value) goto failed;
9928
46.9k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9929
0
            goto failed;
9930
46.9k
        Py_DECREF(value);
9931
46.9k
        value = ast2obj_string(state, o->v.Constant.kind);
9932
46.9k
        if (!value) goto failed;
9933
46.9k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9934
0
            goto failed;
9935
46.9k
        Py_DECREF(value);
9936
46.9k
        break;
9937
2.73k
    case Attribute_kind:
9938
2.73k
        tp = (PyTypeObject *)state->Attribute_type;
9939
2.73k
        result = PyType_GenericNew(tp, NULL, NULL);
9940
2.73k
        if (!result) goto failed;
9941
2.73k
        value = ast2obj_expr(state, o->v.Attribute.value);
9942
2.73k
        if (!value) goto failed;
9943
2.73k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9944
0
            goto failed;
9945
2.73k
        Py_DECREF(value);
9946
2.73k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9947
2.73k
        if (!value) goto failed;
9948
2.73k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
9949
0
            goto failed;
9950
2.73k
        Py_DECREF(value);
9951
2.73k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
9952
2.73k
        if (!value) goto failed;
9953
2.73k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9954
0
            goto failed;
9955
2.73k
        Py_DECREF(value);
9956
2.73k
        break;
9957
562
    case Subscript_kind:
9958
562
        tp = (PyTypeObject *)state->Subscript_type;
9959
562
        result = PyType_GenericNew(tp, NULL, NULL);
9960
562
        if (!result) goto failed;
9961
562
        value = ast2obj_expr(state, o->v.Subscript.value);
9962
562
        if (!value) goto failed;
9963
562
        if (PyObject_SetAttr(result, state->value, value) == -1)
9964
0
            goto failed;
9965
562
        Py_DECREF(value);
9966
562
        value = ast2obj_expr(state, o->v.Subscript.slice);
9967
562
        if (!value) goto failed;
9968
562
        if (PyObject_SetAttr(result, state->slice, value) == -1)
9969
0
            goto failed;
9970
562
        Py_DECREF(value);
9971
562
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
9972
562
        if (!value) goto failed;
9973
562
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9974
0
            goto failed;
9975
562
        Py_DECREF(value);
9976
562
        break;
9977
484
    case Starred_kind:
9978
484
        tp = (PyTypeObject *)state->Starred_type;
9979
484
        result = PyType_GenericNew(tp, NULL, NULL);
9980
484
        if (!result) goto failed;
9981
484
        value = ast2obj_expr(state, o->v.Starred.value);
9982
484
        if (!value) goto failed;
9983
484
        if (PyObject_SetAttr(result, state->value, value) == -1)
9984
0
            goto failed;
9985
484
        Py_DECREF(value);
9986
484
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
9987
484
        if (!value) goto failed;
9988
484
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
9989
0
            goto failed;
9990
484
        Py_DECREF(value);
9991
484
        break;
9992
52.5k
    case Name_kind:
9993
52.5k
        tp = (PyTypeObject *)state->Name_type;
9994
52.5k
        result = PyType_GenericNew(tp, NULL, NULL);
9995
52.5k
        if (!result) goto failed;
9996
52.5k
        value = ast2obj_identifier(state, o->v.Name.id);
9997
52.5k
        if (!value) goto failed;
9998
52.5k
        if (PyObject_SetAttr(result, state->id, value) == -1)
9999
0
            goto failed;
10000
52.5k
        Py_DECREF(value);
10001
52.5k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
10002
52.5k
        if (!value) goto failed;
10003
52.5k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10004
0
            goto failed;
10005
52.5k
        Py_DECREF(value);
10006
52.5k
        break;
10007
1.32k
    case List_kind:
10008
1.32k
        tp = (PyTypeObject *)state->List_type;
10009
1.32k
        result = PyType_GenericNew(tp, NULL, NULL);
10010
1.32k
        if (!result) goto failed;
10011
1.32k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10012
1.32k
        if (!value) goto failed;
10013
1.32k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10014
0
            goto failed;
10015
1.32k
        Py_DECREF(value);
10016
1.32k
        value = ast2obj_expr_context(state, o->v.List.ctx);
10017
1.32k
        if (!value) goto failed;
10018
1.32k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10019
0
            goto failed;
10020
1.32k
        Py_DECREF(value);
10021
1.32k
        break;
10022
5.67k
    case Tuple_kind:
10023
5.67k
        tp = (PyTypeObject *)state->Tuple_type;
10024
5.67k
        result = PyType_GenericNew(tp, NULL, NULL);
10025
5.67k
        if (!result) goto failed;
10026
5.67k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10027
5.67k
        if (!value) goto failed;
10028
5.67k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10029
0
            goto failed;
10030
5.67k
        Py_DECREF(value);
10031
5.67k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10032
5.67k
        if (!value) goto failed;
10033
5.67k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10034
0
            goto failed;
10035
5.67k
        Py_DECREF(value);
10036
5.67k
        break;
10037
1.98k
    case Slice_kind:
10038
1.98k
        tp = (PyTypeObject *)state->Slice_type;
10039
1.98k
        result = PyType_GenericNew(tp, NULL, NULL);
10040
1.98k
        if (!result) goto failed;
10041
1.98k
        value = ast2obj_expr(state, o->v.Slice.lower);
10042
1.98k
        if (!value) goto failed;
10043
1.98k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10044
0
            goto failed;
10045
1.98k
        Py_DECREF(value);
10046
1.98k
        value = ast2obj_expr(state, o->v.Slice.upper);
10047
1.98k
        if (!value) goto failed;
10048
1.98k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10049
0
            goto failed;
10050
1.98k
        Py_DECREF(value);
10051
1.98k
        value = ast2obj_expr(state, o->v.Slice.step);
10052
1.98k
        if (!value) goto failed;
10053
1.98k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10054
0
            goto failed;
10055
1.98k
        Py_DECREF(value);
10056
1.98k
        break;
10057
205k
    }
10058
205k
    value = ast2obj_int(state, o->lineno);
10059
205k
    if (!value) goto failed;
10060
205k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10061
0
        goto failed;
10062
205k
    Py_DECREF(value);
10063
205k
    value = ast2obj_int(state, o->col_offset);
10064
205k
    if (!value) goto failed;
10065
205k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10066
0
        goto failed;
10067
205k
    Py_DECREF(value);
10068
205k
    value = ast2obj_int(state, o->end_lineno);
10069
205k
    if (!value) goto failed;
10070
205k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10071
0
        goto failed;
10072
205k
    Py_DECREF(value);
10073
205k
    value = ast2obj_int(state, o->end_col_offset);
10074
205k
    if (!value) goto failed;
10075
205k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10076
0
        goto failed;
10077
205k
    Py_DECREF(value);
10078
205k
    Py_LeaveRecursiveCall();
10079
205k
    return result;
10080
0
failed:
10081
0
    Py_LeaveRecursiveCall();
10082
0
    Py_XDECREF(value);
10083
0
    Py_XDECREF(result);
10084
0
    return NULL;
10085
205k
}
10086
10087
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10088
63.3k
{
10089
63.3k
    switch(o) {
10090
57.3k
        case Load:
10091
57.3k
            return Py_NewRef(state->Load_singleton);
10092
5.69k
        case Store:
10093
5.69k
            return Py_NewRef(state->Store_singleton);
10094
221
        case Del:
10095
221
            return Py_NewRef(state->Del_singleton);
10096
63.3k
    }
10097
63.3k
    Py_UNREACHABLE();
10098
63.3k
}
10099
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10100
343
{
10101
343
    switch(o) {
10102
122
        case And:
10103
122
            return Py_NewRef(state->And_singleton);
10104
221
        case Or:
10105
221
            return Py_NewRef(state->Or_singleton);
10106
343
    }
10107
343
    Py_UNREACHABLE();
10108
343
}
10109
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10110
18.3k
{
10111
18.3k
    switch(o) {
10112
3.29k
        case Add:
10113
3.29k
            return Py_NewRef(state->Add_singleton);
10114
6.17k
        case Sub:
10115
6.17k
            return Py_NewRef(state->Sub_singleton);
10116
1.69k
        case Mult:
10117
1.69k
            return Py_NewRef(state->Mult_singleton);
10118
862
        case MatMult:
10119
862
            return Py_NewRef(state->MatMult_singleton);
10120
1.14k
        case Div:
10121
1.14k
            return Py_NewRef(state->Div_singleton);
10122
1.60k
        case Mod:
10123
1.60k
            return Py_NewRef(state->Mod_singleton);
10124
591
        case Pow:
10125
591
            return Py_NewRef(state->Pow_singleton);
10126
239
        case LShift:
10127
239
            return Py_NewRef(state->LShift_singleton);
10128
278
        case RShift:
10129
278
            return Py_NewRef(state->RShift_singleton);
10130
664
        case BitOr:
10131
664
            return Py_NewRef(state->BitOr_singleton);
10132
581
        case BitXor:
10133
581
            return Py_NewRef(state->BitXor_singleton);
10134
979
        case BitAnd:
10135
979
            return Py_NewRef(state->BitAnd_singleton);
10136
232
        case FloorDiv:
10137
232
            return Py_NewRef(state->FloorDiv_singleton);
10138
18.3k
    }
10139
18.3k
    Py_UNREACHABLE();
10140
18.3k
}
10141
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10142
46.0k
{
10143
46.0k
    switch(o) {
10144
6.13k
        case Invert:
10145
6.13k
            return Py_NewRef(state->Invert_singleton);
10146
114
        case Not:
10147
114
            return Py_NewRef(state->Not_singleton);
10148
13.6k
        case UAdd:
10149
13.6k
            return Py_NewRef(state->UAdd_singleton);
10150
26.0k
        case USub:
10151
26.0k
            return Py_NewRef(state->USub_singleton);
10152
46.0k
    }
10153
46.0k
    Py_UNREACHABLE();
10154
46.0k
}
10155
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10156
4.66k
{
10157
4.66k
    switch(o) {
10158
383
        case Eq:
10159
383
            return Py_NewRef(state->Eq_singleton);
10160
449
        case NotEq:
10161
449
            return Py_NewRef(state->NotEq_singleton);
10162
836
        case Lt:
10163
836
            return Py_NewRef(state->Lt_singleton);
10164
52
        case LtE:
10165
52
            return Py_NewRef(state->LtE_singleton);
10166
2.33k
        case Gt:
10167
2.33k
            return Py_NewRef(state->Gt_singleton);
10168
205
        case GtE:
10169
205
            return Py_NewRef(state->GtE_singleton);
10170
93
        case Is:
10171
93
            return Py_NewRef(state->Is_singleton);
10172
72
        case IsNot:
10173
72
            return Py_NewRef(state->IsNot_singleton);
10174
176
        case In:
10175
176
            return Py_NewRef(state->In_singleton);
10176
59
        case NotIn:
10177
59
            return Py_NewRef(state->NotIn_singleton);
10178
4.66k
    }
10179
4.66k
    Py_UNREACHABLE();
10180
4.66k
}
10181
PyObject*
10182
ast2obj_comprehension(struct ast_state *state, void* _o)
10183
1.39k
{
10184
1.39k
    comprehension_ty o = (comprehension_ty)_o;
10185
1.39k
    PyObject *result = NULL, *value = NULL;
10186
1.39k
    PyTypeObject *tp;
10187
1.39k
    if (!o) {
10188
0
        Py_RETURN_NONE;
10189
0
    }
10190
1.39k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10191
0
        return NULL;
10192
0
    }
10193
1.39k
    tp = (PyTypeObject *)state->comprehension_type;
10194
1.39k
    result = PyType_GenericNew(tp, NULL, NULL);
10195
1.39k
    if (!result) return NULL;
10196
1.39k
    value = ast2obj_expr(state, o->target);
10197
1.39k
    if (!value) goto failed;
10198
1.39k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10199
0
        goto failed;
10200
1.39k
    Py_DECREF(value);
10201
1.39k
    value = ast2obj_expr(state, o->iter);
10202
1.39k
    if (!value) goto failed;
10203
1.39k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10204
0
        goto failed;
10205
1.39k
    Py_DECREF(value);
10206
1.39k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10207
1.39k
    if (!value) goto failed;
10208
1.39k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10209
0
        goto failed;
10210
1.39k
    Py_DECREF(value);
10211
1.39k
    value = ast2obj_int(state, o->is_async);
10212
1.39k
    if (!value) goto failed;
10213
1.39k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10214
0
        goto failed;
10215
1.39k
    Py_DECREF(value);
10216
1.39k
    Py_LeaveRecursiveCall();
10217
1.39k
    return result;
10218
0
failed:
10219
0
    Py_LeaveRecursiveCall();
10220
0
    Py_XDECREF(value);
10221
0
    Py_XDECREF(result);
10222
0
    return NULL;
10223
1.39k
}
10224
10225
PyObject*
10226
ast2obj_excepthandler(struct ast_state *state, void* _o)
10227
910
{
10228
910
    excepthandler_ty o = (excepthandler_ty)_o;
10229
910
    PyObject *result = NULL, *value = NULL;
10230
910
    PyTypeObject *tp;
10231
910
    if (!o) {
10232
0
        Py_RETURN_NONE;
10233
0
    }
10234
910
    if (Py_EnterRecursiveCall("during  ast construction")) {
10235
0
        return NULL;
10236
0
    }
10237
910
    switch (o->kind) {
10238
910
    case ExceptHandler_kind:
10239
910
        tp = (PyTypeObject *)state->ExceptHandler_type;
10240
910
        result = PyType_GenericNew(tp, NULL, NULL);
10241
910
        if (!result) goto failed;
10242
910
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10243
910
        if (!value) goto failed;
10244
910
        if (PyObject_SetAttr(result, state->type, value) == -1)
10245
0
            goto failed;
10246
910
        Py_DECREF(value);
10247
910
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10248
910
        if (!value) goto failed;
10249
910
        if (PyObject_SetAttr(result, state->name, value) == -1)
10250
0
            goto failed;
10251
910
        Py_DECREF(value);
10252
910
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10253
910
                             ast2obj_stmt);
10254
910
        if (!value) goto failed;
10255
910
        if (PyObject_SetAttr(result, state->body, value) == -1)
10256
0
            goto failed;
10257
910
        Py_DECREF(value);
10258
910
        break;
10259
910
    }
10260
910
    value = ast2obj_int(state, o->lineno);
10261
910
    if (!value) goto failed;
10262
910
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10263
0
        goto failed;
10264
910
    Py_DECREF(value);
10265
910
    value = ast2obj_int(state, o->col_offset);
10266
910
    if (!value) goto failed;
10267
910
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10268
0
        goto failed;
10269
910
    Py_DECREF(value);
10270
910
    value = ast2obj_int(state, o->end_lineno);
10271
910
    if (!value) goto failed;
10272
910
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10273
0
        goto failed;
10274
910
    Py_DECREF(value);
10275
910
    value = ast2obj_int(state, o->end_col_offset);
10276
910
    if (!value) goto failed;
10277
910
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10278
0
        goto failed;
10279
910
    Py_DECREF(value);
10280
910
    Py_LeaveRecursiveCall();
10281
910
    return result;
10282
0
failed:
10283
0
    Py_LeaveRecursiveCall();
10284
0
    Py_XDECREF(value);
10285
0
    Py_XDECREF(result);
10286
0
    return NULL;
10287
910
}
10288
10289
PyObject*
10290
ast2obj_arguments(struct ast_state *state, void* _o)
10291
2.46k
{
10292
2.46k
    arguments_ty o = (arguments_ty)_o;
10293
2.46k
    PyObject *result = NULL, *value = NULL;
10294
2.46k
    PyTypeObject *tp;
10295
2.46k
    if (!o) {
10296
0
        Py_RETURN_NONE;
10297
0
    }
10298
2.46k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10299
0
        return NULL;
10300
0
    }
10301
2.46k
    tp = (PyTypeObject *)state->arguments_type;
10302
2.46k
    result = PyType_GenericNew(tp, NULL, NULL);
10303
2.46k
    if (!result) return NULL;
10304
2.46k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10305
2.46k
    if (!value) goto failed;
10306
2.46k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10307
0
        goto failed;
10308
2.46k
    Py_DECREF(value);
10309
2.46k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10310
2.46k
    if (!value) goto failed;
10311
2.46k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10312
0
        goto failed;
10313
2.46k
    Py_DECREF(value);
10314
2.46k
    value = ast2obj_arg(state, o->vararg);
10315
2.46k
    if (!value) goto failed;
10316
2.46k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10317
0
        goto failed;
10318
2.46k
    Py_DECREF(value);
10319
2.46k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10320
2.46k
    if (!value) goto failed;
10321
2.46k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10322
0
        goto failed;
10323
2.46k
    Py_DECREF(value);
10324
2.46k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10325
2.46k
    if (!value) goto failed;
10326
2.46k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10327
0
        goto failed;
10328
2.46k
    Py_DECREF(value);
10329
2.46k
    value = ast2obj_arg(state, o->kwarg);
10330
2.46k
    if (!value) goto failed;
10331
2.46k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10332
0
        goto failed;
10333
2.46k
    Py_DECREF(value);
10334
2.46k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10335
2.46k
    if (!value) goto failed;
10336
2.46k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10337
0
        goto failed;
10338
2.46k
    Py_DECREF(value);
10339
2.46k
    Py_LeaveRecursiveCall();
10340
2.46k
    return result;
10341
0
failed:
10342
0
    Py_LeaveRecursiveCall();
10343
0
    Py_XDECREF(value);
10344
0
    Py_XDECREF(result);
10345
0
    return NULL;
10346
2.46k
}
10347
10348
PyObject*
10349
ast2obj_arg(struct ast_state *state, void* _o)
10350
13.0k
{
10351
13.0k
    arg_ty o = (arg_ty)_o;
10352
13.0k
    PyObject *result = NULL, *value = NULL;
10353
13.0k
    PyTypeObject *tp;
10354
13.0k
    if (!o) {
10355
4.29k
        Py_RETURN_NONE;
10356
4.29k
    }
10357
8.71k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10358
0
        return NULL;
10359
0
    }
10360
8.71k
    tp = (PyTypeObject *)state->arg_type;
10361
8.71k
    result = PyType_GenericNew(tp, NULL, NULL);
10362
8.71k
    if (!result) return NULL;
10363
8.71k
    value = ast2obj_identifier(state, o->arg);
10364
8.71k
    if (!value) goto failed;
10365
8.71k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10366
0
        goto failed;
10367
8.71k
    Py_DECREF(value);
10368
8.71k
    value = ast2obj_expr(state, o->annotation);
10369
8.71k
    if (!value) goto failed;
10370
8.71k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10371
0
        goto failed;
10372
8.71k
    Py_DECREF(value);
10373
8.71k
    value = ast2obj_string(state, o->type_comment);
10374
8.71k
    if (!value) goto failed;
10375
8.71k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10376
0
        goto failed;
10377
8.71k
    Py_DECREF(value);
10378
8.71k
    value = ast2obj_int(state, o->lineno);
10379
8.71k
    if (!value) goto failed;
10380
8.71k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10381
0
        goto failed;
10382
8.71k
    Py_DECREF(value);
10383
8.71k
    value = ast2obj_int(state, o->col_offset);
10384
8.71k
    if (!value) goto failed;
10385
8.71k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10386
0
        goto failed;
10387
8.71k
    Py_DECREF(value);
10388
8.71k
    value = ast2obj_int(state, o->end_lineno);
10389
8.71k
    if (!value) goto failed;
10390
8.71k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10391
0
        goto failed;
10392
8.71k
    Py_DECREF(value);
10393
8.71k
    value = ast2obj_int(state, o->end_col_offset);
10394
8.71k
    if (!value) goto failed;
10395
8.71k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10396
0
        goto failed;
10397
8.71k
    Py_DECREF(value);
10398
8.71k
    Py_LeaveRecursiveCall();
10399
8.71k
    return result;
10400
0
failed:
10401
0
    Py_LeaveRecursiveCall();
10402
0
    Py_XDECREF(value);
10403
0
    Py_XDECREF(result);
10404
0
    return NULL;
10405
8.71k
}
10406
10407
PyObject*
10408
ast2obj_keyword(struct ast_state *state, void* _o)
10409
1.27k
{
10410
1.27k
    keyword_ty o = (keyword_ty)_o;
10411
1.27k
    PyObject *result = NULL, *value = NULL;
10412
1.27k
    PyTypeObject *tp;
10413
1.27k
    if (!o) {
10414
0
        Py_RETURN_NONE;
10415
0
    }
10416
1.27k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10417
0
        return NULL;
10418
0
    }
10419
1.27k
    tp = (PyTypeObject *)state->keyword_type;
10420
1.27k
    result = PyType_GenericNew(tp, NULL, NULL);
10421
1.27k
    if (!result) return NULL;
10422
1.27k
    value = ast2obj_identifier(state, o->arg);
10423
1.27k
    if (!value) goto failed;
10424
1.27k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10425
0
        goto failed;
10426
1.27k
    Py_DECREF(value);
10427
1.27k
    value = ast2obj_expr(state, o->value);
10428
1.27k
    if (!value) goto failed;
10429
1.27k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10430
0
        goto failed;
10431
1.27k
    Py_DECREF(value);
10432
1.27k
    value = ast2obj_int(state, o->lineno);
10433
1.27k
    if (!value) goto failed;
10434
1.27k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10435
0
        goto failed;
10436
1.27k
    Py_DECREF(value);
10437
1.27k
    value = ast2obj_int(state, o->col_offset);
10438
1.27k
    if (!value) goto failed;
10439
1.27k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10440
0
        goto failed;
10441
1.27k
    Py_DECREF(value);
10442
1.27k
    value = ast2obj_int(state, o->end_lineno);
10443
1.27k
    if (!value) goto failed;
10444
1.27k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10445
0
        goto failed;
10446
1.27k
    Py_DECREF(value);
10447
1.27k
    value = ast2obj_int(state, o->end_col_offset);
10448
1.27k
    if (!value) goto failed;
10449
1.27k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10450
0
        goto failed;
10451
1.27k
    Py_DECREF(value);
10452
1.27k
    Py_LeaveRecursiveCall();
10453
1.27k
    return result;
10454
0
failed:
10455
0
    Py_LeaveRecursiveCall();
10456
0
    Py_XDECREF(value);
10457
0
    Py_XDECREF(result);
10458
0
    return NULL;
10459
1.27k
}
10460
10461
PyObject*
10462
ast2obj_alias(struct ast_state *state, void* _o)
10463
3.71k
{
10464
3.71k
    alias_ty o = (alias_ty)_o;
10465
3.71k
    PyObject *result = NULL, *value = NULL;
10466
3.71k
    PyTypeObject *tp;
10467
3.71k
    if (!o) {
10468
0
        Py_RETURN_NONE;
10469
0
    }
10470
3.71k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10471
0
        return NULL;
10472
0
    }
10473
3.71k
    tp = (PyTypeObject *)state->alias_type;
10474
3.71k
    result = PyType_GenericNew(tp, NULL, NULL);
10475
3.71k
    if (!result) return NULL;
10476
3.71k
    value = ast2obj_identifier(state, o->name);
10477
3.71k
    if (!value) goto failed;
10478
3.71k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10479
0
        goto failed;
10480
3.71k
    Py_DECREF(value);
10481
3.71k
    value = ast2obj_identifier(state, o->asname);
10482
3.71k
    if (!value) goto failed;
10483
3.71k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10484
0
        goto failed;
10485
3.71k
    Py_DECREF(value);
10486
3.71k
    value = ast2obj_int(state, o->lineno);
10487
3.71k
    if (!value) goto failed;
10488
3.71k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10489
0
        goto failed;
10490
3.71k
    Py_DECREF(value);
10491
3.71k
    value = ast2obj_int(state, o->col_offset);
10492
3.71k
    if (!value) goto failed;
10493
3.71k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10494
0
        goto failed;
10495
3.71k
    Py_DECREF(value);
10496
3.71k
    value = ast2obj_int(state, o->end_lineno);
10497
3.71k
    if (!value) goto failed;
10498
3.71k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10499
0
        goto failed;
10500
3.71k
    Py_DECREF(value);
10501
3.71k
    value = ast2obj_int(state, o->end_col_offset);
10502
3.71k
    if (!value) goto failed;
10503
3.71k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10504
0
        goto failed;
10505
3.71k
    Py_DECREF(value);
10506
3.71k
    Py_LeaveRecursiveCall();
10507
3.71k
    return result;
10508
0
failed:
10509
0
    Py_LeaveRecursiveCall();
10510
0
    Py_XDECREF(value);
10511
0
    Py_XDECREF(result);
10512
0
    return NULL;
10513
3.71k
}
10514
10515
PyObject*
10516
ast2obj_withitem(struct ast_state *state, void* _o)
10517
1.28k
{
10518
1.28k
    withitem_ty o = (withitem_ty)_o;
10519
1.28k
    PyObject *result = NULL, *value = NULL;
10520
1.28k
    PyTypeObject *tp;
10521
1.28k
    if (!o) {
10522
0
        Py_RETURN_NONE;
10523
0
    }
10524
1.28k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10525
0
        return NULL;
10526
0
    }
10527
1.28k
    tp = (PyTypeObject *)state->withitem_type;
10528
1.28k
    result = PyType_GenericNew(tp, NULL, NULL);
10529
1.28k
    if (!result) return NULL;
10530
1.28k
    value = ast2obj_expr(state, o->context_expr);
10531
1.28k
    if (!value) goto failed;
10532
1.28k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10533
0
        goto failed;
10534
1.28k
    Py_DECREF(value);
10535
1.28k
    value = ast2obj_expr(state, o->optional_vars);
10536
1.28k
    if (!value) goto failed;
10537
1.28k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10538
0
        goto failed;
10539
1.28k
    Py_DECREF(value);
10540
1.28k
    Py_LeaveRecursiveCall();
10541
1.28k
    return result;
10542
0
failed:
10543
0
    Py_LeaveRecursiveCall();
10544
0
    Py_XDECREF(value);
10545
0
    Py_XDECREF(result);
10546
0
    return NULL;
10547
1.28k
}
10548
10549
PyObject*
10550
ast2obj_match_case(struct ast_state *state, void* _o)
10551
490
{
10552
490
    match_case_ty o = (match_case_ty)_o;
10553
490
    PyObject *result = NULL, *value = NULL;
10554
490
    PyTypeObject *tp;
10555
490
    if (!o) {
10556
0
        Py_RETURN_NONE;
10557
0
    }
10558
490
    if (Py_EnterRecursiveCall("during  ast construction")) {
10559
0
        return NULL;
10560
0
    }
10561
490
    tp = (PyTypeObject *)state->match_case_type;
10562
490
    result = PyType_GenericNew(tp, NULL, NULL);
10563
490
    if (!result) return NULL;
10564
490
    value = ast2obj_pattern(state, o->pattern);
10565
490
    if (!value) goto failed;
10566
490
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10567
0
        goto failed;
10568
490
    Py_DECREF(value);
10569
490
    value = ast2obj_expr(state, o->guard);
10570
490
    if (!value) goto failed;
10571
490
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10572
0
        goto failed;
10573
490
    Py_DECREF(value);
10574
490
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10575
490
    if (!value) goto failed;
10576
490
    if (PyObject_SetAttr(result, state->body, value) == -1)
10577
0
        goto failed;
10578
490
    Py_DECREF(value);
10579
490
    Py_LeaveRecursiveCall();
10580
490
    return result;
10581
0
failed:
10582
0
    Py_LeaveRecursiveCall();
10583
0
    Py_XDECREF(value);
10584
0
    Py_XDECREF(result);
10585
0
    return NULL;
10586
490
}
10587
10588
PyObject*
10589
ast2obj_pattern(struct ast_state *state, void* _o)
10590
16.8k
{
10591
16.8k
    pattern_ty o = (pattern_ty)_o;
10592
16.8k
    PyObject *result = NULL, *value = NULL;
10593
16.8k
    PyTypeObject *tp;
10594
16.8k
    if (!o) {
10595
6.39k
        Py_RETURN_NONE;
10596
6.39k
    }
10597
10.4k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10598
0
        return NULL;
10599
0
    }
10600
10.4k
    switch (o->kind) {
10601
245
    case MatchValue_kind:
10602
245
        tp = (PyTypeObject *)state->MatchValue_type;
10603
245
        result = PyType_GenericNew(tp, NULL, NULL);
10604
245
        if (!result) goto failed;
10605
245
        value = ast2obj_expr(state, o->v.MatchValue.value);
10606
245
        if (!value) goto failed;
10607
245
        if (PyObject_SetAttr(result, state->value, value) == -1)
10608
0
            goto failed;
10609
245
        Py_DECREF(value);
10610
245
        break;
10611
150
    case MatchSingleton_kind:
10612
150
        tp = (PyTypeObject *)state->MatchSingleton_type;
10613
150
        result = PyType_GenericNew(tp, NULL, NULL);
10614
150
        if (!result) goto failed;
10615
150
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10616
150
        if (!value) goto failed;
10617
150
        if (PyObject_SetAttr(result, state->value, value) == -1)
10618
0
            goto failed;
10619
150
        Py_DECREF(value);
10620
150
        break;
10621
380
    case MatchSequence_kind:
10622
380
        tp = (PyTypeObject *)state->MatchSequence_type;
10623
380
        result = PyType_GenericNew(tp, NULL, NULL);
10624
380
        if (!result) goto failed;
10625
380
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10626
380
                             ast2obj_pattern);
10627
380
        if (!value) goto failed;
10628
380
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10629
0
            goto failed;
10630
380
        Py_DECREF(value);
10631
380
        break;
10632
152
    case MatchMapping_kind:
10633
152
        tp = (PyTypeObject *)state->MatchMapping_type;
10634
152
        result = PyType_GenericNew(tp, NULL, NULL);
10635
152
        if (!result) goto failed;
10636
152
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10637
152
                             ast2obj_expr);
10638
152
        if (!value) goto failed;
10639
152
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10640
0
            goto failed;
10641
152
        Py_DECREF(value);
10642
152
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10643
152
                             ast2obj_pattern);
10644
152
        if (!value) goto failed;
10645
152
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10646
0
            goto failed;
10647
152
        Py_DECREF(value);
10648
152
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10649
152
        if (!value) goto failed;
10650
152
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10651
0
            goto failed;
10652
152
        Py_DECREF(value);
10653
152
        break;
10654
928
    case MatchClass_kind:
10655
928
        tp = (PyTypeObject *)state->MatchClass_type;
10656
928
        result = PyType_GenericNew(tp, NULL, NULL);
10657
928
        if (!result) goto failed;
10658
928
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10659
928
        if (!value) goto failed;
10660
928
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10661
0
            goto failed;
10662
928
        Py_DECREF(value);
10663
928
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10664
928
                             ast2obj_pattern);
10665
928
        if (!value) goto failed;
10666
928
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10667
0
            goto failed;
10668
928
        Py_DECREF(value);
10669
928
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10670
928
                             ast2obj_identifier);
10671
928
        if (!value) goto failed;
10672
928
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10673
0
            goto failed;
10674
928
        Py_DECREF(value);
10675
928
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10676
928
                             ast2obj_pattern);
10677
928
        if (!value) goto failed;
10678
928
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10679
0
            goto failed;
10680
928
        Py_DECREF(value);
10681
928
        break;
10682
178
    case MatchStar_kind:
10683
178
        tp = (PyTypeObject *)state->MatchStar_type;
10684
178
        result = PyType_GenericNew(tp, NULL, NULL);
10685
178
        if (!result) goto failed;
10686
178
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10687
178
        if (!value) goto failed;
10688
178
        if (PyObject_SetAttr(result, state->name, value) == -1)
10689
0
            goto failed;
10690
178
        Py_DECREF(value);
10691
178
        break;
10692
6.47k
    case MatchAs_kind:
10693
6.47k
        tp = (PyTypeObject *)state->MatchAs_type;
10694
6.47k
        result = PyType_GenericNew(tp, NULL, NULL);
10695
6.47k
        if (!result) goto failed;
10696
6.47k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10697
6.47k
        if (!value) goto failed;
10698
6.47k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10699
0
            goto failed;
10700
6.47k
        Py_DECREF(value);
10701
6.47k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10702
6.47k
        if (!value) goto failed;
10703
6.47k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10704
0
            goto failed;
10705
6.47k
        Py_DECREF(value);
10706
6.47k
        break;
10707
1.92k
    case MatchOr_kind:
10708
1.92k
        tp = (PyTypeObject *)state->MatchOr_type;
10709
1.92k
        result = PyType_GenericNew(tp, NULL, NULL);
10710
1.92k
        if (!result) goto failed;
10711
1.92k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10712
1.92k
                             ast2obj_pattern);
10713
1.92k
        if (!value) goto failed;
10714
1.92k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10715
0
            goto failed;
10716
1.92k
        Py_DECREF(value);
10717
1.92k
        break;
10718
10.4k
    }
10719
10.4k
    value = ast2obj_int(state, o->lineno);
10720
10.4k
    if (!value) goto failed;
10721
10.4k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10722
0
        goto failed;
10723
10.4k
    Py_DECREF(value);
10724
10.4k
    value = ast2obj_int(state, o->col_offset);
10725
10.4k
    if (!value) goto failed;
10726
10.4k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10727
0
        goto failed;
10728
10.4k
    Py_DECREF(value);
10729
10.4k
    value = ast2obj_int(state, o->end_lineno);
10730
10.4k
    if (!value) goto failed;
10731
10.4k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10732
0
        goto failed;
10733
10.4k
    Py_DECREF(value);
10734
10.4k
    value = ast2obj_int(state, o->end_col_offset);
10735
10.4k
    if (!value) goto failed;
10736
10.4k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10737
0
        goto failed;
10738
10.4k
    Py_DECREF(value);
10739
10.4k
    Py_LeaveRecursiveCall();
10740
10.4k
    return result;
10741
0
failed:
10742
0
    Py_LeaveRecursiveCall();
10743
0
    Py_XDECREF(value);
10744
0
    Py_XDECREF(result);
10745
0
    return NULL;
10746
10.4k
}
10747
10748
PyObject*
10749
ast2obj_type_ignore(struct ast_state *state, void* _o)
10750
0
{
10751
0
    type_ignore_ty o = (type_ignore_ty)_o;
10752
0
    PyObject *result = NULL, *value = NULL;
10753
0
    PyTypeObject *tp;
10754
0
    if (!o) {
10755
0
        Py_RETURN_NONE;
10756
0
    }
10757
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10758
0
        return NULL;
10759
0
    }
10760
0
    switch (o->kind) {
10761
0
    case TypeIgnore_kind:
10762
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10763
0
        result = PyType_GenericNew(tp, NULL, NULL);
10764
0
        if (!result) goto failed;
10765
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10766
0
        if (!value) goto failed;
10767
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10768
0
            goto failed;
10769
0
        Py_DECREF(value);
10770
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10771
0
        if (!value) goto failed;
10772
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10773
0
            goto failed;
10774
0
        Py_DECREF(value);
10775
0
        break;
10776
0
    }
10777
0
    Py_LeaveRecursiveCall();
10778
0
    return result;
10779
0
failed:
10780
0
    Py_LeaveRecursiveCall();
10781
0
    Py_XDECREF(value);
10782
0
    Py_XDECREF(result);
10783
0
    return NULL;
10784
0
}
10785
10786
PyObject*
10787
ast2obj_type_param(struct ast_state *state, void* _o)
10788
4.99k
{
10789
4.99k
    type_param_ty o = (type_param_ty)_o;
10790
4.99k
    PyObject *result = NULL, *value = NULL;
10791
4.99k
    PyTypeObject *tp;
10792
4.99k
    if (!o) {
10793
0
        Py_RETURN_NONE;
10794
0
    }
10795
4.99k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10796
0
        return NULL;
10797
0
    }
10798
4.99k
    switch (o->kind) {
10799
3.87k
    case TypeVar_kind:
10800
3.87k
        tp = (PyTypeObject *)state->TypeVar_type;
10801
3.87k
        result = PyType_GenericNew(tp, NULL, NULL);
10802
3.87k
        if (!result) goto failed;
10803
3.87k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10804
3.87k
        if (!value) goto failed;
10805
3.87k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10806
0
            goto failed;
10807
3.87k
        Py_DECREF(value);
10808
3.87k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10809
3.87k
        if (!value) goto failed;
10810
3.87k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10811
0
            goto failed;
10812
3.87k
        Py_DECREF(value);
10813
3.87k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10814
3.87k
        if (!value) goto failed;
10815
3.87k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10816
0
            goto failed;
10817
3.87k
        Py_DECREF(value);
10818
3.87k
        break;
10819
428
    case ParamSpec_kind:
10820
428
        tp = (PyTypeObject *)state->ParamSpec_type;
10821
428
        result = PyType_GenericNew(tp, NULL, NULL);
10822
428
        if (!result) goto failed;
10823
428
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10824
428
        if (!value) goto failed;
10825
428
        if (PyObject_SetAttr(result, state->name, value) == -1)
10826
0
            goto failed;
10827
428
        Py_DECREF(value);
10828
428
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10829
428
        if (!value) goto failed;
10830
428
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10831
0
            goto failed;
10832
428
        Py_DECREF(value);
10833
428
        break;
10834
687
    case TypeVarTuple_kind:
10835
687
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10836
687
        result = PyType_GenericNew(tp, NULL, NULL);
10837
687
        if (!result) goto failed;
10838
687
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10839
687
        if (!value) goto failed;
10840
687
        if (PyObject_SetAttr(result, state->name, value) == -1)
10841
0
            goto failed;
10842
687
        Py_DECREF(value);
10843
687
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10844
687
        if (!value) goto failed;
10845
687
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10846
0
            goto failed;
10847
687
        Py_DECREF(value);
10848
687
        break;
10849
4.99k
    }
10850
4.99k
    value = ast2obj_int(state, o->lineno);
10851
4.99k
    if (!value) goto failed;
10852
4.99k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10853
0
        goto failed;
10854
4.99k
    Py_DECREF(value);
10855
4.99k
    value = ast2obj_int(state, o->col_offset);
10856
4.99k
    if (!value) goto failed;
10857
4.99k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10858
0
        goto failed;
10859
4.99k
    Py_DECREF(value);
10860
4.99k
    value = ast2obj_int(state, o->end_lineno);
10861
4.99k
    if (!value) goto failed;
10862
4.99k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10863
0
        goto failed;
10864
4.99k
    Py_DECREF(value);
10865
4.99k
    value = ast2obj_int(state, o->end_col_offset);
10866
4.99k
    if (!value) goto failed;
10867
4.99k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10868
0
        goto failed;
10869
4.99k
    Py_DECREF(value);
10870
4.99k
    Py_LeaveRecursiveCall();
10871
4.99k
    return result;
10872
0
failed:
10873
0
    Py_LeaveRecursiveCall();
10874
0
    Py_XDECREF(value);
10875
0
    Py_XDECREF(result);
10876
0
    return NULL;
10877
4.99k
}
10878
10879
10880
int
10881
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
10882
0
{
10883
0
    int isinstance;
10884
10885
0
    PyObject *tmp = NULL;
10886
0
    PyObject *tp;
10887
10888
0
    if (obj == Py_None) {
10889
0
        *out = NULL;
10890
0
        return 0;
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, 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, 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, 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, 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, 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, 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, PyArena*
11137
             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
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11153
0
        return -1;
11154
0
    }
11155
0
    if (tmp == NULL) {
11156
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11157
0
        return -1;
11158
0
    }
11159
0
    else {
11160
0
        int res;
11161
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11162
0
            goto failed;
11163
0
        }
11164
0
        res = obj2ast_int(state, tmp, &lineno, arena);
11165
0
        _Py_LeaveRecursiveCall();
11166
0
        if (res != 0) goto failed;
11167
0
        Py_CLEAR(tmp);
11168
0
    }
11169
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11170
0
        return -1;
11171
0
    }
11172
0
    if (tmp == NULL) {
11173
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11174
0
        return -1;
11175
0
    }
11176
0
    else {
11177
0
        int res;
11178
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11179
0
            goto failed;
11180
0
        }
11181
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
11182
0
        _Py_LeaveRecursiveCall();
11183
0
        if (res != 0) goto failed;
11184
0
        Py_CLEAR(tmp);
11185
0
    }
11186
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11187
0
        return -1;
11188
0
    }
11189
0
    if (tmp == NULL || tmp == Py_None) {
11190
0
        Py_CLEAR(tmp);
11191
0
        end_lineno = lineno;
11192
0
    }
11193
0
    else {
11194
0
        int res;
11195
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11196
0
            goto failed;
11197
0
        }
11198
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
11199
0
        _Py_LeaveRecursiveCall();
11200
0
        if (res != 0) goto failed;
11201
0
        Py_CLEAR(tmp);
11202
0
    }
11203
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11204
0
        return -1;
11205
0
    }
11206
0
    if (tmp == NULL || tmp == Py_None) {
11207
0
        Py_CLEAR(tmp);
11208
0
        end_col_offset = col_offset;
11209
0
    }
11210
0
    else {
11211
0
        int res;
11212
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11213
0
            goto failed;
11214
0
        }
11215
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
11216
0
        _Py_LeaveRecursiveCall();
11217
0
        if (res != 0) goto failed;
11218
0
        Py_CLEAR(tmp);
11219
0
    }
11220
0
    tp = state->FunctionDef_type;
11221
0
    isinstance = PyObject_IsInstance(obj, tp);
11222
0
    if (isinstance == -1) {
11223
0
        return -1;
11224
0
    }
11225
0
    if (isinstance) {
11226
0
        identifier name;
11227
0
        arguments_ty args;
11228
0
        asdl_stmt_seq* body;
11229
0
        asdl_expr_seq* decorator_list;
11230
0
        expr_ty returns;
11231
0
        string type_comment;
11232
0
        asdl_type_param_seq* type_params;
11233
11234
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11235
0
            return -1;
11236
0
        }
11237
0
        if (tmp == NULL) {
11238
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11239
0
            return -1;
11240
0
        }
11241
0
        else {
11242
0
            int res;
11243
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11244
0
                goto failed;
11245
0
            }
11246
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11247
0
            _Py_LeaveRecursiveCall();
11248
0
            if (res != 0) goto failed;
11249
0
            Py_CLEAR(tmp);
11250
0
        }
11251
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11252
0
            return -1;
11253
0
        }
11254
0
        if (tmp == NULL) {
11255
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11256
0
            return -1;
11257
0
        }
11258
0
        else {
11259
0
            int res;
11260
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11261
0
                goto failed;
11262
0
            }
11263
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11264
0
            _Py_LeaveRecursiveCall();
11265
0
            if (res != 0) goto failed;
11266
0
            Py_CLEAR(tmp);
11267
0
        }
11268
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11269
0
            return -1;
11270
0
        }
11271
0
        if (tmp == NULL) {
11272
0
            tmp = PyList_New(0);
11273
0
            if (tmp == NULL) {
11274
0
                return -1;
11275
0
            }
11276
0
        }
11277
0
        {
11278
0
            int res;
11279
0
            Py_ssize_t len;
11280
0
            Py_ssize_t i;
11281
0
            if (!PyList_Check(tmp)) {
11282
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11283
0
                goto failed;
11284
0
            }
11285
0
            len = PyList_GET_SIZE(tmp);
11286
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11287
0
            if (body == NULL) goto failed;
11288
0
            for (i = 0; i < len; i++) {
11289
0
                stmt_ty val;
11290
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11291
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11292
0
                    goto failed;
11293
0
                }
11294
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11295
0
                _Py_LeaveRecursiveCall();
11296
0
                Py_DECREF(tmp2);
11297
0
                if (res != 0) goto failed;
11298
0
                if (len != PyList_GET_SIZE(tmp)) {
11299
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11300
0
                    goto failed;
11301
0
                }
11302
0
                asdl_seq_SET(body, i, val);
11303
0
            }
11304
0
            Py_CLEAR(tmp);
11305
0
        }
11306
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11307
0
            return -1;
11308
0
        }
11309
0
        if (tmp == NULL) {
11310
0
            tmp = PyList_New(0);
11311
0
            if (tmp == NULL) {
11312
0
                return -1;
11313
0
            }
11314
0
        }
11315
0
        {
11316
0
            int res;
11317
0
            Py_ssize_t len;
11318
0
            Py_ssize_t i;
11319
0
            if (!PyList_Check(tmp)) {
11320
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11321
0
                goto failed;
11322
0
            }
11323
0
            len = PyList_GET_SIZE(tmp);
11324
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11325
0
            if (decorator_list == NULL) goto failed;
11326
0
            for (i = 0; i < len; i++) {
11327
0
                expr_ty val;
11328
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11329
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11330
0
                    goto failed;
11331
0
                }
11332
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11333
0
                _Py_LeaveRecursiveCall();
11334
0
                Py_DECREF(tmp2);
11335
0
                if (res != 0) goto failed;
11336
0
                if (len != PyList_GET_SIZE(tmp)) {
11337
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11338
0
                    goto failed;
11339
0
                }
11340
0
                asdl_seq_SET(decorator_list, i, val);
11341
0
            }
11342
0
            Py_CLEAR(tmp);
11343
0
        }
11344
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11345
0
            return -1;
11346
0
        }
11347
0
        if (tmp == NULL || tmp == Py_None) {
11348
0
            Py_CLEAR(tmp);
11349
0
            returns = NULL;
11350
0
        }
11351
0
        else {
11352
0
            int res;
11353
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11354
0
                goto failed;
11355
0
            }
11356
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11357
0
            _Py_LeaveRecursiveCall();
11358
0
            if (res != 0) goto failed;
11359
0
            Py_CLEAR(tmp);
11360
0
        }
11361
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11362
0
            return -1;
11363
0
        }
11364
0
        if (tmp == NULL || tmp == Py_None) {
11365
0
            Py_CLEAR(tmp);
11366
0
            type_comment = NULL;
11367
0
        }
11368
0
        else {
11369
0
            int res;
11370
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11371
0
                goto failed;
11372
0
            }
11373
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11374
0
            _Py_LeaveRecursiveCall();
11375
0
            if (res != 0) goto failed;
11376
0
            Py_CLEAR(tmp);
11377
0
        }
11378
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11379
0
            return -1;
11380
0
        }
11381
0
        if (tmp == NULL) {
11382
0
            tmp = PyList_New(0);
11383
0
            if (tmp == NULL) {
11384
0
                return -1;
11385
0
            }
11386
0
        }
11387
0
        {
11388
0
            int res;
11389
0
            Py_ssize_t len;
11390
0
            Py_ssize_t i;
11391
0
            if (!PyList_Check(tmp)) {
11392
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11393
0
                goto failed;
11394
0
            }
11395
0
            len = PyList_GET_SIZE(tmp);
11396
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11397
0
            if (type_params == NULL) goto failed;
11398
0
            for (i = 0; i < len; i++) {
11399
0
                type_param_ty val;
11400
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11401
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11402
0
                    goto failed;
11403
0
                }
11404
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11405
0
                _Py_LeaveRecursiveCall();
11406
0
                Py_DECREF(tmp2);
11407
0
                if (res != 0) goto failed;
11408
0
                if (len != PyList_GET_SIZE(tmp)) {
11409
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11410
0
                    goto failed;
11411
0
                }
11412
0
                asdl_seq_SET(type_params, i, val);
11413
0
            }
11414
0
            Py_CLEAR(tmp);
11415
0
        }
11416
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11417
0
                                  type_comment, type_params, lineno,
11418
0
                                  col_offset, end_lineno, end_col_offset,
11419
0
                                  arena);
11420
0
        if (*out == NULL) goto failed;
11421
0
        return 0;
11422
0
    }
11423
0
    tp = state->AsyncFunctionDef_type;
11424
0
    isinstance = PyObject_IsInstance(obj, tp);
11425
0
    if (isinstance == -1) {
11426
0
        return -1;
11427
0
    }
11428
0
    if (isinstance) {
11429
0
        identifier name;
11430
0
        arguments_ty args;
11431
0
        asdl_stmt_seq* body;
11432
0
        asdl_expr_seq* decorator_list;
11433
0
        expr_ty returns;
11434
0
        string type_comment;
11435
0
        asdl_type_param_seq* type_params;
11436
11437
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11438
0
            return -1;
11439
0
        }
11440
0
        if (tmp == NULL) {
11441
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11442
0
            return -1;
11443
0
        }
11444
0
        else {
11445
0
            int res;
11446
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11447
0
                goto failed;
11448
0
            }
11449
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11450
0
            _Py_LeaveRecursiveCall();
11451
0
            if (res != 0) goto failed;
11452
0
            Py_CLEAR(tmp);
11453
0
        }
11454
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11455
0
            return -1;
11456
0
        }
11457
0
        if (tmp == NULL) {
11458
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11459
0
            return -1;
11460
0
        }
11461
0
        else {
11462
0
            int res;
11463
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11464
0
                goto failed;
11465
0
            }
11466
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11467
0
            _Py_LeaveRecursiveCall();
11468
0
            if (res != 0) goto failed;
11469
0
            Py_CLEAR(tmp);
11470
0
        }
11471
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11472
0
            return -1;
11473
0
        }
11474
0
        if (tmp == NULL) {
11475
0
            tmp = PyList_New(0);
11476
0
            if (tmp == NULL) {
11477
0
                return -1;
11478
0
            }
11479
0
        }
11480
0
        {
11481
0
            int res;
11482
0
            Py_ssize_t len;
11483
0
            Py_ssize_t i;
11484
0
            if (!PyList_Check(tmp)) {
11485
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11486
0
                goto failed;
11487
0
            }
11488
0
            len = PyList_GET_SIZE(tmp);
11489
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11490
0
            if (body == NULL) goto failed;
11491
0
            for (i = 0; i < len; i++) {
11492
0
                stmt_ty val;
11493
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11494
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11495
0
                    goto failed;
11496
0
                }
11497
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11498
0
                _Py_LeaveRecursiveCall();
11499
0
                Py_DECREF(tmp2);
11500
0
                if (res != 0) goto failed;
11501
0
                if (len != PyList_GET_SIZE(tmp)) {
11502
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11503
0
                    goto failed;
11504
0
                }
11505
0
                asdl_seq_SET(body, i, val);
11506
0
            }
11507
0
            Py_CLEAR(tmp);
11508
0
        }
11509
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11510
0
            return -1;
11511
0
        }
11512
0
        if (tmp == NULL) {
11513
0
            tmp = PyList_New(0);
11514
0
            if (tmp == NULL) {
11515
0
                return -1;
11516
0
            }
11517
0
        }
11518
0
        {
11519
0
            int res;
11520
0
            Py_ssize_t len;
11521
0
            Py_ssize_t i;
11522
0
            if (!PyList_Check(tmp)) {
11523
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11524
0
                goto failed;
11525
0
            }
11526
0
            len = PyList_GET_SIZE(tmp);
11527
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11528
0
            if (decorator_list == NULL) goto failed;
11529
0
            for (i = 0; i < len; i++) {
11530
0
                expr_ty val;
11531
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11532
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11533
0
                    goto failed;
11534
0
                }
11535
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11536
0
                _Py_LeaveRecursiveCall();
11537
0
                Py_DECREF(tmp2);
11538
0
                if (res != 0) goto failed;
11539
0
                if (len != PyList_GET_SIZE(tmp)) {
11540
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11541
0
                    goto failed;
11542
0
                }
11543
0
                asdl_seq_SET(decorator_list, i, val);
11544
0
            }
11545
0
            Py_CLEAR(tmp);
11546
0
        }
11547
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11548
0
            return -1;
11549
0
        }
11550
0
        if (tmp == NULL || tmp == Py_None) {
11551
0
            Py_CLEAR(tmp);
11552
0
            returns = NULL;
11553
0
        }
11554
0
        else {
11555
0
            int res;
11556
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11557
0
                goto failed;
11558
0
            }
11559
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11560
0
            _Py_LeaveRecursiveCall();
11561
0
            if (res != 0) goto failed;
11562
0
            Py_CLEAR(tmp);
11563
0
        }
11564
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11565
0
            return -1;
11566
0
        }
11567
0
        if (tmp == NULL || tmp == Py_None) {
11568
0
            Py_CLEAR(tmp);
11569
0
            type_comment = NULL;
11570
0
        }
11571
0
        else {
11572
0
            int res;
11573
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11574
0
                goto failed;
11575
0
            }
11576
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11577
0
            _Py_LeaveRecursiveCall();
11578
0
            if (res != 0) goto failed;
11579
0
            Py_CLEAR(tmp);
11580
0
        }
11581
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11582
0
            return -1;
11583
0
        }
11584
0
        if (tmp == NULL) {
11585
0
            tmp = PyList_New(0);
11586
0
            if (tmp == NULL) {
11587
0
                return -1;
11588
0
            }
11589
0
        }
11590
0
        {
11591
0
            int res;
11592
0
            Py_ssize_t len;
11593
0
            Py_ssize_t i;
11594
0
            if (!PyList_Check(tmp)) {
11595
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11596
0
                goto failed;
11597
0
            }
11598
0
            len = PyList_GET_SIZE(tmp);
11599
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11600
0
            if (type_params == NULL) goto failed;
11601
0
            for (i = 0; i < len; i++) {
11602
0
                type_param_ty val;
11603
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11604
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11605
0
                    goto failed;
11606
0
                }
11607
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11608
0
                _Py_LeaveRecursiveCall();
11609
0
                Py_DECREF(tmp2);
11610
0
                if (res != 0) goto failed;
11611
0
                if (len != PyList_GET_SIZE(tmp)) {
11612
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11613
0
                    goto failed;
11614
0
                }
11615
0
                asdl_seq_SET(type_params, i, val);
11616
0
            }
11617
0
            Py_CLEAR(tmp);
11618
0
        }
11619
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11620
0
                                       returns, type_comment, type_params,
11621
0
                                       lineno, col_offset, end_lineno,
11622
0
                                       end_col_offset, arena);
11623
0
        if (*out == NULL) goto failed;
11624
0
        return 0;
11625
0
    }
11626
0
    tp = state->ClassDef_type;
11627
0
    isinstance = PyObject_IsInstance(obj, tp);
11628
0
    if (isinstance == -1) {
11629
0
        return -1;
11630
0
    }
11631
0
    if (isinstance) {
11632
0
        identifier name;
11633
0
        asdl_expr_seq* bases;
11634
0
        asdl_keyword_seq* keywords;
11635
0
        asdl_stmt_seq* body;
11636
0
        asdl_expr_seq* decorator_list;
11637
0
        asdl_type_param_seq* type_params;
11638
11639
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11640
0
            return -1;
11641
0
        }
11642
0
        if (tmp == NULL) {
11643
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11644
0
            return -1;
11645
0
        }
11646
0
        else {
11647
0
            int res;
11648
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11649
0
                goto failed;
11650
0
            }
11651
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11652
0
            _Py_LeaveRecursiveCall();
11653
0
            if (res != 0) goto failed;
11654
0
            Py_CLEAR(tmp);
11655
0
        }
11656
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11657
0
            return -1;
11658
0
        }
11659
0
        if (tmp == NULL) {
11660
0
            tmp = PyList_New(0);
11661
0
            if (tmp == NULL) {
11662
0
                return -1;
11663
0
            }
11664
0
        }
11665
0
        {
11666
0
            int res;
11667
0
            Py_ssize_t len;
11668
0
            Py_ssize_t i;
11669
0
            if (!PyList_Check(tmp)) {
11670
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11671
0
                goto failed;
11672
0
            }
11673
0
            len = PyList_GET_SIZE(tmp);
11674
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11675
0
            if (bases == NULL) goto failed;
11676
0
            for (i = 0; i < len; i++) {
11677
0
                expr_ty val;
11678
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11679
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11680
0
                    goto failed;
11681
0
                }
11682
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11683
0
                _Py_LeaveRecursiveCall();
11684
0
                Py_DECREF(tmp2);
11685
0
                if (res != 0) goto failed;
11686
0
                if (len != PyList_GET_SIZE(tmp)) {
11687
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11688
0
                    goto failed;
11689
0
                }
11690
0
                asdl_seq_SET(bases, i, val);
11691
0
            }
11692
0
            Py_CLEAR(tmp);
11693
0
        }
11694
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11695
0
            return -1;
11696
0
        }
11697
0
        if (tmp == NULL) {
11698
0
            tmp = PyList_New(0);
11699
0
            if (tmp == NULL) {
11700
0
                return -1;
11701
0
            }
11702
0
        }
11703
0
        {
11704
0
            int res;
11705
0
            Py_ssize_t len;
11706
0
            Py_ssize_t i;
11707
0
            if (!PyList_Check(tmp)) {
11708
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11709
0
                goto failed;
11710
0
            }
11711
0
            len = PyList_GET_SIZE(tmp);
11712
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11713
0
            if (keywords == NULL) goto failed;
11714
0
            for (i = 0; i < len; i++) {
11715
0
                keyword_ty val;
11716
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11717
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11718
0
                    goto failed;
11719
0
                }
11720
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
11721
0
                _Py_LeaveRecursiveCall();
11722
0
                Py_DECREF(tmp2);
11723
0
                if (res != 0) goto failed;
11724
0
                if (len != PyList_GET_SIZE(tmp)) {
11725
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11726
0
                    goto failed;
11727
0
                }
11728
0
                asdl_seq_SET(keywords, i, val);
11729
0
            }
11730
0
            Py_CLEAR(tmp);
11731
0
        }
11732
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11733
0
            return -1;
11734
0
        }
11735
0
        if (tmp == NULL) {
11736
0
            tmp = PyList_New(0);
11737
0
            if (tmp == NULL) {
11738
0
                return -1;
11739
0
            }
11740
0
        }
11741
0
        {
11742
0
            int res;
11743
0
            Py_ssize_t len;
11744
0
            Py_ssize_t i;
11745
0
            if (!PyList_Check(tmp)) {
11746
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11747
0
                goto failed;
11748
0
            }
11749
0
            len = PyList_GET_SIZE(tmp);
11750
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11751
0
            if (body == NULL) goto failed;
11752
0
            for (i = 0; i < len; i++) {
11753
0
                stmt_ty val;
11754
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11755
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11756
0
                    goto failed;
11757
0
                }
11758
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11759
0
                _Py_LeaveRecursiveCall();
11760
0
                Py_DECREF(tmp2);
11761
0
                if (res != 0) goto failed;
11762
0
                if (len != PyList_GET_SIZE(tmp)) {
11763
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11764
0
                    goto failed;
11765
0
                }
11766
0
                asdl_seq_SET(body, i, val);
11767
0
            }
11768
0
            Py_CLEAR(tmp);
11769
0
        }
11770
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11771
0
            return -1;
11772
0
        }
11773
0
        if (tmp == NULL) {
11774
0
            tmp = PyList_New(0);
11775
0
            if (tmp == NULL) {
11776
0
                return -1;
11777
0
            }
11778
0
        }
11779
0
        {
11780
0
            int res;
11781
0
            Py_ssize_t len;
11782
0
            Py_ssize_t i;
11783
0
            if (!PyList_Check(tmp)) {
11784
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11785
0
                goto failed;
11786
0
            }
11787
0
            len = PyList_GET_SIZE(tmp);
11788
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11789
0
            if (decorator_list == NULL) goto failed;
11790
0
            for (i = 0; i < len; i++) {
11791
0
                expr_ty val;
11792
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11793
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11794
0
                    goto failed;
11795
0
                }
11796
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11797
0
                _Py_LeaveRecursiveCall();
11798
0
                Py_DECREF(tmp2);
11799
0
                if (res != 0) goto failed;
11800
0
                if (len != PyList_GET_SIZE(tmp)) {
11801
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11802
0
                    goto failed;
11803
0
                }
11804
0
                asdl_seq_SET(decorator_list, i, val);
11805
0
            }
11806
0
            Py_CLEAR(tmp);
11807
0
        }
11808
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11809
0
            return -1;
11810
0
        }
11811
0
        if (tmp == NULL) {
11812
0
            tmp = PyList_New(0);
11813
0
            if (tmp == NULL) {
11814
0
                return -1;
11815
0
            }
11816
0
        }
11817
0
        {
11818
0
            int res;
11819
0
            Py_ssize_t len;
11820
0
            Py_ssize_t i;
11821
0
            if (!PyList_Check(tmp)) {
11822
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11823
0
                goto failed;
11824
0
            }
11825
0
            len = PyList_GET_SIZE(tmp);
11826
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11827
0
            if (type_params == NULL) goto failed;
11828
0
            for (i = 0; i < len; i++) {
11829
0
                type_param_ty val;
11830
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11831
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11832
0
                    goto failed;
11833
0
                }
11834
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11835
0
                _Py_LeaveRecursiveCall();
11836
0
                Py_DECREF(tmp2);
11837
0
                if (res != 0) goto failed;
11838
0
                if (len != PyList_GET_SIZE(tmp)) {
11839
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11840
0
                    goto failed;
11841
0
                }
11842
0
                asdl_seq_SET(type_params, i, val);
11843
0
            }
11844
0
            Py_CLEAR(tmp);
11845
0
        }
11846
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11847
0
                               type_params, lineno, col_offset, end_lineno,
11848
0
                               end_col_offset, arena);
11849
0
        if (*out == NULL) goto failed;
11850
0
        return 0;
11851
0
    }
11852
0
    tp = state->Return_type;
11853
0
    isinstance = PyObject_IsInstance(obj, tp);
11854
0
    if (isinstance == -1) {
11855
0
        return -1;
11856
0
    }
11857
0
    if (isinstance) {
11858
0
        expr_ty value;
11859
11860
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11861
0
            return -1;
11862
0
        }
11863
0
        if (tmp == NULL || tmp == Py_None) {
11864
0
            Py_CLEAR(tmp);
11865
0
            value = NULL;
11866
0
        }
11867
0
        else {
11868
0
            int res;
11869
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11870
0
                goto failed;
11871
0
            }
11872
0
            res = obj2ast_expr(state, tmp, &value, arena);
11873
0
            _Py_LeaveRecursiveCall();
11874
0
            if (res != 0) goto failed;
11875
0
            Py_CLEAR(tmp);
11876
0
        }
11877
0
        *out = _PyAST_Return(value, lineno, col_offset, end_lineno,
11878
0
                             end_col_offset, arena);
11879
0
        if (*out == NULL) goto failed;
11880
0
        return 0;
11881
0
    }
11882
0
    tp = state->Delete_type;
11883
0
    isinstance = PyObject_IsInstance(obj, tp);
11884
0
    if (isinstance == -1) {
11885
0
        return -1;
11886
0
    }
11887
0
    if (isinstance) {
11888
0
        asdl_expr_seq* targets;
11889
11890
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11891
0
            return -1;
11892
0
        }
11893
0
        if (tmp == NULL) {
11894
0
            tmp = PyList_New(0);
11895
0
            if (tmp == NULL) {
11896
0
                return -1;
11897
0
            }
11898
0
        }
11899
0
        {
11900
0
            int res;
11901
0
            Py_ssize_t len;
11902
0
            Py_ssize_t i;
11903
0
            if (!PyList_Check(tmp)) {
11904
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11905
0
                goto failed;
11906
0
            }
11907
0
            len = PyList_GET_SIZE(tmp);
11908
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11909
0
            if (targets == NULL) goto failed;
11910
0
            for (i = 0; i < len; i++) {
11911
0
                expr_ty val;
11912
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11913
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11914
0
                    goto failed;
11915
0
                }
11916
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11917
0
                _Py_LeaveRecursiveCall();
11918
0
                Py_DECREF(tmp2);
11919
0
                if (res != 0) goto failed;
11920
0
                if (len != PyList_GET_SIZE(tmp)) {
11921
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11922
0
                    goto failed;
11923
0
                }
11924
0
                asdl_seq_SET(targets, i, val);
11925
0
            }
11926
0
            Py_CLEAR(tmp);
11927
0
        }
11928
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11929
0
                             end_col_offset, arena);
11930
0
        if (*out == NULL) goto failed;
11931
0
        return 0;
11932
0
    }
11933
0
    tp = state->Assign_type;
11934
0
    isinstance = PyObject_IsInstance(obj, tp);
11935
0
    if (isinstance == -1) {
11936
0
        return -1;
11937
0
    }
11938
0
    if (isinstance) {
11939
0
        asdl_expr_seq* targets;
11940
0
        expr_ty value;
11941
0
        string type_comment;
11942
11943
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11944
0
            return -1;
11945
0
        }
11946
0
        if (tmp == NULL) {
11947
0
            tmp = PyList_New(0);
11948
0
            if (tmp == NULL) {
11949
0
                return -1;
11950
0
            }
11951
0
        }
11952
0
        {
11953
0
            int res;
11954
0
            Py_ssize_t len;
11955
0
            Py_ssize_t i;
11956
0
            if (!PyList_Check(tmp)) {
11957
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11958
0
                goto failed;
11959
0
            }
11960
0
            len = PyList_GET_SIZE(tmp);
11961
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11962
0
            if (targets == NULL) goto failed;
11963
0
            for (i = 0; i < len; i++) {
11964
0
                expr_ty val;
11965
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11966
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11967
0
                    goto failed;
11968
0
                }
11969
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11970
0
                _Py_LeaveRecursiveCall();
11971
0
                Py_DECREF(tmp2);
11972
0
                if (res != 0) goto failed;
11973
0
                if (len != PyList_GET_SIZE(tmp)) {
11974
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
11975
0
                    goto failed;
11976
0
                }
11977
0
                asdl_seq_SET(targets, i, val);
11978
0
            }
11979
0
            Py_CLEAR(tmp);
11980
0
        }
11981
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11982
0
            return -1;
11983
0
        }
11984
0
        if (tmp == NULL) {
11985
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
11986
0
            return -1;
11987
0
        }
11988
0
        else {
11989
0
            int res;
11990
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
11991
0
                goto failed;
11992
0
            }
11993
0
            res = obj2ast_expr(state, tmp, &value, arena);
11994
0
            _Py_LeaveRecursiveCall();
11995
0
            if (res != 0) goto failed;
11996
0
            Py_CLEAR(tmp);
11997
0
        }
11998
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11999
0
            return -1;
12000
0
        }
12001
0
        if (tmp == NULL || tmp == Py_None) {
12002
0
            Py_CLEAR(tmp);
12003
0
            type_comment = NULL;
12004
0
        }
12005
0
        else {
12006
0
            int res;
12007
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12008
0
                goto failed;
12009
0
            }
12010
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12011
0
            _Py_LeaveRecursiveCall();
12012
0
            if (res != 0) goto failed;
12013
0
            Py_CLEAR(tmp);
12014
0
        }
12015
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
12016
0
                             end_lineno, end_col_offset, arena);
12017
0
        if (*out == NULL) goto failed;
12018
0
        return 0;
12019
0
    }
12020
0
    tp = state->TypeAlias_type;
12021
0
    isinstance = PyObject_IsInstance(obj, tp);
12022
0
    if (isinstance == -1) {
12023
0
        return -1;
12024
0
    }
12025
0
    if (isinstance) {
12026
0
        expr_ty name;
12027
0
        asdl_type_param_seq* type_params;
12028
0
        expr_ty value;
12029
12030
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12031
0
            return -1;
12032
0
        }
12033
0
        if (tmp == NULL) {
12034
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12035
0
            return -1;
12036
0
        }
12037
0
        else {
12038
0
            int res;
12039
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12040
0
                goto failed;
12041
0
            }
12042
0
            res = obj2ast_expr(state, tmp, &name, arena);
12043
0
            _Py_LeaveRecursiveCall();
12044
0
            if (res != 0) goto failed;
12045
0
            Py_CLEAR(tmp);
12046
0
        }
12047
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12048
0
            return -1;
12049
0
        }
12050
0
        if (tmp == NULL) {
12051
0
            tmp = PyList_New(0);
12052
0
            if (tmp == NULL) {
12053
0
                return -1;
12054
0
            }
12055
0
        }
12056
0
        {
12057
0
            int res;
12058
0
            Py_ssize_t len;
12059
0
            Py_ssize_t i;
12060
0
            if (!PyList_Check(tmp)) {
12061
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12062
0
                goto failed;
12063
0
            }
12064
0
            len = PyList_GET_SIZE(tmp);
12065
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12066
0
            if (type_params == NULL) goto failed;
12067
0
            for (i = 0; i < len; i++) {
12068
0
                type_param_ty val;
12069
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12070
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12071
0
                    goto failed;
12072
0
                }
12073
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
12074
0
                _Py_LeaveRecursiveCall();
12075
0
                Py_DECREF(tmp2);
12076
0
                if (res != 0) goto failed;
12077
0
                if (len != PyList_GET_SIZE(tmp)) {
12078
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12079
0
                    goto failed;
12080
0
                }
12081
0
                asdl_seq_SET(type_params, i, val);
12082
0
            }
12083
0
            Py_CLEAR(tmp);
12084
0
        }
12085
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12086
0
            return -1;
12087
0
        }
12088
0
        if (tmp == NULL) {
12089
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12090
0
            return -1;
12091
0
        }
12092
0
        else {
12093
0
            int res;
12094
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12095
0
                goto failed;
12096
0
            }
12097
0
            res = obj2ast_expr(state, tmp, &value, arena);
12098
0
            _Py_LeaveRecursiveCall();
12099
0
            if (res != 0) goto failed;
12100
0
            Py_CLEAR(tmp);
12101
0
        }
12102
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12103
0
                                end_lineno, end_col_offset, arena);
12104
0
        if (*out == NULL) goto failed;
12105
0
        return 0;
12106
0
    }
12107
0
    tp = state->AugAssign_type;
12108
0
    isinstance = PyObject_IsInstance(obj, tp);
12109
0
    if (isinstance == -1) {
12110
0
        return -1;
12111
0
    }
12112
0
    if (isinstance) {
12113
0
        expr_ty target;
12114
0
        operator_ty op;
12115
0
        expr_ty value;
12116
12117
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12118
0
            return -1;
12119
0
        }
12120
0
        if (tmp == NULL) {
12121
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12122
0
            return -1;
12123
0
        }
12124
0
        else {
12125
0
            int res;
12126
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12127
0
                goto failed;
12128
0
            }
12129
0
            res = obj2ast_expr(state, tmp, &target, arena);
12130
0
            _Py_LeaveRecursiveCall();
12131
0
            if (res != 0) goto failed;
12132
0
            Py_CLEAR(tmp);
12133
0
        }
12134
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12135
0
            return -1;
12136
0
        }
12137
0
        if (tmp == NULL) {
12138
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12139
0
            return -1;
12140
0
        }
12141
0
        else {
12142
0
            int res;
12143
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12144
0
                goto failed;
12145
0
            }
12146
0
            res = obj2ast_operator(state, tmp, &op, arena);
12147
0
            _Py_LeaveRecursiveCall();
12148
0
            if (res != 0) goto failed;
12149
0
            Py_CLEAR(tmp);
12150
0
        }
12151
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12152
0
            return -1;
12153
0
        }
12154
0
        if (tmp == NULL) {
12155
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12156
0
            return -1;
12157
0
        }
12158
0
        else {
12159
0
            int res;
12160
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12161
0
                goto failed;
12162
0
            }
12163
0
            res = obj2ast_expr(state, tmp, &value, arena);
12164
0
            _Py_LeaveRecursiveCall();
12165
0
            if (res != 0) goto failed;
12166
0
            Py_CLEAR(tmp);
12167
0
        }
12168
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12169
0
                                end_lineno, end_col_offset, arena);
12170
0
        if (*out == NULL) goto failed;
12171
0
        return 0;
12172
0
    }
12173
0
    tp = state->AnnAssign_type;
12174
0
    isinstance = PyObject_IsInstance(obj, tp);
12175
0
    if (isinstance == -1) {
12176
0
        return -1;
12177
0
    }
12178
0
    if (isinstance) {
12179
0
        expr_ty target;
12180
0
        expr_ty annotation;
12181
0
        expr_ty value;
12182
0
        int simple;
12183
12184
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12185
0
            return -1;
12186
0
        }
12187
0
        if (tmp == NULL) {
12188
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AnnAssign");
12189
0
            return -1;
12190
0
        }
12191
0
        else {
12192
0
            int res;
12193
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12194
0
                goto failed;
12195
0
            }
12196
0
            res = obj2ast_expr(state, tmp, &target, arena);
12197
0
            _Py_LeaveRecursiveCall();
12198
0
            if (res != 0) goto failed;
12199
0
            Py_CLEAR(tmp);
12200
0
        }
12201
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12202
0
            return -1;
12203
0
        }
12204
0
        if (tmp == NULL) {
12205
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12206
0
            return -1;
12207
0
        }
12208
0
        else {
12209
0
            int res;
12210
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12211
0
                goto failed;
12212
0
            }
12213
0
            res = obj2ast_expr(state, tmp, &annotation, arena);
12214
0
            _Py_LeaveRecursiveCall();
12215
0
            if (res != 0) goto failed;
12216
0
            Py_CLEAR(tmp);
12217
0
        }
12218
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12219
0
            return -1;
12220
0
        }
12221
0
        if (tmp == NULL || tmp == Py_None) {
12222
0
            Py_CLEAR(tmp);
12223
0
            value = NULL;
12224
0
        }
12225
0
        else {
12226
0
            int res;
12227
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12228
0
                goto failed;
12229
0
            }
12230
0
            res = obj2ast_expr(state, tmp, &value, arena);
12231
0
            _Py_LeaveRecursiveCall();
12232
0
            if (res != 0) goto failed;
12233
0
            Py_CLEAR(tmp);
12234
0
        }
12235
0
        if (PyObject_GetOptionalAttr(obj, state->simple, &tmp) < 0) {
12236
0
            return -1;
12237
0
        }
12238
0
        if (tmp == NULL) {
12239
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12240
0
            return -1;
12241
0
        }
12242
0
        else {
12243
0
            int res;
12244
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12245
0
                goto failed;
12246
0
            }
12247
0
            res = obj2ast_int(state, tmp, &simple, arena);
12248
0
            _Py_LeaveRecursiveCall();
12249
0
            if (res != 0) goto failed;
12250
0
            Py_CLEAR(tmp);
12251
0
        }
12252
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12253
0
                                col_offset, end_lineno, end_col_offset, arena);
12254
0
        if (*out == NULL) goto failed;
12255
0
        return 0;
12256
0
    }
12257
0
    tp = state->For_type;
12258
0
    isinstance = PyObject_IsInstance(obj, tp);
12259
0
    if (isinstance == -1) {
12260
0
        return -1;
12261
0
    }
12262
0
    if (isinstance) {
12263
0
        expr_ty target;
12264
0
        expr_ty iter;
12265
0
        asdl_stmt_seq* body;
12266
0
        asdl_stmt_seq* orelse;
12267
0
        string type_comment;
12268
12269
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12270
0
            return -1;
12271
0
        }
12272
0
        if (tmp == NULL) {
12273
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12274
0
            return -1;
12275
0
        }
12276
0
        else {
12277
0
            int res;
12278
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12279
0
                goto failed;
12280
0
            }
12281
0
            res = obj2ast_expr(state, tmp, &target, arena);
12282
0
            _Py_LeaveRecursiveCall();
12283
0
            if (res != 0) goto failed;
12284
0
            Py_CLEAR(tmp);
12285
0
        }
12286
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12287
0
            return -1;
12288
0
        }
12289
0
        if (tmp == NULL) {
12290
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12291
0
            return -1;
12292
0
        }
12293
0
        else {
12294
0
            int res;
12295
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12296
0
                goto failed;
12297
0
            }
12298
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12299
0
            _Py_LeaveRecursiveCall();
12300
0
            if (res != 0) goto failed;
12301
0
            Py_CLEAR(tmp);
12302
0
        }
12303
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12304
0
            return -1;
12305
0
        }
12306
0
        if (tmp == NULL) {
12307
0
            tmp = PyList_New(0);
12308
0
            if (tmp == NULL) {
12309
0
                return -1;
12310
0
            }
12311
0
        }
12312
0
        {
12313
0
            int res;
12314
0
            Py_ssize_t len;
12315
0
            Py_ssize_t i;
12316
0
            if (!PyList_Check(tmp)) {
12317
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12318
0
                goto failed;
12319
0
            }
12320
0
            len = PyList_GET_SIZE(tmp);
12321
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12322
0
            if (body == NULL) goto failed;
12323
0
            for (i = 0; i < len; i++) {
12324
0
                stmt_ty val;
12325
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12326
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12327
0
                    goto failed;
12328
0
                }
12329
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12330
0
                _Py_LeaveRecursiveCall();
12331
0
                Py_DECREF(tmp2);
12332
0
                if (res != 0) goto failed;
12333
0
                if (len != PyList_GET_SIZE(tmp)) {
12334
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12335
0
                    goto failed;
12336
0
                }
12337
0
                asdl_seq_SET(body, i, val);
12338
0
            }
12339
0
            Py_CLEAR(tmp);
12340
0
        }
12341
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12342
0
            return -1;
12343
0
        }
12344
0
        if (tmp == NULL) {
12345
0
            tmp = PyList_New(0);
12346
0
            if (tmp == NULL) {
12347
0
                return -1;
12348
0
            }
12349
0
        }
12350
0
        {
12351
0
            int res;
12352
0
            Py_ssize_t len;
12353
0
            Py_ssize_t i;
12354
0
            if (!PyList_Check(tmp)) {
12355
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12356
0
                goto failed;
12357
0
            }
12358
0
            len = PyList_GET_SIZE(tmp);
12359
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12360
0
            if (orelse == NULL) goto failed;
12361
0
            for (i = 0; i < len; i++) {
12362
0
                stmt_ty val;
12363
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12364
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12365
0
                    goto failed;
12366
0
                }
12367
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12368
0
                _Py_LeaveRecursiveCall();
12369
0
                Py_DECREF(tmp2);
12370
0
                if (res != 0) goto failed;
12371
0
                if (len != PyList_GET_SIZE(tmp)) {
12372
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12373
0
                    goto failed;
12374
0
                }
12375
0
                asdl_seq_SET(orelse, i, val);
12376
0
            }
12377
0
            Py_CLEAR(tmp);
12378
0
        }
12379
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12380
0
            return -1;
12381
0
        }
12382
0
        if (tmp == NULL || tmp == Py_None) {
12383
0
            Py_CLEAR(tmp);
12384
0
            type_comment = NULL;
12385
0
        }
12386
0
        else {
12387
0
            int res;
12388
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12389
0
                goto failed;
12390
0
            }
12391
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12392
0
            _Py_LeaveRecursiveCall();
12393
0
            if (res != 0) goto failed;
12394
0
            Py_CLEAR(tmp);
12395
0
        }
12396
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12397
0
                          col_offset, end_lineno, end_col_offset, arena);
12398
0
        if (*out == NULL) goto failed;
12399
0
        return 0;
12400
0
    }
12401
0
    tp = state->AsyncFor_type;
12402
0
    isinstance = PyObject_IsInstance(obj, tp);
12403
0
    if (isinstance == -1) {
12404
0
        return -1;
12405
0
    }
12406
0
    if (isinstance) {
12407
0
        expr_ty target;
12408
0
        expr_ty iter;
12409
0
        asdl_stmt_seq* body;
12410
0
        asdl_stmt_seq* orelse;
12411
0
        string type_comment;
12412
12413
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12414
0
            return -1;
12415
0
        }
12416
0
        if (tmp == NULL) {
12417
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12418
0
            return -1;
12419
0
        }
12420
0
        else {
12421
0
            int res;
12422
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12423
0
                goto failed;
12424
0
            }
12425
0
            res = obj2ast_expr(state, tmp, &target, arena);
12426
0
            _Py_LeaveRecursiveCall();
12427
0
            if (res != 0) goto failed;
12428
0
            Py_CLEAR(tmp);
12429
0
        }
12430
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12431
0
            return -1;
12432
0
        }
12433
0
        if (tmp == NULL) {
12434
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12435
0
            return -1;
12436
0
        }
12437
0
        else {
12438
0
            int res;
12439
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12440
0
                goto failed;
12441
0
            }
12442
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12443
0
            _Py_LeaveRecursiveCall();
12444
0
            if (res != 0) goto failed;
12445
0
            Py_CLEAR(tmp);
12446
0
        }
12447
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12448
0
            return -1;
12449
0
        }
12450
0
        if (tmp == NULL) {
12451
0
            tmp = PyList_New(0);
12452
0
            if (tmp == NULL) {
12453
0
                return -1;
12454
0
            }
12455
0
        }
12456
0
        {
12457
0
            int res;
12458
0
            Py_ssize_t len;
12459
0
            Py_ssize_t i;
12460
0
            if (!PyList_Check(tmp)) {
12461
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12462
0
                goto failed;
12463
0
            }
12464
0
            len = PyList_GET_SIZE(tmp);
12465
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12466
0
            if (body == NULL) goto failed;
12467
0
            for (i = 0; i < len; i++) {
12468
0
                stmt_ty val;
12469
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12470
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12471
0
                    goto failed;
12472
0
                }
12473
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12474
0
                _Py_LeaveRecursiveCall();
12475
0
                Py_DECREF(tmp2);
12476
0
                if (res != 0) goto failed;
12477
0
                if (len != PyList_GET_SIZE(tmp)) {
12478
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12479
0
                    goto failed;
12480
0
                }
12481
0
                asdl_seq_SET(body, i, val);
12482
0
            }
12483
0
            Py_CLEAR(tmp);
12484
0
        }
12485
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12486
0
            return -1;
12487
0
        }
12488
0
        if (tmp == NULL) {
12489
0
            tmp = PyList_New(0);
12490
0
            if (tmp == NULL) {
12491
0
                return -1;
12492
0
            }
12493
0
        }
12494
0
        {
12495
0
            int res;
12496
0
            Py_ssize_t len;
12497
0
            Py_ssize_t i;
12498
0
            if (!PyList_Check(tmp)) {
12499
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12500
0
                goto failed;
12501
0
            }
12502
0
            len = PyList_GET_SIZE(tmp);
12503
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12504
0
            if (orelse == NULL) goto failed;
12505
0
            for (i = 0; i < len; i++) {
12506
0
                stmt_ty val;
12507
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12508
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12509
0
                    goto failed;
12510
0
                }
12511
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12512
0
                _Py_LeaveRecursiveCall();
12513
0
                Py_DECREF(tmp2);
12514
0
                if (res != 0) goto failed;
12515
0
                if (len != PyList_GET_SIZE(tmp)) {
12516
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12517
0
                    goto failed;
12518
0
                }
12519
0
                asdl_seq_SET(orelse, i, val);
12520
0
            }
12521
0
            Py_CLEAR(tmp);
12522
0
        }
12523
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12524
0
            return -1;
12525
0
        }
12526
0
        if (tmp == NULL || tmp == Py_None) {
12527
0
            Py_CLEAR(tmp);
12528
0
            type_comment = NULL;
12529
0
        }
12530
0
        else {
12531
0
            int res;
12532
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12533
0
                goto failed;
12534
0
            }
12535
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12536
0
            _Py_LeaveRecursiveCall();
12537
0
            if (res != 0) goto failed;
12538
0
            Py_CLEAR(tmp);
12539
0
        }
12540
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12541
0
                               lineno, col_offset, end_lineno, end_col_offset,
12542
0
                               arena);
12543
0
        if (*out == NULL) goto failed;
12544
0
        return 0;
12545
0
    }
12546
0
    tp = state->While_type;
12547
0
    isinstance = PyObject_IsInstance(obj, tp);
12548
0
    if (isinstance == -1) {
12549
0
        return -1;
12550
0
    }
12551
0
    if (isinstance) {
12552
0
        expr_ty test;
12553
0
        asdl_stmt_seq* body;
12554
0
        asdl_stmt_seq* orelse;
12555
12556
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12557
0
            return -1;
12558
0
        }
12559
0
        if (tmp == NULL) {
12560
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12561
0
            return -1;
12562
0
        }
12563
0
        else {
12564
0
            int res;
12565
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12566
0
                goto failed;
12567
0
            }
12568
0
            res = obj2ast_expr(state, tmp, &test, arena);
12569
0
            _Py_LeaveRecursiveCall();
12570
0
            if (res != 0) goto failed;
12571
0
            Py_CLEAR(tmp);
12572
0
        }
12573
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12574
0
            return -1;
12575
0
        }
12576
0
        if (tmp == NULL) {
12577
0
            tmp = PyList_New(0);
12578
0
            if (tmp == NULL) {
12579
0
                return -1;
12580
0
            }
12581
0
        }
12582
0
        {
12583
0
            int res;
12584
0
            Py_ssize_t len;
12585
0
            Py_ssize_t i;
12586
0
            if (!PyList_Check(tmp)) {
12587
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12588
0
                goto failed;
12589
0
            }
12590
0
            len = PyList_GET_SIZE(tmp);
12591
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12592
0
            if (body == NULL) goto failed;
12593
0
            for (i = 0; i < len; i++) {
12594
0
                stmt_ty val;
12595
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12596
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12597
0
                    goto failed;
12598
0
                }
12599
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12600
0
                _Py_LeaveRecursiveCall();
12601
0
                Py_DECREF(tmp2);
12602
0
                if (res != 0) goto failed;
12603
0
                if (len != PyList_GET_SIZE(tmp)) {
12604
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12605
0
                    goto failed;
12606
0
                }
12607
0
                asdl_seq_SET(body, i, val);
12608
0
            }
12609
0
            Py_CLEAR(tmp);
12610
0
        }
12611
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12612
0
            return -1;
12613
0
        }
12614
0
        if (tmp == NULL) {
12615
0
            tmp = PyList_New(0);
12616
0
            if (tmp == NULL) {
12617
0
                return -1;
12618
0
            }
12619
0
        }
12620
0
        {
12621
0
            int res;
12622
0
            Py_ssize_t len;
12623
0
            Py_ssize_t i;
12624
0
            if (!PyList_Check(tmp)) {
12625
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12626
0
                goto failed;
12627
0
            }
12628
0
            len = PyList_GET_SIZE(tmp);
12629
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12630
0
            if (orelse == NULL) goto failed;
12631
0
            for (i = 0; i < len; i++) {
12632
0
                stmt_ty val;
12633
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12634
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12635
0
                    goto failed;
12636
0
                }
12637
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12638
0
                _Py_LeaveRecursiveCall();
12639
0
                Py_DECREF(tmp2);
12640
0
                if (res != 0) goto failed;
12641
0
                if (len != PyList_GET_SIZE(tmp)) {
12642
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12643
0
                    goto failed;
12644
0
                }
12645
0
                asdl_seq_SET(orelse, i, val);
12646
0
            }
12647
0
            Py_CLEAR(tmp);
12648
0
        }
12649
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12650
0
                            end_col_offset, arena);
12651
0
        if (*out == NULL) goto failed;
12652
0
        return 0;
12653
0
    }
12654
0
    tp = state->If_type;
12655
0
    isinstance = PyObject_IsInstance(obj, tp);
12656
0
    if (isinstance == -1) {
12657
0
        return -1;
12658
0
    }
12659
0
    if (isinstance) {
12660
0
        expr_ty test;
12661
0
        asdl_stmt_seq* body;
12662
0
        asdl_stmt_seq* orelse;
12663
12664
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12665
0
            return -1;
12666
0
        }
12667
0
        if (tmp == NULL) {
12668
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12669
0
            return -1;
12670
0
        }
12671
0
        else {
12672
0
            int res;
12673
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12674
0
                goto failed;
12675
0
            }
12676
0
            res = obj2ast_expr(state, tmp, &test, arena);
12677
0
            _Py_LeaveRecursiveCall();
12678
0
            if (res != 0) goto failed;
12679
0
            Py_CLEAR(tmp);
12680
0
        }
12681
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12682
0
            return -1;
12683
0
        }
12684
0
        if (tmp == NULL) {
12685
0
            tmp = PyList_New(0);
12686
0
            if (tmp == NULL) {
12687
0
                return -1;
12688
0
            }
12689
0
        }
12690
0
        {
12691
0
            int res;
12692
0
            Py_ssize_t len;
12693
0
            Py_ssize_t i;
12694
0
            if (!PyList_Check(tmp)) {
12695
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12696
0
                goto failed;
12697
0
            }
12698
0
            len = PyList_GET_SIZE(tmp);
12699
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12700
0
            if (body == NULL) goto failed;
12701
0
            for (i = 0; i < len; i++) {
12702
0
                stmt_ty val;
12703
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12704
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12705
0
                    goto failed;
12706
0
                }
12707
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12708
0
                _Py_LeaveRecursiveCall();
12709
0
                Py_DECREF(tmp2);
12710
0
                if (res != 0) goto failed;
12711
0
                if (len != PyList_GET_SIZE(tmp)) {
12712
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12713
0
                    goto failed;
12714
0
                }
12715
0
                asdl_seq_SET(body, i, val);
12716
0
            }
12717
0
            Py_CLEAR(tmp);
12718
0
        }
12719
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12720
0
            return -1;
12721
0
        }
12722
0
        if (tmp == NULL) {
12723
0
            tmp = PyList_New(0);
12724
0
            if (tmp == NULL) {
12725
0
                return -1;
12726
0
            }
12727
0
        }
12728
0
        {
12729
0
            int res;
12730
0
            Py_ssize_t len;
12731
0
            Py_ssize_t i;
12732
0
            if (!PyList_Check(tmp)) {
12733
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12734
0
                goto failed;
12735
0
            }
12736
0
            len = PyList_GET_SIZE(tmp);
12737
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12738
0
            if (orelse == NULL) goto failed;
12739
0
            for (i = 0; i < len; i++) {
12740
0
                stmt_ty val;
12741
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12742
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12743
0
                    goto failed;
12744
0
                }
12745
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12746
0
                _Py_LeaveRecursiveCall();
12747
0
                Py_DECREF(tmp2);
12748
0
                if (res != 0) goto failed;
12749
0
                if (len != PyList_GET_SIZE(tmp)) {
12750
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12751
0
                    goto failed;
12752
0
                }
12753
0
                asdl_seq_SET(orelse, i, val);
12754
0
            }
12755
0
            Py_CLEAR(tmp);
12756
0
        }
12757
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12758
0
                         end_col_offset, arena);
12759
0
        if (*out == NULL) goto failed;
12760
0
        return 0;
12761
0
    }
12762
0
    tp = state->With_type;
12763
0
    isinstance = PyObject_IsInstance(obj, tp);
12764
0
    if (isinstance == -1) {
12765
0
        return -1;
12766
0
    }
12767
0
    if (isinstance) {
12768
0
        asdl_withitem_seq* items;
12769
0
        asdl_stmt_seq* body;
12770
0
        string type_comment;
12771
12772
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12773
0
            return -1;
12774
0
        }
12775
0
        if (tmp == NULL) {
12776
0
            tmp = PyList_New(0);
12777
0
            if (tmp == NULL) {
12778
0
                return -1;
12779
0
            }
12780
0
        }
12781
0
        {
12782
0
            int res;
12783
0
            Py_ssize_t len;
12784
0
            Py_ssize_t i;
12785
0
            if (!PyList_Check(tmp)) {
12786
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12787
0
                goto failed;
12788
0
            }
12789
0
            len = PyList_GET_SIZE(tmp);
12790
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12791
0
            if (items == NULL) goto failed;
12792
0
            for (i = 0; i < len; i++) {
12793
0
                withitem_ty val;
12794
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12795
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12796
0
                    goto failed;
12797
0
                }
12798
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12799
0
                _Py_LeaveRecursiveCall();
12800
0
                Py_DECREF(tmp2);
12801
0
                if (res != 0) goto failed;
12802
0
                if (len != PyList_GET_SIZE(tmp)) {
12803
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12804
0
                    goto failed;
12805
0
                }
12806
0
                asdl_seq_SET(items, i, val);
12807
0
            }
12808
0
            Py_CLEAR(tmp);
12809
0
        }
12810
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12811
0
            return -1;
12812
0
        }
12813
0
        if (tmp == NULL) {
12814
0
            tmp = PyList_New(0);
12815
0
            if (tmp == NULL) {
12816
0
                return -1;
12817
0
            }
12818
0
        }
12819
0
        {
12820
0
            int res;
12821
0
            Py_ssize_t len;
12822
0
            Py_ssize_t i;
12823
0
            if (!PyList_Check(tmp)) {
12824
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12825
0
                goto failed;
12826
0
            }
12827
0
            len = PyList_GET_SIZE(tmp);
12828
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12829
0
            if (body == NULL) goto failed;
12830
0
            for (i = 0; i < len; i++) {
12831
0
                stmt_ty val;
12832
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12833
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12834
0
                    goto failed;
12835
0
                }
12836
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12837
0
                _Py_LeaveRecursiveCall();
12838
0
                Py_DECREF(tmp2);
12839
0
                if (res != 0) goto failed;
12840
0
                if (len != PyList_GET_SIZE(tmp)) {
12841
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12842
0
                    goto failed;
12843
0
                }
12844
0
                asdl_seq_SET(body, i, val);
12845
0
            }
12846
0
            Py_CLEAR(tmp);
12847
0
        }
12848
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12849
0
            return -1;
12850
0
        }
12851
0
        if (tmp == NULL || tmp == Py_None) {
12852
0
            Py_CLEAR(tmp);
12853
0
            type_comment = NULL;
12854
0
        }
12855
0
        else {
12856
0
            int res;
12857
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12858
0
                goto failed;
12859
0
            }
12860
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12861
0
            _Py_LeaveRecursiveCall();
12862
0
            if (res != 0) goto failed;
12863
0
            Py_CLEAR(tmp);
12864
0
        }
12865
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12866
0
                           end_lineno, end_col_offset, arena);
12867
0
        if (*out == NULL) goto failed;
12868
0
        return 0;
12869
0
    }
12870
0
    tp = state->AsyncWith_type;
12871
0
    isinstance = PyObject_IsInstance(obj, tp);
12872
0
    if (isinstance == -1) {
12873
0
        return -1;
12874
0
    }
12875
0
    if (isinstance) {
12876
0
        asdl_withitem_seq* items;
12877
0
        asdl_stmt_seq* body;
12878
0
        string type_comment;
12879
12880
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12881
0
            return -1;
12882
0
        }
12883
0
        if (tmp == NULL) {
12884
0
            tmp = PyList_New(0);
12885
0
            if (tmp == NULL) {
12886
0
                return -1;
12887
0
            }
12888
0
        }
12889
0
        {
12890
0
            int res;
12891
0
            Py_ssize_t len;
12892
0
            Py_ssize_t i;
12893
0
            if (!PyList_Check(tmp)) {
12894
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12895
0
                goto failed;
12896
0
            }
12897
0
            len = PyList_GET_SIZE(tmp);
12898
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12899
0
            if (items == NULL) goto failed;
12900
0
            for (i = 0; i < len; i++) {
12901
0
                withitem_ty val;
12902
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12903
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12904
0
                    goto failed;
12905
0
                }
12906
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12907
0
                _Py_LeaveRecursiveCall();
12908
0
                Py_DECREF(tmp2);
12909
0
                if (res != 0) goto failed;
12910
0
                if (len != PyList_GET_SIZE(tmp)) {
12911
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12912
0
                    goto failed;
12913
0
                }
12914
0
                asdl_seq_SET(items, i, val);
12915
0
            }
12916
0
            Py_CLEAR(tmp);
12917
0
        }
12918
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12919
0
            return -1;
12920
0
        }
12921
0
        if (tmp == NULL) {
12922
0
            tmp = PyList_New(0);
12923
0
            if (tmp == NULL) {
12924
0
                return -1;
12925
0
            }
12926
0
        }
12927
0
        {
12928
0
            int res;
12929
0
            Py_ssize_t len;
12930
0
            Py_ssize_t i;
12931
0
            if (!PyList_Check(tmp)) {
12932
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12933
0
                goto failed;
12934
0
            }
12935
0
            len = PyList_GET_SIZE(tmp);
12936
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12937
0
            if (body == NULL) goto failed;
12938
0
            for (i = 0; i < len; i++) {
12939
0
                stmt_ty val;
12940
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12941
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12942
0
                    goto failed;
12943
0
                }
12944
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12945
0
                _Py_LeaveRecursiveCall();
12946
0
                Py_DECREF(tmp2);
12947
0
                if (res != 0) goto failed;
12948
0
                if (len != PyList_GET_SIZE(tmp)) {
12949
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
12950
0
                    goto failed;
12951
0
                }
12952
0
                asdl_seq_SET(body, i, val);
12953
0
            }
12954
0
            Py_CLEAR(tmp);
12955
0
        }
12956
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12957
0
            return -1;
12958
0
        }
12959
0
        if (tmp == NULL || tmp == Py_None) {
12960
0
            Py_CLEAR(tmp);
12961
0
            type_comment = NULL;
12962
0
        }
12963
0
        else {
12964
0
            int res;
12965
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12966
0
                goto failed;
12967
0
            }
12968
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12969
0
            _Py_LeaveRecursiveCall();
12970
0
            if (res != 0) goto failed;
12971
0
            Py_CLEAR(tmp);
12972
0
        }
12973
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
12974
0
                                end_lineno, end_col_offset, arena);
12975
0
        if (*out == NULL) goto failed;
12976
0
        return 0;
12977
0
    }
12978
0
    tp = state->Match_type;
12979
0
    isinstance = PyObject_IsInstance(obj, tp);
12980
0
    if (isinstance == -1) {
12981
0
        return -1;
12982
0
    }
12983
0
    if (isinstance) {
12984
0
        expr_ty subject;
12985
0
        asdl_match_case_seq* cases;
12986
12987
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
12988
0
            return -1;
12989
0
        }
12990
0
        if (tmp == NULL) {
12991
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
12992
0
            return -1;
12993
0
        }
12994
0
        else {
12995
0
            int res;
12996
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
12997
0
                goto failed;
12998
0
            }
12999
0
            res = obj2ast_expr(state, tmp, &subject, arena);
13000
0
            _Py_LeaveRecursiveCall();
13001
0
            if (res != 0) goto failed;
13002
0
            Py_CLEAR(tmp);
13003
0
        }
13004
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
13005
0
            return -1;
13006
0
        }
13007
0
        if (tmp == NULL) {
13008
0
            tmp = PyList_New(0);
13009
0
            if (tmp == NULL) {
13010
0
                return -1;
13011
0
            }
13012
0
        }
13013
0
        {
13014
0
            int res;
13015
0
            Py_ssize_t len;
13016
0
            Py_ssize_t i;
13017
0
            if (!PyList_Check(tmp)) {
13018
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13019
0
                goto failed;
13020
0
            }
13021
0
            len = PyList_GET_SIZE(tmp);
13022
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13023
0
            if (cases == NULL) goto failed;
13024
0
            for (i = 0; i < len; i++) {
13025
0
                match_case_ty val;
13026
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13027
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13028
0
                    goto failed;
13029
0
                }
13030
0
                res = obj2ast_match_case(state, tmp2, &val, arena);
13031
0
                _Py_LeaveRecursiveCall();
13032
0
                Py_DECREF(tmp2);
13033
0
                if (res != 0) goto failed;
13034
0
                if (len != PyList_GET_SIZE(tmp)) {
13035
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13036
0
                    goto failed;
13037
0
                }
13038
0
                asdl_seq_SET(cases, i, val);
13039
0
            }
13040
0
            Py_CLEAR(tmp);
13041
0
        }
13042
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13043
0
                            end_col_offset, arena);
13044
0
        if (*out == NULL) goto failed;
13045
0
        return 0;
13046
0
    }
13047
0
    tp = state->Raise_type;
13048
0
    isinstance = PyObject_IsInstance(obj, tp);
13049
0
    if (isinstance == -1) {
13050
0
        return -1;
13051
0
    }
13052
0
    if (isinstance) {
13053
0
        expr_ty exc;
13054
0
        expr_ty cause;
13055
13056
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13057
0
            return -1;
13058
0
        }
13059
0
        if (tmp == NULL || tmp == Py_None) {
13060
0
            Py_CLEAR(tmp);
13061
0
            exc = NULL;
13062
0
        }
13063
0
        else {
13064
0
            int res;
13065
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13066
0
                goto failed;
13067
0
            }
13068
0
            res = obj2ast_expr(state, tmp, &exc, arena);
13069
0
            _Py_LeaveRecursiveCall();
13070
0
            if (res != 0) goto failed;
13071
0
            Py_CLEAR(tmp);
13072
0
        }
13073
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13074
0
            return -1;
13075
0
        }
13076
0
        if (tmp == NULL || tmp == Py_None) {
13077
0
            Py_CLEAR(tmp);
13078
0
            cause = NULL;
13079
0
        }
13080
0
        else {
13081
0
            int res;
13082
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13083
0
                goto failed;
13084
0
            }
13085
0
            res = obj2ast_expr(state, tmp, &cause, arena);
13086
0
            _Py_LeaveRecursiveCall();
13087
0
            if (res != 0) goto failed;
13088
0
            Py_CLEAR(tmp);
13089
0
        }
13090
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13091
0
                            end_col_offset, arena);
13092
0
        if (*out == NULL) goto failed;
13093
0
        return 0;
13094
0
    }
13095
0
    tp = state->Try_type;
13096
0
    isinstance = PyObject_IsInstance(obj, tp);
13097
0
    if (isinstance == -1) {
13098
0
        return -1;
13099
0
    }
13100
0
    if (isinstance) {
13101
0
        asdl_stmt_seq* body;
13102
0
        asdl_excepthandler_seq* handlers;
13103
0
        asdl_stmt_seq* orelse;
13104
0
        asdl_stmt_seq* finalbody;
13105
13106
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13107
0
            return -1;
13108
0
        }
13109
0
        if (tmp == NULL) {
13110
0
            tmp = PyList_New(0);
13111
0
            if (tmp == NULL) {
13112
0
                return -1;
13113
0
            }
13114
0
        }
13115
0
        {
13116
0
            int res;
13117
0
            Py_ssize_t len;
13118
0
            Py_ssize_t i;
13119
0
            if (!PyList_Check(tmp)) {
13120
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13121
0
                goto failed;
13122
0
            }
13123
0
            len = PyList_GET_SIZE(tmp);
13124
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13125
0
            if (body == NULL) goto failed;
13126
0
            for (i = 0; i < len; i++) {
13127
0
                stmt_ty val;
13128
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13129
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13130
0
                    goto failed;
13131
0
                }
13132
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13133
0
                _Py_LeaveRecursiveCall();
13134
0
                Py_DECREF(tmp2);
13135
0
                if (res != 0) goto failed;
13136
0
                if (len != PyList_GET_SIZE(tmp)) {
13137
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13138
0
                    goto failed;
13139
0
                }
13140
0
                asdl_seq_SET(body, i, val);
13141
0
            }
13142
0
            Py_CLEAR(tmp);
13143
0
        }
13144
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13145
0
            return -1;
13146
0
        }
13147
0
        if (tmp == NULL) {
13148
0
            tmp = PyList_New(0);
13149
0
            if (tmp == NULL) {
13150
0
                return -1;
13151
0
            }
13152
0
        }
13153
0
        {
13154
0
            int res;
13155
0
            Py_ssize_t len;
13156
0
            Py_ssize_t i;
13157
0
            if (!PyList_Check(tmp)) {
13158
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13159
0
                goto failed;
13160
0
            }
13161
0
            len = PyList_GET_SIZE(tmp);
13162
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13163
0
            if (handlers == NULL) goto failed;
13164
0
            for (i = 0; i < len; i++) {
13165
0
                excepthandler_ty val;
13166
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13167
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13168
0
                    goto failed;
13169
0
                }
13170
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13171
0
                _Py_LeaveRecursiveCall();
13172
0
                Py_DECREF(tmp2);
13173
0
                if (res != 0) goto failed;
13174
0
                if (len != PyList_GET_SIZE(tmp)) {
13175
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13176
0
                    goto failed;
13177
0
                }
13178
0
                asdl_seq_SET(handlers, i, val);
13179
0
            }
13180
0
            Py_CLEAR(tmp);
13181
0
        }
13182
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13183
0
            return -1;
13184
0
        }
13185
0
        if (tmp == NULL) {
13186
0
            tmp = PyList_New(0);
13187
0
            if (tmp == NULL) {
13188
0
                return -1;
13189
0
            }
13190
0
        }
13191
0
        {
13192
0
            int res;
13193
0
            Py_ssize_t len;
13194
0
            Py_ssize_t i;
13195
0
            if (!PyList_Check(tmp)) {
13196
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13197
0
                goto failed;
13198
0
            }
13199
0
            len = PyList_GET_SIZE(tmp);
13200
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13201
0
            if (orelse == NULL) goto failed;
13202
0
            for (i = 0; i < len; i++) {
13203
0
                stmt_ty val;
13204
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13205
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13206
0
                    goto failed;
13207
0
                }
13208
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13209
0
                _Py_LeaveRecursiveCall();
13210
0
                Py_DECREF(tmp2);
13211
0
                if (res != 0) goto failed;
13212
0
                if (len != PyList_GET_SIZE(tmp)) {
13213
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13214
0
                    goto failed;
13215
0
                }
13216
0
                asdl_seq_SET(orelse, i, val);
13217
0
            }
13218
0
            Py_CLEAR(tmp);
13219
0
        }
13220
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13221
0
            return -1;
13222
0
        }
13223
0
        if (tmp == NULL) {
13224
0
            tmp = PyList_New(0);
13225
0
            if (tmp == NULL) {
13226
0
                return -1;
13227
0
            }
13228
0
        }
13229
0
        {
13230
0
            int res;
13231
0
            Py_ssize_t len;
13232
0
            Py_ssize_t i;
13233
0
            if (!PyList_Check(tmp)) {
13234
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13235
0
                goto failed;
13236
0
            }
13237
0
            len = PyList_GET_SIZE(tmp);
13238
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13239
0
            if (finalbody == NULL) goto failed;
13240
0
            for (i = 0; i < len; i++) {
13241
0
                stmt_ty val;
13242
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13243
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13244
0
                    goto failed;
13245
0
                }
13246
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13247
0
                _Py_LeaveRecursiveCall();
13248
0
                Py_DECREF(tmp2);
13249
0
                if (res != 0) goto failed;
13250
0
                if (len != PyList_GET_SIZE(tmp)) {
13251
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13252
0
                    goto failed;
13253
0
                }
13254
0
                asdl_seq_SET(finalbody, i, val);
13255
0
            }
13256
0
            Py_CLEAR(tmp);
13257
0
        }
13258
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13259
0
                          col_offset, end_lineno, end_col_offset, arena);
13260
0
        if (*out == NULL) goto failed;
13261
0
        return 0;
13262
0
    }
13263
0
    tp = state->TryStar_type;
13264
0
    isinstance = PyObject_IsInstance(obj, tp);
13265
0
    if (isinstance == -1) {
13266
0
        return -1;
13267
0
    }
13268
0
    if (isinstance) {
13269
0
        asdl_stmt_seq* body;
13270
0
        asdl_excepthandler_seq* handlers;
13271
0
        asdl_stmt_seq* orelse;
13272
0
        asdl_stmt_seq* finalbody;
13273
13274
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13275
0
            return -1;
13276
0
        }
13277
0
        if (tmp == NULL) {
13278
0
            tmp = PyList_New(0);
13279
0
            if (tmp == NULL) {
13280
0
                return -1;
13281
0
            }
13282
0
        }
13283
0
        {
13284
0
            int res;
13285
0
            Py_ssize_t len;
13286
0
            Py_ssize_t i;
13287
0
            if (!PyList_Check(tmp)) {
13288
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13289
0
                goto failed;
13290
0
            }
13291
0
            len = PyList_GET_SIZE(tmp);
13292
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13293
0
            if (body == NULL) goto failed;
13294
0
            for (i = 0; i < len; i++) {
13295
0
                stmt_ty val;
13296
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13297
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13298
0
                    goto failed;
13299
0
                }
13300
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13301
0
                _Py_LeaveRecursiveCall();
13302
0
                Py_DECREF(tmp2);
13303
0
                if (res != 0) goto failed;
13304
0
                if (len != PyList_GET_SIZE(tmp)) {
13305
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13306
0
                    goto failed;
13307
0
                }
13308
0
                asdl_seq_SET(body, i, val);
13309
0
            }
13310
0
            Py_CLEAR(tmp);
13311
0
        }
13312
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13313
0
            return -1;
13314
0
        }
13315
0
        if (tmp == NULL) {
13316
0
            tmp = PyList_New(0);
13317
0
            if (tmp == NULL) {
13318
0
                return -1;
13319
0
            }
13320
0
        }
13321
0
        {
13322
0
            int res;
13323
0
            Py_ssize_t len;
13324
0
            Py_ssize_t i;
13325
0
            if (!PyList_Check(tmp)) {
13326
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13327
0
                goto failed;
13328
0
            }
13329
0
            len = PyList_GET_SIZE(tmp);
13330
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13331
0
            if (handlers == NULL) goto failed;
13332
0
            for (i = 0; i < len; i++) {
13333
0
                excepthandler_ty val;
13334
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13335
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13336
0
                    goto failed;
13337
0
                }
13338
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13339
0
                _Py_LeaveRecursiveCall();
13340
0
                Py_DECREF(tmp2);
13341
0
                if (res != 0) goto failed;
13342
0
                if (len != PyList_GET_SIZE(tmp)) {
13343
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13344
0
                    goto failed;
13345
0
                }
13346
0
                asdl_seq_SET(handlers, i, val);
13347
0
            }
13348
0
            Py_CLEAR(tmp);
13349
0
        }
13350
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13351
0
            return -1;
13352
0
        }
13353
0
        if (tmp == NULL) {
13354
0
            tmp = PyList_New(0);
13355
0
            if (tmp == NULL) {
13356
0
                return -1;
13357
0
            }
13358
0
        }
13359
0
        {
13360
0
            int res;
13361
0
            Py_ssize_t len;
13362
0
            Py_ssize_t i;
13363
0
            if (!PyList_Check(tmp)) {
13364
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13365
0
                goto failed;
13366
0
            }
13367
0
            len = PyList_GET_SIZE(tmp);
13368
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13369
0
            if (orelse == NULL) goto failed;
13370
0
            for (i = 0; i < len; i++) {
13371
0
                stmt_ty val;
13372
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13373
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13374
0
                    goto failed;
13375
0
                }
13376
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13377
0
                _Py_LeaveRecursiveCall();
13378
0
                Py_DECREF(tmp2);
13379
0
                if (res != 0) goto failed;
13380
0
                if (len != PyList_GET_SIZE(tmp)) {
13381
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13382
0
                    goto failed;
13383
0
                }
13384
0
                asdl_seq_SET(orelse, i, val);
13385
0
            }
13386
0
            Py_CLEAR(tmp);
13387
0
        }
13388
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13389
0
            return -1;
13390
0
        }
13391
0
        if (tmp == NULL) {
13392
0
            tmp = PyList_New(0);
13393
0
            if (tmp == NULL) {
13394
0
                return -1;
13395
0
            }
13396
0
        }
13397
0
        {
13398
0
            int res;
13399
0
            Py_ssize_t len;
13400
0
            Py_ssize_t i;
13401
0
            if (!PyList_Check(tmp)) {
13402
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13403
0
                goto failed;
13404
0
            }
13405
0
            len = PyList_GET_SIZE(tmp);
13406
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13407
0
            if (finalbody == NULL) goto failed;
13408
0
            for (i = 0; i < len; i++) {
13409
0
                stmt_ty val;
13410
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13411
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13412
0
                    goto failed;
13413
0
                }
13414
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13415
0
                _Py_LeaveRecursiveCall();
13416
0
                Py_DECREF(tmp2);
13417
0
                if (res != 0) goto failed;
13418
0
                if (len != PyList_GET_SIZE(tmp)) {
13419
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13420
0
                    goto failed;
13421
0
                }
13422
0
                asdl_seq_SET(finalbody, i, val);
13423
0
            }
13424
0
            Py_CLEAR(tmp);
13425
0
        }
13426
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13427
0
                              col_offset, end_lineno, end_col_offset, arena);
13428
0
        if (*out == NULL) goto failed;
13429
0
        return 0;
13430
0
    }
13431
0
    tp = state->Assert_type;
13432
0
    isinstance = PyObject_IsInstance(obj, tp);
13433
0
    if (isinstance == -1) {
13434
0
        return -1;
13435
0
    }
13436
0
    if (isinstance) {
13437
0
        expr_ty test;
13438
0
        expr_ty msg;
13439
13440
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13441
0
            return -1;
13442
0
        }
13443
0
        if (tmp == NULL) {
13444
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13445
0
            return -1;
13446
0
        }
13447
0
        else {
13448
0
            int res;
13449
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13450
0
                goto failed;
13451
0
            }
13452
0
            res = obj2ast_expr(state, tmp, &test, arena);
13453
0
            _Py_LeaveRecursiveCall();
13454
0
            if (res != 0) goto failed;
13455
0
            Py_CLEAR(tmp);
13456
0
        }
13457
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13458
0
            return -1;
13459
0
        }
13460
0
        if (tmp == NULL || tmp == Py_None) {
13461
0
            Py_CLEAR(tmp);
13462
0
            msg = NULL;
13463
0
        }
13464
0
        else {
13465
0
            int res;
13466
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13467
0
                goto failed;
13468
0
            }
13469
0
            res = obj2ast_expr(state, tmp, &msg, arena);
13470
0
            _Py_LeaveRecursiveCall();
13471
0
            if (res != 0) goto failed;
13472
0
            Py_CLEAR(tmp);
13473
0
        }
13474
0
        *out = _PyAST_Assert(test, msg, lineno, col_offset, end_lineno,
13475
0
                             end_col_offset, arena);
13476
0
        if (*out == NULL) goto failed;
13477
0
        return 0;
13478
0
    }
13479
0
    tp = state->Import_type;
13480
0
    isinstance = PyObject_IsInstance(obj, tp);
13481
0
    if (isinstance == -1) {
13482
0
        return -1;
13483
0
    }
13484
0
    if (isinstance) {
13485
0
        asdl_alias_seq* names;
13486
13487
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13488
0
            return -1;
13489
0
        }
13490
0
        if (tmp == NULL) {
13491
0
            tmp = PyList_New(0);
13492
0
            if (tmp == NULL) {
13493
0
                return -1;
13494
0
            }
13495
0
        }
13496
0
        {
13497
0
            int res;
13498
0
            Py_ssize_t len;
13499
0
            Py_ssize_t i;
13500
0
            if (!PyList_Check(tmp)) {
13501
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13502
0
                goto failed;
13503
0
            }
13504
0
            len = PyList_GET_SIZE(tmp);
13505
0
            names = _Py_asdl_alias_seq_new(len, arena);
13506
0
            if (names == NULL) goto failed;
13507
0
            for (i = 0; i < len; i++) {
13508
0
                alias_ty val;
13509
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13510
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13511
0
                    goto failed;
13512
0
                }
13513
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13514
0
                _Py_LeaveRecursiveCall();
13515
0
                Py_DECREF(tmp2);
13516
0
                if (res != 0) goto failed;
13517
0
                if (len != PyList_GET_SIZE(tmp)) {
13518
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13519
0
                    goto failed;
13520
0
                }
13521
0
                asdl_seq_SET(names, i, val);
13522
0
            }
13523
0
            Py_CLEAR(tmp);
13524
0
        }
13525
0
        *out = _PyAST_Import(names, lineno, col_offset, end_lineno,
13526
0
                             end_col_offset, arena);
13527
0
        if (*out == NULL) goto failed;
13528
0
        return 0;
13529
0
    }
13530
0
    tp = state->ImportFrom_type;
13531
0
    isinstance = PyObject_IsInstance(obj, tp);
13532
0
    if (isinstance == -1) {
13533
0
        return -1;
13534
0
    }
13535
0
    if (isinstance) {
13536
0
        identifier module;
13537
0
        asdl_alias_seq* names;
13538
0
        int level;
13539
13540
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13541
0
            return -1;
13542
0
        }
13543
0
        if (tmp == NULL || tmp == Py_None) {
13544
0
            Py_CLEAR(tmp);
13545
0
            module = NULL;
13546
0
        }
13547
0
        else {
13548
0
            int res;
13549
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13550
0
                goto failed;
13551
0
            }
13552
0
            res = obj2ast_identifier(state, tmp, &module, arena);
13553
0
            _Py_LeaveRecursiveCall();
13554
0
            if (res != 0) goto failed;
13555
0
            Py_CLEAR(tmp);
13556
0
        }
13557
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13558
0
            return -1;
13559
0
        }
13560
0
        if (tmp == NULL) {
13561
0
            tmp = PyList_New(0);
13562
0
            if (tmp == NULL) {
13563
0
                return -1;
13564
0
            }
13565
0
        }
13566
0
        {
13567
0
            int res;
13568
0
            Py_ssize_t len;
13569
0
            Py_ssize_t i;
13570
0
            if (!PyList_Check(tmp)) {
13571
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13572
0
                goto failed;
13573
0
            }
13574
0
            len = PyList_GET_SIZE(tmp);
13575
0
            names = _Py_asdl_alias_seq_new(len, arena);
13576
0
            if (names == NULL) goto failed;
13577
0
            for (i = 0; i < len; i++) {
13578
0
                alias_ty val;
13579
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13580
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13581
0
                    goto failed;
13582
0
                }
13583
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13584
0
                _Py_LeaveRecursiveCall();
13585
0
                Py_DECREF(tmp2);
13586
0
                if (res != 0) goto failed;
13587
0
                if (len != PyList_GET_SIZE(tmp)) {
13588
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13589
0
                    goto failed;
13590
0
                }
13591
0
                asdl_seq_SET(names, i, val);
13592
0
            }
13593
0
            Py_CLEAR(tmp);
13594
0
        }
13595
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13596
0
            return -1;
13597
0
        }
13598
0
        if (tmp == NULL || tmp == Py_None) {
13599
0
            Py_CLEAR(tmp);
13600
0
            level = 0;
13601
0
        }
13602
0
        else {
13603
0
            int res;
13604
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13605
0
                goto failed;
13606
0
            }
13607
0
            res = obj2ast_int(state, tmp, &level, arena);
13608
0
            _Py_LeaveRecursiveCall();
13609
0
            if (res != 0) goto failed;
13610
0
            Py_CLEAR(tmp);
13611
0
        }
13612
0
        *out = _PyAST_ImportFrom(module, names, level, lineno, col_offset,
13613
0
                                 end_lineno, end_col_offset, arena);
13614
0
        if (*out == NULL) goto failed;
13615
0
        return 0;
13616
0
    }
13617
0
    tp = state->Global_type;
13618
0
    isinstance = PyObject_IsInstance(obj, tp);
13619
0
    if (isinstance == -1) {
13620
0
        return -1;
13621
0
    }
13622
0
    if (isinstance) {
13623
0
        asdl_identifier_seq* names;
13624
13625
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13626
0
            return -1;
13627
0
        }
13628
0
        if (tmp == NULL) {
13629
0
            tmp = PyList_New(0);
13630
0
            if (tmp == NULL) {
13631
0
                return -1;
13632
0
            }
13633
0
        }
13634
0
        {
13635
0
            int res;
13636
0
            Py_ssize_t len;
13637
0
            Py_ssize_t i;
13638
0
            if (!PyList_Check(tmp)) {
13639
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13640
0
                goto failed;
13641
0
            }
13642
0
            len = PyList_GET_SIZE(tmp);
13643
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13644
0
            if (names == NULL) goto failed;
13645
0
            for (i = 0; i < len; i++) {
13646
0
                identifier val;
13647
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13648
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13649
0
                    goto failed;
13650
0
                }
13651
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13652
0
                _Py_LeaveRecursiveCall();
13653
0
                Py_DECREF(tmp2);
13654
0
                if (res != 0) goto failed;
13655
0
                if (len != PyList_GET_SIZE(tmp)) {
13656
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13657
0
                    goto failed;
13658
0
                }
13659
0
                asdl_seq_SET(names, i, val);
13660
0
            }
13661
0
            Py_CLEAR(tmp);
13662
0
        }
13663
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13664
0
                             end_col_offset, arena);
13665
0
        if (*out == NULL) goto failed;
13666
0
        return 0;
13667
0
    }
13668
0
    tp = state->Nonlocal_type;
13669
0
    isinstance = PyObject_IsInstance(obj, tp);
13670
0
    if (isinstance == -1) {
13671
0
        return -1;
13672
0
    }
13673
0
    if (isinstance) {
13674
0
        asdl_identifier_seq* names;
13675
13676
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13677
0
            return -1;
13678
0
        }
13679
0
        if (tmp == NULL) {
13680
0
            tmp = PyList_New(0);
13681
0
            if (tmp == NULL) {
13682
0
                return -1;
13683
0
            }
13684
0
        }
13685
0
        {
13686
0
            int res;
13687
0
            Py_ssize_t len;
13688
0
            Py_ssize_t i;
13689
0
            if (!PyList_Check(tmp)) {
13690
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13691
0
                goto failed;
13692
0
            }
13693
0
            len = PyList_GET_SIZE(tmp);
13694
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13695
0
            if (names == NULL) goto failed;
13696
0
            for (i = 0; i < len; i++) {
13697
0
                identifier val;
13698
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13699
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13700
0
                    goto failed;
13701
0
                }
13702
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13703
0
                _Py_LeaveRecursiveCall();
13704
0
                Py_DECREF(tmp2);
13705
0
                if (res != 0) goto failed;
13706
0
                if (len != PyList_GET_SIZE(tmp)) {
13707
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13708
0
                    goto failed;
13709
0
                }
13710
0
                asdl_seq_SET(names, i, val);
13711
0
            }
13712
0
            Py_CLEAR(tmp);
13713
0
        }
13714
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13715
0
                               end_col_offset, arena);
13716
0
        if (*out == NULL) goto failed;
13717
0
        return 0;
13718
0
    }
13719
0
    tp = state->Expr_type;
13720
0
    isinstance = PyObject_IsInstance(obj, tp);
13721
0
    if (isinstance == -1) {
13722
0
        return -1;
13723
0
    }
13724
0
    if (isinstance) {
13725
0
        expr_ty value;
13726
13727
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13728
0
            return -1;
13729
0
        }
13730
0
        if (tmp == NULL) {
13731
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13732
0
            return -1;
13733
0
        }
13734
0
        else {
13735
0
            int res;
13736
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13737
0
                goto failed;
13738
0
            }
13739
0
            res = obj2ast_expr(state, tmp, &value, arena);
13740
0
            _Py_LeaveRecursiveCall();
13741
0
            if (res != 0) goto failed;
13742
0
            Py_CLEAR(tmp);
13743
0
        }
13744
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13745
0
                           end_col_offset, arena);
13746
0
        if (*out == NULL) goto failed;
13747
0
        return 0;
13748
0
    }
13749
0
    tp = state->Pass_type;
13750
0
    isinstance = PyObject_IsInstance(obj, tp);
13751
0
    if (isinstance == -1) {
13752
0
        return -1;
13753
0
    }
13754
0
    if (isinstance) {
13755
13756
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13757
0
                           arena);
13758
0
        if (*out == NULL) goto failed;
13759
0
        return 0;
13760
0
    }
13761
0
    tp = state->Break_type;
13762
0
    isinstance = PyObject_IsInstance(obj, tp);
13763
0
    if (isinstance == -1) {
13764
0
        return -1;
13765
0
    }
13766
0
    if (isinstance) {
13767
13768
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13769
0
                            arena);
13770
0
        if (*out == NULL) goto failed;
13771
0
        return 0;
13772
0
    }
13773
0
    tp = state->Continue_type;
13774
0
    isinstance = PyObject_IsInstance(obj, tp);
13775
0
    if (isinstance == -1) {
13776
0
        return -1;
13777
0
    }
13778
0
    if (isinstance) {
13779
13780
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13781
0
                               arena);
13782
0
        if (*out == NULL) goto failed;
13783
0
        return 0;
13784
0
    }
13785
13786
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13787
0
    failed:
13788
0
    Py_XDECREF(tmp);
13789
0
    return -1;
13790
0
}
13791
13792
int
13793
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
13794
             arena)
13795
0
{
13796
0
    int isinstance;
13797
13798
0
    PyObject *tmp = NULL;
13799
0
    PyObject *tp;
13800
0
    int lineno;
13801
0
    int col_offset;
13802
0
    int end_lineno;
13803
0
    int end_col_offset;
13804
13805
0
    if (obj == Py_None) {
13806
0
        *out = NULL;
13807
0
        return 0;
13808
0
    }
13809
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13810
0
        return -1;
13811
0
    }
13812
0
    if (tmp == NULL) {
13813
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13814
0
        return -1;
13815
0
    }
13816
0
    else {
13817
0
        int res;
13818
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13819
0
            goto failed;
13820
0
        }
13821
0
        res = obj2ast_int(state, tmp, &lineno, arena);
13822
0
        _Py_LeaveRecursiveCall();
13823
0
        if (res != 0) goto failed;
13824
0
        Py_CLEAR(tmp);
13825
0
    }
13826
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13827
0
        return -1;
13828
0
    }
13829
0
    if (tmp == NULL) {
13830
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13831
0
        return -1;
13832
0
    }
13833
0
    else {
13834
0
        int res;
13835
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13836
0
            goto failed;
13837
0
        }
13838
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
13839
0
        _Py_LeaveRecursiveCall();
13840
0
        if (res != 0) goto failed;
13841
0
        Py_CLEAR(tmp);
13842
0
    }
13843
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13844
0
        return -1;
13845
0
    }
13846
0
    if (tmp == NULL || tmp == Py_None) {
13847
0
        Py_CLEAR(tmp);
13848
0
        end_lineno = lineno;
13849
0
    }
13850
0
    else {
13851
0
        int res;
13852
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13853
0
            goto failed;
13854
0
        }
13855
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
13856
0
        _Py_LeaveRecursiveCall();
13857
0
        if (res != 0) goto failed;
13858
0
        Py_CLEAR(tmp);
13859
0
    }
13860
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13861
0
        return -1;
13862
0
    }
13863
0
    if (tmp == NULL || tmp == Py_None) {
13864
0
        Py_CLEAR(tmp);
13865
0
        end_col_offset = col_offset;
13866
0
    }
13867
0
    else {
13868
0
        int res;
13869
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13870
0
            goto failed;
13871
0
        }
13872
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
13873
0
        _Py_LeaveRecursiveCall();
13874
0
        if (res != 0) goto failed;
13875
0
        Py_CLEAR(tmp);
13876
0
    }
13877
0
    tp = state->BoolOp_type;
13878
0
    isinstance = PyObject_IsInstance(obj, tp);
13879
0
    if (isinstance == -1) {
13880
0
        return -1;
13881
0
    }
13882
0
    if (isinstance) {
13883
0
        boolop_ty op;
13884
0
        asdl_expr_seq* values;
13885
13886
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13887
0
            return -1;
13888
0
        }
13889
0
        if (tmp == NULL) {
13890
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13891
0
            return -1;
13892
0
        }
13893
0
        else {
13894
0
            int res;
13895
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13896
0
                goto failed;
13897
0
            }
13898
0
            res = obj2ast_boolop(state, tmp, &op, arena);
13899
0
            _Py_LeaveRecursiveCall();
13900
0
            if (res != 0) goto failed;
13901
0
            Py_CLEAR(tmp);
13902
0
        }
13903
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13904
0
            return -1;
13905
0
        }
13906
0
        if (tmp == NULL) {
13907
0
            tmp = PyList_New(0);
13908
0
            if (tmp == NULL) {
13909
0
                return -1;
13910
0
            }
13911
0
        }
13912
0
        {
13913
0
            int res;
13914
0
            Py_ssize_t len;
13915
0
            Py_ssize_t i;
13916
0
            if (!PyList_Check(tmp)) {
13917
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13918
0
                goto failed;
13919
0
            }
13920
0
            len = PyList_GET_SIZE(tmp);
13921
0
            values = _Py_asdl_expr_seq_new(len, arena);
13922
0
            if (values == NULL) goto failed;
13923
0
            for (i = 0; i < len; i++) {
13924
0
                expr_ty val;
13925
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13926
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13927
0
                    goto failed;
13928
0
                }
13929
0
                res = obj2ast_expr(state, tmp2, &val, arena);
13930
0
                _Py_LeaveRecursiveCall();
13931
0
                Py_DECREF(tmp2);
13932
0
                if (res != 0) goto failed;
13933
0
                if (len != PyList_GET_SIZE(tmp)) {
13934
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
13935
0
                    goto failed;
13936
0
                }
13937
0
                asdl_seq_SET(values, i, val);
13938
0
            }
13939
0
            Py_CLEAR(tmp);
13940
0
        }
13941
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
13942
0
                             end_col_offset, arena);
13943
0
        if (*out == NULL) goto failed;
13944
0
        return 0;
13945
0
    }
13946
0
    tp = state->NamedExpr_type;
13947
0
    isinstance = PyObject_IsInstance(obj, tp);
13948
0
    if (isinstance == -1) {
13949
0
        return -1;
13950
0
    }
13951
0
    if (isinstance) {
13952
0
        expr_ty target;
13953
0
        expr_ty value;
13954
13955
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
13956
0
            return -1;
13957
0
        }
13958
0
        if (tmp == NULL) {
13959
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
13960
0
            return -1;
13961
0
        }
13962
0
        else {
13963
0
            int res;
13964
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13965
0
                goto failed;
13966
0
            }
13967
0
            res = obj2ast_expr(state, tmp, &target, arena);
13968
0
            _Py_LeaveRecursiveCall();
13969
0
            if (res != 0) goto failed;
13970
0
            Py_CLEAR(tmp);
13971
0
        }
13972
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13973
0
            return -1;
13974
0
        }
13975
0
        if (tmp == NULL) {
13976
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
13977
0
            return -1;
13978
0
        }
13979
0
        else {
13980
0
            int res;
13981
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
13982
0
                goto failed;
13983
0
            }
13984
0
            res = obj2ast_expr(state, tmp, &value, arena);
13985
0
            _Py_LeaveRecursiveCall();
13986
0
            if (res != 0) goto failed;
13987
0
            Py_CLEAR(tmp);
13988
0
        }
13989
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
13990
0
                                end_col_offset, arena);
13991
0
        if (*out == NULL) goto failed;
13992
0
        return 0;
13993
0
    }
13994
0
    tp = state->BinOp_type;
13995
0
    isinstance = PyObject_IsInstance(obj, tp);
13996
0
    if (isinstance == -1) {
13997
0
        return -1;
13998
0
    }
13999
0
    if (isinstance) {
14000
0
        expr_ty left;
14001
0
        operator_ty op;
14002
0
        expr_ty right;
14003
14004
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14005
0
            return -1;
14006
0
        }
14007
0
        if (tmp == NULL) {
14008
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14009
0
            return -1;
14010
0
        }
14011
0
        else {
14012
0
            int res;
14013
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14014
0
                goto failed;
14015
0
            }
14016
0
            res = obj2ast_expr(state, tmp, &left, arena);
14017
0
            _Py_LeaveRecursiveCall();
14018
0
            if (res != 0) goto failed;
14019
0
            Py_CLEAR(tmp);
14020
0
        }
14021
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14022
0
            return -1;
14023
0
        }
14024
0
        if (tmp == NULL) {
14025
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14026
0
            return -1;
14027
0
        }
14028
0
        else {
14029
0
            int res;
14030
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14031
0
                goto failed;
14032
0
            }
14033
0
            res = obj2ast_operator(state, tmp, &op, arena);
14034
0
            _Py_LeaveRecursiveCall();
14035
0
            if (res != 0) goto failed;
14036
0
            Py_CLEAR(tmp);
14037
0
        }
14038
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14039
0
            return -1;
14040
0
        }
14041
0
        if (tmp == NULL) {
14042
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14043
0
            return -1;
14044
0
        }
14045
0
        else {
14046
0
            int res;
14047
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14048
0
                goto failed;
14049
0
            }
14050
0
            res = obj2ast_expr(state, tmp, &right, arena);
14051
0
            _Py_LeaveRecursiveCall();
14052
0
            if (res != 0) goto failed;
14053
0
            Py_CLEAR(tmp);
14054
0
        }
14055
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14056
0
                            end_col_offset, arena);
14057
0
        if (*out == NULL) goto failed;
14058
0
        return 0;
14059
0
    }
14060
0
    tp = state->UnaryOp_type;
14061
0
    isinstance = PyObject_IsInstance(obj, tp);
14062
0
    if (isinstance == -1) {
14063
0
        return -1;
14064
0
    }
14065
0
    if (isinstance) {
14066
0
        unaryop_ty op;
14067
0
        expr_ty operand;
14068
14069
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14070
0
            return -1;
14071
0
        }
14072
0
        if (tmp == NULL) {
14073
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14074
0
            return -1;
14075
0
        }
14076
0
        else {
14077
0
            int res;
14078
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14079
0
                goto failed;
14080
0
            }
14081
0
            res = obj2ast_unaryop(state, tmp, &op, arena);
14082
0
            _Py_LeaveRecursiveCall();
14083
0
            if (res != 0) goto failed;
14084
0
            Py_CLEAR(tmp);
14085
0
        }
14086
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
14087
0
            return -1;
14088
0
        }
14089
0
        if (tmp == NULL) {
14090
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14091
0
            return -1;
14092
0
        }
14093
0
        else {
14094
0
            int res;
14095
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14096
0
                goto failed;
14097
0
            }
14098
0
            res = obj2ast_expr(state, tmp, &operand, arena);
14099
0
            _Py_LeaveRecursiveCall();
14100
0
            if (res != 0) goto failed;
14101
0
            Py_CLEAR(tmp);
14102
0
        }
14103
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14104
0
                              end_col_offset, arena);
14105
0
        if (*out == NULL) goto failed;
14106
0
        return 0;
14107
0
    }
14108
0
    tp = state->Lambda_type;
14109
0
    isinstance = PyObject_IsInstance(obj, tp);
14110
0
    if (isinstance == -1) {
14111
0
        return -1;
14112
0
    }
14113
0
    if (isinstance) {
14114
0
        arguments_ty args;
14115
0
        expr_ty body;
14116
14117
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14118
0
            return -1;
14119
0
        }
14120
0
        if (tmp == NULL) {
14121
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14122
0
            return -1;
14123
0
        }
14124
0
        else {
14125
0
            int res;
14126
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14127
0
                goto failed;
14128
0
            }
14129
0
            res = obj2ast_arguments(state, tmp, &args, arena);
14130
0
            _Py_LeaveRecursiveCall();
14131
0
            if (res != 0) goto failed;
14132
0
            Py_CLEAR(tmp);
14133
0
        }
14134
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14135
0
            return -1;
14136
0
        }
14137
0
        if (tmp == NULL) {
14138
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14139
0
            return -1;
14140
0
        }
14141
0
        else {
14142
0
            int res;
14143
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14144
0
                goto failed;
14145
0
            }
14146
0
            res = obj2ast_expr(state, tmp, &body, arena);
14147
0
            _Py_LeaveRecursiveCall();
14148
0
            if (res != 0) goto failed;
14149
0
            Py_CLEAR(tmp);
14150
0
        }
14151
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14152
0
                             end_col_offset, arena);
14153
0
        if (*out == NULL) goto failed;
14154
0
        return 0;
14155
0
    }
14156
0
    tp = state->IfExp_type;
14157
0
    isinstance = PyObject_IsInstance(obj, tp);
14158
0
    if (isinstance == -1) {
14159
0
        return -1;
14160
0
    }
14161
0
    if (isinstance) {
14162
0
        expr_ty test;
14163
0
        expr_ty body;
14164
0
        expr_ty orelse;
14165
14166
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14167
0
            return -1;
14168
0
        }
14169
0
        if (tmp == NULL) {
14170
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14171
0
            return -1;
14172
0
        }
14173
0
        else {
14174
0
            int res;
14175
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14176
0
                goto failed;
14177
0
            }
14178
0
            res = obj2ast_expr(state, tmp, &test, arena);
14179
0
            _Py_LeaveRecursiveCall();
14180
0
            if (res != 0) goto failed;
14181
0
            Py_CLEAR(tmp);
14182
0
        }
14183
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14184
0
            return -1;
14185
0
        }
14186
0
        if (tmp == NULL) {
14187
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14188
0
            return -1;
14189
0
        }
14190
0
        else {
14191
0
            int res;
14192
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14193
0
                goto failed;
14194
0
            }
14195
0
            res = obj2ast_expr(state, tmp, &body, arena);
14196
0
            _Py_LeaveRecursiveCall();
14197
0
            if (res != 0) goto failed;
14198
0
            Py_CLEAR(tmp);
14199
0
        }
14200
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14201
0
            return -1;
14202
0
        }
14203
0
        if (tmp == NULL) {
14204
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14205
0
            return -1;
14206
0
        }
14207
0
        else {
14208
0
            int res;
14209
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14210
0
                goto failed;
14211
0
            }
14212
0
            res = obj2ast_expr(state, tmp, &orelse, arena);
14213
0
            _Py_LeaveRecursiveCall();
14214
0
            if (res != 0) goto failed;
14215
0
            Py_CLEAR(tmp);
14216
0
        }
14217
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14218
0
                            end_col_offset, arena);
14219
0
        if (*out == NULL) goto failed;
14220
0
        return 0;
14221
0
    }
14222
0
    tp = state->Dict_type;
14223
0
    isinstance = PyObject_IsInstance(obj, tp);
14224
0
    if (isinstance == -1) {
14225
0
        return -1;
14226
0
    }
14227
0
    if (isinstance) {
14228
0
        asdl_expr_seq* keys;
14229
0
        asdl_expr_seq* values;
14230
14231
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14232
0
            return -1;
14233
0
        }
14234
0
        if (tmp == NULL) {
14235
0
            tmp = PyList_New(0);
14236
0
            if (tmp == NULL) {
14237
0
                return -1;
14238
0
            }
14239
0
        }
14240
0
        {
14241
0
            int res;
14242
0
            Py_ssize_t len;
14243
0
            Py_ssize_t i;
14244
0
            if (!PyList_Check(tmp)) {
14245
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14246
0
                goto failed;
14247
0
            }
14248
0
            len = PyList_GET_SIZE(tmp);
14249
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14250
0
            if (keys == NULL) goto failed;
14251
0
            for (i = 0; i < len; i++) {
14252
0
                expr_ty val;
14253
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14254
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14255
0
                    goto failed;
14256
0
                }
14257
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14258
0
                _Py_LeaveRecursiveCall();
14259
0
                Py_DECREF(tmp2);
14260
0
                if (res != 0) goto failed;
14261
0
                if (len != PyList_GET_SIZE(tmp)) {
14262
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14263
0
                    goto failed;
14264
0
                }
14265
0
                asdl_seq_SET(keys, i, val);
14266
0
            }
14267
0
            Py_CLEAR(tmp);
14268
0
        }
14269
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14270
0
            return -1;
14271
0
        }
14272
0
        if (tmp == NULL) {
14273
0
            tmp = PyList_New(0);
14274
0
            if (tmp == NULL) {
14275
0
                return -1;
14276
0
            }
14277
0
        }
14278
0
        {
14279
0
            int res;
14280
0
            Py_ssize_t len;
14281
0
            Py_ssize_t i;
14282
0
            if (!PyList_Check(tmp)) {
14283
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14284
0
                goto failed;
14285
0
            }
14286
0
            len = PyList_GET_SIZE(tmp);
14287
0
            values = _Py_asdl_expr_seq_new(len, arena);
14288
0
            if (values == NULL) goto failed;
14289
0
            for (i = 0; i < len; i++) {
14290
0
                expr_ty val;
14291
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14292
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14293
0
                    goto failed;
14294
0
                }
14295
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14296
0
                _Py_LeaveRecursiveCall();
14297
0
                Py_DECREF(tmp2);
14298
0
                if (res != 0) goto failed;
14299
0
                if (len != PyList_GET_SIZE(tmp)) {
14300
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14301
0
                    goto failed;
14302
0
                }
14303
0
                asdl_seq_SET(values, i, val);
14304
0
            }
14305
0
            Py_CLEAR(tmp);
14306
0
        }
14307
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14308
0
                           end_col_offset, arena);
14309
0
        if (*out == NULL) goto failed;
14310
0
        return 0;
14311
0
    }
14312
0
    tp = state->Set_type;
14313
0
    isinstance = PyObject_IsInstance(obj, tp);
14314
0
    if (isinstance == -1) {
14315
0
        return -1;
14316
0
    }
14317
0
    if (isinstance) {
14318
0
        asdl_expr_seq* elts;
14319
14320
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14321
0
            return -1;
14322
0
        }
14323
0
        if (tmp == NULL) {
14324
0
            tmp = PyList_New(0);
14325
0
            if (tmp == NULL) {
14326
0
                return -1;
14327
0
            }
14328
0
        }
14329
0
        {
14330
0
            int res;
14331
0
            Py_ssize_t len;
14332
0
            Py_ssize_t i;
14333
0
            if (!PyList_Check(tmp)) {
14334
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14335
0
                goto failed;
14336
0
            }
14337
0
            len = PyList_GET_SIZE(tmp);
14338
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14339
0
            if (elts == NULL) goto failed;
14340
0
            for (i = 0; i < len; i++) {
14341
0
                expr_ty val;
14342
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14343
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14344
0
                    goto failed;
14345
0
                }
14346
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14347
0
                _Py_LeaveRecursiveCall();
14348
0
                Py_DECREF(tmp2);
14349
0
                if (res != 0) goto failed;
14350
0
                if (len != PyList_GET_SIZE(tmp)) {
14351
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14352
0
                    goto failed;
14353
0
                }
14354
0
                asdl_seq_SET(elts, i, val);
14355
0
            }
14356
0
            Py_CLEAR(tmp);
14357
0
        }
14358
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14359
0
                          arena);
14360
0
        if (*out == NULL) goto failed;
14361
0
        return 0;
14362
0
    }
14363
0
    tp = state->ListComp_type;
14364
0
    isinstance = PyObject_IsInstance(obj, tp);
14365
0
    if (isinstance == -1) {
14366
0
        return -1;
14367
0
    }
14368
0
    if (isinstance) {
14369
0
        expr_ty elt;
14370
0
        asdl_comprehension_seq* generators;
14371
14372
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14373
0
            return -1;
14374
0
        }
14375
0
        if (tmp == NULL) {
14376
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14377
0
            return -1;
14378
0
        }
14379
0
        else {
14380
0
            int res;
14381
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14382
0
                goto failed;
14383
0
            }
14384
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14385
0
            _Py_LeaveRecursiveCall();
14386
0
            if (res != 0) goto failed;
14387
0
            Py_CLEAR(tmp);
14388
0
        }
14389
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14390
0
            return -1;
14391
0
        }
14392
0
        if (tmp == NULL) {
14393
0
            tmp = PyList_New(0);
14394
0
            if (tmp == NULL) {
14395
0
                return -1;
14396
0
            }
14397
0
        }
14398
0
        {
14399
0
            int res;
14400
0
            Py_ssize_t len;
14401
0
            Py_ssize_t i;
14402
0
            if (!PyList_Check(tmp)) {
14403
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14404
0
                goto failed;
14405
0
            }
14406
0
            len = PyList_GET_SIZE(tmp);
14407
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14408
0
            if (generators == NULL) goto failed;
14409
0
            for (i = 0; i < len; i++) {
14410
0
                comprehension_ty val;
14411
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14412
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14413
0
                    goto failed;
14414
0
                }
14415
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14416
0
                _Py_LeaveRecursiveCall();
14417
0
                Py_DECREF(tmp2);
14418
0
                if (res != 0) goto failed;
14419
0
                if (len != PyList_GET_SIZE(tmp)) {
14420
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14421
0
                    goto failed;
14422
0
                }
14423
0
                asdl_seq_SET(generators, i, val);
14424
0
            }
14425
0
            Py_CLEAR(tmp);
14426
0
        }
14427
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14428
0
                               end_col_offset, arena);
14429
0
        if (*out == NULL) goto failed;
14430
0
        return 0;
14431
0
    }
14432
0
    tp = state->SetComp_type;
14433
0
    isinstance = PyObject_IsInstance(obj, tp);
14434
0
    if (isinstance == -1) {
14435
0
        return -1;
14436
0
    }
14437
0
    if (isinstance) {
14438
0
        expr_ty elt;
14439
0
        asdl_comprehension_seq* generators;
14440
14441
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14442
0
            return -1;
14443
0
        }
14444
0
        if (tmp == NULL) {
14445
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14446
0
            return -1;
14447
0
        }
14448
0
        else {
14449
0
            int res;
14450
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14451
0
                goto failed;
14452
0
            }
14453
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14454
0
            _Py_LeaveRecursiveCall();
14455
0
            if (res != 0) goto failed;
14456
0
            Py_CLEAR(tmp);
14457
0
        }
14458
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14459
0
            return -1;
14460
0
        }
14461
0
        if (tmp == NULL) {
14462
0
            tmp = PyList_New(0);
14463
0
            if (tmp == NULL) {
14464
0
                return -1;
14465
0
            }
14466
0
        }
14467
0
        {
14468
0
            int res;
14469
0
            Py_ssize_t len;
14470
0
            Py_ssize_t i;
14471
0
            if (!PyList_Check(tmp)) {
14472
0
                PyErr_Format(PyExc_TypeError, "SetComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14473
0
                goto failed;
14474
0
            }
14475
0
            len = PyList_GET_SIZE(tmp);
14476
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14477
0
            if (generators == NULL) goto failed;
14478
0
            for (i = 0; i < len; i++) {
14479
0
                comprehension_ty val;
14480
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14481
0
                if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14482
0
                    goto failed;
14483
0
                }
14484
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14485
0
                _Py_LeaveRecursiveCall();
14486
0
                Py_DECREF(tmp2);
14487
0
                if (res != 0) goto failed;
14488
0
                if (len != PyList_GET_SIZE(tmp)) {
14489
0
                    PyErr_SetString(PyExc_RuntimeError, "SetComp field \"generators\" changed size during iteration");
14490
0
                    goto failed;
14491
0
                }
14492
0
                asdl_seq_SET(generators, i, val);
14493
0
            }
14494
0
            Py_CLEAR(tmp);
14495
0
        }
14496
0
        *out = _PyAST_SetComp(elt, generators, lineno, col_offset, end_lineno,
14497
0
                              end_col_offset, arena);
14498
0
        if (*out == NULL) goto failed;
14499
0
        return 0;
14500
0
    }
14501
0
    tp = state->DictComp_type;
14502
0
    isinstance = PyObject_IsInstance(obj, tp);
14503
0
    if (isinstance == -1) {
14504
0
        return -1;
14505
0
    }
14506
0
    if (isinstance) {
14507
0
        expr_ty key;
14508
0
        expr_ty value;
14509
0
        asdl_comprehension_seq* generators;
14510
14511
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14512
0
            return -1;
14513
0
        }
14514
0
        if (tmp == NULL) {
14515
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14516
0
            return -1;
14517
0
        }
14518
0
        else {
14519
0
            int res;
14520
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14521
0
                goto failed;
14522
0
            }
14523
0
            res = obj2ast_expr(state, tmp, &key, arena);
14524
0
            _Py_LeaveRecursiveCall();
14525
0
            if (res != 0) goto failed;
14526
0
            Py_CLEAR(tmp);
14527
0
        }
14528
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14529
0
            return -1;
14530
0
        }
14531
0
        if (tmp == NULL || tmp == Py_None) {
14532
0
            Py_CLEAR(tmp);
14533
0
            value = NULL;
14534
0
        }
14535
0
        else {
14536
0
            int res;
14537
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14538
0
                goto failed;
14539
0
            }
14540
0
            res = obj2ast_expr(state, tmp, &value, arena);
14541
0
            _Py_LeaveRecursiveCall();
14542
0
            if (res != 0) goto failed;
14543
0
            Py_CLEAR(tmp);
14544
0
        }
14545
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14546
0
            return -1;
14547
0
        }
14548
0
        if (tmp == NULL) {
14549
0
            tmp = PyList_New(0);
14550
0
            if (tmp == NULL) {
14551
0
                return -1;
14552
0
            }
14553
0
        }
14554
0
        {
14555
0
            int res;
14556
0
            Py_ssize_t len;
14557
0
            Py_ssize_t i;
14558
0
            if (!PyList_Check(tmp)) {
14559
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14560
0
                goto failed;
14561
0
            }
14562
0
            len = PyList_GET_SIZE(tmp);
14563
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14564
0
            if (generators == NULL) goto failed;
14565
0
            for (i = 0; i < len; i++) {
14566
0
                comprehension_ty val;
14567
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14568
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14569
0
                    goto failed;
14570
0
                }
14571
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14572
0
                _Py_LeaveRecursiveCall();
14573
0
                Py_DECREF(tmp2);
14574
0
                if (res != 0) goto failed;
14575
0
                if (len != PyList_GET_SIZE(tmp)) {
14576
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14577
0
                    goto failed;
14578
0
                }
14579
0
                asdl_seq_SET(generators, i, val);
14580
0
            }
14581
0
            Py_CLEAR(tmp);
14582
0
        }
14583
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14584
0
                               end_lineno, end_col_offset, arena);
14585
0
        if (*out == NULL) goto failed;
14586
0
        return 0;
14587
0
    }
14588
0
    tp = state->GeneratorExp_type;
14589
0
    isinstance = PyObject_IsInstance(obj, tp);
14590
0
    if (isinstance == -1) {
14591
0
        return -1;
14592
0
    }
14593
0
    if (isinstance) {
14594
0
        expr_ty elt;
14595
0
        asdl_comprehension_seq* generators;
14596
14597
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14598
0
            return -1;
14599
0
        }
14600
0
        if (tmp == NULL) {
14601
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14602
0
            return -1;
14603
0
        }
14604
0
        else {
14605
0
            int res;
14606
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14607
0
                goto failed;
14608
0
            }
14609
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14610
0
            _Py_LeaveRecursiveCall();
14611
0
            if (res != 0) goto failed;
14612
0
            Py_CLEAR(tmp);
14613
0
        }
14614
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14615
0
            return -1;
14616
0
        }
14617
0
        if (tmp == NULL) {
14618
0
            tmp = PyList_New(0);
14619
0
            if (tmp == NULL) {
14620
0
                return -1;
14621
0
            }
14622
0
        }
14623
0
        {
14624
0
            int res;
14625
0
            Py_ssize_t len;
14626
0
            Py_ssize_t i;
14627
0
            if (!PyList_Check(tmp)) {
14628
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14629
0
                goto failed;
14630
0
            }
14631
0
            len = PyList_GET_SIZE(tmp);
14632
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14633
0
            if (generators == NULL) goto failed;
14634
0
            for (i = 0; i < len; i++) {
14635
0
                comprehension_ty val;
14636
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14637
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14638
0
                    goto failed;
14639
0
                }
14640
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14641
0
                _Py_LeaveRecursiveCall();
14642
0
                Py_DECREF(tmp2);
14643
0
                if (res != 0) goto failed;
14644
0
                if (len != PyList_GET_SIZE(tmp)) {
14645
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14646
0
                    goto failed;
14647
0
                }
14648
0
                asdl_seq_SET(generators, i, val);
14649
0
            }
14650
0
            Py_CLEAR(tmp);
14651
0
        }
14652
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14653
0
                                   end_lineno, end_col_offset, arena);
14654
0
        if (*out == NULL) goto failed;
14655
0
        return 0;
14656
0
    }
14657
0
    tp = state->Await_type;
14658
0
    isinstance = PyObject_IsInstance(obj, tp);
14659
0
    if (isinstance == -1) {
14660
0
        return -1;
14661
0
    }
14662
0
    if (isinstance) {
14663
0
        expr_ty value;
14664
14665
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14666
0
            return -1;
14667
0
        }
14668
0
        if (tmp == NULL) {
14669
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14670
0
            return -1;
14671
0
        }
14672
0
        else {
14673
0
            int res;
14674
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14675
0
                goto failed;
14676
0
            }
14677
0
            res = obj2ast_expr(state, tmp, &value, arena);
14678
0
            _Py_LeaveRecursiveCall();
14679
0
            if (res != 0) goto failed;
14680
0
            Py_CLEAR(tmp);
14681
0
        }
14682
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14683
0
                            end_col_offset, arena);
14684
0
        if (*out == NULL) goto failed;
14685
0
        return 0;
14686
0
    }
14687
0
    tp = state->Yield_type;
14688
0
    isinstance = PyObject_IsInstance(obj, tp);
14689
0
    if (isinstance == -1) {
14690
0
        return -1;
14691
0
    }
14692
0
    if (isinstance) {
14693
0
        expr_ty value;
14694
14695
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14696
0
            return -1;
14697
0
        }
14698
0
        if (tmp == NULL || tmp == Py_None) {
14699
0
            Py_CLEAR(tmp);
14700
0
            value = NULL;
14701
0
        }
14702
0
        else {
14703
0
            int res;
14704
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14705
0
                goto failed;
14706
0
            }
14707
0
            res = obj2ast_expr(state, tmp, &value, arena);
14708
0
            _Py_LeaveRecursiveCall();
14709
0
            if (res != 0) goto failed;
14710
0
            Py_CLEAR(tmp);
14711
0
        }
14712
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14713
0
                            end_col_offset, arena);
14714
0
        if (*out == NULL) goto failed;
14715
0
        return 0;
14716
0
    }
14717
0
    tp = state->YieldFrom_type;
14718
0
    isinstance = PyObject_IsInstance(obj, tp);
14719
0
    if (isinstance == -1) {
14720
0
        return -1;
14721
0
    }
14722
0
    if (isinstance) {
14723
0
        expr_ty value;
14724
14725
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14726
0
            return -1;
14727
0
        }
14728
0
        if (tmp == NULL) {
14729
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14730
0
            return -1;
14731
0
        }
14732
0
        else {
14733
0
            int res;
14734
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14735
0
                goto failed;
14736
0
            }
14737
0
            res = obj2ast_expr(state, tmp, &value, arena);
14738
0
            _Py_LeaveRecursiveCall();
14739
0
            if (res != 0) goto failed;
14740
0
            Py_CLEAR(tmp);
14741
0
        }
14742
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14743
0
                                end_col_offset, arena);
14744
0
        if (*out == NULL) goto failed;
14745
0
        return 0;
14746
0
    }
14747
0
    tp = state->Compare_type;
14748
0
    isinstance = PyObject_IsInstance(obj, tp);
14749
0
    if (isinstance == -1) {
14750
0
        return -1;
14751
0
    }
14752
0
    if (isinstance) {
14753
0
        expr_ty left;
14754
0
        asdl_int_seq* ops;
14755
0
        asdl_expr_seq* comparators;
14756
14757
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14758
0
            return -1;
14759
0
        }
14760
0
        if (tmp == NULL) {
14761
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14762
0
            return -1;
14763
0
        }
14764
0
        else {
14765
0
            int res;
14766
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14767
0
                goto failed;
14768
0
            }
14769
0
            res = obj2ast_expr(state, tmp, &left, arena);
14770
0
            _Py_LeaveRecursiveCall();
14771
0
            if (res != 0) goto failed;
14772
0
            Py_CLEAR(tmp);
14773
0
        }
14774
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14775
0
            return -1;
14776
0
        }
14777
0
        if (tmp == NULL) {
14778
0
            tmp = PyList_New(0);
14779
0
            if (tmp == NULL) {
14780
0
                return -1;
14781
0
            }
14782
0
        }
14783
0
        {
14784
0
            int res;
14785
0
            Py_ssize_t len;
14786
0
            Py_ssize_t i;
14787
0
            if (!PyList_Check(tmp)) {
14788
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14789
0
                goto failed;
14790
0
            }
14791
0
            len = PyList_GET_SIZE(tmp);
14792
0
            ops = _Py_asdl_int_seq_new(len, arena);
14793
0
            if (ops == NULL) goto failed;
14794
0
            for (i = 0; i < len; i++) {
14795
0
                cmpop_ty val;
14796
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14797
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14798
0
                    goto failed;
14799
0
                }
14800
0
                res = obj2ast_cmpop(state, tmp2, &val, arena);
14801
0
                _Py_LeaveRecursiveCall();
14802
0
                Py_DECREF(tmp2);
14803
0
                if (res != 0) goto failed;
14804
0
                if (len != PyList_GET_SIZE(tmp)) {
14805
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14806
0
                    goto failed;
14807
0
                }
14808
0
                asdl_seq_SET(ops, i, val);
14809
0
            }
14810
0
            Py_CLEAR(tmp);
14811
0
        }
14812
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14813
0
            return -1;
14814
0
        }
14815
0
        if (tmp == NULL) {
14816
0
            tmp = PyList_New(0);
14817
0
            if (tmp == NULL) {
14818
0
                return -1;
14819
0
            }
14820
0
        }
14821
0
        {
14822
0
            int res;
14823
0
            Py_ssize_t len;
14824
0
            Py_ssize_t i;
14825
0
            if (!PyList_Check(tmp)) {
14826
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14827
0
                goto failed;
14828
0
            }
14829
0
            len = PyList_GET_SIZE(tmp);
14830
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14831
0
            if (comparators == NULL) goto failed;
14832
0
            for (i = 0; i < len; i++) {
14833
0
                expr_ty val;
14834
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14835
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14836
0
                    goto failed;
14837
0
                }
14838
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14839
0
                _Py_LeaveRecursiveCall();
14840
0
                Py_DECREF(tmp2);
14841
0
                if (res != 0) goto failed;
14842
0
                if (len != PyList_GET_SIZE(tmp)) {
14843
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14844
0
                    goto failed;
14845
0
                }
14846
0
                asdl_seq_SET(comparators, i, val);
14847
0
            }
14848
0
            Py_CLEAR(tmp);
14849
0
        }
14850
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14851
0
                              end_lineno, end_col_offset, arena);
14852
0
        if (*out == NULL) goto failed;
14853
0
        return 0;
14854
0
    }
14855
0
    tp = state->Call_type;
14856
0
    isinstance = PyObject_IsInstance(obj, tp);
14857
0
    if (isinstance == -1) {
14858
0
        return -1;
14859
0
    }
14860
0
    if (isinstance) {
14861
0
        expr_ty func;
14862
0
        asdl_expr_seq* args;
14863
0
        asdl_keyword_seq* keywords;
14864
14865
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14866
0
            return -1;
14867
0
        }
14868
0
        if (tmp == NULL) {
14869
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14870
0
            return -1;
14871
0
        }
14872
0
        else {
14873
0
            int res;
14874
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14875
0
                goto failed;
14876
0
            }
14877
0
            res = obj2ast_expr(state, tmp, &func, arena);
14878
0
            _Py_LeaveRecursiveCall();
14879
0
            if (res != 0) goto failed;
14880
0
            Py_CLEAR(tmp);
14881
0
        }
14882
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14883
0
            return -1;
14884
0
        }
14885
0
        if (tmp == NULL) {
14886
0
            tmp = PyList_New(0);
14887
0
            if (tmp == NULL) {
14888
0
                return -1;
14889
0
            }
14890
0
        }
14891
0
        {
14892
0
            int res;
14893
0
            Py_ssize_t len;
14894
0
            Py_ssize_t i;
14895
0
            if (!PyList_Check(tmp)) {
14896
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14897
0
                goto failed;
14898
0
            }
14899
0
            len = PyList_GET_SIZE(tmp);
14900
0
            args = _Py_asdl_expr_seq_new(len, arena);
14901
0
            if (args == NULL) goto failed;
14902
0
            for (i = 0; i < len; i++) {
14903
0
                expr_ty val;
14904
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14905
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14906
0
                    goto failed;
14907
0
                }
14908
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14909
0
                _Py_LeaveRecursiveCall();
14910
0
                Py_DECREF(tmp2);
14911
0
                if (res != 0) goto failed;
14912
0
                if (len != PyList_GET_SIZE(tmp)) {
14913
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
14914
0
                    goto failed;
14915
0
                }
14916
0
                asdl_seq_SET(args, i, val);
14917
0
            }
14918
0
            Py_CLEAR(tmp);
14919
0
        }
14920
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
14921
0
            return -1;
14922
0
        }
14923
0
        if (tmp == NULL) {
14924
0
            tmp = PyList_New(0);
14925
0
            if (tmp == NULL) {
14926
0
                return -1;
14927
0
            }
14928
0
        }
14929
0
        {
14930
0
            int res;
14931
0
            Py_ssize_t len;
14932
0
            Py_ssize_t i;
14933
0
            if (!PyList_Check(tmp)) {
14934
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14935
0
                goto failed;
14936
0
            }
14937
0
            len = PyList_GET_SIZE(tmp);
14938
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
14939
0
            if (keywords == NULL) goto failed;
14940
0
            for (i = 0; i < len; i++) {
14941
0
                keyword_ty val;
14942
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14943
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14944
0
                    goto failed;
14945
0
                }
14946
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
14947
0
                _Py_LeaveRecursiveCall();
14948
0
                Py_DECREF(tmp2);
14949
0
                if (res != 0) goto failed;
14950
0
                if (len != PyList_GET_SIZE(tmp)) {
14951
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
14952
0
                    goto failed;
14953
0
                }
14954
0
                asdl_seq_SET(keywords, i, val);
14955
0
            }
14956
0
            Py_CLEAR(tmp);
14957
0
        }
14958
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
14959
0
                           end_lineno, end_col_offset, arena);
14960
0
        if (*out == NULL) goto failed;
14961
0
        return 0;
14962
0
    }
14963
0
    tp = state->FormattedValue_type;
14964
0
    isinstance = PyObject_IsInstance(obj, tp);
14965
0
    if (isinstance == -1) {
14966
0
        return -1;
14967
0
    }
14968
0
    if (isinstance) {
14969
0
        expr_ty value;
14970
0
        int conversion;
14971
0
        expr_ty format_spec;
14972
14973
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14974
0
            return -1;
14975
0
        }
14976
0
        if (tmp == NULL) {
14977
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
14978
0
            return -1;
14979
0
        }
14980
0
        else {
14981
0
            int res;
14982
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
14983
0
                goto failed;
14984
0
            }
14985
0
            res = obj2ast_expr(state, tmp, &value, arena);
14986
0
            _Py_LeaveRecursiveCall();
14987
0
            if (res != 0) goto failed;
14988
0
            Py_CLEAR(tmp);
14989
0
        }
14990
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
14991
0
            return -1;
14992
0
        }
14993
0
        if (tmp == NULL) {
14994
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
14995
0
            return -1;
14996
0
        }
14997
0
        else {
14998
0
            int res;
14999
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15000
0
                goto failed;
15001
0
            }
15002
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15003
0
            _Py_LeaveRecursiveCall();
15004
0
            if (res != 0) goto failed;
15005
0
            Py_CLEAR(tmp);
15006
0
        }
15007
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15008
0
            return -1;
15009
0
        }
15010
0
        if (tmp == NULL || tmp == Py_None) {
15011
0
            Py_CLEAR(tmp);
15012
0
            format_spec = NULL;
15013
0
        }
15014
0
        else {
15015
0
            int res;
15016
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15017
0
                goto failed;
15018
0
            }
15019
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15020
0
            _Py_LeaveRecursiveCall();
15021
0
            if (res != 0) goto failed;
15022
0
            Py_CLEAR(tmp);
15023
0
        }
15024
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15025
0
                                     col_offset, end_lineno, end_col_offset,
15026
0
                                     arena);
15027
0
        if (*out == NULL) goto failed;
15028
0
        return 0;
15029
0
    }
15030
0
    tp = state->Interpolation_type;
15031
0
    isinstance = PyObject_IsInstance(obj, tp);
15032
0
    if (isinstance == -1) {
15033
0
        return -1;
15034
0
    }
15035
0
    if (isinstance) {
15036
0
        expr_ty value;
15037
0
        constant str;
15038
0
        int conversion;
15039
0
        expr_ty format_spec;
15040
15041
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15042
0
            return -1;
15043
0
        }
15044
0
        if (tmp == NULL) {
15045
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15046
0
            return -1;
15047
0
        }
15048
0
        else {
15049
0
            int res;
15050
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15051
0
                goto failed;
15052
0
            }
15053
0
            res = obj2ast_expr(state, tmp, &value, arena);
15054
0
            _Py_LeaveRecursiveCall();
15055
0
            if (res != 0) goto failed;
15056
0
            Py_CLEAR(tmp);
15057
0
        }
15058
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15059
0
            return -1;
15060
0
        }
15061
0
        if (tmp == NULL) {
15062
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15063
0
            return -1;
15064
0
        }
15065
0
        else {
15066
0
            int res;
15067
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15068
0
                goto failed;
15069
0
            }
15070
0
            res = obj2ast_constant(state, tmp, &str, arena);
15071
0
            _Py_LeaveRecursiveCall();
15072
0
            if (res != 0) goto failed;
15073
0
            Py_CLEAR(tmp);
15074
0
        }
15075
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15076
0
            return -1;
15077
0
        }
15078
0
        if (tmp == NULL) {
15079
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15080
0
            return -1;
15081
0
        }
15082
0
        else {
15083
0
            int res;
15084
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15085
0
                goto failed;
15086
0
            }
15087
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15088
0
            _Py_LeaveRecursiveCall();
15089
0
            if (res != 0) goto failed;
15090
0
            Py_CLEAR(tmp);
15091
0
        }
15092
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15093
0
            return -1;
15094
0
        }
15095
0
        if (tmp == NULL || tmp == Py_None) {
15096
0
            Py_CLEAR(tmp);
15097
0
            format_spec = NULL;
15098
0
        }
15099
0
        else {
15100
0
            int res;
15101
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15102
0
                goto failed;
15103
0
            }
15104
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15105
0
            _Py_LeaveRecursiveCall();
15106
0
            if (res != 0) goto failed;
15107
0
            Py_CLEAR(tmp);
15108
0
        }
15109
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15110
0
                                    lineno, col_offset, end_lineno,
15111
0
                                    end_col_offset, arena);
15112
0
        if (*out == NULL) goto failed;
15113
0
        return 0;
15114
0
    }
15115
0
    tp = state->JoinedStr_type;
15116
0
    isinstance = PyObject_IsInstance(obj, tp);
15117
0
    if (isinstance == -1) {
15118
0
        return -1;
15119
0
    }
15120
0
    if (isinstance) {
15121
0
        asdl_expr_seq* values;
15122
15123
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15124
0
            return -1;
15125
0
        }
15126
0
        if (tmp == NULL) {
15127
0
            tmp = PyList_New(0);
15128
0
            if (tmp == NULL) {
15129
0
                return -1;
15130
0
            }
15131
0
        }
15132
0
        {
15133
0
            int res;
15134
0
            Py_ssize_t len;
15135
0
            Py_ssize_t i;
15136
0
            if (!PyList_Check(tmp)) {
15137
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15138
0
                goto failed;
15139
0
            }
15140
0
            len = PyList_GET_SIZE(tmp);
15141
0
            values = _Py_asdl_expr_seq_new(len, arena);
15142
0
            if (values == NULL) goto failed;
15143
0
            for (i = 0; i < len; i++) {
15144
0
                expr_ty val;
15145
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15146
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15147
0
                    goto failed;
15148
0
                }
15149
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15150
0
                _Py_LeaveRecursiveCall();
15151
0
                Py_DECREF(tmp2);
15152
0
                if (res != 0) goto failed;
15153
0
                if (len != PyList_GET_SIZE(tmp)) {
15154
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15155
0
                    goto failed;
15156
0
                }
15157
0
                asdl_seq_SET(values, i, val);
15158
0
            }
15159
0
            Py_CLEAR(tmp);
15160
0
        }
15161
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15162
0
                                end_col_offset, arena);
15163
0
        if (*out == NULL) goto failed;
15164
0
        return 0;
15165
0
    }
15166
0
    tp = state->TemplateStr_type;
15167
0
    isinstance = PyObject_IsInstance(obj, tp);
15168
0
    if (isinstance == -1) {
15169
0
        return -1;
15170
0
    }
15171
0
    if (isinstance) {
15172
0
        asdl_expr_seq* values;
15173
15174
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15175
0
            return -1;
15176
0
        }
15177
0
        if (tmp == NULL) {
15178
0
            tmp = PyList_New(0);
15179
0
            if (tmp == NULL) {
15180
0
                return -1;
15181
0
            }
15182
0
        }
15183
0
        {
15184
0
            int res;
15185
0
            Py_ssize_t len;
15186
0
            Py_ssize_t i;
15187
0
            if (!PyList_Check(tmp)) {
15188
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15189
0
                goto failed;
15190
0
            }
15191
0
            len = PyList_GET_SIZE(tmp);
15192
0
            values = _Py_asdl_expr_seq_new(len, arena);
15193
0
            if (values == NULL) goto failed;
15194
0
            for (i = 0; i < len; i++) {
15195
0
                expr_ty val;
15196
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15197
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15198
0
                    goto failed;
15199
0
                }
15200
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15201
0
                _Py_LeaveRecursiveCall();
15202
0
                Py_DECREF(tmp2);
15203
0
                if (res != 0) goto failed;
15204
0
                if (len != PyList_GET_SIZE(tmp)) {
15205
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15206
0
                    goto failed;
15207
0
                }
15208
0
                asdl_seq_SET(values, i, val);
15209
0
            }
15210
0
            Py_CLEAR(tmp);
15211
0
        }
15212
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15213
0
                                  end_col_offset, arena);
15214
0
        if (*out == NULL) goto failed;
15215
0
        return 0;
15216
0
    }
15217
0
    tp = state->Constant_type;
15218
0
    isinstance = PyObject_IsInstance(obj, tp);
15219
0
    if (isinstance == -1) {
15220
0
        return -1;
15221
0
    }
15222
0
    if (isinstance) {
15223
0
        constant value;
15224
0
        string kind;
15225
15226
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15227
0
            return -1;
15228
0
        }
15229
0
        if (tmp == NULL) {
15230
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15231
0
            return -1;
15232
0
        }
15233
0
        else {
15234
0
            int res;
15235
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15236
0
                goto failed;
15237
0
            }
15238
0
            res = obj2ast_constant(state, tmp, &value, arena);
15239
0
            _Py_LeaveRecursiveCall();
15240
0
            if (res != 0) goto failed;
15241
0
            Py_CLEAR(tmp);
15242
0
        }
15243
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15244
0
            return -1;
15245
0
        }
15246
0
        if (tmp == NULL || tmp == Py_None) {
15247
0
            Py_CLEAR(tmp);
15248
0
            kind = NULL;
15249
0
        }
15250
0
        else {
15251
0
            int res;
15252
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15253
0
                goto failed;
15254
0
            }
15255
0
            res = obj2ast_string(state, tmp, &kind, arena);
15256
0
            _Py_LeaveRecursiveCall();
15257
0
            if (res != 0) goto failed;
15258
0
            Py_CLEAR(tmp);
15259
0
        }
15260
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15261
0
                               end_col_offset, arena);
15262
0
        if (*out == NULL) goto failed;
15263
0
        return 0;
15264
0
    }
15265
0
    tp = state->Attribute_type;
15266
0
    isinstance = PyObject_IsInstance(obj, tp);
15267
0
    if (isinstance == -1) {
15268
0
        return -1;
15269
0
    }
15270
0
    if (isinstance) {
15271
0
        expr_ty value;
15272
0
        identifier attr;
15273
0
        expr_context_ty ctx;
15274
15275
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15276
0
            return -1;
15277
0
        }
15278
0
        if (tmp == NULL) {
15279
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15280
0
            return -1;
15281
0
        }
15282
0
        else {
15283
0
            int res;
15284
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15285
0
                goto failed;
15286
0
            }
15287
0
            res = obj2ast_expr(state, tmp, &value, arena);
15288
0
            _Py_LeaveRecursiveCall();
15289
0
            if (res != 0) goto failed;
15290
0
            Py_CLEAR(tmp);
15291
0
        }
15292
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15293
0
            return -1;
15294
0
        }
15295
0
        if (tmp == NULL) {
15296
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15297
0
            return -1;
15298
0
        }
15299
0
        else {
15300
0
            int res;
15301
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15302
0
                goto failed;
15303
0
            }
15304
0
            res = obj2ast_identifier(state, tmp, &attr, arena);
15305
0
            _Py_LeaveRecursiveCall();
15306
0
            if (res != 0) goto failed;
15307
0
            Py_CLEAR(tmp);
15308
0
        }
15309
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15310
0
            return -1;
15311
0
        }
15312
0
        if (tmp == NULL) {
15313
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15314
0
            return -1;
15315
0
        }
15316
0
        else {
15317
0
            int res;
15318
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15319
0
                goto failed;
15320
0
            }
15321
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15322
0
            _Py_LeaveRecursiveCall();
15323
0
            if (res != 0) goto failed;
15324
0
            Py_CLEAR(tmp);
15325
0
        }
15326
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15327
0
                                end_lineno, end_col_offset, arena);
15328
0
        if (*out == NULL) goto failed;
15329
0
        return 0;
15330
0
    }
15331
0
    tp = state->Subscript_type;
15332
0
    isinstance = PyObject_IsInstance(obj, tp);
15333
0
    if (isinstance == -1) {
15334
0
        return -1;
15335
0
    }
15336
0
    if (isinstance) {
15337
0
        expr_ty value;
15338
0
        expr_ty slice;
15339
0
        expr_context_ty ctx;
15340
15341
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15342
0
            return -1;
15343
0
        }
15344
0
        if (tmp == NULL) {
15345
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15346
0
            return -1;
15347
0
        }
15348
0
        else {
15349
0
            int res;
15350
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15351
0
                goto failed;
15352
0
            }
15353
0
            res = obj2ast_expr(state, tmp, &value, arena);
15354
0
            _Py_LeaveRecursiveCall();
15355
0
            if (res != 0) goto failed;
15356
0
            Py_CLEAR(tmp);
15357
0
        }
15358
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15359
0
            return -1;
15360
0
        }
15361
0
        if (tmp == NULL) {
15362
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15363
0
            return -1;
15364
0
        }
15365
0
        else {
15366
0
            int res;
15367
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15368
0
                goto failed;
15369
0
            }
15370
0
            res = obj2ast_expr(state, tmp, &slice, arena);
15371
0
            _Py_LeaveRecursiveCall();
15372
0
            if (res != 0) goto failed;
15373
0
            Py_CLEAR(tmp);
15374
0
        }
15375
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15376
0
            return -1;
15377
0
        }
15378
0
        if (tmp == NULL) {
15379
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15380
0
            return -1;
15381
0
        }
15382
0
        else {
15383
0
            int res;
15384
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15385
0
                goto failed;
15386
0
            }
15387
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15388
0
            _Py_LeaveRecursiveCall();
15389
0
            if (res != 0) goto failed;
15390
0
            Py_CLEAR(tmp);
15391
0
        }
15392
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15393
0
                                end_lineno, end_col_offset, arena);
15394
0
        if (*out == NULL) goto failed;
15395
0
        return 0;
15396
0
    }
15397
0
    tp = state->Starred_type;
15398
0
    isinstance = PyObject_IsInstance(obj, tp);
15399
0
    if (isinstance == -1) {
15400
0
        return -1;
15401
0
    }
15402
0
    if (isinstance) {
15403
0
        expr_ty value;
15404
0
        expr_context_ty ctx;
15405
15406
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15407
0
            return -1;
15408
0
        }
15409
0
        if (tmp == NULL) {
15410
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15411
0
            return -1;
15412
0
        }
15413
0
        else {
15414
0
            int res;
15415
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15416
0
                goto failed;
15417
0
            }
15418
0
            res = obj2ast_expr(state, tmp, &value, arena);
15419
0
            _Py_LeaveRecursiveCall();
15420
0
            if (res != 0) goto failed;
15421
0
            Py_CLEAR(tmp);
15422
0
        }
15423
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15424
0
            return -1;
15425
0
        }
15426
0
        if (tmp == NULL) {
15427
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15428
0
            return -1;
15429
0
        }
15430
0
        else {
15431
0
            int res;
15432
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15433
0
                goto failed;
15434
0
            }
15435
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15436
0
            _Py_LeaveRecursiveCall();
15437
0
            if (res != 0) goto failed;
15438
0
            Py_CLEAR(tmp);
15439
0
        }
15440
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15441
0
                              end_col_offset, arena);
15442
0
        if (*out == NULL) goto failed;
15443
0
        return 0;
15444
0
    }
15445
0
    tp = state->Name_type;
15446
0
    isinstance = PyObject_IsInstance(obj, tp);
15447
0
    if (isinstance == -1) {
15448
0
        return -1;
15449
0
    }
15450
0
    if (isinstance) {
15451
0
        identifier id;
15452
0
        expr_context_ty ctx;
15453
15454
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15455
0
            return -1;
15456
0
        }
15457
0
        if (tmp == NULL) {
15458
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15459
0
            return -1;
15460
0
        }
15461
0
        else {
15462
0
            int res;
15463
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15464
0
                goto failed;
15465
0
            }
15466
0
            res = obj2ast_identifier(state, tmp, &id, arena);
15467
0
            _Py_LeaveRecursiveCall();
15468
0
            if (res != 0) goto failed;
15469
0
            Py_CLEAR(tmp);
15470
0
        }
15471
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15472
0
            return -1;
15473
0
        }
15474
0
        if (tmp == NULL) {
15475
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15476
0
            return -1;
15477
0
        }
15478
0
        else {
15479
0
            int res;
15480
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15481
0
                goto failed;
15482
0
            }
15483
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15484
0
            _Py_LeaveRecursiveCall();
15485
0
            if (res != 0) goto failed;
15486
0
            Py_CLEAR(tmp);
15487
0
        }
15488
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15489
0
                           end_col_offset, arena);
15490
0
        if (*out == NULL) goto failed;
15491
0
        return 0;
15492
0
    }
15493
0
    tp = state->List_type;
15494
0
    isinstance = PyObject_IsInstance(obj, tp);
15495
0
    if (isinstance == -1) {
15496
0
        return -1;
15497
0
    }
15498
0
    if (isinstance) {
15499
0
        asdl_expr_seq* elts;
15500
0
        expr_context_ty ctx;
15501
15502
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15503
0
            return -1;
15504
0
        }
15505
0
        if (tmp == NULL) {
15506
0
            tmp = PyList_New(0);
15507
0
            if (tmp == NULL) {
15508
0
                return -1;
15509
0
            }
15510
0
        }
15511
0
        {
15512
0
            int res;
15513
0
            Py_ssize_t len;
15514
0
            Py_ssize_t i;
15515
0
            if (!PyList_Check(tmp)) {
15516
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15517
0
                goto failed;
15518
0
            }
15519
0
            len = PyList_GET_SIZE(tmp);
15520
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15521
0
            if (elts == NULL) goto failed;
15522
0
            for (i = 0; i < len; i++) {
15523
0
                expr_ty val;
15524
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15525
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15526
0
                    goto failed;
15527
0
                }
15528
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15529
0
                _Py_LeaveRecursiveCall();
15530
0
                Py_DECREF(tmp2);
15531
0
                if (res != 0) goto failed;
15532
0
                if (len != PyList_GET_SIZE(tmp)) {
15533
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15534
0
                    goto failed;
15535
0
                }
15536
0
                asdl_seq_SET(elts, i, val);
15537
0
            }
15538
0
            Py_CLEAR(tmp);
15539
0
        }
15540
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15541
0
            return -1;
15542
0
        }
15543
0
        if (tmp == NULL) {
15544
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15545
0
            return -1;
15546
0
        }
15547
0
        else {
15548
0
            int res;
15549
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15550
0
                goto failed;
15551
0
            }
15552
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15553
0
            _Py_LeaveRecursiveCall();
15554
0
            if (res != 0) goto failed;
15555
0
            Py_CLEAR(tmp);
15556
0
        }
15557
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15558
0
                           end_col_offset, arena);
15559
0
        if (*out == NULL) goto failed;
15560
0
        return 0;
15561
0
    }
15562
0
    tp = state->Tuple_type;
15563
0
    isinstance = PyObject_IsInstance(obj, tp);
15564
0
    if (isinstance == -1) {
15565
0
        return -1;
15566
0
    }
15567
0
    if (isinstance) {
15568
0
        asdl_expr_seq* elts;
15569
0
        expr_context_ty ctx;
15570
15571
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15572
0
            return -1;
15573
0
        }
15574
0
        if (tmp == NULL) {
15575
0
            tmp = PyList_New(0);
15576
0
            if (tmp == NULL) {
15577
0
                return -1;
15578
0
            }
15579
0
        }
15580
0
        {
15581
0
            int res;
15582
0
            Py_ssize_t len;
15583
0
            Py_ssize_t i;
15584
0
            if (!PyList_Check(tmp)) {
15585
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15586
0
                goto failed;
15587
0
            }
15588
0
            len = PyList_GET_SIZE(tmp);
15589
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15590
0
            if (elts == NULL) goto failed;
15591
0
            for (i = 0; i < len; i++) {
15592
0
                expr_ty val;
15593
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15594
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15595
0
                    goto failed;
15596
0
                }
15597
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15598
0
                _Py_LeaveRecursiveCall();
15599
0
                Py_DECREF(tmp2);
15600
0
                if (res != 0) goto failed;
15601
0
                if (len != PyList_GET_SIZE(tmp)) {
15602
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15603
0
                    goto failed;
15604
0
                }
15605
0
                asdl_seq_SET(elts, i, val);
15606
0
            }
15607
0
            Py_CLEAR(tmp);
15608
0
        }
15609
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15610
0
            return -1;
15611
0
        }
15612
0
        if (tmp == NULL) {
15613
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15614
0
            return -1;
15615
0
        }
15616
0
        else {
15617
0
            int res;
15618
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15619
0
                goto failed;
15620
0
            }
15621
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15622
0
            _Py_LeaveRecursiveCall();
15623
0
            if (res != 0) goto failed;
15624
0
            Py_CLEAR(tmp);
15625
0
        }
15626
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15627
0
                            end_col_offset, arena);
15628
0
        if (*out == NULL) goto failed;
15629
0
        return 0;
15630
0
    }
15631
0
    tp = state->Slice_type;
15632
0
    isinstance = PyObject_IsInstance(obj, tp);
15633
0
    if (isinstance == -1) {
15634
0
        return -1;
15635
0
    }
15636
0
    if (isinstance) {
15637
0
        expr_ty lower;
15638
0
        expr_ty upper;
15639
0
        expr_ty step;
15640
15641
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15642
0
            return -1;
15643
0
        }
15644
0
        if (tmp == NULL || tmp == Py_None) {
15645
0
            Py_CLEAR(tmp);
15646
0
            lower = NULL;
15647
0
        }
15648
0
        else {
15649
0
            int res;
15650
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15651
0
                goto failed;
15652
0
            }
15653
0
            res = obj2ast_expr(state, tmp, &lower, arena);
15654
0
            _Py_LeaveRecursiveCall();
15655
0
            if (res != 0) goto failed;
15656
0
            Py_CLEAR(tmp);
15657
0
        }
15658
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15659
0
            return -1;
15660
0
        }
15661
0
        if (tmp == NULL || tmp == Py_None) {
15662
0
            Py_CLEAR(tmp);
15663
0
            upper = NULL;
15664
0
        }
15665
0
        else {
15666
0
            int res;
15667
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15668
0
                goto failed;
15669
0
            }
15670
0
            res = obj2ast_expr(state, tmp, &upper, arena);
15671
0
            _Py_LeaveRecursiveCall();
15672
0
            if (res != 0) goto failed;
15673
0
            Py_CLEAR(tmp);
15674
0
        }
15675
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15676
0
            return -1;
15677
0
        }
15678
0
        if (tmp == NULL || tmp == Py_None) {
15679
0
            Py_CLEAR(tmp);
15680
0
            step = NULL;
15681
0
        }
15682
0
        else {
15683
0
            int res;
15684
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15685
0
                goto failed;
15686
0
            }
15687
0
            res = obj2ast_expr(state, tmp, &step, arena);
15688
0
            _Py_LeaveRecursiveCall();
15689
0
            if (res != 0) goto failed;
15690
0
            Py_CLEAR(tmp);
15691
0
        }
15692
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15693
0
                            end_col_offset, arena);
15694
0
        if (*out == NULL) goto failed;
15695
0
        return 0;
15696
0
    }
15697
15698
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15699
0
    failed:
15700
0
    Py_XDECREF(tmp);
15701
0
    return -1;
15702
0
}
15703
15704
int
15705
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15706
                     out, PyArena* arena)
15707
0
{
15708
0
    int isinstance;
15709
15710
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15711
0
    if (isinstance == -1) {
15712
0
        return -1;
15713
0
    }
15714
0
    if (isinstance) {
15715
0
        *out = Load;
15716
0
        return 0;
15717
0
    }
15718
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15719
0
    if (isinstance == -1) {
15720
0
        return -1;
15721
0
    }
15722
0
    if (isinstance) {
15723
0
        *out = Store;
15724
0
        return 0;
15725
0
    }
15726
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15727
0
    if (isinstance == -1) {
15728
0
        return -1;
15729
0
    }
15730
0
    if (isinstance) {
15731
0
        *out = Del;
15732
0
        return 0;
15733
0
    }
15734
15735
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15736
0
    return -1;
15737
0
}
15738
15739
int
15740
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
15741
               arena)
15742
0
{
15743
0
    int isinstance;
15744
15745
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15746
0
    if (isinstance == -1) {
15747
0
        return -1;
15748
0
    }
15749
0
    if (isinstance) {
15750
0
        *out = And;
15751
0
        return 0;
15752
0
    }
15753
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15754
0
    if (isinstance == -1) {
15755
0
        return -1;
15756
0
    }
15757
0
    if (isinstance) {
15758
0
        *out = Or;
15759
0
        return 0;
15760
0
    }
15761
15762
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15763
0
    return -1;
15764
0
}
15765
15766
int
15767
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15768
                 PyArena* arena)
15769
0
{
15770
0
    int isinstance;
15771
15772
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15773
0
    if (isinstance == -1) {
15774
0
        return -1;
15775
0
    }
15776
0
    if (isinstance) {
15777
0
        *out = Add;
15778
0
        return 0;
15779
0
    }
15780
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15781
0
    if (isinstance == -1) {
15782
0
        return -1;
15783
0
    }
15784
0
    if (isinstance) {
15785
0
        *out = Sub;
15786
0
        return 0;
15787
0
    }
15788
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15789
0
    if (isinstance == -1) {
15790
0
        return -1;
15791
0
    }
15792
0
    if (isinstance) {
15793
0
        *out = Mult;
15794
0
        return 0;
15795
0
    }
15796
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15797
0
    if (isinstance == -1) {
15798
0
        return -1;
15799
0
    }
15800
0
    if (isinstance) {
15801
0
        *out = MatMult;
15802
0
        return 0;
15803
0
    }
15804
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15805
0
    if (isinstance == -1) {
15806
0
        return -1;
15807
0
    }
15808
0
    if (isinstance) {
15809
0
        *out = Div;
15810
0
        return 0;
15811
0
    }
15812
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15813
0
    if (isinstance == -1) {
15814
0
        return -1;
15815
0
    }
15816
0
    if (isinstance) {
15817
0
        *out = Mod;
15818
0
        return 0;
15819
0
    }
15820
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15821
0
    if (isinstance == -1) {
15822
0
        return -1;
15823
0
    }
15824
0
    if (isinstance) {
15825
0
        *out = Pow;
15826
0
        return 0;
15827
0
    }
15828
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15829
0
    if (isinstance == -1) {
15830
0
        return -1;
15831
0
    }
15832
0
    if (isinstance) {
15833
0
        *out = LShift;
15834
0
        return 0;
15835
0
    }
15836
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15837
0
    if (isinstance == -1) {
15838
0
        return -1;
15839
0
    }
15840
0
    if (isinstance) {
15841
0
        *out = RShift;
15842
0
        return 0;
15843
0
    }
15844
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15845
0
    if (isinstance == -1) {
15846
0
        return -1;
15847
0
    }
15848
0
    if (isinstance) {
15849
0
        *out = BitOr;
15850
0
        return 0;
15851
0
    }
15852
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15853
0
    if (isinstance == -1) {
15854
0
        return -1;
15855
0
    }
15856
0
    if (isinstance) {
15857
0
        *out = BitXor;
15858
0
        return 0;
15859
0
    }
15860
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15861
0
    if (isinstance == -1) {
15862
0
        return -1;
15863
0
    }
15864
0
    if (isinstance) {
15865
0
        *out = BitAnd;
15866
0
        return 0;
15867
0
    }
15868
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15869
0
    if (isinstance == -1) {
15870
0
        return -1;
15871
0
    }
15872
0
    if (isinstance) {
15873
0
        *out = FloorDiv;
15874
0
        return 0;
15875
0
    }
15876
15877
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15878
0
    return -1;
15879
0
}
15880
15881
int
15882
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
15883
                PyArena* arena)
15884
0
{
15885
0
    int isinstance;
15886
15887
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15888
0
    if (isinstance == -1) {
15889
0
        return -1;
15890
0
    }
15891
0
    if (isinstance) {
15892
0
        *out = Invert;
15893
0
        return 0;
15894
0
    }
15895
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15896
0
    if (isinstance == -1) {
15897
0
        return -1;
15898
0
    }
15899
0
    if (isinstance) {
15900
0
        *out = Not;
15901
0
        return 0;
15902
0
    }
15903
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15904
0
    if (isinstance == -1) {
15905
0
        return -1;
15906
0
    }
15907
0
    if (isinstance) {
15908
0
        *out = UAdd;
15909
0
        return 0;
15910
0
    }
15911
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15912
0
    if (isinstance == -1) {
15913
0
        return -1;
15914
0
    }
15915
0
    if (isinstance) {
15916
0
        *out = USub;
15917
0
        return 0;
15918
0
    }
15919
15920
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
15921
0
    return -1;
15922
0
}
15923
15924
int
15925
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
15926
              arena)
15927
0
{
15928
0
    int isinstance;
15929
15930
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
15931
0
    if (isinstance == -1) {
15932
0
        return -1;
15933
0
    }
15934
0
    if (isinstance) {
15935
0
        *out = Eq;
15936
0
        return 0;
15937
0
    }
15938
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
15939
0
    if (isinstance == -1) {
15940
0
        return -1;
15941
0
    }
15942
0
    if (isinstance) {
15943
0
        *out = NotEq;
15944
0
        return 0;
15945
0
    }
15946
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
15947
0
    if (isinstance == -1) {
15948
0
        return -1;
15949
0
    }
15950
0
    if (isinstance) {
15951
0
        *out = Lt;
15952
0
        return 0;
15953
0
    }
15954
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
15955
0
    if (isinstance == -1) {
15956
0
        return -1;
15957
0
    }
15958
0
    if (isinstance) {
15959
0
        *out = LtE;
15960
0
        return 0;
15961
0
    }
15962
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
15963
0
    if (isinstance == -1) {
15964
0
        return -1;
15965
0
    }
15966
0
    if (isinstance) {
15967
0
        *out = Gt;
15968
0
        return 0;
15969
0
    }
15970
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
15971
0
    if (isinstance == -1) {
15972
0
        return -1;
15973
0
    }
15974
0
    if (isinstance) {
15975
0
        *out = GtE;
15976
0
        return 0;
15977
0
    }
15978
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
15979
0
    if (isinstance == -1) {
15980
0
        return -1;
15981
0
    }
15982
0
    if (isinstance) {
15983
0
        *out = Is;
15984
0
        return 0;
15985
0
    }
15986
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
15987
0
    if (isinstance == -1) {
15988
0
        return -1;
15989
0
    }
15990
0
    if (isinstance) {
15991
0
        *out = IsNot;
15992
0
        return 0;
15993
0
    }
15994
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
15995
0
    if (isinstance == -1) {
15996
0
        return -1;
15997
0
    }
15998
0
    if (isinstance) {
15999
0
        *out = In;
16000
0
        return 0;
16001
0
    }
16002
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16003
0
    if (isinstance == -1) {
16004
0
        return -1;
16005
0
    }
16006
0
    if (isinstance) {
16007
0
        *out = NotIn;
16008
0
        return 0;
16009
0
    }
16010
16011
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16012
0
    return -1;
16013
0
}
16014
16015
int
16016
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16017
                      out, PyArena* arena)
16018
0
{
16019
0
    PyObject* tmp = NULL;
16020
0
    expr_ty target;
16021
0
    expr_ty iter;
16022
0
    asdl_expr_seq* ifs;
16023
0
    int is_async;
16024
16025
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16026
0
        return -1;
16027
0
    }
16028
0
    if (tmp == NULL) {
16029
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16030
0
        return -1;
16031
0
    }
16032
0
    else {
16033
0
        int res;
16034
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16035
0
            goto failed;
16036
0
        }
16037
0
        res = obj2ast_expr(state, tmp, &target, arena);
16038
0
        _Py_LeaveRecursiveCall();
16039
0
        if (res != 0) goto failed;
16040
0
        Py_CLEAR(tmp);
16041
0
    }
16042
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16043
0
        return -1;
16044
0
    }
16045
0
    if (tmp == NULL) {
16046
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16047
0
        return -1;
16048
0
    }
16049
0
    else {
16050
0
        int res;
16051
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16052
0
            goto failed;
16053
0
        }
16054
0
        res = obj2ast_expr(state, tmp, &iter, arena);
16055
0
        _Py_LeaveRecursiveCall();
16056
0
        if (res != 0) goto failed;
16057
0
        Py_CLEAR(tmp);
16058
0
    }
16059
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16060
0
        return -1;
16061
0
    }
16062
0
    if (tmp == NULL) {
16063
0
        tmp = PyList_New(0);
16064
0
        if (tmp == NULL) {
16065
0
            return -1;
16066
0
        }
16067
0
    }
16068
0
    {
16069
0
        int res;
16070
0
        Py_ssize_t len;
16071
0
        Py_ssize_t i;
16072
0
        if (!PyList_Check(tmp)) {
16073
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16074
0
            goto failed;
16075
0
        }
16076
0
        len = PyList_GET_SIZE(tmp);
16077
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16078
0
        if (ifs == NULL) goto failed;
16079
0
        for (i = 0; i < len; i++) {
16080
0
            expr_ty val;
16081
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16082
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16083
0
                goto failed;
16084
0
            }
16085
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16086
0
            _Py_LeaveRecursiveCall();
16087
0
            Py_DECREF(tmp2);
16088
0
            if (res != 0) goto failed;
16089
0
            if (len != PyList_GET_SIZE(tmp)) {
16090
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16091
0
                goto failed;
16092
0
            }
16093
0
            asdl_seq_SET(ifs, i, val);
16094
0
        }
16095
0
        Py_CLEAR(tmp);
16096
0
    }
16097
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16098
0
        return -1;
16099
0
    }
16100
0
    if (tmp == NULL) {
16101
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16102
0
        return -1;
16103
0
    }
16104
0
    else {
16105
0
        int res;
16106
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16107
0
            goto failed;
16108
0
        }
16109
0
        res = obj2ast_int(state, tmp, &is_async, arena);
16110
0
        _Py_LeaveRecursiveCall();
16111
0
        if (res != 0) goto failed;
16112
0
        Py_CLEAR(tmp);
16113
0
    }
16114
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16115
0
    if (*out == NULL) goto failed;
16116
0
    return 0;
16117
0
failed:
16118
0
    Py_XDECREF(tmp);
16119
0
    return -1;
16120
0
}
16121
16122
int
16123
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16124
                      out, PyArena* arena)
16125
0
{
16126
0
    int isinstance;
16127
16128
0
    PyObject *tmp = NULL;
16129
0
    PyObject *tp;
16130
0
    int lineno;
16131
0
    int col_offset;
16132
0
    int end_lineno;
16133
0
    int end_col_offset;
16134
16135
0
    if (obj == Py_None) {
16136
0
        *out = NULL;
16137
0
        return 0;
16138
0
    }
16139
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16140
0
        return -1;
16141
0
    }
16142
0
    if (tmp == NULL) {
16143
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16144
0
        return -1;
16145
0
    }
16146
0
    else {
16147
0
        int res;
16148
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16149
0
            goto failed;
16150
0
        }
16151
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16152
0
        _Py_LeaveRecursiveCall();
16153
0
        if (res != 0) goto failed;
16154
0
        Py_CLEAR(tmp);
16155
0
    }
16156
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16157
0
        return -1;
16158
0
    }
16159
0
    if (tmp == NULL) {
16160
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16161
0
        return -1;
16162
0
    }
16163
0
    else {
16164
0
        int res;
16165
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16166
0
            goto failed;
16167
0
        }
16168
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16169
0
        _Py_LeaveRecursiveCall();
16170
0
        if (res != 0) goto failed;
16171
0
        Py_CLEAR(tmp);
16172
0
    }
16173
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16174
0
        return -1;
16175
0
    }
16176
0
    if (tmp == NULL || tmp == Py_None) {
16177
0
        Py_CLEAR(tmp);
16178
0
        end_lineno = lineno;
16179
0
    }
16180
0
    else {
16181
0
        int res;
16182
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16183
0
            goto failed;
16184
0
        }
16185
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16186
0
        _Py_LeaveRecursiveCall();
16187
0
        if (res != 0) goto failed;
16188
0
        Py_CLEAR(tmp);
16189
0
    }
16190
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16191
0
        return -1;
16192
0
    }
16193
0
    if (tmp == NULL || tmp == Py_None) {
16194
0
        Py_CLEAR(tmp);
16195
0
        end_col_offset = col_offset;
16196
0
    }
16197
0
    else {
16198
0
        int res;
16199
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16200
0
            goto failed;
16201
0
        }
16202
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16203
0
        _Py_LeaveRecursiveCall();
16204
0
        if (res != 0) goto failed;
16205
0
        Py_CLEAR(tmp);
16206
0
    }
16207
0
    tp = state->ExceptHandler_type;
16208
0
    isinstance = PyObject_IsInstance(obj, tp);
16209
0
    if (isinstance == -1) {
16210
0
        return -1;
16211
0
    }
16212
0
    if (isinstance) {
16213
0
        expr_ty type;
16214
0
        identifier name;
16215
0
        asdl_stmt_seq* body;
16216
16217
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16218
0
            return -1;
16219
0
        }
16220
0
        if (tmp == NULL || tmp == Py_None) {
16221
0
            Py_CLEAR(tmp);
16222
0
            type = NULL;
16223
0
        }
16224
0
        else {
16225
0
            int res;
16226
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16227
0
                goto failed;
16228
0
            }
16229
0
            res = obj2ast_expr(state, tmp, &type, arena);
16230
0
            _Py_LeaveRecursiveCall();
16231
0
            if (res != 0) goto failed;
16232
0
            Py_CLEAR(tmp);
16233
0
        }
16234
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16235
0
            return -1;
16236
0
        }
16237
0
        if (tmp == NULL || tmp == Py_None) {
16238
0
            Py_CLEAR(tmp);
16239
0
            name = NULL;
16240
0
        }
16241
0
        else {
16242
0
            int res;
16243
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16244
0
                goto failed;
16245
0
            }
16246
0
            res = obj2ast_identifier(state, tmp, &name, arena);
16247
0
            _Py_LeaveRecursiveCall();
16248
0
            if (res != 0) goto failed;
16249
0
            Py_CLEAR(tmp);
16250
0
        }
16251
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16252
0
            return -1;
16253
0
        }
16254
0
        if (tmp == NULL) {
16255
0
            tmp = PyList_New(0);
16256
0
            if (tmp == NULL) {
16257
0
                return -1;
16258
0
            }
16259
0
        }
16260
0
        {
16261
0
            int res;
16262
0
            Py_ssize_t len;
16263
0
            Py_ssize_t i;
16264
0
            if (!PyList_Check(tmp)) {
16265
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16266
0
                goto failed;
16267
0
            }
16268
0
            len = PyList_GET_SIZE(tmp);
16269
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16270
0
            if (body == NULL) goto failed;
16271
0
            for (i = 0; i < len; i++) {
16272
0
                stmt_ty val;
16273
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16274
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16275
0
                    goto failed;
16276
0
                }
16277
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
16278
0
                _Py_LeaveRecursiveCall();
16279
0
                Py_DECREF(tmp2);
16280
0
                if (res != 0) goto failed;
16281
0
                if (len != PyList_GET_SIZE(tmp)) {
16282
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16283
0
                    goto failed;
16284
0
                }
16285
0
                asdl_seq_SET(body, i, val);
16286
0
            }
16287
0
            Py_CLEAR(tmp);
16288
0
        }
16289
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16290
0
                                    end_lineno, end_col_offset, arena);
16291
0
        if (*out == NULL) goto failed;
16292
0
        return 0;
16293
0
    }
16294
16295
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16296
0
    failed:
16297
0
    Py_XDECREF(tmp);
16298
0
    return -1;
16299
0
}
16300
16301
int
16302
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16303
                  PyArena* arena)
16304
0
{
16305
0
    PyObject* tmp = NULL;
16306
0
    asdl_arg_seq* posonlyargs;
16307
0
    asdl_arg_seq* args;
16308
0
    arg_ty vararg;
16309
0
    asdl_arg_seq* kwonlyargs;
16310
0
    asdl_expr_seq* kw_defaults;
16311
0
    arg_ty kwarg;
16312
0
    asdl_expr_seq* defaults;
16313
16314
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16315
0
        return -1;
16316
0
    }
16317
0
    if (tmp == NULL) {
16318
0
        tmp = PyList_New(0);
16319
0
        if (tmp == NULL) {
16320
0
            return -1;
16321
0
        }
16322
0
    }
16323
0
    {
16324
0
        int res;
16325
0
        Py_ssize_t len;
16326
0
        Py_ssize_t i;
16327
0
        if (!PyList_Check(tmp)) {
16328
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16329
0
            goto failed;
16330
0
        }
16331
0
        len = PyList_GET_SIZE(tmp);
16332
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16333
0
        if (posonlyargs == NULL) goto failed;
16334
0
        for (i = 0; i < len; i++) {
16335
0
            arg_ty val;
16336
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16337
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16338
0
                goto failed;
16339
0
            }
16340
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16341
0
            _Py_LeaveRecursiveCall();
16342
0
            Py_DECREF(tmp2);
16343
0
            if (res != 0) goto failed;
16344
0
            if (len != PyList_GET_SIZE(tmp)) {
16345
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16346
0
                goto failed;
16347
0
            }
16348
0
            asdl_seq_SET(posonlyargs, i, val);
16349
0
        }
16350
0
        Py_CLEAR(tmp);
16351
0
    }
16352
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16353
0
        return -1;
16354
0
    }
16355
0
    if (tmp == NULL) {
16356
0
        tmp = PyList_New(0);
16357
0
        if (tmp == NULL) {
16358
0
            return -1;
16359
0
        }
16360
0
    }
16361
0
    {
16362
0
        int res;
16363
0
        Py_ssize_t len;
16364
0
        Py_ssize_t i;
16365
0
        if (!PyList_Check(tmp)) {
16366
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16367
0
            goto failed;
16368
0
        }
16369
0
        len = PyList_GET_SIZE(tmp);
16370
0
        args = _Py_asdl_arg_seq_new(len, arena);
16371
0
        if (args == NULL) goto failed;
16372
0
        for (i = 0; i < len; i++) {
16373
0
            arg_ty val;
16374
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16375
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16376
0
                goto failed;
16377
0
            }
16378
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16379
0
            _Py_LeaveRecursiveCall();
16380
0
            Py_DECREF(tmp2);
16381
0
            if (res != 0) goto failed;
16382
0
            if (len != PyList_GET_SIZE(tmp)) {
16383
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16384
0
                goto failed;
16385
0
            }
16386
0
            asdl_seq_SET(args, i, val);
16387
0
        }
16388
0
        Py_CLEAR(tmp);
16389
0
    }
16390
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16391
0
        return -1;
16392
0
    }
16393
0
    if (tmp == NULL || tmp == Py_None) {
16394
0
        Py_CLEAR(tmp);
16395
0
        vararg = NULL;
16396
0
    }
16397
0
    else {
16398
0
        int res;
16399
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16400
0
            goto failed;
16401
0
        }
16402
0
        res = obj2ast_arg(state, tmp, &vararg, arena);
16403
0
        _Py_LeaveRecursiveCall();
16404
0
        if (res != 0) goto failed;
16405
0
        Py_CLEAR(tmp);
16406
0
    }
16407
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16408
0
        return -1;
16409
0
    }
16410
0
    if (tmp == NULL) {
16411
0
        tmp = PyList_New(0);
16412
0
        if (tmp == NULL) {
16413
0
            return -1;
16414
0
        }
16415
0
    }
16416
0
    {
16417
0
        int res;
16418
0
        Py_ssize_t len;
16419
0
        Py_ssize_t i;
16420
0
        if (!PyList_Check(tmp)) {
16421
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16422
0
            goto failed;
16423
0
        }
16424
0
        len = PyList_GET_SIZE(tmp);
16425
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16426
0
        if (kwonlyargs == NULL) goto failed;
16427
0
        for (i = 0; i < len; i++) {
16428
0
            arg_ty val;
16429
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16430
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16431
0
                goto failed;
16432
0
            }
16433
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16434
0
            _Py_LeaveRecursiveCall();
16435
0
            Py_DECREF(tmp2);
16436
0
            if (res != 0) goto failed;
16437
0
            if (len != PyList_GET_SIZE(tmp)) {
16438
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16439
0
                goto failed;
16440
0
            }
16441
0
            asdl_seq_SET(kwonlyargs, i, val);
16442
0
        }
16443
0
        Py_CLEAR(tmp);
16444
0
    }
16445
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16446
0
        return -1;
16447
0
    }
16448
0
    if (tmp == NULL) {
16449
0
        tmp = PyList_New(0);
16450
0
        if (tmp == NULL) {
16451
0
            return -1;
16452
0
        }
16453
0
    }
16454
0
    {
16455
0
        int res;
16456
0
        Py_ssize_t len;
16457
0
        Py_ssize_t i;
16458
0
        if (!PyList_Check(tmp)) {
16459
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16460
0
            goto failed;
16461
0
        }
16462
0
        len = PyList_GET_SIZE(tmp);
16463
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16464
0
        if (kw_defaults == NULL) goto failed;
16465
0
        for (i = 0; i < len; i++) {
16466
0
            expr_ty val;
16467
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16468
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16469
0
                goto failed;
16470
0
            }
16471
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16472
0
            _Py_LeaveRecursiveCall();
16473
0
            Py_DECREF(tmp2);
16474
0
            if (res != 0) goto failed;
16475
0
            if (len != PyList_GET_SIZE(tmp)) {
16476
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16477
0
                goto failed;
16478
0
            }
16479
0
            asdl_seq_SET(kw_defaults, i, val);
16480
0
        }
16481
0
        Py_CLEAR(tmp);
16482
0
    }
16483
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16484
0
        return -1;
16485
0
    }
16486
0
    if (tmp == NULL || tmp == Py_None) {
16487
0
        Py_CLEAR(tmp);
16488
0
        kwarg = NULL;
16489
0
    }
16490
0
    else {
16491
0
        int res;
16492
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16493
0
            goto failed;
16494
0
        }
16495
0
        res = obj2ast_arg(state, tmp, &kwarg, arena);
16496
0
        _Py_LeaveRecursiveCall();
16497
0
        if (res != 0) goto failed;
16498
0
        Py_CLEAR(tmp);
16499
0
    }
16500
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16501
0
        return -1;
16502
0
    }
16503
0
    if (tmp == NULL) {
16504
0
        tmp = PyList_New(0);
16505
0
        if (tmp == NULL) {
16506
0
            return -1;
16507
0
        }
16508
0
    }
16509
0
    {
16510
0
        int res;
16511
0
        Py_ssize_t len;
16512
0
        Py_ssize_t i;
16513
0
        if (!PyList_Check(tmp)) {
16514
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16515
0
            goto failed;
16516
0
        }
16517
0
        len = PyList_GET_SIZE(tmp);
16518
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16519
0
        if (defaults == NULL) goto failed;
16520
0
        for (i = 0; i < len; i++) {
16521
0
            expr_ty val;
16522
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16523
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16524
0
                goto failed;
16525
0
            }
16526
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16527
0
            _Py_LeaveRecursiveCall();
16528
0
            Py_DECREF(tmp2);
16529
0
            if (res != 0) goto failed;
16530
0
            if (len != PyList_GET_SIZE(tmp)) {
16531
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16532
0
                goto failed;
16533
0
            }
16534
0
            asdl_seq_SET(defaults, i, val);
16535
0
        }
16536
0
        Py_CLEAR(tmp);
16537
0
    }
16538
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16539
0
                            kwarg, defaults, arena);
16540
0
    if (*out == NULL) goto failed;
16541
0
    return 0;
16542
0
failed:
16543
0
    Py_XDECREF(tmp);
16544
0
    return -1;
16545
0
}
16546
16547
int
16548
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
16549
0
{
16550
0
    PyObject* tmp = NULL;
16551
0
    identifier arg;
16552
0
    expr_ty annotation;
16553
0
    string type_comment;
16554
0
    int lineno;
16555
0
    int col_offset;
16556
0
    int end_lineno;
16557
0
    int end_col_offset;
16558
16559
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16560
0
        return -1;
16561
0
    }
16562
0
    if (tmp == NULL) {
16563
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16564
0
        return -1;
16565
0
    }
16566
0
    else {
16567
0
        int res;
16568
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16569
0
            goto failed;
16570
0
        }
16571
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16572
0
        _Py_LeaveRecursiveCall();
16573
0
        if (res != 0) goto failed;
16574
0
        Py_CLEAR(tmp);
16575
0
    }
16576
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16577
0
        return -1;
16578
0
    }
16579
0
    if (tmp == NULL || tmp == Py_None) {
16580
0
        Py_CLEAR(tmp);
16581
0
        annotation = NULL;
16582
0
    }
16583
0
    else {
16584
0
        int res;
16585
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16586
0
            goto failed;
16587
0
        }
16588
0
        res = obj2ast_expr(state, tmp, &annotation, arena);
16589
0
        _Py_LeaveRecursiveCall();
16590
0
        if (res != 0) goto failed;
16591
0
        Py_CLEAR(tmp);
16592
0
    }
16593
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16594
0
        return -1;
16595
0
    }
16596
0
    if (tmp == NULL || tmp == Py_None) {
16597
0
        Py_CLEAR(tmp);
16598
0
        type_comment = NULL;
16599
0
    }
16600
0
    else {
16601
0
        int res;
16602
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16603
0
            goto failed;
16604
0
        }
16605
0
        res = obj2ast_string(state, tmp, &type_comment, arena);
16606
0
        _Py_LeaveRecursiveCall();
16607
0
        if (res != 0) goto failed;
16608
0
        Py_CLEAR(tmp);
16609
0
    }
16610
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16611
0
        return -1;
16612
0
    }
16613
0
    if (tmp == NULL) {
16614
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16615
0
        return -1;
16616
0
    }
16617
0
    else {
16618
0
        int res;
16619
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16620
0
            goto failed;
16621
0
        }
16622
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16623
0
        _Py_LeaveRecursiveCall();
16624
0
        if (res != 0) goto failed;
16625
0
        Py_CLEAR(tmp);
16626
0
    }
16627
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16628
0
        return -1;
16629
0
    }
16630
0
    if (tmp == NULL) {
16631
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16632
0
        return -1;
16633
0
    }
16634
0
    else {
16635
0
        int res;
16636
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16637
0
            goto failed;
16638
0
        }
16639
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16640
0
        _Py_LeaveRecursiveCall();
16641
0
        if (res != 0) goto failed;
16642
0
        Py_CLEAR(tmp);
16643
0
    }
16644
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16645
0
        return -1;
16646
0
    }
16647
0
    if (tmp == NULL || tmp == Py_None) {
16648
0
        Py_CLEAR(tmp);
16649
0
        end_lineno = lineno;
16650
0
    }
16651
0
    else {
16652
0
        int res;
16653
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16654
0
            goto failed;
16655
0
        }
16656
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16657
0
        _Py_LeaveRecursiveCall();
16658
0
        if (res != 0) goto failed;
16659
0
        Py_CLEAR(tmp);
16660
0
    }
16661
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16662
0
        return -1;
16663
0
    }
16664
0
    if (tmp == NULL || tmp == Py_None) {
16665
0
        Py_CLEAR(tmp);
16666
0
        end_col_offset = col_offset;
16667
0
    }
16668
0
    else {
16669
0
        int res;
16670
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16671
0
            goto failed;
16672
0
        }
16673
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16674
0
        _Py_LeaveRecursiveCall();
16675
0
        if (res != 0) goto failed;
16676
0
        Py_CLEAR(tmp);
16677
0
    }
16678
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16679
0
                      end_lineno, end_col_offset, arena);
16680
0
    if (*out == NULL) goto failed;
16681
0
    return 0;
16682
0
failed:
16683
0
    Py_XDECREF(tmp);
16684
0
    return -1;
16685
0
}
16686
16687
int
16688
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
16689
                PyArena* arena)
16690
0
{
16691
0
    PyObject* tmp = NULL;
16692
0
    identifier arg;
16693
0
    expr_ty value;
16694
0
    int lineno;
16695
0
    int col_offset;
16696
0
    int end_lineno;
16697
0
    int end_col_offset;
16698
16699
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16700
0
        return -1;
16701
0
    }
16702
0
    if (tmp == NULL || tmp == Py_None) {
16703
0
        Py_CLEAR(tmp);
16704
0
        arg = NULL;
16705
0
    }
16706
0
    else {
16707
0
        int res;
16708
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16709
0
            goto failed;
16710
0
        }
16711
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16712
0
        _Py_LeaveRecursiveCall();
16713
0
        if (res != 0) goto failed;
16714
0
        Py_CLEAR(tmp);
16715
0
    }
16716
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16717
0
        return -1;
16718
0
    }
16719
0
    if (tmp == NULL) {
16720
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16721
0
        return -1;
16722
0
    }
16723
0
    else {
16724
0
        int res;
16725
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16726
0
            goto failed;
16727
0
        }
16728
0
        res = obj2ast_expr(state, tmp, &value, arena);
16729
0
        _Py_LeaveRecursiveCall();
16730
0
        if (res != 0) goto failed;
16731
0
        Py_CLEAR(tmp);
16732
0
    }
16733
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16734
0
        return -1;
16735
0
    }
16736
0
    if (tmp == NULL) {
16737
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16738
0
        return -1;
16739
0
    }
16740
0
    else {
16741
0
        int res;
16742
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16743
0
            goto failed;
16744
0
        }
16745
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16746
0
        _Py_LeaveRecursiveCall();
16747
0
        if (res != 0) goto failed;
16748
0
        Py_CLEAR(tmp);
16749
0
    }
16750
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16751
0
        return -1;
16752
0
    }
16753
0
    if (tmp == NULL) {
16754
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16755
0
        return -1;
16756
0
    }
16757
0
    else {
16758
0
        int res;
16759
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16760
0
            goto failed;
16761
0
        }
16762
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16763
0
        _Py_LeaveRecursiveCall();
16764
0
        if (res != 0) goto failed;
16765
0
        Py_CLEAR(tmp);
16766
0
    }
16767
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16768
0
        return -1;
16769
0
    }
16770
0
    if (tmp == NULL || tmp == Py_None) {
16771
0
        Py_CLEAR(tmp);
16772
0
        end_lineno = lineno;
16773
0
    }
16774
0
    else {
16775
0
        int res;
16776
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16777
0
            goto failed;
16778
0
        }
16779
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16780
0
        _Py_LeaveRecursiveCall();
16781
0
        if (res != 0) goto failed;
16782
0
        Py_CLEAR(tmp);
16783
0
    }
16784
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16785
0
        return -1;
16786
0
    }
16787
0
    if (tmp == NULL || tmp == Py_None) {
16788
0
        Py_CLEAR(tmp);
16789
0
        end_col_offset = col_offset;
16790
0
    }
16791
0
    else {
16792
0
        int res;
16793
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16794
0
            goto failed;
16795
0
        }
16796
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16797
0
        _Py_LeaveRecursiveCall();
16798
0
        if (res != 0) goto failed;
16799
0
        Py_CLEAR(tmp);
16800
0
    }
16801
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16802
0
                          end_col_offset, arena);
16803
0
    if (*out == NULL) goto failed;
16804
0
    return 0;
16805
0
failed:
16806
0
    Py_XDECREF(tmp);
16807
0
    return -1;
16808
0
}
16809
16810
int
16811
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
16812
              arena)
16813
0
{
16814
0
    PyObject* tmp = NULL;
16815
0
    identifier name;
16816
0
    identifier asname;
16817
0
    int lineno;
16818
0
    int col_offset;
16819
0
    int end_lineno;
16820
0
    int end_col_offset;
16821
16822
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16823
0
        return -1;
16824
0
    }
16825
0
    if (tmp == NULL) {
16826
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16827
0
        return -1;
16828
0
    }
16829
0
    else {
16830
0
        int res;
16831
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16832
0
            goto failed;
16833
0
        }
16834
0
        res = obj2ast_identifier(state, tmp, &name, arena);
16835
0
        _Py_LeaveRecursiveCall();
16836
0
        if (res != 0) goto failed;
16837
0
        Py_CLEAR(tmp);
16838
0
    }
16839
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16840
0
        return -1;
16841
0
    }
16842
0
    if (tmp == NULL || tmp == Py_None) {
16843
0
        Py_CLEAR(tmp);
16844
0
        asname = NULL;
16845
0
    }
16846
0
    else {
16847
0
        int res;
16848
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16849
0
            goto failed;
16850
0
        }
16851
0
        res = obj2ast_identifier(state, tmp, &asname, arena);
16852
0
        _Py_LeaveRecursiveCall();
16853
0
        if (res != 0) goto failed;
16854
0
        Py_CLEAR(tmp);
16855
0
    }
16856
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16857
0
        return -1;
16858
0
    }
16859
0
    if (tmp == NULL) {
16860
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16861
0
        return -1;
16862
0
    }
16863
0
    else {
16864
0
        int res;
16865
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16866
0
            goto failed;
16867
0
        }
16868
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16869
0
        _Py_LeaveRecursiveCall();
16870
0
        if (res != 0) goto failed;
16871
0
        Py_CLEAR(tmp);
16872
0
    }
16873
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16874
0
        return -1;
16875
0
    }
16876
0
    if (tmp == NULL) {
16877
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16878
0
        return -1;
16879
0
    }
16880
0
    else {
16881
0
        int res;
16882
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16883
0
            goto failed;
16884
0
        }
16885
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16886
0
        _Py_LeaveRecursiveCall();
16887
0
        if (res != 0) goto failed;
16888
0
        Py_CLEAR(tmp);
16889
0
    }
16890
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16891
0
        return -1;
16892
0
    }
16893
0
    if (tmp == NULL || tmp == Py_None) {
16894
0
        Py_CLEAR(tmp);
16895
0
        end_lineno = lineno;
16896
0
    }
16897
0
    else {
16898
0
        int res;
16899
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16900
0
            goto failed;
16901
0
        }
16902
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16903
0
        _Py_LeaveRecursiveCall();
16904
0
        if (res != 0) goto failed;
16905
0
        Py_CLEAR(tmp);
16906
0
    }
16907
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16908
0
        return -1;
16909
0
    }
16910
0
    if (tmp == NULL || tmp == Py_None) {
16911
0
        Py_CLEAR(tmp);
16912
0
        end_col_offset = col_offset;
16913
0
    }
16914
0
    else {
16915
0
        int res;
16916
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16917
0
            goto failed;
16918
0
        }
16919
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16920
0
        _Py_LeaveRecursiveCall();
16921
0
        if (res != 0) goto failed;
16922
0
        Py_CLEAR(tmp);
16923
0
    }
16924
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
16925
0
                        end_col_offset, arena);
16926
0
    if (*out == NULL) goto failed;
16927
0
    return 0;
16928
0
failed:
16929
0
    Py_XDECREF(tmp);
16930
0
    return -1;
16931
0
}
16932
16933
int
16934
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
16935
                 PyArena* arena)
16936
0
{
16937
0
    PyObject* tmp = NULL;
16938
0
    expr_ty context_expr;
16939
0
    expr_ty optional_vars;
16940
16941
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
16942
0
        return -1;
16943
0
    }
16944
0
    if (tmp == NULL) {
16945
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
16946
0
        return -1;
16947
0
    }
16948
0
    else {
16949
0
        int res;
16950
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16951
0
            goto failed;
16952
0
        }
16953
0
        res = obj2ast_expr(state, tmp, &context_expr, arena);
16954
0
        _Py_LeaveRecursiveCall();
16955
0
        if (res != 0) goto failed;
16956
0
        Py_CLEAR(tmp);
16957
0
    }
16958
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
16959
0
        return -1;
16960
0
    }
16961
0
    if (tmp == NULL || tmp == Py_None) {
16962
0
        Py_CLEAR(tmp);
16963
0
        optional_vars = NULL;
16964
0
    }
16965
0
    else {
16966
0
        int res;
16967
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
16968
0
            goto failed;
16969
0
        }
16970
0
        res = obj2ast_expr(state, tmp, &optional_vars, arena);
16971
0
        _Py_LeaveRecursiveCall();
16972
0
        if (res != 0) goto failed;
16973
0
        Py_CLEAR(tmp);
16974
0
    }
16975
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
16976
0
    if (*out == NULL) goto failed;
16977
0
    return 0;
16978
0
failed:
16979
0
    Py_XDECREF(tmp);
16980
0
    return -1;
16981
0
}
16982
16983
int
16984
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
16985
                   PyArena* arena)
16986
0
{
16987
0
    PyObject* tmp = NULL;
16988
0
    pattern_ty pattern;
16989
0
    expr_ty guard;
16990
0
    asdl_stmt_seq* body;
16991
16992
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
16993
0
        return -1;
16994
0
    }
16995
0
    if (tmp == NULL) {
16996
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
16997
0
        return -1;
16998
0
    }
16999
0
    else {
17000
0
        int res;
17001
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17002
0
            goto failed;
17003
0
        }
17004
0
        res = obj2ast_pattern(state, tmp, &pattern, arena);
17005
0
        _Py_LeaveRecursiveCall();
17006
0
        if (res != 0) goto failed;
17007
0
        Py_CLEAR(tmp);
17008
0
    }
17009
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17010
0
        return -1;
17011
0
    }
17012
0
    if (tmp == NULL || tmp == Py_None) {
17013
0
        Py_CLEAR(tmp);
17014
0
        guard = NULL;
17015
0
    }
17016
0
    else {
17017
0
        int res;
17018
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17019
0
            goto failed;
17020
0
        }
17021
0
        res = obj2ast_expr(state, tmp, &guard, arena);
17022
0
        _Py_LeaveRecursiveCall();
17023
0
        if (res != 0) goto failed;
17024
0
        Py_CLEAR(tmp);
17025
0
    }
17026
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17027
0
        return -1;
17028
0
    }
17029
0
    if (tmp == NULL) {
17030
0
        tmp = PyList_New(0);
17031
0
        if (tmp == NULL) {
17032
0
            return -1;
17033
0
        }
17034
0
    }
17035
0
    {
17036
0
        int res;
17037
0
        Py_ssize_t len;
17038
0
        Py_ssize_t i;
17039
0
        if (!PyList_Check(tmp)) {
17040
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17041
0
            goto failed;
17042
0
        }
17043
0
        len = PyList_GET_SIZE(tmp);
17044
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17045
0
        if (body == NULL) goto failed;
17046
0
        for (i = 0; i < len; i++) {
17047
0
            stmt_ty val;
17048
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17049
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17050
0
                goto failed;
17051
0
            }
17052
0
            res = obj2ast_stmt(state, tmp2, &val, arena);
17053
0
            _Py_LeaveRecursiveCall();
17054
0
            Py_DECREF(tmp2);
17055
0
            if (res != 0) goto failed;
17056
0
            if (len != PyList_GET_SIZE(tmp)) {
17057
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17058
0
                goto failed;
17059
0
            }
17060
0
            asdl_seq_SET(body, i, val);
17061
0
        }
17062
0
        Py_CLEAR(tmp);
17063
0
    }
17064
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17065
0
    if (*out == NULL) goto failed;
17066
0
    return 0;
17067
0
failed:
17068
0
    Py_XDECREF(tmp);
17069
0
    return -1;
17070
0
}
17071
17072
int
17073
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
17074
                PyArena* arena)
17075
0
{
17076
0
    int isinstance;
17077
17078
0
    PyObject *tmp = NULL;
17079
0
    PyObject *tp;
17080
0
    int lineno;
17081
0
    int col_offset;
17082
0
    int end_lineno;
17083
0
    int end_col_offset;
17084
17085
0
    if (obj == Py_None) {
17086
0
        *out = NULL;
17087
0
        return 0;
17088
0
    }
17089
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17090
0
        return -1;
17091
0
    }
17092
0
    if (tmp == NULL) {
17093
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17094
0
        return -1;
17095
0
    }
17096
0
    else {
17097
0
        int res;
17098
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17099
0
            goto failed;
17100
0
        }
17101
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17102
0
        _Py_LeaveRecursiveCall();
17103
0
        if (res != 0) goto failed;
17104
0
        Py_CLEAR(tmp);
17105
0
    }
17106
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17107
0
        return -1;
17108
0
    }
17109
0
    if (tmp == NULL) {
17110
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17111
0
        return -1;
17112
0
    }
17113
0
    else {
17114
0
        int res;
17115
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17116
0
            goto failed;
17117
0
        }
17118
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17119
0
        _Py_LeaveRecursiveCall();
17120
0
        if (res != 0) goto failed;
17121
0
        Py_CLEAR(tmp);
17122
0
    }
17123
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17124
0
        return -1;
17125
0
    }
17126
0
    if (tmp == NULL) {
17127
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17128
0
        return -1;
17129
0
    }
17130
0
    else {
17131
0
        int res;
17132
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17133
0
            goto failed;
17134
0
        }
17135
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17136
0
        _Py_LeaveRecursiveCall();
17137
0
        if (res != 0) goto failed;
17138
0
        Py_CLEAR(tmp);
17139
0
    }
17140
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17141
0
        return -1;
17142
0
    }
17143
0
    if (tmp == NULL) {
17144
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17145
0
        return -1;
17146
0
    }
17147
0
    else {
17148
0
        int res;
17149
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17150
0
            goto failed;
17151
0
        }
17152
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17153
0
        _Py_LeaveRecursiveCall();
17154
0
        if (res != 0) goto failed;
17155
0
        Py_CLEAR(tmp);
17156
0
    }
17157
0
    tp = state->MatchValue_type;
17158
0
    isinstance = PyObject_IsInstance(obj, tp);
17159
0
    if (isinstance == -1) {
17160
0
        return -1;
17161
0
    }
17162
0
    if (isinstance) {
17163
0
        expr_ty value;
17164
17165
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17166
0
            return -1;
17167
0
        }
17168
0
        if (tmp == NULL) {
17169
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17170
0
            return -1;
17171
0
        }
17172
0
        else {
17173
0
            int res;
17174
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17175
0
                goto failed;
17176
0
            }
17177
0
            res = obj2ast_expr(state, tmp, &value, arena);
17178
0
            _Py_LeaveRecursiveCall();
17179
0
            if (res != 0) goto failed;
17180
0
            Py_CLEAR(tmp);
17181
0
        }
17182
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17183
0
                                 end_col_offset, arena);
17184
0
        if (*out == NULL) goto failed;
17185
0
        return 0;
17186
0
    }
17187
0
    tp = state->MatchSingleton_type;
17188
0
    isinstance = PyObject_IsInstance(obj, tp);
17189
0
    if (isinstance == -1) {
17190
0
        return -1;
17191
0
    }
17192
0
    if (isinstance) {
17193
0
        constant value;
17194
17195
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17196
0
            return -1;
17197
0
        }
17198
0
        if (tmp == NULL) {
17199
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17200
0
            return -1;
17201
0
        }
17202
0
        else {
17203
0
            int res;
17204
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17205
0
                goto failed;
17206
0
            }
17207
0
            res = obj2ast_constant(state, tmp, &value, arena);
17208
0
            _Py_LeaveRecursiveCall();
17209
0
            if (res != 0) goto failed;
17210
0
            Py_CLEAR(tmp);
17211
0
        }
17212
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17213
0
                                     end_col_offset, arena);
17214
0
        if (*out == NULL) goto failed;
17215
0
        return 0;
17216
0
    }
17217
0
    tp = state->MatchSequence_type;
17218
0
    isinstance = PyObject_IsInstance(obj, tp);
17219
0
    if (isinstance == -1) {
17220
0
        return -1;
17221
0
    }
17222
0
    if (isinstance) {
17223
0
        asdl_pattern_seq* patterns;
17224
17225
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17226
0
            return -1;
17227
0
        }
17228
0
        if (tmp == NULL) {
17229
0
            tmp = PyList_New(0);
17230
0
            if (tmp == NULL) {
17231
0
                return -1;
17232
0
            }
17233
0
        }
17234
0
        {
17235
0
            int res;
17236
0
            Py_ssize_t len;
17237
0
            Py_ssize_t i;
17238
0
            if (!PyList_Check(tmp)) {
17239
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17240
0
                goto failed;
17241
0
            }
17242
0
            len = PyList_GET_SIZE(tmp);
17243
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17244
0
            if (patterns == NULL) goto failed;
17245
0
            for (i = 0; i < len; i++) {
17246
0
                pattern_ty val;
17247
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17248
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17249
0
                    goto failed;
17250
0
                }
17251
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17252
0
                _Py_LeaveRecursiveCall();
17253
0
                Py_DECREF(tmp2);
17254
0
                if (res != 0) goto failed;
17255
0
                if (len != PyList_GET_SIZE(tmp)) {
17256
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17257
0
                    goto failed;
17258
0
                }
17259
0
                asdl_seq_SET(patterns, i, val);
17260
0
            }
17261
0
            Py_CLEAR(tmp);
17262
0
        }
17263
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17264
0
                                    end_col_offset, arena);
17265
0
        if (*out == NULL) goto failed;
17266
0
        return 0;
17267
0
    }
17268
0
    tp = state->MatchMapping_type;
17269
0
    isinstance = PyObject_IsInstance(obj, tp);
17270
0
    if (isinstance == -1) {
17271
0
        return -1;
17272
0
    }
17273
0
    if (isinstance) {
17274
0
        asdl_expr_seq* keys;
17275
0
        asdl_pattern_seq* patterns;
17276
0
        identifier rest;
17277
17278
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17279
0
            return -1;
17280
0
        }
17281
0
        if (tmp == NULL) {
17282
0
            tmp = PyList_New(0);
17283
0
            if (tmp == NULL) {
17284
0
                return -1;
17285
0
            }
17286
0
        }
17287
0
        {
17288
0
            int res;
17289
0
            Py_ssize_t len;
17290
0
            Py_ssize_t i;
17291
0
            if (!PyList_Check(tmp)) {
17292
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17293
0
                goto failed;
17294
0
            }
17295
0
            len = PyList_GET_SIZE(tmp);
17296
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17297
0
            if (keys == NULL) goto failed;
17298
0
            for (i = 0; i < len; i++) {
17299
0
                expr_ty val;
17300
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17301
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17302
0
                    goto failed;
17303
0
                }
17304
0
                res = obj2ast_expr(state, tmp2, &val, arena);
17305
0
                _Py_LeaveRecursiveCall();
17306
0
                Py_DECREF(tmp2);
17307
0
                if (res != 0) goto failed;
17308
0
                if (len != PyList_GET_SIZE(tmp)) {
17309
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17310
0
                    goto failed;
17311
0
                }
17312
0
                asdl_seq_SET(keys, i, val);
17313
0
            }
17314
0
            Py_CLEAR(tmp);
17315
0
        }
17316
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17317
0
            return -1;
17318
0
        }
17319
0
        if (tmp == NULL) {
17320
0
            tmp = PyList_New(0);
17321
0
            if (tmp == NULL) {
17322
0
                return -1;
17323
0
            }
17324
0
        }
17325
0
        {
17326
0
            int res;
17327
0
            Py_ssize_t len;
17328
0
            Py_ssize_t i;
17329
0
            if (!PyList_Check(tmp)) {
17330
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17331
0
                goto failed;
17332
0
            }
17333
0
            len = PyList_GET_SIZE(tmp);
17334
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17335
0
            if (patterns == NULL) goto failed;
17336
0
            for (i = 0; i < len; i++) {
17337
0
                pattern_ty val;
17338
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17339
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17340
0
                    goto failed;
17341
0
                }
17342
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17343
0
                _Py_LeaveRecursiveCall();
17344
0
                Py_DECREF(tmp2);
17345
0
                if (res != 0) goto failed;
17346
0
                if (len != PyList_GET_SIZE(tmp)) {
17347
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17348
0
                    goto failed;
17349
0
                }
17350
0
                asdl_seq_SET(patterns, i, val);
17351
0
            }
17352
0
            Py_CLEAR(tmp);
17353
0
        }
17354
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17355
0
            return -1;
17356
0
        }
17357
0
        if (tmp == NULL || tmp == Py_None) {
17358
0
            Py_CLEAR(tmp);
17359
0
            rest = NULL;
17360
0
        }
17361
0
        else {
17362
0
            int res;
17363
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17364
0
                goto failed;
17365
0
            }
17366
0
            res = obj2ast_identifier(state, tmp, &rest, arena);
17367
0
            _Py_LeaveRecursiveCall();
17368
0
            if (res != 0) goto failed;
17369
0
            Py_CLEAR(tmp);
17370
0
        }
17371
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17372
0
                                   end_lineno, end_col_offset, arena);
17373
0
        if (*out == NULL) goto failed;
17374
0
        return 0;
17375
0
    }
17376
0
    tp = state->MatchClass_type;
17377
0
    isinstance = PyObject_IsInstance(obj, tp);
17378
0
    if (isinstance == -1) {
17379
0
        return -1;
17380
0
    }
17381
0
    if (isinstance) {
17382
0
        expr_ty cls;
17383
0
        asdl_pattern_seq* patterns;
17384
0
        asdl_identifier_seq* kwd_attrs;
17385
0
        asdl_pattern_seq* kwd_patterns;
17386
17387
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17388
0
            return -1;
17389
0
        }
17390
0
        if (tmp == NULL) {
17391
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17392
0
            return -1;
17393
0
        }
17394
0
        else {
17395
0
            int res;
17396
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17397
0
                goto failed;
17398
0
            }
17399
0
            res = obj2ast_expr(state, tmp, &cls, arena);
17400
0
            _Py_LeaveRecursiveCall();
17401
0
            if (res != 0) goto failed;
17402
0
            Py_CLEAR(tmp);
17403
0
        }
17404
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17405
0
            return -1;
17406
0
        }
17407
0
        if (tmp == NULL) {
17408
0
            tmp = PyList_New(0);
17409
0
            if (tmp == NULL) {
17410
0
                return -1;
17411
0
            }
17412
0
        }
17413
0
        {
17414
0
            int res;
17415
0
            Py_ssize_t len;
17416
0
            Py_ssize_t i;
17417
0
            if (!PyList_Check(tmp)) {
17418
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17419
0
                goto failed;
17420
0
            }
17421
0
            len = PyList_GET_SIZE(tmp);
17422
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17423
0
            if (patterns == NULL) goto failed;
17424
0
            for (i = 0; i < len; i++) {
17425
0
                pattern_ty val;
17426
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17427
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17428
0
                    goto failed;
17429
0
                }
17430
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17431
0
                _Py_LeaveRecursiveCall();
17432
0
                Py_DECREF(tmp2);
17433
0
                if (res != 0) goto failed;
17434
0
                if (len != PyList_GET_SIZE(tmp)) {
17435
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17436
0
                    goto failed;
17437
0
                }
17438
0
                asdl_seq_SET(patterns, i, val);
17439
0
            }
17440
0
            Py_CLEAR(tmp);
17441
0
        }
17442
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17443
0
            return -1;
17444
0
        }
17445
0
        if (tmp == NULL) {
17446
0
            tmp = PyList_New(0);
17447
0
            if (tmp == NULL) {
17448
0
                return -1;
17449
0
            }
17450
0
        }
17451
0
        {
17452
0
            int res;
17453
0
            Py_ssize_t len;
17454
0
            Py_ssize_t i;
17455
0
            if (!PyList_Check(tmp)) {
17456
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17457
0
                goto failed;
17458
0
            }
17459
0
            len = PyList_GET_SIZE(tmp);
17460
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17461
0
            if (kwd_attrs == NULL) goto failed;
17462
0
            for (i = 0; i < len; i++) {
17463
0
                identifier val;
17464
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17465
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17466
0
                    goto failed;
17467
0
                }
17468
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
17469
0
                _Py_LeaveRecursiveCall();
17470
0
                Py_DECREF(tmp2);
17471
0
                if (res != 0) goto failed;
17472
0
                if (len != PyList_GET_SIZE(tmp)) {
17473
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17474
0
                    goto failed;
17475
0
                }
17476
0
                asdl_seq_SET(kwd_attrs, i, val);
17477
0
            }
17478
0
            Py_CLEAR(tmp);
17479
0
        }
17480
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17481
0
            return -1;
17482
0
        }
17483
0
        if (tmp == NULL) {
17484
0
            tmp = PyList_New(0);
17485
0
            if (tmp == NULL) {
17486
0
                return -1;
17487
0
            }
17488
0
        }
17489
0
        {
17490
0
            int res;
17491
0
            Py_ssize_t len;
17492
0
            Py_ssize_t i;
17493
0
            if (!PyList_Check(tmp)) {
17494
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17495
0
                goto failed;
17496
0
            }
17497
0
            len = PyList_GET_SIZE(tmp);
17498
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17499
0
            if (kwd_patterns == NULL) goto failed;
17500
0
            for (i = 0; i < len; i++) {
17501
0
                pattern_ty val;
17502
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17503
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17504
0
                    goto failed;
17505
0
                }
17506
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17507
0
                _Py_LeaveRecursiveCall();
17508
0
                Py_DECREF(tmp2);
17509
0
                if (res != 0) goto failed;
17510
0
                if (len != PyList_GET_SIZE(tmp)) {
17511
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17512
0
                    goto failed;
17513
0
                }
17514
0
                asdl_seq_SET(kwd_patterns, i, val);
17515
0
            }
17516
0
            Py_CLEAR(tmp);
17517
0
        }
17518
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17519
0
                                 lineno, col_offset, end_lineno,
17520
0
                                 end_col_offset, arena);
17521
0
        if (*out == NULL) goto failed;
17522
0
        return 0;
17523
0
    }
17524
0
    tp = state->MatchStar_type;
17525
0
    isinstance = PyObject_IsInstance(obj, tp);
17526
0
    if (isinstance == -1) {
17527
0
        return -1;
17528
0
    }
17529
0
    if (isinstance) {
17530
0
        identifier name;
17531
17532
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17533
0
            return -1;
17534
0
        }
17535
0
        if (tmp == NULL || tmp == Py_None) {
17536
0
            Py_CLEAR(tmp);
17537
0
            name = NULL;
17538
0
        }
17539
0
        else {
17540
0
            int res;
17541
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17542
0
                goto failed;
17543
0
            }
17544
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17545
0
            _Py_LeaveRecursiveCall();
17546
0
            if (res != 0) goto failed;
17547
0
            Py_CLEAR(tmp);
17548
0
        }
17549
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17550
0
                                end_col_offset, arena);
17551
0
        if (*out == NULL) goto failed;
17552
0
        return 0;
17553
0
    }
17554
0
    tp = state->MatchAs_type;
17555
0
    isinstance = PyObject_IsInstance(obj, tp);
17556
0
    if (isinstance == -1) {
17557
0
        return -1;
17558
0
    }
17559
0
    if (isinstance) {
17560
0
        pattern_ty pattern;
17561
0
        identifier name;
17562
17563
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17564
0
            return -1;
17565
0
        }
17566
0
        if (tmp == NULL || tmp == Py_None) {
17567
0
            Py_CLEAR(tmp);
17568
0
            pattern = NULL;
17569
0
        }
17570
0
        else {
17571
0
            int res;
17572
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17573
0
                goto failed;
17574
0
            }
17575
0
            res = obj2ast_pattern(state, tmp, &pattern, arena);
17576
0
            _Py_LeaveRecursiveCall();
17577
0
            if (res != 0) goto failed;
17578
0
            Py_CLEAR(tmp);
17579
0
        }
17580
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17581
0
            return -1;
17582
0
        }
17583
0
        if (tmp == NULL || tmp == Py_None) {
17584
0
            Py_CLEAR(tmp);
17585
0
            name = NULL;
17586
0
        }
17587
0
        else {
17588
0
            int res;
17589
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17590
0
                goto failed;
17591
0
            }
17592
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17593
0
            _Py_LeaveRecursiveCall();
17594
0
            if (res != 0) goto failed;
17595
0
            Py_CLEAR(tmp);
17596
0
        }
17597
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17598
0
                              end_col_offset, arena);
17599
0
        if (*out == NULL) goto failed;
17600
0
        return 0;
17601
0
    }
17602
0
    tp = state->MatchOr_type;
17603
0
    isinstance = PyObject_IsInstance(obj, tp);
17604
0
    if (isinstance == -1) {
17605
0
        return -1;
17606
0
    }
17607
0
    if (isinstance) {
17608
0
        asdl_pattern_seq* patterns;
17609
17610
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17611
0
            return -1;
17612
0
        }
17613
0
        if (tmp == NULL) {
17614
0
            tmp = PyList_New(0);
17615
0
            if (tmp == NULL) {
17616
0
                return -1;
17617
0
            }
17618
0
        }
17619
0
        {
17620
0
            int res;
17621
0
            Py_ssize_t len;
17622
0
            Py_ssize_t i;
17623
0
            if (!PyList_Check(tmp)) {
17624
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17625
0
                goto failed;
17626
0
            }
17627
0
            len = PyList_GET_SIZE(tmp);
17628
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17629
0
            if (patterns == NULL) goto failed;
17630
0
            for (i = 0; i < len; i++) {
17631
0
                pattern_ty val;
17632
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17633
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17634
0
                    goto failed;
17635
0
                }
17636
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17637
0
                _Py_LeaveRecursiveCall();
17638
0
                Py_DECREF(tmp2);
17639
0
                if (res != 0) goto failed;
17640
0
                if (len != PyList_GET_SIZE(tmp)) {
17641
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17642
0
                    goto failed;
17643
0
                }
17644
0
                asdl_seq_SET(patterns, i, val);
17645
0
            }
17646
0
            Py_CLEAR(tmp);
17647
0
        }
17648
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17649
0
                              end_col_offset, arena);
17650
0
        if (*out == NULL) goto failed;
17651
0
        return 0;
17652
0
    }
17653
17654
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17655
0
    failed:
17656
0
    Py_XDECREF(tmp);
17657
0
    return -1;
17658
0
}
17659
17660
int
17661
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17662
                    out, PyArena* arena)
17663
0
{
17664
0
    int isinstance;
17665
17666
0
    PyObject *tmp = NULL;
17667
0
    PyObject *tp;
17668
17669
0
    if (obj == Py_None) {
17670
0
        *out = NULL;
17671
0
        return 0;
17672
0
    }
17673
0
    tp = state->TypeIgnore_type;
17674
0
    isinstance = PyObject_IsInstance(obj, tp);
17675
0
    if (isinstance == -1) {
17676
0
        return -1;
17677
0
    }
17678
0
    if (isinstance) {
17679
0
        int lineno;
17680
0
        string tag;
17681
17682
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17683
0
            return -1;
17684
0
        }
17685
0
        if (tmp == NULL) {
17686
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17687
0
            return -1;
17688
0
        }
17689
0
        else {
17690
0
            int res;
17691
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17692
0
                goto failed;
17693
0
            }
17694
0
            res = obj2ast_int(state, tmp, &lineno, arena);
17695
0
            _Py_LeaveRecursiveCall();
17696
0
            if (res != 0) goto failed;
17697
0
            Py_CLEAR(tmp);
17698
0
        }
17699
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17700
0
            return -1;
17701
0
        }
17702
0
        if (tmp == NULL) {
17703
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17704
0
            return -1;
17705
0
        }
17706
0
        else {
17707
0
            int res;
17708
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17709
0
                goto failed;
17710
0
            }
17711
0
            res = obj2ast_string(state, tmp, &tag, arena);
17712
0
            _Py_LeaveRecursiveCall();
17713
0
            if (res != 0) goto failed;
17714
0
            Py_CLEAR(tmp);
17715
0
        }
17716
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17717
0
        if (*out == NULL) goto failed;
17718
0
        return 0;
17719
0
    }
17720
17721
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17722
0
    failed:
17723
0
    Py_XDECREF(tmp);
17724
0
    return -1;
17725
0
}
17726
17727
int
17728
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17729
                   PyArena* arena)
17730
0
{
17731
0
    int isinstance;
17732
17733
0
    PyObject *tmp = NULL;
17734
0
    PyObject *tp;
17735
0
    int lineno;
17736
0
    int col_offset;
17737
0
    int end_lineno;
17738
0
    int end_col_offset;
17739
17740
0
    if (obj == Py_None) {
17741
0
        *out = NULL;
17742
0
        return 0;
17743
0
    }
17744
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17745
0
        return -1;
17746
0
    }
17747
0
    if (tmp == NULL) {
17748
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17749
0
        return -1;
17750
0
    }
17751
0
    else {
17752
0
        int res;
17753
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17754
0
            goto failed;
17755
0
        }
17756
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17757
0
        _Py_LeaveRecursiveCall();
17758
0
        if (res != 0) goto failed;
17759
0
        Py_CLEAR(tmp);
17760
0
    }
17761
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17762
0
        return -1;
17763
0
    }
17764
0
    if (tmp == NULL) {
17765
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17766
0
        return -1;
17767
0
    }
17768
0
    else {
17769
0
        int res;
17770
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17771
0
            goto failed;
17772
0
        }
17773
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17774
0
        _Py_LeaveRecursiveCall();
17775
0
        if (res != 0) goto failed;
17776
0
        Py_CLEAR(tmp);
17777
0
    }
17778
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17779
0
        return -1;
17780
0
    }
17781
0
    if (tmp == NULL) {
17782
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17783
0
        return -1;
17784
0
    }
17785
0
    else {
17786
0
        int res;
17787
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17788
0
            goto failed;
17789
0
        }
17790
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17791
0
        _Py_LeaveRecursiveCall();
17792
0
        if (res != 0) goto failed;
17793
0
        Py_CLEAR(tmp);
17794
0
    }
17795
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17796
0
        return -1;
17797
0
    }
17798
0
    if (tmp == NULL) {
17799
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17800
0
        return -1;
17801
0
    }
17802
0
    else {
17803
0
        int res;
17804
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17805
0
            goto failed;
17806
0
        }
17807
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17808
0
        _Py_LeaveRecursiveCall();
17809
0
        if (res != 0) goto failed;
17810
0
        Py_CLEAR(tmp);
17811
0
    }
17812
0
    tp = state->TypeVar_type;
17813
0
    isinstance = PyObject_IsInstance(obj, tp);
17814
0
    if (isinstance == -1) {
17815
0
        return -1;
17816
0
    }
17817
0
    if (isinstance) {
17818
0
        identifier name;
17819
0
        expr_ty bound;
17820
0
        expr_ty default_value;
17821
17822
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17823
0
            return -1;
17824
0
        }
17825
0
        if (tmp == NULL) {
17826
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17827
0
            return -1;
17828
0
        }
17829
0
        else {
17830
0
            int res;
17831
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17832
0
                goto failed;
17833
0
            }
17834
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17835
0
            _Py_LeaveRecursiveCall();
17836
0
            if (res != 0) goto failed;
17837
0
            Py_CLEAR(tmp);
17838
0
        }
17839
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17840
0
            return -1;
17841
0
        }
17842
0
        if (tmp == NULL || tmp == Py_None) {
17843
0
            Py_CLEAR(tmp);
17844
0
            bound = NULL;
17845
0
        }
17846
0
        else {
17847
0
            int res;
17848
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17849
0
                goto failed;
17850
0
            }
17851
0
            res = obj2ast_expr(state, tmp, &bound, arena);
17852
0
            _Py_LeaveRecursiveCall();
17853
0
            if (res != 0) goto failed;
17854
0
            Py_CLEAR(tmp);
17855
0
        }
17856
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17857
0
            return -1;
17858
0
        }
17859
0
        if (tmp == NULL || tmp == Py_None) {
17860
0
            Py_CLEAR(tmp);
17861
0
            default_value = NULL;
17862
0
        }
17863
0
        else {
17864
0
            int res;
17865
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17866
0
                goto failed;
17867
0
            }
17868
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17869
0
            _Py_LeaveRecursiveCall();
17870
0
            if (res != 0) goto failed;
17871
0
            Py_CLEAR(tmp);
17872
0
        }
17873
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17874
0
                              end_lineno, end_col_offset, arena);
17875
0
        if (*out == NULL) goto failed;
17876
0
        return 0;
17877
0
    }
17878
0
    tp = state->ParamSpec_type;
17879
0
    isinstance = PyObject_IsInstance(obj, tp);
17880
0
    if (isinstance == -1) {
17881
0
        return -1;
17882
0
    }
17883
0
    if (isinstance) {
17884
0
        identifier name;
17885
0
        expr_ty default_value;
17886
17887
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17888
0
            return -1;
17889
0
        }
17890
0
        if (tmp == NULL) {
17891
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17892
0
            return -1;
17893
0
        }
17894
0
        else {
17895
0
            int res;
17896
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17897
0
                goto failed;
17898
0
            }
17899
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17900
0
            _Py_LeaveRecursiveCall();
17901
0
            if (res != 0) goto failed;
17902
0
            Py_CLEAR(tmp);
17903
0
        }
17904
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17905
0
            return -1;
17906
0
        }
17907
0
        if (tmp == NULL || tmp == Py_None) {
17908
0
            Py_CLEAR(tmp);
17909
0
            default_value = NULL;
17910
0
        }
17911
0
        else {
17912
0
            int res;
17913
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17914
0
                goto failed;
17915
0
            }
17916
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17917
0
            _Py_LeaveRecursiveCall();
17918
0
            if (res != 0) goto failed;
17919
0
            Py_CLEAR(tmp);
17920
0
        }
17921
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
17922
0
                                end_lineno, end_col_offset, arena);
17923
0
        if (*out == NULL) goto failed;
17924
0
        return 0;
17925
0
    }
17926
0
    tp = state->TypeVarTuple_type;
17927
0
    isinstance = PyObject_IsInstance(obj, tp);
17928
0
    if (isinstance == -1) {
17929
0
        return -1;
17930
0
    }
17931
0
    if (isinstance) {
17932
0
        identifier name;
17933
0
        expr_ty default_value;
17934
17935
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17936
0
            return -1;
17937
0
        }
17938
0
        if (tmp == NULL) {
17939
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
17940
0
            return -1;
17941
0
        }
17942
0
        else {
17943
0
            int res;
17944
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17945
0
                goto failed;
17946
0
            }
17947
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17948
0
            _Py_LeaveRecursiveCall();
17949
0
            if (res != 0) goto failed;
17950
0
            Py_CLEAR(tmp);
17951
0
        }
17952
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17953
0
            return -1;
17954
0
        }
17955
0
        if (tmp == NULL || tmp == Py_None) {
17956
0
            Py_CLEAR(tmp);
17957
0
            default_value = NULL;
17958
0
        }
17959
0
        else {
17960
0
            int res;
17961
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
17962
0
                goto failed;
17963
0
            }
17964
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17965
0
            _Py_LeaveRecursiveCall();
17966
0
            if (res != 0) goto failed;
17967
0
            Py_CLEAR(tmp);
17968
0
        }
17969
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
17970
0
                                   end_lineno, end_col_offset, arena);
17971
0
        if (*out == NULL) goto failed;
17972
0
        return 0;
17973
0
    }
17974
17975
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
17976
0
    failed:
17977
0
    Py_XDECREF(tmp);
17978
0
    return -1;
17979
0
}
17980
17981
17982
static int
17983
astmodule_exec(PyObject *m)
17984
6
{
17985
6
    struct ast_state *state = get_ast_state();
17986
6
    if (state == NULL) {
17987
0
        return -1;
17988
0
    }
17989
6
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
17990
0
        return -1;
17991
0
    }
17992
6
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
17993
0
        return -1;
17994
0
    }
17995
6
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
17996
0
        return -1;
17997
0
    }
17998
6
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
17999
0
        return -1;
18000
0
    }
18001
6
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18002
0
        return -1;
18003
0
    }
18004
6
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18005
0
        return -1;
18006
0
    }
18007
6
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18008
0
        return -1;
18009
0
    }
18010
6
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18011
0
        return -1;
18012
0
    }
18013
6
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18014
0
        return -1;
18015
0
    }
18016
6
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18017
0
        {
18018
0
        return -1;
18019
0
    }
18020
6
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18021
0
        return -1;
18022
0
    }
18023
6
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18024
0
        return -1;
18025
0
    }
18026
6
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18027
6
        state->AsyncFunctionDef_type) < 0) {
18028
0
        return -1;
18029
0
    }
18030
6
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18031
0
        return -1;
18032
0
    }
18033
6
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18034
0
        return -1;
18035
0
    }
18036
6
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18037
0
        return -1;
18038
0
    }
18039
6
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18040
0
        return -1;
18041
0
    }
18042
6
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18043
0
        return -1;
18044
0
    }
18045
6
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18046
0
        return -1;
18047
0
    }
18048
6
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18049
0
        return -1;
18050
0
    }
18051
6
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18052
0
        return -1;
18053
0
    }
18054
6
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18055
0
        return -1;
18056
0
    }
18057
6
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18058
0
        return -1;
18059
0
    }
18060
6
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18061
0
        return -1;
18062
0
    }
18063
6
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18064
0
        return -1;
18065
0
    }
18066
6
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18067
0
        return -1;
18068
0
    }
18069
6
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18070
0
        return -1;
18071
0
    }
18072
6
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18073
0
        return -1;
18074
0
    }
18075
6
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18076
0
        return -1;
18077
0
    }
18078
6
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18079
0
        return -1;
18080
0
    }
18081
6
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18082
0
        return -1;
18083
0
    }
18084
6
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18085
0
        return -1;
18086
0
    }
18087
6
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18088
0
        return -1;
18089
0
    }
18090
6
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18091
0
        return -1;
18092
0
    }
18093
6
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18094
0
        return -1;
18095
0
    }
18096
6
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18097
0
        return -1;
18098
0
    }
18099
6
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18100
0
        return -1;
18101
0
    }
18102
6
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18103
0
        return -1;
18104
0
    }
18105
6
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18106
0
        return -1;
18107
0
    }
18108
6
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18109
0
        return -1;
18110
0
    }
18111
6
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18112
0
        return -1;
18113
0
    }
18114
6
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18115
0
        return -1;
18116
0
    }
18117
6
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18118
0
        return -1;
18119
0
    }
18120
6
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18121
0
        return -1;
18122
0
    }
18123
6
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18124
0
        return -1;
18125
0
    }
18126
6
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18127
0
        return -1;
18128
0
    }
18129
6
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18130
0
        return -1;
18131
0
    }
18132
6
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18133
0
        return -1;
18134
0
    }
18135
6
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18136
0
        return -1;
18137
0
    }
18138
6
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18139
0
        return -1;
18140
0
    }
18141
6
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18142
0
        return -1;
18143
0
    }
18144
6
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18145
0
        {
18146
0
        return -1;
18147
0
    }
18148
6
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18149
0
        return -1;
18150
0
    }
18151
6
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18152
0
        return -1;
18153
0
    }
18154
6
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18155
0
        return -1;
18156
0
    }
18157
6
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18158
0
        return -1;
18159
0
    }
18160
6
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18161
0
        return -1;
18162
0
    }
18163
6
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18164
6
        < 0) {
18165
0
        return -1;
18166
0
    }
18167
6
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18168
6
        0) {
18169
0
        return -1;
18170
0
    }
18171
6
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18172
0
        return -1;
18173
0
    }
18174
6
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18175
0
        return -1;
18176
0
    }
18177
6
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18178
0
        return -1;
18179
0
    }
18180
6
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18181
0
        return -1;
18182
0
    }
18183
6
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18184
0
        return -1;
18185
0
    }
18186
6
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18187
0
        return -1;
18188
0
    }
18189
6
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18190
0
        return -1;
18191
0
    }
18192
6
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18193
0
        return -1;
18194
0
    }
18195
6
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18196
0
        return -1;
18197
0
    }
18198
6
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18199
0
        return -1;
18200
0
    }
18201
6
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18202
0
        {
18203
0
        return -1;
18204
0
    }
18205
6
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18206
0
        return -1;
18207
0
    }
18208
6
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18209
0
        return -1;
18210
0
    }
18211
6
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18212
0
        return -1;
18213
0
    }
18214
6
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18215
0
        return -1;
18216
0
    }
18217
6
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18218
0
        return -1;
18219
0
    }
18220
6
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18221
0
        return -1;
18222
0
    }
18223
6
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18224
0
        return -1;
18225
0
    }
18226
6
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18227
0
        return -1;
18228
0
    }
18229
6
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18230
0
        return -1;
18231
0
    }
18232
6
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18233
0
        return -1;
18234
0
    }
18235
6
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18236
0
        return -1;
18237
0
    }
18238
6
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18239
0
        return -1;
18240
0
    }
18241
6
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18242
0
        return -1;
18243
0
    }
18244
6
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18245
0
        return -1;
18246
0
    }
18247
6
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18248
0
        return -1;
18249
0
    }
18250
6
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18251
0
        return -1;
18252
0
    }
18253
6
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18254
0
        return -1;
18255
0
    }
18256
6
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18257
0
        return -1;
18258
0
    }
18259
6
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18260
0
        return -1;
18261
0
    }
18262
6
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18263
0
        return -1;
18264
0
    }
18265
6
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18266
0
        return -1;
18267
0
    }
18268
6
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18269
0
        return -1;
18270
0
    }
18271
6
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18272
0
        return -1;
18273
0
    }
18274
6
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18275
0
        return -1;
18276
0
    }
18277
6
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18278
0
        return -1;
18279
0
    }
18280
6
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18281
0
        return -1;
18282
0
    }
18283
6
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18284
0
        return -1;
18285
0
    }
18286
6
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18287
0
        return -1;
18288
0
    }
18289
6
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18290
0
        return -1;
18291
0
    }
18292
6
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18293
0
        return -1;
18294
0
    }
18295
6
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18296
0
        return -1;
18297
0
    }
18298
6
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18299
0
        return -1;
18300
0
    }
18301
6
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18302
0
        return -1;
18303
0
    }
18304
6
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18305
0
        return -1;
18306
0
    }
18307
6
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18308
0
        return -1;
18309
0
    }
18310
6
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18311
0
        return -1;
18312
0
    }
18313
6
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18314
6
        0) {
18315
0
        return -1;
18316
0
    }
18317
6
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18318
6
        0) {
18319
0
        return -1;
18320
0
    }
18321
6
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18322
6
        0) {
18323
0
        return -1;
18324
0
    }
18325
6
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18326
0
        return -1;
18327
0
    }
18328
6
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18329
0
        return -1;
18330
0
    }
18331
6
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18332
0
        return -1;
18333
0
    }
18334
6
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18335
0
        return -1;
18336
0
    }
18337
6
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18338
0
        return -1;
18339
0
    }
18340
6
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18341
0
        return -1;
18342
0
    }
18343
6
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18344
0
        return -1;
18345
0
    }
18346
6
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18347
0
        return -1;
18348
0
    }
18349
6
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18350
6
        < 0) {
18351
0
        return -1;
18352
0
    }
18353
6
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18354
6
        0) {
18355
0
        return -1;
18356
0
    }
18357
6
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18358
0
        {
18359
0
        return -1;
18360
0
    }
18361
6
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18362
0
        return -1;
18363
0
    }
18364
6
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18365
0
        return -1;
18366
0
    }
18367
6
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18368
0
        return -1;
18369
0
    }
18370
6
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18371
0
        return -1;
18372
0
    }
18373
6
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18374
0
        return -1;
18375
0
    }
18376
6
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18377
0
        return -1;
18378
0
    }
18379
6
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18380
0
        return -1;
18381
0
    }
18382
6
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18383
0
        return -1;
18384
0
    }
18385
6
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18386
0
        return -1;
18387
0
    }
18388
6
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18389
0
        {
18390
0
        return -1;
18391
0
    }
18392
6
    return 0;
18393
6
}
18394
18395
static PyModuleDef_Slot astmodule_slots[] = {
18396
    {Py_mod_exec, astmodule_exec},
18397
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18398
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18399
    {0, NULL}
18400
};
18401
18402
static struct PyModuleDef _astmodule = {
18403
    PyModuleDef_HEAD_INIT,
18404
    .m_name = "_ast",
18405
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18406
    .m_size = 0,
18407
    .m_slots = astmodule_slots,
18408
};
18409
18410
PyMODINIT_FUNC
18411
PyInit__ast(void)
18412
6
{
18413
6
    return PyModuleDef_Init(&_astmodule);
18414
6
}
18415
18416
18417
PyObject* PyAST_mod2obj(mod_ty t)
18418
5.07k
{
18419
5.07k
    struct ast_state *state = get_ast_state();
18420
5.07k
    if (state == NULL) {
18421
0
        return NULL;
18422
0
    }
18423
5.07k
    PyObject *result = ast2obj_mod(state, t);
18424
18425
5.07k
    return result;
18426
5.07k
}
18427
18428
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18429
int PyAst_CheckMode(PyObject *ast, int mode)
18430
0
{
18431
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18432
18433
0
    struct ast_state *state = get_ast_state();
18434
0
    if (state == NULL) {
18435
0
        return -1;
18436
0
    }
18437
18438
0
    PyObject *req_type[3];
18439
0
    req_type[0] = state->Module_type;
18440
0
    req_type[1] = state->Expression_type;
18441
0
    req_type[2] = state->Interactive_type;
18442
18443
0
    assert(0 <= mode && mode <= 2);
18444
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18445
0
    if (isinstance == -1) {
18446
0
        return -1;
18447
0
    }
18448
0
    if (!isinstance) {
18449
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18450
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18451
0
        return -1;
18452
0
    }
18453
0
    return 0;
18454
0
}
18455
18456
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18457
0
{
18458
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18459
0
        return NULL;
18460
0
    }
18461
18462
0
    struct ast_state *state = get_ast_state();
18463
0
    if (state == NULL) {
18464
0
        return NULL;
18465
0
    }
18466
18467
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18468
0
        return NULL;
18469
0
    }
18470
18471
0
    mod_ty res = NULL;
18472
0
    if (obj2ast_mod(state, ast, &res, arena) != 0)
18473
0
        return NULL;
18474
0
    else
18475
0
        return res;
18476
0
}
18477
18478
int PyAST_Check(PyObject* obj)
18479
17.4k
{
18480
17.4k
    struct ast_state *state = get_ast_state();
18481
17.4k
    if (state == NULL) {
18482
0
        return -1;
18483
0
    }
18484
17.4k
    return PyObject_IsInstance(obj, state->AST_type);
18485
17.4k
}
18486
18487