Coverage Report

Created: 2026-02-26 06:53

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.5k
{
23
22.5k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
22.5k
    struct ast_state *state = &interp->ast;
25
22.5k
    assert(!state->finalized);
26
22.5k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
22.5k
    return state;
30
22.5k
}
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->is_lazy);
226
0
    Py_CLEAR(state->items);
227
0
    Py_CLEAR(state->iter);
228
0
    Py_CLEAR(state->key);
229
0
    Py_CLEAR(state->keys);
230
0
    Py_CLEAR(state->keyword_type);
231
0
    Py_CLEAR(state->keywords);
232
0
    Py_CLEAR(state->kind);
233
0
    Py_CLEAR(state->kw_defaults);
234
0
    Py_CLEAR(state->kwarg);
235
0
    Py_CLEAR(state->kwd_attrs);
236
0
    Py_CLEAR(state->kwd_patterns);
237
0
    Py_CLEAR(state->kwonlyargs);
238
0
    Py_CLEAR(state->left);
239
0
    Py_CLEAR(state->level);
240
0
    Py_CLEAR(state->lineno);
241
0
    Py_CLEAR(state->lower);
242
0
    Py_CLEAR(state->match_case_type);
243
0
    Py_CLEAR(state->mod_type);
244
0
    Py_CLEAR(state->module);
245
0
    Py_CLEAR(state->msg);
246
0
    Py_CLEAR(state->name);
247
0
    Py_CLEAR(state->names);
248
0
    Py_CLEAR(state->op);
249
0
    Py_CLEAR(state->operand);
250
0
    Py_CLEAR(state->operator_type);
251
0
    Py_CLEAR(state->ops);
252
0
    Py_CLEAR(state->optional_vars);
253
0
    Py_CLEAR(state->orelse);
254
0
    Py_CLEAR(state->pattern);
255
0
    Py_CLEAR(state->pattern_type);
256
0
    Py_CLEAR(state->patterns);
257
0
    Py_CLEAR(state->posonlyargs);
258
0
    Py_CLEAR(state->rest);
259
0
    Py_CLEAR(state->returns);
260
0
    Py_CLEAR(state->right);
261
0
    Py_CLEAR(state->simple);
262
0
    Py_CLEAR(state->slice);
263
0
    Py_CLEAR(state->step);
264
0
    Py_CLEAR(state->stmt_type);
265
0
    Py_CLEAR(state->str);
266
0
    Py_CLEAR(state->subject);
267
0
    Py_CLEAR(state->tag);
268
0
    Py_CLEAR(state->target);
269
0
    Py_CLEAR(state->targets);
270
0
    Py_CLEAR(state->test);
271
0
    Py_CLEAR(state->type);
272
0
    Py_CLEAR(state->type_comment);
273
0
    Py_CLEAR(state->type_ignore_type);
274
0
    Py_CLEAR(state->type_ignores);
275
0
    Py_CLEAR(state->type_param_type);
276
0
    Py_CLEAR(state->type_params);
277
0
    Py_CLEAR(state->unaryop_type);
278
0
    Py_CLEAR(state->upper);
279
0
    Py_CLEAR(state->value);
280
0
    Py_CLEAR(state->values);
281
0
    Py_CLEAR(state->vararg);
282
0
    Py_CLEAR(state->withitem_type);
283
284
0
    state->finalized = 1;
285
0
    state->once = (_PyOnceFlag){0};
286
0
}
287
288
static int init_identifiers(struct ast_state *state)
289
12
{
290
12
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
291
12
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
292
12
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
293
12
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
294
12
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
295
12
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
296
12
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
297
12
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
298
12
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
299
12
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
300
12
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
301
12
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
302
12
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
303
12
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
304
12
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
305
12
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
306
12
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
307
12
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
308
12
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
309
12
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
310
12
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
311
12
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
312
12
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
313
12
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
314
12
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
315
12
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
316
12
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
317
12
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
318
12
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
319
12
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
320
12
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
321
12
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
322
12
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
323
12
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
324
12
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
325
12
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
326
12
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
327
12
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
328
12
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
329
12
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
330
12
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
331
12
    if ((state->is_lazy = PyUnicode_InternFromString("is_lazy")) == NULL) return -1;
332
12
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
333
12
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
334
12
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
335
12
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
336
12
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
337
12
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
338
12
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
339
12
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
340
12
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
341
12
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
342
12
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
343
12
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
344
12
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
345
12
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
346
12
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
347
12
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
348
12
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
349
12
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
350
12
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
351
12
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
352
12
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
353
12
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
354
12
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
355
12
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
356
12
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
357
12
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
358
12
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
359
12
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
360
12
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
361
12
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
362
12
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
363
12
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
364
12
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
365
12
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
366
12
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
367
12
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
368
12
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
369
12
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
370
12
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
371
12
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
372
12
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
373
12
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
374
12
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
375
12
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
376
12
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
377
12
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
378
12
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
379
12
    return 0;
380
12
};
381
382
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
384
98.8k
GENERATE_ASDL_SEQ_CONSTRUCTOR(expr, expr_ty)
385
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(comprehension, comprehension_ty)
386
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(excepthandler, excepthandler_ty)
387
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(arguments, arguments_ty)
388
45.1k
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
389
8.01k
GENERATE_ASDL_SEQ_CONSTRUCTOR(keyword, keyword_ty)
390
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(alias, alias_ty)
391
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(withitem, withitem_ty)
392
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(match_case, match_case_ty)
393
1.29k
GENERATE_ASDL_SEQ_CONSTRUCTOR(pattern, pattern_ty)
394
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_ignore, type_ignore_ty)
395
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(type_param, type_param_ty)
396
397
static PyObject* ast2obj_mod(struct ast_state *state, void*);
398
static const char * const Module_fields[]={
399
    "body",
400
    "type_ignores",
401
};
402
static const char * const Interactive_fields[]={
403
    "body",
404
};
405
static const char * const Expression_fields[]={
406
    "body",
407
};
408
static const char * const FunctionType_fields[]={
409
    "argtypes",
410
    "returns",
411
};
412
static const char * const stmt_attributes[] = {
413
    "lineno",
414
    "col_offset",
415
    "end_lineno",
416
    "end_col_offset",
417
};
418
static PyObject* ast2obj_stmt(struct ast_state *state, void*);
419
static const char * const FunctionDef_fields[]={
420
    "name",
421
    "args",
422
    "body",
423
    "decorator_list",
424
    "returns",
425
    "type_comment",
426
    "type_params",
427
};
428
static const char * const AsyncFunctionDef_fields[]={
429
    "name",
430
    "args",
431
    "body",
432
    "decorator_list",
433
    "returns",
434
    "type_comment",
435
    "type_params",
436
};
437
static const char * const ClassDef_fields[]={
438
    "name",
439
    "bases",
440
    "keywords",
441
    "body",
442
    "decorator_list",
443
    "type_params",
444
};
445
static const char * const Return_fields[]={
446
    "value",
447
};
448
static const char * const Delete_fields[]={
449
    "targets",
450
};
451
static const char * const Assign_fields[]={
452
    "targets",
453
    "value",
454
    "type_comment",
455
};
456
static const char * const TypeAlias_fields[]={
457
    "name",
458
    "type_params",
459
    "value",
460
};
461
static const char * const AugAssign_fields[]={
462
    "target",
463
    "op",
464
    "value",
465
};
466
static const char * const AnnAssign_fields[]={
467
    "target",
468
    "annotation",
469
    "value",
470
    "simple",
471
};
472
static const char * const For_fields[]={
473
    "target",
474
    "iter",
475
    "body",
476
    "orelse",
477
    "type_comment",
478
};
479
static const char * const AsyncFor_fields[]={
480
    "target",
481
    "iter",
482
    "body",
483
    "orelse",
484
    "type_comment",
485
};
486
static const char * const While_fields[]={
487
    "test",
488
    "body",
489
    "orelse",
490
};
491
static const char * const If_fields[]={
492
    "test",
493
    "body",
494
    "orelse",
495
};
496
static const char * const With_fields[]={
497
    "items",
498
    "body",
499
    "type_comment",
500
};
501
static const char * const AsyncWith_fields[]={
502
    "items",
503
    "body",
504
    "type_comment",
505
};
506
static const char * const Match_fields[]={
507
    "subject",
508
    "cases",
509
};
510
static const char * const Raise_fields[]={
511
    "exc",
512
    "cause",
513
};
514
static const char * const Try_fields[]={
515
    "body",
516
    "handlers",
517
    "orelse",
518
    "finalbody",
519
};
520
static const char * const TryStar_fields[]={
521
    "body",
522
    "handlers",
523
    "orelse",
524
    "finalbody",
525
};
526
static const char * const Assert_fields[]={
527
    "test",
528
    "msg",
529
};
530
static const char * const Import_fields[]={
531
    "names",
532
    "is_lazy",
533
};
534
static const char * const ImportFrom_fields[]={
535
    "module",
536
    "names",
537
    "level",
538
    "is_lazy",
539
};
540
static const char * const Global_fields[]={
541
    "names",
542
};
543
static const char * const Nonlocal_fields[]={
544
    "names",
545
};
546
static const char * const Expr_fields[]={
547
    "value",
548
};
549
static const char * const expr_attributes[] = {
550
    "lineno",
551
    "col_offset",
552
    "end_lineno",
553
    "end_col_offset",
554
};
555
static PyObject* ast2obj_expr(struct ast_state *state, void*);
556
static const char * const BoolOp_fields[]={
557
    "op",
558
    "values",
559
};
560
static const char * const NamedExpr_fields[]={
561
    "target",
562
    "value",
563
};
564
static const char * const BinOp_fields[]={
565
    "left",
566
    "op",
567
    "right",
568
};
569
static const char * const UnaryOp_fields[]={
570
    "op",
571
    "operand",
572
};
573
static const char * const Lambda_fields[]={
574
    "args",
575
    "body",
576
};
577
static const char * const IfExp_fields[]={
578
    "test",
579
    "body",
580
    "orelse",
581
};
582
static const char * const Dict_fields[]={
583
    "keys",
584
    "values",
585
};
586
static const char * const Set_fields[]={
587
    "elts",
588
};
589
static const char * const ListComp_fields[]={
590
    "elt",
591
    "generators",
592
};
593
static const char * const SetComp_fields[]={
594
    "elt",
595
    "generators",
596
};
597
static const char * const DictComp_fields[]={
598
    "key",
599
    "value",
600
    "generators",
601
};
602
static const char * const GeneratorExp_fields[]={
603
    "elt",
604
    "generators",
605
};
606
static const char * const Await_fields[]={
607
    "value",
608
};
609
static const char * const Yield_fields[]={
610
    "value",
611
};
612
static const char * const YieldFrom_fields[]={
613
    "value",
614
};
615
static const char * const Compare_fields[]={
616
    "left",
617
    "ops",
618
    "comparators",
619
};
620
static const char * const Call_fields[]={
621
    "func",
622
    "args",
623
    "keywords",
624
};
625
static const char * const FormattedValue_fields[]={
626
    "value",
627
    "conversion",
628
    "format_spec",
629
};
630
static const char * const Interpolation_fields[]={
631
    "value",
632
    "str",
633
    "conversion",
634
    "format_spec",
635
};
636
static const char * const JoinedStr_fields[]={
637
    "values",
638
};
639
static const char * const TemplateStr_fields[]={
640
    "values",
641
};
642
static const char * const Constant_fields[]={
643
    "value",
644
    "kind",
645
};
646
static const char * const Attribute_fields[]={
647
    "value",
648
    "attr",
649
    "ctx",
650
};
651
static const char * const Subscript_fields[]={
652
    "value",
653
    "slice",
654
    "ctx",
655
};
656
static const char * const Starred_fields[]={
657
    "value",
658
    "ctx",
659
};
660
static const char * const Name_fields[]={
661
    "id",
662
    "ctx",
663
};
664
static const char * const List_fields[]={
665
    "elts",
666
    "ctx",
667
};
668
static const char * const Tuple_fields[]={
669
    "elts",
670
    "ctx",
671
};
672
static const char * const Slice_fields[]={
673
    "lower",
674
    "upper",
675
    "step",
676
};
677
static PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty);
678
static PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty);
679
static PyObject* ast2obj_operator(struct ast_state *state, operator_ty);
680
static PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty);
681
static PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty);
682
static PyObject* ast2obj_comprehension(struct ast_state *state, void*);
683
static const char * const comprehension_fields[]={
684
    "target",
685
    "iter",
686
    "ifs",
687
    "is_async",
688
};
689
static const char * const excepthandler_attributes[] = {
690
    "lineno",
691
    "col_offset",
692
    "end_lineno",
693
    "end_col_offset",
694
};
695
static PyObject* ast2obj_excepthandler(struct ast_state *state, void*);
696
static const char * const ExceptHandler_fields[]={
697
    "type",
698
    "name",
699
    "body",
700
};
701
static PyObject* ast2obj_arguments(struct ast_state *state, void*);
702
static const char * const arguments_fields[]={
703
    "posonlyargs",
704
    "args",
705
    "vararg",
706
    "kwonlyargs",
707
    "kw_defaults",
708
    "kwarg",
709
    "defaults",
710
};
711
static PyObject* ast2obj_arg(struct ast_state *state, void*);
712
static const char * const arg_attributes[] = {
713
    "lineno",
714
    "col_offset",
715
    "end_lineno",
716
    "end_col_offset",
717
};
718
static const char * const arg_fields[]={
719
    "arg",
720
    "annotation",
721
    "type_comment",
722
};
723
static PyObject* ast2obj_keyword(struct ast_state *state, void*);
724
static const char * const keyword_attributes[] = {
725
    "lineno",
726
    "col_offset",
727
    "end_lineno",
728
    "end_col_offset",
729
};
730
static const char * const keyword_fields[]={
731
    "arg",
732
    "value",
733
};
734
static PyObject* ast2obj_alias(struct ast_state *state, void*);
735
static const char * const alias_attributes[] = {
736
    "lineno",
737
    "col_offset",
738
    "end_lineno",
739
    "end_col_offset",
740
};
741
static const char * const alias_fields[]={
742
    "name",
743
    "asname",
744
};
745
static PyObject* ast2obj_withitem(struct ast_state *state, void*);
746
static const char * const withitem_fields[]={
747
    "context_expr",
748
    "optional_vars",
749
};
750
static PyObject* ast2obj_match_case(struct ast_state *state, void*);
751
static const char * const match_case_fields[]={
752
    "pattern",
753
    "guard",
754
    "body",
755
};
756
static const char * const pattern_attributes[] = {
757
    "lineno",
758
    "col_offset",
759
    "end_lineno",
760
    "end_col_offset",
761
};
762
static PyObject* ast2obj_pattern(struct ast_state *state, void*);
763
static const char * const MatchValue_fields[]={
764
    "value",
765
};
766
static const char * const MatchSingleton_fields[]={
767
    "value",
768
};
769
static const char * const MatchSequence_fields[]={
770
    "patterns",
771
};
772
static const char * const MatchMapping_fields[]={
773
    "keys",
774
    "patterns",
775
    "rest",
776
};
777
static const char * const MatchClass_fields[]={
778
    "cls",
779
    "patterns",
780
    "kwd_attrs",
781
    "kwd_patterns",
782
};
783
static const char * const MatchStar_fields[]={
784
    "name",
785
};
786
static const char * const MatchAs_fields[]={
787
    "pattern",
788
    "name",
789
};
790
static const char * const MatchOr_fields[]={
791
    "patterns",
792
};
793
static PyObject* ast2obj_type_ignore(struct ast_state *state, void*);
794
static const char * const TypeIgnore_fields[]={
795
    "lineno",
796
    "tag",
797
};
798
static const char * const type_param_attributes[] = {
799
    "lineno",
800
    "col_offset",
801
    "end_lineno",
802
    "end_col_offset",
803
};
804
static PyObject* ast2obj_type_param(struct ast_state *state, void*);
805
static const char * const TypeVar_fields[]={
806
    "name",
807
    "bound",
808
    "default_value",
809
};
810
static const char * const ParamSpec_fields[]={
811
    "name",
812
    "default_value",
813
};
814
static const char * const TypeVarTuple_fields[]={
815
    "name",
816
    "default_value",
817
};
818
819
820
static int
821
add_ast_annotations(struct ast_state *state)
822
12
{
823
12
    bool cond;
824
12
    PyObject *Module_annotations = PyDict_New();
825
12
    if (!Module_annotations) return 0;
826
12
    {
827
12
        PyObject *type = state->stmt_type;
828
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
829
12
        cond = type != NULL;
830
12
        if (!cond) {
831
0
            Py_DECREF(Module_annotations);
832
0
            return 0;
833
0
        }
834
12
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
835
12
        Py_DECREF(type);
836
12
        if (!cond) {
837
0
            Py_DECREF(Module_annotations);
838
0
            return 0;
839
0
        }
840
12
    }
841
12
    {
842
12
        PyObject *type = state->type_ignore_type;
843
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
844
12
        cond = type != NULL;
845
12
        if (!cond) {
846
0
            Py_DECREF(Module_annotations);
847
0
            return 0;
848
0
        }
849
12
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
850
12
                                    == 0;
851
12
        Py_DECREF(type);
852
12
        if (!cond) {
853
0
            Py_DECREF(Module_annotations);
854
0
            return 0;
855
0
        }
856
12
    }
857
12
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
858
12
                                  Module_annotations) == 0;
859
12
    if (!cond) {
860
0
        Py_DECREF(Module_annotations);
861
0
        return 0;
862
0
    }
863
12
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
864
12
                                  Module_annotations) == 0;
865
12
    if (!cond) {
866
0
        Py_DECREF(Module_annotations);
867
0
        return 0;
868
0
    }
869
12
    Py_DECREF(Module_annotations);
870
12
    PyObject *Interactive_annotations = PyDict_New();
871
12
    if (!Interactive_annotations) return 0;
872
12
    {
873
12
        PyObject *type = state->stmt_type;
874
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
875
12
        cond = type != NULL;
876
12
        if (!cond) {
877
0
            Py_DECREF(Interactive_annotations);
878
0
            return 0;
879
0
        }
880
12
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
881
12
        Py_DECREF(type);
882
12
        if (!cond) {
883
0
            Py_DECREF(Interactive_annotations);
884
0
            return 0;
885
0
        }
886
12
    }
887
12
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
888
12
                                  Interactive_annotations) == 0;
889
12
    if (!cond) {
890
0
        Py_DECREF(Interactive_annotations);
891
0
        return 0;
892
0
    }
893
12
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
894
12
                                  Interactive_annotations) == 0;
895
12
    if (!cond) {
896
0
        Py_DECREF(Interactive_annotations);
897
0
        return 0;
898
0
    }
899
12
    Py_DECREF(Interactive_annotations);
900
12
    PyObject *Expression_annotations = PyDict_New();
901
12
    if (!Expression_annotations) return 0;
902
12
    {
903
12
        PyObject *type = state->expr_type;
904
12
        Py_INCREF(type);
905
12
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
906
12
        Py_DECREF(type);
907
12
        if (!cond) {
908
0
            Py_DECREF(Expression_annotations);
909
0
            return 0;
910
0
        }
911
12
    }
912
12
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
913
12
                                  Expression_annotations) == 0;
914
12
    if (!cond) {
915
0
        Py_DECREF(Expression_annotations);
916
0
        return 0;
917
0
    }
918
12
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
919
12
                                  Expression_annotations) == 0;
920
12
    if (!cond) {
921
0
        Py_DECREF(Expression_annotations);
922
0
        return 0;
923
0
    }
924
12
    Py_DECREF(Expression_annotations);
925
12
    PyObject *FunctionType_annotations = PyDict_New();
926
12
    if (!FunctionType_annotations) return 0;
927
12
    {
928
12
        PyObject *type = state->expr_type;
929
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
930
12
        cond = type != NULL;
931
12
        if (!cond) {
932
0
            Py_DECREF(FunctionType_annotations);
933
0
            return 0;
934
0
        }
935
12
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
936
12
                                    == 0;
937
12
        Py_DECREF(type);
938
12
        if (!cond) {
939
0
            Py_DECREF(FunctionType_annotations);
940
0
            return 0;
941
0
        }
942
12
    }
943
12
    {
944
12
        PyObject *type = state->expr_type;
945
12
        Py_INCREF(type);
946
12
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
947
12
                                    == 0;
948
12
        Py_DECREF(type);
949
12
        if (!cond) {
950
0
            Py_DECREF(FunctionType_annotations);
951
0
            return 0;
952
0
        }
953
12
    }
954
12
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
955
12
                                  FunctionType_annotations) == 0;
956
12
    if (!cond) {
957
0
        Py_DECREF(FunctionType_annotations);
958
0
        return 0;
959
0
    }
960
12
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
961
12
                                  FunctionType_annotations) == 0;
962
12
    if (!cond) {
963
0
        Py_DECREF(FunctionType_annotations);
964
0
        return 0;
965
0
    }
966
12
    Py_DECREF(FunctionType_annotations);
967
12
    PyObject *FunctionDef_annotations = PyDict_New();
968
12
    if (!FunctionDef_annotations) return 0;
969
12
    {
970
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
971
12
        Py_INCREF(type);
972
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
973
12
        Py_DECREF(type);
974
12
        if (!cond) {
975
0
            Py_DECREF(FunctionDef_annotations);
976
0
            return 0;
977
0
        }
978
12
    }
979
12
    {
980
12
        PyObject *type = state->arguments_type;
981
12
        Py_INCREF(type);
982
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
983
12
        Py_DECREF(type);
984
12
        if (!cond) {
985
0
            Py_DECREF(FunctionDef_annotations);
986
0
            return 0;
987
0
        }
988
12
    }
989
12
    {
990
12
        PyObject *type = state->stmt_type;
991
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
992
12
        cond = type != NULL;
993
12
        if (!cond) {
994
0
            Py_DECREF(FunctionDef_annotations);
995
0
            return 0;
996
0
        }
997
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
998
12
        Py_DECREF(type);
999
12
        if (!cond) {
1000
0
            Py_DECREF(FunctionDef_annotations);
1001
0
            return 0;
1002
0
        }
1003
12
    }
1004
12
    {
1005
12
        PyObject *type = state->expr_type;
1006
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1007
12
        cond = type != NULL;
1008
12
        if (!cond) {
1009
0
            Py_DECREF(FunctionDef_annotations);
1010
0
            return 0;
1011
0
        }
1012
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1013
12
                                    type) == 0;
1014
12
        Py_DECREF(type);
1015
12
        if (!cond) {
1016
0
            Py_DECREF(FunctionDef_annotations);
1017
0
            return 0;
1018
0
        }
1019
12
    }
1020
12
    {
1021
12
        PyObject *type = state->expr_type;
1022
12
        type = _Py_union_type_or(type, Py_None);
1023
12
        cond = type != NULL;
1024
12
        if (!cond) {
1025
0
            Py_DECREF(FunctionDef_annotations);
1026
0
            return 0;
1027
0
        }
1028
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1029
12
                                    == 0;
1030
12
        Py_DECREF(type);
1031
12
        if (!cond) {
1032
0
            Py_DECREF(FunctionDef_annotations);
1033
0
            return 0;
1034
0
        }
1035
12
    }
1036
12
    {
1037
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1038
12
        type = _Py_union_type_or(type, Py_None);
1039
12
        cond = type != NULL;
1040
12
        if (!cond) {
1041
0
            Py_DECREF(FunctionDef_annotations);
1042
0
            return 0;
1043
0
        }
1044
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1045
12
                                    type) == 0;
1046
12
        Py_DECREF(type);
1047
12
        if (!cond) {
1048
0
            Py_DECREF(FunctionDef_annotations);
1049
0
            return 0;
1050
0
        }
1051
12
    }
1052
12
    {
1053
12
        PyObject *type = state->type_param_type;
1054
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1055
12
        cond = type != NULL;
1056
12
        if (!cond) {
1057
0
            Py_DECREF(FunctionDef_annotations);
1058
0
            return 0;
1059
0
        }
1060
12
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1061
12
                                    type) == 0;
1062
12
        Py_DECREF(type);
1063
12
        if (!cond) {
1064
0
            Py_DECREF(FunctionDef_annotations);
1065
0
            return 0;
1066
0
        }
1067
12
    }
1068
12
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1069
12
                                  FunctionDef_annotations) == 0;
1070
12
    if (!cond) {
1071
0
        Py_DECREF(FunctionDef_annotations);
1072
0
        return 0;
1073
0
    }
1074
12
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1075
12
                                  FunctionDef_annotations) == 0;
1076
12
    if (!cond) {
1077
0
        Py_DECREF(FunctionDef_annotations);
1078
0
        return 0;
1079
0
    }
1080
12
    Py_DECREF(FunctionDef_annotations);
1081
12
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1082
12
    if (!AsyncFunctionDef_annotations) return 0;
1083
12
    {
1084
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1085
12
        Py_INCREF(type);
1086
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1087
12
                                    == 0;
1088
12
        Py_DECREF(type);
1089
12
        if (!cond) {
1090
0
            Py_DECREF(AsyncFunctionDef_annotations);
1091
0
            return 0;
1092
0
        }
1093
12
    }
1094
12
    {
1095
12
        PyObject *type = state->arguments_type;
1096
12
        Py_INCREF(type);
1097
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1098
12
                                    == 0;
1099
12
        Py_DECREF(type);
1100
12
        if (!cond) {
1101
0
            Py_DECREF(AsyncFunctionDef_annotations);
1102
0
            return 0;
1103
0
        }
1104
12
    }
1105
12
    {
1106
12
        PyObject *type = state->stmt_type;
1107
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1108
12
        cond = type != NULL;
1109
12
        if (!cond) {
1110
0
            Py_DECREF(AsyncFunctionDef_annotations);
1111
0
            return 0;
1112
0
        }
1113
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1114
12
                                    == 0;
1115
12
        Py_DECREF(type);
1116
12
        if (!cond) {
1117
0
            Py_DECREF(AsyncFunctionDef_annotations);
1118
0
            return 0;
1119
0
        }
1120
12
    }
1121
12
    {
1122
12
        PyObject *type = state->expr_type;
1123
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1124
12
        cond = type != NULL;
1125
12
        if (!cond) {
1126
0
            Py_DECREF(AsyncFunctionDef_annotations);
1127
0
            return 0;
1128
0
        }
1129
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1130
12
                                    "decorator_list", type) == 0;
1131
12
        Py_DECREF(type);
1132
12
        if (!cond) {
1133
0
            Py_DECREF(AsyncFunctionDef_annotations);
1134
0
            return 0;
1135
0
        }
1136
12
    }
1137
12
    {
1138
12
        PyObject *type = state->expr_type;
1139
12
        type = _Py_union_type_or(type, Py_None);
1140
12
        cond = type != NULL;
1141
12
        if (!cond) {
1142
0
            Py_DECREF(AsyncFunctionDef_annotations);
1143
0
            return 0;
1144
0
        }
1145
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1146
12
                                    type) == 0;
1147
12
        Py_DECREF(type);
1148
12
        if (!cond) {
1149
0
            Py_DECREF(AsyncFunctionDef_annotations);
1150
0
            return 0;
1151
0
        }
1152
12
    }
1153
12
    {
1154
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1155
12
        type = _Py_union_type_or(type, Py_None);
1156
12
        cond = type != NULL;
1157
12
        if (!cond) {
1158
0
            Py_DECREF(AsyncFunctionDef_annotations);
1159
0
            return 0;
1160
0
        }
1161
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1162
12
                                    "type_comment", type) == 0;
1163
12
        Py_DECREF(type);
1164
12
        if (!cond) {
1165
0
            Py_DECREF(AsyncFunctionDef_annotations);
1166
0
            return 0;
1167
0
        }
1168
12
    }
1169
12
    {
1170
12
        PyObject *type = state->type_param_type;
1171
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1172
12
        cond = type != NULL;
1173
12
        if (!cond) {
1174
0
            Py_DECREF(AsyncFunctionDef_annotations);
1175
0
            return 0;
1176
0
        }
1177
12
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1178
12
                                    "type_params", type) == 0;
1179
12
        Py_DECREF(type);
1180
12
        if (!cond) {
1181
0
            Py_DECREF(AsyncFunctionDef_annotations);
1182
0
            return 0;
1183
0
        }
1184
12
    }
1185
12
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1186
12
                                  AsyncFunctionDef_annotations) == 0;
1187
12
    if (!cond) {
1188
0
        Py_DECREF(AsyncFunctionDef_annotations);
1189
0
        return 0;
1190
0
    }
1191
12
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1192
12
                                  "__annotations__",
1193
12
                                  AsyncFunctionDef_annotations) == 0;
1194
12
    if (!cond) {
1195
0
        Py_DECREF(AsyncFunctionDef_annotations);
1196
0
        return 0;
1197
0
    }
1198
12
    Py_DECREF(AsyncFunctionDef_annotations);
1199
12
    PyObject *ClassDef_annotations = PyDict_New();
1200
12
    if (!ClassDef_annotations) return 0;
1201
12
    {
1202
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1203
12
        Py_INCREF(type);
1204
12
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1205
12
        Py_DECREF(type);
1206
12
        if (!cond) {
1207
0
            Py_DECREF(ClassDef_annotations);
1208
0
            return 0;
1209
0
        }
1210
12
    }
1211
12
    {
1212
12
        PyObject *type = state->expr_type;
1213
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1214
12
        cond = type != NULL;
1215
12
        if (!cond) {
1216
0
            Py_DECREF(ClassDef_annotations);
1217
0
            return 0;
1218
0
        }
1219
12
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1220
12
        Py_DECREF(type);
1221
12
        if (!cond) {
1222
0
            Py_DECREF(ClassDef_annotations);
1223
0
            return 0;
1224
0
        }
1225
12
    }
1226
12
    {
1227
12
        PyObject *type = state->keyword_type;
1228
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1229
12
        cond = type != NULL;
1230
12
        if (!cond) {
1231
0
            Py_DECREF(ClassDef_annotations);
1232
0
            return 0;
1233
0
        }
1234
12
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1235
12
                                    0;
1236
12
        Py_DECREF(type);
1237
12
        if (!cond) {
1238
0
            Py_DECREF(ClassDef_annotations);
1239
0
            return 0;
1240
0
        }
1241
12
    }
1242
12
    {
1243
12
        PyObject *type = state->stmt_type;
1244
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1245
12
        cond = type != NULL;
1246
12
        if (!cond) {
1247
0
            Py_DECREF(ClassDef_annotations);
1248
0
            return 0;
1249
0
        }
1250
12
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1251
12
        Py_DECREF(type);
1252
12
        if (!cond) {
1253
0
            Py_DECREF(ClassDef_annotations);
1254
0
            return 0;
1255
0
        }
1256
12
    }
1257
12
    {
1258
12
        PyObject *type = state->expr_type;
1259
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1260
12
        cond = type != NULL;
1261
12
        if (!cond) {
1262
0
            Py_DECREF(ClassDef_annotations);
1263
0
            return 0;
1264
0
        }
1265
12
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1266
12
                                    type) == 0;
1267
12
        Py_DECREF(type);
1268
12
        if (!cond) {
1269
0
            Py_DECREF(ClassDef_annotations);
1270
0
            return 0;
1271
0
        }
1272
12
    }
1273
12
    {
1274
12
        PyObject *type = state->type_param_type;
1275
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1276
12
        cond = type != NULL;
1277
12
        if (!cond) {
1278
0
            Py_DECREF(ClassDef_annotations);
1279
0
            return 0;
1280
0
        }
1281
12
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1282
12
                                    == 0;
1283
12
        Py_DECREF(type);
1284
12
        if (!cond) {
1285
0
            Py_DECREF(ClassDef_annotations);
1286
0
            return 0;
1287
0
        }
1288
12
    }
1289
12
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1290
12
                                  ClassDef_annotations) == 0;
1291
12
    if (!cond) {
1292
0
        Py_DECREF(ClassDef_annotations);
1293
0
        return 0;
1294
0
    }
1295
12
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1296
12
                                  ClassDef_annotations) == 0;
1297
12
    if (!cond) {
1298
0
        Py_DECREF(ClassDef_annotations);
1299
0
        return 0;
1300
0
    }
1301
12
    Py_DECREF(ClassDef_annotations);
1302
12
    PyObject *Return_annotations = PyDict_New();
1303
12
    if (!Return_annotations) return 0;
1304
12
    {
1305
12
        PyObject *type = state->expr_type;
1306
12
        type = _Py_union_type_or(type, Py_None);
1307
12
        cond = type != NULL;
1308
12
        if (!cond) {
1309
0
            Py_DECREF(Return_annotations);
1310
0
            return 0;
1311
0
        }
1312
12
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1313
12
        Py_DECREF(type);
1314
12
        if (!cond) {
1315
0
            Py_DECREF(Return_annotations);
1316
0
            return 0;
1317
0
        }
1318
12
    }
1319
12
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1320
12
                                  Return_annotations) == 0;
1321
12
    if (!cond) {
1322
0
        Py_DECREF(Return_annotations);
1323
0
        return 0;
1324
0
    }
1325
12
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1326
12
                                  Return_annotations) == 0;
1327
12
    if (!cond) {
1328
0
        Py_DECREF(Return_annotations);
1329
0
        return 0;
1330
0
    }
1331
12
    Py_DECREF(Return_annotations);
1332
12
    PyObject *Delete_annotations = PyDict_New();
1333
12
    if (!Delete_annotations) return 0;
1334
12
    {
1335
12
        PyObject *type = state->expr_type;
1336
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1337
12
        cond = type != NULL;
1338
12
        if (!cond) {
1339
0
            Py_DECREF(Delete_annotations);
1340
0
            return 0;
1341
0
        }
1342
12
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1343
12
        Py_DECREF(type);
1344
12
        if (!cond) {
1345
0
            Py_DECREF(Delete_annotations);
1346
0
            return 0;
1347
0
        }
1348
12
    }
1349
12
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1350
12
                                  Delete_annotations) == 0;
1351
12
    if (!cond) {
1352
0
        Py_DECREF(Delete_annotations);
1353
0
        return 0;
1354
0
    }
1355
12
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1356
12
                                  Delete_annotations) == 0;
1357
12
    if (!cond) {
1358
0
        Py_DECREF(Delete_annotations);
1359
0
        return 0;
1360
0
    }
1361
12
    Py_DECREF(Delete_annotations);
1362
12
    PyObject *Assign_annotations = PyDict_New();
1363
12
    if (!Assign_annotations) return 0;
1364
12
    {
1365
12
        PyObject *type = state->expr_type;
1366
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1367
12
        cond = type != NULL;
1368
12
        if (!cond) {
1369
0
            Py_DECREF(Assign_annotations);
1370
0
            return 0;
1371
0
        }
1372
12
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1373
12
        Py_DECREF(type);
1374
12
        if (!cond) {
1375
0
            Py_DECREF(Assign_annotations);
1376
0
            return 0;
1377
0
        }
1378
12
    }
1379
12
    {
1380
12
        PyObject *type = state->expr_type;
1381
12
        Py_INCREF(type);
1382
12
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1383
12
        Py_DECREF(type);
1384
12
        if (!cond) {
1385
0
            Py_DECREF(Assign_annotations);
1386
0
            return 0;
1387
0
        }
1388
12
    }
1389
12
    {
1390
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1391
12
        type = _Py_union_type_or(type, Py_None);
1392
12
        cond = type != NULL;
1393
12
        if (!cond) {
1394
0
            Py_DECREF(Assign_annotations);
1395
0
            return 0;
1396
0
        }
1397
12
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1398
12
                                    == 0;
1399
12
        Py_DECREF(type);
1400
12
        if (!cond) {
1401
0
            Py_DECREF(Assign_annotations);
1402
0
            return 0;
1403
0
        }
1404
12
    }
1405
12
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1406
12
                                  Assign_annotations) == 0;
1407
12
    if (!cond) {
1408
0
        Py_DECREF(Assign_annotations);
1409
0
        return 0;
1410
0
    }
1411
12
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1412
12
                                  Assign_annotations) == 0;
1413
12
    if (!cond) {
1414
0
        Py_DECREF(Assign_annotations);
1415
0
        return 0;
1416
0
    }
1417
12
    Py_DECREF(Assign_annotations);
1418
12
    PyObject *TypeAlias_annotations = PyDict_New();
1419
12
    if (!TypeAlias_annotations) return 0;
1420
12
    {
1421
12
        PyObject *type = state->expr_type;
1422
12
        Py_INCREF(type);
1423
12
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1424
12
        Py_DECREF(type);
1425
12
        if (!cond) {
1426
0
            Py_DECREF(TypeAlias_annotations);
1427
0
            return 0;
1428
0
        }
1429
12
    }
1430
12
    {
1431
12
        PyObject *type = state->type_param_type;
1432
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1433
12
        cond = type != NULL;
1434
12
        if (!cond) {
1435
0
            Py_DECREF(TypeAlias_annotations);
1436
0
            return 0;
1437
0
        }
1438
12
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1439
12
                                    == 0;
1440
12
        Py_DECREF(type);
1441
12
        if (!cond) {
1442
0
            Py_DECREF(TypeAlias_annotations);
1443
0
            return 0;
1444
0
        }
1445
12
    }
1446
12
    {
1447
12
        PyObject *type = state->expr_type;
1448
12
        Py_INCREF(type);
1449
12
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1450
12
        Py_DECREF(type);
1451
12
        if (!cond) {
1452
0
            Py_DECREF(TypeAlias_annotations);
1453
0
            return 0;
1454
0
        }
1455
12
    }
1456
12
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1457
12
                                  TypeAlias_annotations) == 0;
1458
12
    if (!cond) {
1459
0
        Py_DECREF(TypeAlias_annotations);
1460
0
        return 0;
1461
0
    }
1462
12
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1463
12
                                  TypeAlias_annotations) == 0;
1464
12
    if (!cond) {
1465
0
        Py_DECREF(TypeAlias_annotations);
1466
0
        return 0;
1467
0
    }
1468
12
    Py_DECREF(TypeAlias_annotations);
1469
12
    PyObject *AugAssign_annotations = PyDict_New();
1470
12
    if (!AugAssign_annotations) return 0;
1471
12
    {
1472
12
        PyObject *type = state->expr_type;
1473
12
        Py_INCREF(type);
1474
12
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1475
12
        Py_DECREF(type);
1476
12
        if (!cond) {
1477
0
            Py_DECREF(AugAssign_annotations);
1478
0
            return 0;
1479
0
        }
1480
12
    }
1481
12
    {
1482
12
        PyObject *type = state->operator_type;
1483
12
        Py_INCREF(type);
1484
12
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1485
12
        Py_DECREF(type);
1486
12
        if (!cond) {
1487
0
            Py_DECREF(AugAssign_annotations);
1488
0
            return 0;
1489
0
        }
1490
12
    }
1491
12
    {
1492
12
        PyObject *type = state->expr_type;
1493
12
        Py_INCREF(type);
1494
12
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1495
12
        Py_DECREF(type);
1496
12
        if (!cond) {
1497
0
            Py_DECREF(AugAssign_annotations);
1498
0
            return 0;
1499
0
        }
1500
12
    }
1501
12
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1502
12
                                  AugAssign_annotations) == 0;
1503
12
    if (!cond) {
1504
0
        Py_DECREF(AugAssign_annotations);
1505
0
        return 0;
1506
0
    }
1507
12
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1508
12
                                  AugAssign_annotations) == 0;
1509
12
    if (!cond) {
1510
0
        Py_DECREF(AugAssign_annotations);
1511
0
        return 0;
1512
0
    }
1513
12
    Py_DECREF(AugAssign_annotations);
1514
12
    PyObject *AnnAssign_annotations = PyDict_New();
1515
12
    if (!AnnAssign_annotations) return 0;
1516
12
    {
1517
12
        PyObject *type = state->expr_type;
1518
12
        Py_INCREF(type);
1519
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1520
12
        Py_DECREF(type);
1521
12
        if (!cond) {
1522
0
            Py_DECREF(AnnAssign_annotations);
1523
0
            return 0;
1524
0
        }
1525
12
    }
1526
12
    {
1527
12
        PyObject *type = state->expr_type;
1528
12
        Py_INCREF(type);
1529
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1530
12
                                    == 0;
1531
12
        Py_DECREF(type);
1532
12
        if (!cond) {
1533
0
            Py_DECREF(AnnAssign_annotations);
1534
0
            return 0;
1535
0
        }
1536
12
    }
1537
12
    {
1538
12
        PyObject *type = state->expr_type;
1539
12
        type = _Py_union_type_or(type, Py_None);
1540
12
        cond = type != NULL;
1541
12
        if (!cond) {
1542
0
            Py_DECREF(AnnAssign_annotations);
1543
0
            return 0;
1544
0
        }
1545
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1546
12
        Py_DECREF(type);
1547
12
        if (!cond) {
1548
0
            Py_DECREF(AnnAssign_annotations);
1549
0
            return 0;
1550
0
        }
1551
12
    }
1552
12
    {
1553
12
        PyObject *type = (PyObject *)&PyLong_Type;
1554
12
        Py_INCREF(type);
1555
12
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1556
12
        Py_DECREF(type);
1557
12
        if (!cond) {
1558
0
            Py_DECREF(AnnAssign_annotations);
1559
0
            return 0;
1560
0
        }
1561
12
    }
1562
12
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1563
12
                                  AnnAssign_annotations) == 0;
1564
12
    if (!cond) {
1565
0
        Py_DECREF(AnnAssign_annotations);
1566
0
        return 0;
1567
0
    }
1568
12
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1569
12
                                  AnnAssign_annotations) == 0;
1570
12
    if (!cond) {
1571
0
        Py_DECREF(AnnAssign_annotations);
1572
0
        return 0;
1573
0
    }
1574
12
    Py_DECREF(AnnAssign_annotations);
1575
12
    PyObject *For_annotations = PyDict_New();
1576
12
    if (!For_annotations) return 0;
1577
12
    {
1578
12
        PyObject *type = state->expr_type;
1579
12
        Py_INCREF(type);
1580
12
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1581
12
        Py_DECREF(type);
1582
12
        if (!cond) {
1583
0
            Py_DECREF(For_annotations);
1584
0
            return 0;
1585
0
        }
1586
12
    }
1587
12
    {
1588
12
        PyObject *type = state->expr_type;
1589
12
        Py_INCREF(type);
1590
12
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1591
12
        Py_DECREF(type);
1592
12
        if (!cond) {
1593
0
            Py_DECREF(For_annotations);
1594
0
            return 0;
1595
0
        }
1596
12
    }
1597
12
    {
1598
12
        PyObject *type = state->stmt_type;
1599
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1600
12
        cond = type != NULL;
1601
12
        if (!cond) {
1602
0
            Py_DECREF(For_annotations);
1603
0
            return 0;
1604
0
        }
1605
12
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1606
12
        Py_DECREF(type);
1607
12
        if (!cond) {
1608
0
            Py_DECREF(For_annotations);
1609
0
            return 0;
1610
0
        }
1611
12
    }
1612
12
    {
1613
12
        PyObject *type = state->stmt_type;
1614
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1615
12
        cond = type != NULL;
1616
12
        if (!cond) {
1617
0
            Py_DECREF(For_annotations);
1618
0
            return 0;
1619
0
        }
1620
12
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1621
12
        Py_DECREF(type);
1622
12
        if (!cond) {
1623
0
            Py_DECREF(For_annotations);
1624
0
            return 0;
1625
0
        }
1626
12
    }
1627
12
    {
1628
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1629
12
        type = _Py_union_type_or(type, Py_None);
1630
12
        cond = type != NULL;
1631
12
        if (!cond) {
1632
0
            Py_DECREF(For_annotations);
1633
0
            return 0;
1634
0
        }
1635
12
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1636
12
        Py_DECREF(type);
1637
12
        if (!cond) {
1638
0
            Py_DECREF(For_annotations);
1639
0
            return 0;
1640
0
        }
1641
12
    }
1642
12
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1643
12
                                  For_annotations) == 0;
1644
12
    if (!cond) {
1645
0
        Py_DECREF(For_annotations);
1646
0
        return 0;
1647
0
    }
1648
12
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1649
12
                                  For_annotations) == 0;
1650
12
    if (!cond) {
1651
0
        Py_DECREF(For_annotations);
1652
0
        return 0;
1653
0
    }
1654
12
    Py_DECREF(For_annotations);
1655
12
    PyObject *AsyncFor_annotations = PyDict_New();
1656
12
    if (!AsyncFor_annotations) return 0;
1657
12
    {
1658
12
        PyObject *type = state->expr_type;
1659
12
        Py_INCREF(type);
1660
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1661
12
        Py_DECREF(type);
1662
12
        if (!cond) {
1663
0
            Py_DECREF(AsyncFor_annotations);
1664
0
            return 0;
1665
0
        }
1666
12
    }
1667
12
    {
1668
12
        PyObject *type = state->expr_type;
1669
12
        Py_INCREF(type);
1670
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1671
12
        Py_DECREF(type);
1672
12
        if (!cond) {
1673
0
            Py_DECREF(AsyncFor_annotations);
1674
0
            return 0;
1675
0
        }
1676
12
    }
1677
12
    {
1678
12
        PyObject *type = state->stmt_type;
1679
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1680
12
        cond = type != NULL;
1681
12
        if (!cond) {
1682
0
            Py_DECREF(AsyncFor_annotations);
1683
0
            return 0;
1684
0
        }
1685
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1686
12
        Py_DECREF(type);
1687
12
        if (!cond) {
1688
0
            Py_DECREF(AsyncFor_annotations);
1689
0
            return 0;
1690
0
        }
1691
12
    }
1692
12
    {
1693
12
        PyObject *type = state->stmt_type;
1694
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1695
12
        cond = type != NULL;
1696
12
        if (!cond) {
1697
0
            Py_DECREF(AsyncFor_annotations);
1698
0
            return 0;
1699
0
        }
1700
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1701
12
        Py_DECREF(type);
1702
12
        if (!cond) {
1703
0
            Py_DECREF(AsyncFor_annotations);
1704
0
            return 0;
1705
0
        }
1706
12
    }
1707
12
    {
1708
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1709
12
        type = _Py_union_type_or(type, Py_None);
1710
12
        cond = type != NULL;
1711
12
        if (!cond) {
1712
0
            Py_DECREF(AsyncFor_annotations);
1713
0
            return 0;
1714
0
        }
1715
12
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1716
12
                                    == 0;
1717
12
        Py_DECREF(type);
1718
12
        if (!cond) {
1719
0
            Py_DECREF(AsyncFor_annotations);
1720
0
            return 0;
1721
0
        }
1722
12
    }
1723
12
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1724
12
                                  AsyncFor_annotations) == 0;
1725
12
    if (!cond) {
1726
0
        Py_DECREF(AsyncFor_annotations);
1727
0
        return 0;
1728
0
    }
1729
12
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1730
12
                                  AsyncFor_annotations) == 0;
1731
12
    if (!cond) {
1732
0
        Py_DECREF(AsyncFor_annotations);
1733
0
        return 0;
1734
0
    }
1735
12
    Py_DECREF(AsyncFor_annotations);
1736
12
    PyObject *While_annotations = PyDict_New();
1737
12
    if (!While_annotations) return 0;
1738
12
    {
1739
12
        PyObject *type = state->expr_type;
1740
12
        Py_INCREF(type);
1741
12
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1742
12
        Py_DECREF(type);
1743
12
        if (!cond) {
1744
0
            Py_DECREF(While_annotations);
1745
0
            return 0;
1746
0
        }
1747
12
    }
1748
12
    {
1749
12
        PyObject *type = state->stmt_type;
1750
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1751
12
        cond = type != NULL;
1752
12
        if (!cond) {
1753
0
            Py_DECREF(While_annotations);
1754
0
            return 0;
1755
0
        }
1756
12
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1757
12
        Py_DECREF(type);
1758
12
        if (!cond) {
1759
0
            Py_DECREF(While_annotations);
1760
0
            return 0;
1761
0
        }
1762
12
    }
1763
12
    {
1764
12
        PyObject *type = state->stmt_type;
1765
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1766
12
        cond = type != NULL;
1767
12
        if (!cond) {
1768
0
            Py_DECREF(While_annotations);
1769
0
            return 0;
1770
0
        }
1771
12
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1772
12
        Py_DECREF(type);
1773
12
        if (!cond) {
1774
0
            Py_DECREF(While_annotations);
1775
0
            return 0;
1776
0
        }
1777
12
    }
1778
12
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1779
12
                                  While_annotations) == 0;
1780
12
    if (!cond) {
1781
0
        Py_DECREF(While_annotations);
1782
0
        return 0;
1783
0
    }
1784
12
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1785
12
                                  While_annotations) == 0;
1786
12
    if (!cond) {
1787
0
        Py_DECREF(While_annotations);
1788
0
        return 0;
1789
0
    }
1790
12
    Py_DECREF(While_annotations);
1791
12
    PyObject *If_annotations = PyDict_New();
1792
12
    if (!If_annotations) return 0;
1793
12
    {
1794
12
        PyObject *type = state->expr_type;
1795
12
        Py_INCREF(type);
1796
12
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1797
12
        Py_DECREF(type);
1798
12
        if (!cond) {
1799
0
            Py_DECREF(If_annotations);
1800
0
            return 0;
1801
0
        }
1802
12
    }
1803
12
    {
1804
12
        PyObject *type = state->stmt_type;
1805
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1806
12
        cond = type != NULL;
1807
12
        if (!cond) {
1808
0
            Py_DECREF(If_annotations);
1809
0
            return 0;
1810
0
        }
1811
12
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1812
12
        Py_DECREF(type);
1813
12
        if (!cond) {
1814
0
            Py_DECREF(If_annotations);
1815
0
            return 0;
1816
0
        }
1817
12
    }
1818
12
    {
1819
12
        PyObject *type = state->stmt_type;
1820
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1821
12
        cond = type != NULL;
1822
12
        if (!cond) {
1823
0
            Py_DECREF(If_annotations);
1824
0
            return 0;
1825
0
        }
1826
12
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1827
12
        Py_DECREF(type);
1828
12
        if (!cond) {
1829
0
            Py_DECREF(If_annotations);
1830
0
            return 0;
1831
0
        }
1832
12
    }
1833
12
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1834
12
                                  If_annotations) == 0;
1835
12
    if (!cond) {
1836
0
        Py_DECREF(If_annotations);
1837
0
        return 0;
1838
0
    }
1839
12
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1840
12
                                  If_annotations) == 0;
1841
12
    if (!cond) {
1842
0
        Py_DECREF(If_annotations);
1843
0
        return 0;
1844
0
    }
1845
12
    Py_DECREF(If_annotations);
1846
12
    PyObject *With_annotations = PyDict_New();
1847
12
    if (!With_annotations) return 0;
1848
12
    {
1849
12
        PyObject *type = state->withitem_type;
1850
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1851
12
        cond = type != NULL;
1852
12
        if (!cond) {
1853
0
            Py_DECREF(With_annotations);
1854
0
            return 0;
1855
0
        }
1856
12
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1857
12
        Py_DECREF(type);
1858
12
        if (!cond) {
1859
0
            Py_DECREF(With_annotations);
1860
0
            return 0;
1861
0
        }
1862
12
    }
1863
12
    {
1864
12
        PyObject *type = state->stmt_type;
1865
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1866
12
        cond = type != NULL;
1867
12
        if (!cond) {
1868
0
            Py_DECREF(With_annotations);
1869
0
            return 0;
1870
0
        }
1871
12
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1872
12
        Py_DECREF(type);
1873
12
        if (!cond) {
1874
0
            Py_DECREF(With_annotations);
1875
0
            return 0;
1876
0
        }
1877
12
    }
1878
12
    {
1879
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1880
12
        type = _Py_union_type_or(type, Py_None);
1881
12
        cond = type != NULL;
1882
12
        if (!cond) {
1883
0
            Py_DECREF(With_annotations);
1884
0
            return 0;
1885
0
        }
1886
12
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1887
12
                                    0;
1888
12
        Py_DECREF(type);
1889
12
        if (!cond) {
1890
0
            Py_DECREF(With_annotations);
1891
0
            return 0;
1892
0
        }
1893
12
    }
1894
12
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1895
12
                                  With_annotations) == 0;
1896
12
    if (!cond) {
1897
0
        Py_DECREF(With_annotations);
1898
0
        return 0;
1899
0
    }
1900
12
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1901
12
                                  With_annotations) == 0;
1902
12
    if (!cond) {
1903
0
        Py_DECREF(With_annotations);
1904
0
        return 0;
1905
0
    }
1906
12
    Py_DECREF(With_annotations);
1907
12
    PyObject *AsyncWith_annotations = PyDict_New();
1908
12
    if (!AsyncWith_annotations) return 0;
1909
12
    {
1910
12
        PyObject *type = state->withitem_type;
1911
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1912
12
        cond = type != NULL;
1913
12
        if (!cond) {
1914
0
            Py_DECREF(AsyncWith_annotations);
1915
0
            return 0;
1916
0
        }
1917
12
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1918
12
        Py_DECREF(type);
1919
12
        if (!cond) {
1920
0
            Py_DECREF(AsyncWith_annotations);
1921
0
            return 0;
1922
0
        }
1923
12
    }
1924
12
    {
1925
12
        PyObject *type = state->stmt_type;
1926
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1927
12
        cond = type != NULL;
1928
12
        if (!cond) {
1929
0
            Py_DECREF(AsyncWith_annotations);
1930
0
            return 0;
1931
0
        }
1932
12
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1933
12
        Py_DECREF(type);
1934
12
        if (!cond) {
1935
0
            Py_DECREF(AsyncWith_annotations);
1936
0
            return 0;
1937
0
        }
1938
12
    }
1939
12
    {
1940
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
1941
12
        type = _Py_union_type_or(type, Py_None);
1942
12
        cond = type != NULL;
1943
12
        if (!cond) {
1944
0
            Py_DECREF(AsyncWith_annotations);
1945
0
            return 0;
1946
0
        }
1947
12
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1948
12
                                    type) == 0;
1949
12
        Py_DECREF(type);
1950
12
        if (!cond) {
1951
0
            Py_DECREF(AsyncWith_annotations);
1952
0
            return 0;
1953
0
        }
1954
12
    }
1955
12
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1956
12
                                  AsyncWith_annotations) == 0;
1957
12
    if (!cond) {
1958
0
        Py_DECREF(AsyncWith_annotations);
1959
0
        return 0;
1960
0
    }
1961
12
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1962
12
                                  AsyncWith_annotations) == 0;
1963
12
    if (!cond) {
1964
0
        Py_DECREF(AsyncWith_annotations);
1965
0
        return 0;
1966
0
    }
1967
12
    Py_DECREF(AsyncWith_annotations);
1968
12
    PyObject *Match_annotations = PyDict_New();
1969
12
    if (!Match_annotations) return 0;
1970
12
    {
1971
12
        PyObject *type = state->expr_type;
1972
12
        Py_INCREF(type);
1973
12
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1974
12
        Py_DECREF(type);
1975
12
        if (!cond) {
1976
0
            Py_DECREF(Match_annotations);
1977
0
            return 0;
1978
0
        }
1979
12
    }
1980
12
    {
1981
12
        PyObject *type = state->match_case_type;
1982
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1983
12
        cond = type != NULL;
1984
12
        if (!cond) {
1985
0
            Py_DECREF(Match_annotations);
1986
0
            return 0;
1987
0
        }
1988
12
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1989
12
        Py_DECREF(type);
1990
12
        if (!cond) {
1991
0
            Py_DECREF(Match_annotations);
1992
0
            return 0;
1993
0
        }
1994
12
    }
1995
12
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1996
12
                                  Match_annotations) == 0;
1997
12
    if (!cond) {
1998
0
        Py_DECREF(Match_annotations);
1999
0
        return 0;
2000
0
    }
2001
12
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
2002
12
                                  Match_annotations) == 0;
2003
12
    if (!cond) {
2004
0
        Py_DECREF(Match_annotations);
2005
0
        return 0;
2006
0
    }
2007
12
    Py_DECREF(Match_annotations);
2008
12
    PyObject *Raise_annotations = PyDict_New();
2009
12
    if (!Raise_annotations) return 0;
2010
12
    {
2011
12
        PyObject *type = state->expr_type;
2012
12
        type = _Py_union_type_or(type, Py_None);
2013
12
        cond = type != NULL;
2014
12
        if (!cond) {
2015
0
            Py_DECREF(Raise_annotations);
2016
0
            return 0;
2017
0
        }
2018
12
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2019
12
        Py_DECREF(type);
2020
12
        if (!cond) {
2021
0
            Py_DECREF(Raise_annotations);
2022
0
            return 0;
2023
0
        }
2024
12
    }
2025
12
    {
2026
12
        PyObject *type = state->expr_type;
2027
12
        type = _Py_union_type_or(type, Py_None);
2028
12
        cond = type != NULL;
2029
12
        if (!cond) {
2030
0
            Py_DECREF(Raise_annotations);
2031
0
            return 0;
2032
0
        }
2033
12
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2034
12
        Py_DECREF(type);
2035
12
        if (!cond) {
2036
0
            Py_DECREF(Raise_annotations);
2037
0
            return 0;
2038
0
        }
2039
12
    }
2040
12
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2041
12
                                  Raise_annotations) == 0;
2042
12
    if (!cond) {
2043
0
        Py_DECREF(Raise_annotations);
2044
0
        return 0;
2045
0
    }
2046
12
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2047
12
                                  Raise_annotations) == 0;
2048
12
    if (!cond) {
2049
0
        Py_DECREF(Raise_annotations);
2050
0
        return 0;
2051
0
    }
2052
12
    Py_DECREF(Raise_annotations);
2053
12
    PyObject *Try_annotations = PyDict_New();
2054
12
    if (!Try_annotations) return 0;
2055
12
    {
2056
12
        PyObject *type = state->stmt_type;
2057
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2058
12
        cond = type != NULL;
2059
12
        if (!cond) {
2060
0
            Py_DECREF(Try_annotations);
2061
0
            return 0;
2062
0
        }
2063
12
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2064
12
        Py_DECREF(type);
2065
12
        if (!cond) {
2066
0
            Py_DECREF(Try_annotations);
2067
0
            return 0;
2068
0
        }
2069
12
    }
2070
12
    {
2071
12
        PyObject *type = state->excepthandler_type;
2072
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2073
12
        cond = type != NULL;
2074
12
        if (!cond) {
2075
0
            Py_DECREF(Try_annotations);
2076
0
            return 0;
2077
0
        }
2078
12
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2079
12
        Py_DECREF(type);
2080
12
        if (!cond) {
2081
0
            Py_DECREF(Try_annotations);
2082
0
            return 0;
2083
0
        }
2084
12
    }
2085
12
    {
2086
12
        PyObject *type = state->stmt_type;
2087
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2088
12
        cond = type != NULL;
2089
12
        if (!cond) {
2090
0
            Py_DECREF(Try_annotations);
2091
0
            return 0;
2092
0
        }
2093
12
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2094
12
        Py_DECREF(type);
2095
12
        if (!cond) {
2096
0
            Py_DECREF(Try_annotations);
2097
0
            return 0;
2098
0
        }
2099
12
    }
2100
12
    {
2101
12
        PyObject *type = state->stmt_type;
2102
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2103
12
        cond = type != NULL;
2104
12
        if (!cond) {
2105
0
            Py_DECREF(Try_annotations);
2106
0
            return 0;
2107
0
        }
2108
12
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2109
12
        Py_DECREF(type);
2110
12
        if (!cond) {
2111
0
            Py_DECREF(Try_annotations);
2112
0
            return 0;
2113
0
        }
2114
12
    }
2115
12
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2116
12
                                  Try_annotations) == 0;
2117
12
    if (!cond) {
2118
0
        Py_DECREF(Try_annotations);
2119
0
        return 0;
2120
0
    }
2121
12
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2122
12
                                  Try_annotations) == 0;
2123
12
    if (!cond) {
2124
0
        Py_DECREF(Try_annotations);
2125
0
        return 0;
2126
0
    }
2127
12
    Py_DECREF(Try_annotations);
2128
12
    PyObject *TryStar_annotations = PyDict_New();
2129
12
    if (!TryStar_annotations) return 0;
2130
12
    {
2131
12
        PyObject *type = state->stmt_type;
2132
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2133
12
        cond = type != NULL;
2134
12
        if (!cond) {
2135
0
            Py_DECREF(TryStar_annotations);
2136
0
            return 0;
2137
0
        }
2138
12
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2139
12
        Py_DECREF(type);
2140
12
        if (!cond) {
2141
0
            Py_DECREF(TryStar_annotations);
2142
0
            return 0;
2143
0
        }
2144
12
    }
2145
12
    {
2146
12
        PyObject *type = state->excepthandler_type;
2147
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2148
12
        cond = type != NULL;
2149
12
        if (!cond) {
2150
0
            Py_DECREF(TryStar_annotations);
2151
0
            return 0;
2152
0
        }
2153
12
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2154
12
        Py_DECREF(type);
2155
12
        if (!cond) {
2156
0
            Py_DECREF(TryStar_annotations);
2157
0
            return 0;
2158
0
        }
2159
12
    }
2160
12
    {
2161
12
        PyObject *type = state->stmt_type;
2162
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2163
12
        cond = type != NULL;
2164
12
        if (!cond) {
2165
0
            Py_DECREF(TryStar_annotations);
2166
0
            return 0;
2167
0
        }
2168
12
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2169
12
        Py_DECREF(type);
2170
12
        if (!cond) {
2171
0
            Py_DECREF(TryStar_annotations);
2172
0
            return 0;
2173
0
        }
2174
12
    }
2175
12
    {
2176
12
        PyObject *type = state->stmt_type;
2177
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2178
12
        cond = type != NULL;
2179
12
        if (!cond) {
2180
0
            Py_DECREF(TryStar_annotations);
2181
0
            return 0;
2182
0
        }
2183
12
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2184
12
                                    0;
2185
12
        Py_DECREF(type);
2186
12
        if (!cond) {
2187
0
            Py_DECREF(TryStar_annotations);
2188
0
            return 0;
2189
0
        }
2190
12
    }
2191
12
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2192
12
                                  TryStar_annotations) == 0;
2193
12
    if (!cond) {
2194
0
        Py_DECREF(TryStar_annotations);
2195
0
        return 0;
2196
0
    }
2197
12
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2198
12
                                  TryStar_annotations) == 0;
2199
12
    if (!cond) {
2200
0
        Py_DECREF(TryStar_annotations);
2201
0
        return 0;
2202
0
    }
2203
12
    Py_DECREF(TryStar_annotations);
2204
12
    PyObject *Assert_annotations = PyDict_New();
2205
12
    if (!Assert_annotations) return 0;
2206
12
    {
2207
12
        PyObject *type = state->expr_type;
2208
12
        Py_INCREF(type);
2209
12
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2210
12
        Py_DECREF(type);
2211
12
        if (!cond) {
2212
0
            Py_DECREF(Assert_annotations);
2213
0
            return 0;
2214
0
        }
2215
12
    }
2216
12
    {
2217
12
        PyObject *type = state->expr_type;
2218
12
        type = _Py_union_type_or(type, Py_None);
2219
12
        cond = type != NULL;
2220
12
        if (!cond) {
2221
0
            Py_DECREF(Assert_annotations);
2222
0
            return 0;
2223
0
        }
2224
12
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2225
12
        Py_DECREF(type);
2226
12
        if (!cond) {
2227
0
            Py_DECREF(Assert_annotations);
2228
0
            return 0;
2229
0
        }
2230
12
    }
2231
12
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2232
12
                                  Assert_annotations) == 0;
2233
12
    if (!cond) {
2234
0
        Py_DECREF(Assert_annotations);
2235
0
        return 0;
2236
0
    }
2237
12
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2238
12
                                  Assert_annotations) == 0;
2239
12
    if (!cond) {
2240
0
        Py_DECREF(Assert_annotations);
2241
0
        return 0;
2242
0
    }
2243
12
    Py_DECREF(Assert_annotations);
2244
12
    PyObject *Import_annotations = PyDict_New();
2245
12
    if (!Import_annotations) return 0;
2246
12
    {
2247
12
        PyObject *type = state->alias_type;
2248
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2249
12
        cond = type != NULL;
2250
12
        if (!cond) {
2251
0
            Py_DECREF(Import_annotations);
2252
0
            return 0;
2253
0
        }
2254
12
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2255
12
        Py_DECREF(type);
2256
12
        if (!cond) {
2257
0
            Py_DECREF(Import_annotations);
2258
0
            return 0;
2259
0
        }
2260
12
    }
2261
12
    {
2262
12
        PyObject *type = (PyObject *)&PyLong_Type;
2263
12
        type = _Py_union_type_or(type, Py_None);
2264
12
        cond = type != NULL;
2265
12
        if (!cond) {
2266
0
            Py_DECREF(Import_annotations);
2267
0
            return 0;
2268
0
        }
2269
12
        cond = PyDict_SetItemString(Import_annotations, "is_lazy", type) == 0;
2270
12
        Py_DECREF(type);
2271
12
        if (!cond) {
2272
0
            Py_DECREF(Import_annotations);
2273
0
            return 0;
2274
0
        }
2275
12
    }
2276
12
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2277
12
                                  Import_annotations) == 0;
2278
12
    if (!cond) {
2279
0
        Py_DECREF(Import_annotations);
2280
0
        return 0;
2281
0
    }
2282
12
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2283
12
                                  Import_annotations) == 0;
2284
12
    if (!cond) {
2285
0
        Py_DECREF(Import_annotations);
2286
0
        return 0;
2287
0
    }
2288
12
    Py_DECREF(Import_annotations);
2289
12
    PyObject *ImportFrom_annotations = PyDict_New();
2290
12
    if (!ImportFrom_annotations) return 0;
2291
12
    {
2292
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
2293
12
        type = _Py_union_type_or(type, Py_None);
2294
12
        cond = type != NULL;
2295
12
        if (!cond) {
2296
0
            Py_DECREF(ImportFrom_annotations);
2297
0
            return 0;
2298
0
        }
2299
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2300
12
                                    0;
2301
12
        Py_DECREF(type);
2302
12
        if (!cond) {
2303
0
            Py_DECREF(ImportFrom_annotations);
2304
0
            return 0;
2305
0
        }
2306
12
    }
2307
12
    {
2308
12
        PyObject *type = state->alias_type;
2309
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2310
12
        cond = type != NULL;
2311
12
        if (!cond) {
2312
0
            Py_DECREF(ImportFrom_annotations);
2313
0
            return 0;
2314
0
        }
2315
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2316
12
        Py_DECREF(type);
2317
12
        if (!cond) {
2318
0
            Py_DECREF(ImportFrom_annotations);
2319
0
            return 0;
2320
0
        }
2321
12
    }
2322
12
    {
2323
12
        PyObject *type = (PyObject *)&PyLong_Type;
2324
12
        type = _Py_union_type_or(type, Py_None);
2325
12
        cond = type != NULL;
2326
12
        if (!cond) {
2327
0
            Py_DECREF(ImportFrom_annotations);
2328
0
            return 0;
2329
0
        }
2330
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2331
12
        Py_DECREF(type);
2332
12
        if (!cond) {
2333
0
            Py_DECREF(ImportFrom_annotations);
2334
0
            return 0;
2335
0
        }
2336
12
    }
2337
12
    {
2338
12
        PyObject *type = (PyObject *)&PyLong_Type;
2339
12
        type = _Py_union_type_or(type, Py_None);
2340
12
        cond = type != NULL;
2341
12
        if (!cond) {
2342
0
            Py_DECREF(ImportFrom_annotations);
2343
0
            return 0;
2344
0
        }
2345
12
        cond = PyDict_SetItemString(ImportFrom_annotations, "is_lazy", type) ==
2346
12
                                    0;
2347
12
        Py_DECREF(type);
2348
12
        if (!cond) {
2349
0
            Py_DECREF(ImportFrom_annotations);
2350
0
            return 0;
2351
0
        }
2352
12
    }
2353
12
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2354
12
                                  ImportFrom_annotations) == 0;
2355
12
    if (!cond) {
2356
0
        Py_DECREF(ImportFrom_annotations);
2357
0
        return 0;
2358
0
    }
2359
12
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2360
12
                                  ImportFrom_annotations) == 0;
2361
12
    if (!cond) {
2362
0
        Py_DECREF(ImportFrom_annotations);
2363
0
        return 0;
2364
0
    }
2365
12
    Py_DECREF(ImportFrom_annotations);
2366
12
    PyObject *Global_annotations = PyDict_New();
2367
12
    if (!Global_annotations) return 0;
2368
12
    {
2369
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
2370
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2371
12
        cond = type != NULL;
2372
12
        if (!cond) {
2373
0
            Py_DECREF(Global_annotations);
2374
0
            return 0;
2375
0
        }
2376
12
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2377
12
        Py_DECREF(type);
2378
12
        if (!cond) {
2379
0
            Py_DECREF(Global_annotations);
2380
0
            return 0;
2381
0
        }
2382
12
    }
2383
12
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2384
12
                                  Global_annotations) == 0;
2385
12
    if (!cond) {
2386
0
        Py_DECREF(Global_annotations);
2387
0
        return 0;
2388
0
    }
2389
12
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2390
12
                                  Global_annotations) == 0;
2391
12
    if (!cond) {
2392
0
        Py_DECREF(Global_annotations);
2393
0
        return 0;
2394
0
    }
2395
12
    Py_DECREF(Global_annotations);
2396
12
    PyObject *Nonlocal_annotations = PyDict_New();
2397
12
    if (!Nonlocal_annotations) return 0;
2398
12
    {
2399
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
2400
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2401
12
        cond = type != NULL;
2402
12
        if (!cond) {
2403
0
            Py_DECREF(Nonlocal_annotations);
2404
0
            return 0;
2405
0
        }
2406
12
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2407
12
        Py_DECREF(type);
2408
12
        if (!cond) {
2409
0
            Py_DECREF(Nonlocal_annotations);
2410
0
            return 0;
2411
0
        }
2412
12
    }
2413
12
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2414
12
                                  Nonlocal_annotations) == 0;
2415
12
    if (!cond) {
2416
0
        Py_DECREF(Nonlocal_annotations);
2417
0
        return 0;
2418
0
    }
2419
12
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2420
12
                                  Nonlocal_annotations) == 0;
2421
12
    if (!cond) {
2422
0
        Py_DECREF(Nonlocal_annotations);
2423
0
        return 0;
2424
0
    }
2425
12
    Py_DECREF(Nonlocal_annotations);
2426
12
    PyObject *Expr_annotations = PyDict_New();
2427
12
    if (!Expr_annotations) return 0;
2428
12
    {
2429
12
        PyObject *type = state->expr_type;
2430
12
        Py_INCREF(type);
2431
12
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2432
12
        Py_DECREF(type);
2433
12
        if (!cond) {
2434
0
            Py_DECREF(Expr_annotations);
2435
0
            return 0;
2436
0
        }
2437
12
    }
2438
12
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2439
12
                                  Expr_annotations) == 0;
2440
12
    if (!cond) {
2441
0
        Py_DECREF(Expr_annotations);
2442
0
        return 0;
2443
0
    }
2444
12
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2445
12
                                  Expr_annotations) == 0;
2446
12
    if (!cond) {
2447
0
        Py_DECREF(Expr_annotations);
2448
0
        return 0;
2449
0
    }
2450
12
    Py_DECREF(Expr_annotations);
2451
12
    PyObject *Pass_annotations = PyDict_New();
2452
12
    if (!Pass_annotations) return 0;
2453
12
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2454
12
                                  Pass_annotations) == 0;
2455
12
    if (!cond) {
2456
0
        Py_DECREF(Pass_annotations);
2457
0
        return 0;
2458
0
    }
2459
12
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2460
12
                                  Pass_annotations) == 0;
2461
12
    if (!cond) {
2462
0
        Py_DECREF(Pass_annotations);
2463
0
        return 0;
2464
0
    }
2465
12
    Py_DECREF(Pass_annotations);
2466
12
    PyObject *Break_annotations = PyDict_New();
2467
12
    if (!Break_annotations) return 0;
2468
12
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2469
12
                                  Break_annotations) == 0;
2470
12
    if (!cond) {
2471
0
        Py_DECREF(Break_annotations);
2472
0
        return 0;
2473
0
    }
2474
12
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2475
12
                                  Break_annotations) == 0;
2476
12
    if (!cond) {
2477
0
        Py_DECREF(Break_annotations);
2478
0
        return 0;
2479
0
    }
2480
12
    Py_DECREF(Break_annotations);
2481
12
    PyObject *Continue_annotations = PyDict_New();
2482
12
    if (!Continue_annotations) return 0;
2483
12
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2484
12
                                  Continue_annotations) == 0;
2485
12
    if (!cond) {
2486
0
        Py_DECREF(Continue_annotations);
2487
0
        return 0;
2488
0
    }
2489
12
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2490
12
                                  Continue_annotations) == 0;
2491
12
    if (!cond) {
2492
0
        Py_DECREF(Continue_annotations);
2493
0
        return 0;
2494
0
    }
2495
12
    Py_DECREF(Continue_annotations);
2496
12
    PyObject *BoolOp_annotations = PyDict_New();
2497
12
    if (!BoolOp_annotations) return 0;
2498
12
    {
2499
12
        PyObject *type = state->boolop_type;
2500
12
        Py_INCREF(type);
2501
12
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2502
12
        Py_DECREF(type);
2503
12
        if (!cond) {
2504
0
            Py_DECREF(BoolOp_annotations);
2505
0
            return 0;
2506
0
        }
2507
12
    }
2508
12
    {
2509
12
        PyObject *type = state->expr_type;
2510
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2511
12
        cond = type != NULL;
2512
12
        if (!cond) {
2513
0
            Py_DECREF(BoolOp_annotations);
2514
0
            return 0;
2515
0
        }
2516
12
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2517
12
        Py_DECREF(type);
2518
12
        if (!cond) {
2519
0
            Py_DECREF(BoolOp_annotations);
2520
0
            return 0;
2521
0
        }
2522
12
    }
2523
12
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2524
12
                                  BoolOp_annotations) == 0;
2525
12
    if (!cond) {
2526
0
        Py_DECREF(BoolOp_annotations);
2527
0
        return 0;
2528
0
    }
2529
12
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2530
12
                                  BoolOp_annotations) == 0;
2531
12
    if (!cond) {
2532
0
        Py_DECREF(BoolOp_annotations);
2533
0
        return 0;
2534
0
    }
2535
12
    Py_DECREF(BoolOp_annotations);
2536
12
    PyObject *NamedExpr_annotations = PyDict_New();
2537
12
    if (!NamedExpr_annotations) return 0;
2538
12
    {
2539
12
        PyObject *type = state->expr_type;
2540
12
        Py_INCREF(type);
2541
12
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2542
12
        Py_DECREF(type);
2543
12
        if (!cond) {
2544
0
            Py_DECREF(NamedExpr_annotations);
2545
0
            return 0;
2546
0
        }
2547
12
    }
2548
12
    {
2549
12
        PyObject *type = state->expr_type;
2550
12
        Py_INCREF(type);
2551
12
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2552
12
        Py_DECREF(type);
2553
12
        if (!cond) {
2554
0
            Py_DECREF(NamedExpr_annotations);
2555
0
            return 0;
2556
0
        }
2557
12
    }
2558
12
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2559
12
                                  NamedExpr_annotations) == 0;
2560
12
    if (!cond) {
2561
0
        Py_DECREF(NamedExpr_annotations);
2562
0
        return 0;
2563
0
    }
2564
12
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2565
12
                                  NamedExpr_annotations) == 0;
2566
12
    if (!cond) {
2567
0
        Py_DECREF(NamedExpr_annotations);
2568
0
        return 0;
2569
0
    }
2570
12
    Py_DECREF(NamedExpr_annotations);
2571
12
    PyObject *BinOp_annotations = PyDict_New();
2572
12
    if (!BinOp_annotations) return 0;
2573
12
    {
2574
12
        PyObject *type = state->expr_type;
2575
12
        Py_INCREF(type);
2576
12
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2577
12
        Py_DECREF(type);
2578
12
        if (!cond) {
2579
0
            Py_DECREF(BinOp_annotations);
2580
0
            return 0;
2581
0
        }
2582
12
    }
2583
12
    {
2584
12
        PyObject *type = state->operator_type;
2585
12
        Py_INCREF(type);
2586
12
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2587
12
        Py_DECREF(type);
2588
12
        if (!cond) {
2589
0
            Py_DECREF(BinOp_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(BinOp_annotations, "right", type) == 0;
2597
12
        Py_DECREF(type);
2598
12
        if (!cond) {
2599
0
            Py_DECREF(BinOp_annotations);
2600
0
            return 0;
2601
0
        }
2602
12
    }
2603
12
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2604
12
                                  BinOp_annotations) == 0;
2605
12
    if (!cond) {
2606
0
        Py_DECREF(BinOp_annotations);
2607
0
        return 0;
2608
0
    }
2609
12
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2610
12
                                  BinOp_annotations) == 0;
2611
12
    if (!cond) {
2612
0
        Py_DECREF(BinOp_annotations);
2613
0
        return 0;
2614
0
    }
2615
12
    Py_DECREF(BinOp_annotations);
2616
12
    PyObject *UnaryOp_annotations = PyDict_New();
2617
12
    if (!UnaryOp_annotations) return 0;
2618
12
    {
2619
12
        PyObject *type = state->unaryop_type;
2620
12
        Py_INCREF(type);
2621
12
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2622
12
        Py_DECREF(type);
2623
12
        if (!cond) {
2624
0
            Py_DECREF(UnaryOp_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(UnaryOp_annotations, "operand", type) == 0;
2632
12
        Py_DECREF(type);
2633
12
        if (!cond) {
2634
0
            Py_DECREF(UnaryOp_annotations);
2635
0
            return 0;
2636
0
        }
2637
12
    }
2638
12
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2639
12
                                  UnaryOp_annotations) == 0;
2640
12
    if (!cond) {
2641
0
        Py_DECREF(UnaryOp_annotations);
2642
0
        return 0;
2643
0
    }
2644
12
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2645
12
                                  UnaryOp_annotations) == 0;
2646
12
    if (!cond) {
2647
0
        Py_DECREF(UnaryOp_annotations);
2648
0
        return 0;
2649
0
    }
2650
12
    Py_DECREF(UnaryOp_annotations);
2651
12
    PyObject *Lambda_annotations = PyDict_New();
2652
12
    if (!Lambda_annotations) return 0;
2653
12
    {
2654
12
        PyObject *type = state->arguments_type;
2655
12
        Py_INCREF(type);
2656
12
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2657
12
        Py_DECREF(type);
2658
12
        if (!cond) {
2659
0
            Py_DECREF(Lambda_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(Lambda_annotations, "body", type) == 0;
2667
12
        Py_DECREF(type);
2668
12
        if (!cond) {
2669
0
            Py_DECREF(Lambda_annotations);
2670
0
            return 0;
2671
0
        }
2672
12
    }
2673
12
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2674
12
                                  Lambda_annotations) == 0;
2675
12
    if (!cond) {
2676
0
        Py_DECREF(Lambda_annotations);
2677
0
        return 0;
2678
0
    }
2679
12
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2680
12
                                  Lambda_annotations) == 0;
2681
12
    if (!cond) {
2682
0
        Py_DECREF(Lambda_annotations);
2683
0
        return 0;
2684
0
    }
2685
12
    Py_DECREF(Lambda_annotations);
2686
12
    PyObject *IfExp_annotations = PyDict_New();
2687
12
    if (!IfExp_annotations) return 0;
2688
12
    {
2689
12
        PyObject *type = state->expr_type;
2690
12
        Py_INCREF(type);
2691
12
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2692
12
        Py_DECREF(type);
2693
12
        if (!cond) {
2694
0
            Py_DECREF(IfExp_annotations);
2695
0
            return 0;
2696
0
        }
2697
12
    }
2698
12
    {
2699
12
        PyObject *type = state->expr_type;
2700
12
        Py_INCREF(type);
2701
12
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2702
12
        Py_DECREF(type);
2703
12
        if (!cond) {
2704
0
            Py_DECREF(IfExp_annotations);
2705
0
            return 0;
2706
0
        }
2707
12
    }
2708
12
    {
2709
12
        PyObject *type = state->expr_type;
2710
12
        Py_INCREF(type);
2711
12
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2712
12
        Py_DECREF(type);
2713
12
        if (!cond) {
2714
0
            Py_DECREF(IfExp_annotations);
2715
0
            return 0;
2716
0
        }
2717
12
    }
2718
12
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2719
12
                                  IfExp_annotations) == 0;
2720
12
    if (!cond) {
2721
0
        Py_DECREF(IfExp_annotations);
2722
0
        return 0;
2723
0
    }
2724
12
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2725
12
                                  IfExp_annotations) == 0;
2726
12
    if (!cond) {
2727
0
        Py_DECREF(IfExp_annotations);
2728
0
        return 0;
2729
0
    }
2730
12
    Py_DECREF(IfExp_annotations);
2731
12
    PyObject *Dict_annotations = PyDict_New();
2732
12
    if (!Dict_annotations) return 0;
2733
12
    {
2734
12
        PyObject *type = state->expr_type;
2735
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2736
12
        cond = type != NULL;
2737
12
        if (!cond) {
2738
0
            Py_DECREF(Dict_annotations);
2739
0
            return 0;
2740
0
        }
2741
12
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2742
12
        Py_DECREF(type);
2743
12
        if (!cond) {
2744
0
            Py_DECREF(Dict_annotations);
2745
0
            return 0;
2746
0
        }
2747
12
    }
2748
12
    {
2749
12
        PyObject *type = state->expr_type;
2750
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2751
12
        cond = type != NULL;
2752
12
        if (!cond) {
2753
0
            Py_DECREF(Dict_annotations);
2754
0
            return 0;
2755
0
        }
2756
12
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2757
12
        Py_DECREF(type);
2758
12
        if (!cond) {
2759
0
            Py_DECREF(Dict_annotations);
2760
0
            return 0;
2761
0
        }
2762
12
    }
2763
12
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2764
12
                                  Dict_annotations) == 0;
2765
12
    if (!cond) {
2766
0
        Py_DECREF(Dict_annotations);
2767
0
        return 0;
2768
0
    }
2769
12
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2770
12
                                  Dict_annotations) == 0;
2771
12
    if (!cond) {
2772
0
        Py_DECREF(Dict_annotations);
2773
0
        return 0;
2774
0
    }
2775
12
    Py_DECREF(Dict_annotations);
2776
12
    PyObject *Set_annotations = PyDict_New();
2777
12
    if (!Set_annotations) return 0;
2778
12
    {
2779
12
        PyObject *type = state->expr_type;
2780
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2781
12
        cond = type != NULL;
2782
12
        if (!cond) {
2783
0
            Py_DECREF(Set_annotations);
2784
0
            return 0;
2785
0
        }
2786
12
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2787
12
        Py_DECREF(type);
2788
12
        if (!cond) {
2789
0
            Py_DECREF(Set_annotations);
2790
0
            return 0;
2791
0
        }
2792
12
    }
2793
12
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2794
12
                                  Set_annotations) == 0;
2795
12
    if (!cond) {
2796
0
        Py_DECREF(Set_annotations);
2797
0
        return 0;
2798
0
    }
2799
12
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2800
12
                                  Set_annotations) == 0;
2801
12
    if (!cond) {
2802
0
        Py_DECREF(Set_annotations);
2803
0
        return 0;
2804
0
    }
2805
12
    Py_DECREF(Set_annotations);
2806
12
    PyObject *ListComp_annotations = PyDict_New();
2807
12
    if (!ListComp_annotations) return 0;
2808
12
    {
2809
12
        PyObject *type = state->expr_type;
2810
12
        Py_INCREF(type);
2811
12
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2812
12
        Py_DECREF(type);
2813
12
        if (!cond) {
2814
0
            Py_DECREF(ListComp_annotations);
2815
0
            return 0;
2816
0
        }
2817
12
    }
2818
12
    {
2819
12
        PyObject *type = state->comprehension_type;
2820
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2821
12
        cond = type != NULL;
2822
12
        if (!cond) {
2823
0
            Py_DECREF(ListComp_annotations);
2824
0
            return 0;
2825
0
        }
2826
12
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2827
12
                                    == 0;
2828
12
        Py_DECREF(type);
2829
12
        if (!cond) {
2830
0
            Py_DECREF(ListComp_annotations);
2831
0
            return 0;
2832
0
        }
2833
12
    }
2834
12
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2835
12
                                  ListComp_annotations) == 0;
2836
12
    if (!cond) {
2837
0
        Py_DECREF(ListComp_annotations);
2838
0
        return 0;
2839
0
    }
2840
12
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2841
12
                                  ListComp_annotations) == 0;
2842
12
    if (!cond) {
2843
0
        Py_DECREF(ListComp_annotations);
2844
0
        return 0;
2845
0
    }
2846
12
    Py_DECREF(ListComp_annotations);
2847
12
    PyObject *SetComp_annotations = PyDict_New();
2848
12
    if (!SetComp_annotations) return 0;
2849
12
    {
2850
12
        PyObject *type = state->expr_type;
2851
12
        Py_INCREF(type);
2852
12
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2853
12
        Py_DECREF(type);
2854
12
        if (!cond) {
2855
0
            Py_DECREF(SetComp_annotations);
2856
0
            return 0;
2857
0
        }
2858
12
    }
2859
12
    {
2860
12
        PyObject *type = state->comprehension_type;
2861
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2862
12
        cond = type != NULL;
2863
12
        if (!cond) {
2864
0
            Py_DECREF(SetComp_annotations);
2865
0
            return 0;
2866
0
        }
2867
12
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2868
12
                                    0;
2869
12
        Py_DECREF(type);
2870
12
        if (!cond) {
2871
0
            Py_DECREF(SetComp_annotations);
2872
0
            return 0;
2873
0
        }
2874
12
    }
2875
12
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2876
12
                                  SetComp_annotations) == 0;
2877
12
    if (!cond) {
2878
0
        Py_DECREF(SetComp_annotations);
2879
0
        return 0;
2880
0
    }
2881
12
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2882
12
                                  SetComp_annotations) == 0;
2883
12
    if (!cond) {
2884
0
        Py_DECREF(SetComp_annotations);
2885
0
        return 0;
2886
0
    }
2887
12
    Py_DECREF(SetComp_annotations);
2888
12
    PyObject *DictComp_annotations = PyDict_New();
2889
12
    if (!DictComp_annotations) return 0;
2890
12
    {
2891
12
        PyObject *type = state->expr_type;
2892
12
        Py_INCREF(type);
2893
12
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2894
12
        Py_DECREF(type);
2895
12
        if (!cond) {
2896
0
            Py_DECREF(DictComp_annotations);
2897
0
            return 0;
2898
0
        }
2899
12
    }
2900
12
    {
2901
12
        PyObject *type = state->expr_type;
2902
12
        type = _Py_union_type_or(type, Py_None);
2903
12
        cond = type != NULL;
2904
12
        if (!cond) {
2905
0
            Py_DECREF(DictComp_annotations);
2906
0
            return 0;
2907
0
        }
2908
12
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2909
12
        Py_DECREF(type);
2910
12
        if (!cond) {
2911
0
            Py_DECREF(DictComp_annotations);
2912
0
            return 0;
2913
0
        }
2914
12
    }
2915
12
    {
2916
12
        PyObject *type = state->comprehension_type;
2917
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2918
12
        cond = type != NULL;
2919
12
        if (!cond) {
2920
0
            Py_DECREF(DictComp_annotations);
2921
0
            return 0;
2922
0
        }
2923
12
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2924
12
                                    == 0;
2925
12
        Py_DECREF(type);
2926
12
        if (!cond) {
2927
0
            Py_DECREF(DictComp_annotations);
2928
0
            return 0;
2929
0
        }
2930
12
    }
2931
12
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2932
12
                                  DictComp_annotations) == 0;
2933
12
    if (!cond) {
2934
0
        Py_DECREF(DictComp_annotations);
2935
0
        return 0;
2936
0
    }
2937
12
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2938
12
                                  DictComp_annotations) == 0;
2939
12
    if (!cond) {
2940
0
        Py_DECREF(DictComp_annotations);
2941
0
        return 0;
2942
0
    }
2943
12
    Py_DECREF(DictComp_annotations);
2944
12
    PyObject *GeneratorExp_annotations = PyDict_New();
2945
12
    if (!GeneratorExp_annotations) return 0;
2946
12
    {
2947
12
        PyObject *type = state->expr_type;
2948
12
        Py_INCREF(type);
2949
12
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2950
12
        Py_DECREF(type);
2951
12
        if (!cond) {
2952
0
            Py_DECREF(GeneratorExp_annotations);
2953
0
            return 0;
2954
0
        }
2955
12
    }
2956
12
    {
2957
12
        PyObject *type = state->comprehension_type;
2958
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2959
12
        cond = type != NULL;
2960
12
        if (!cond) {
2961
0
            Py_DECREF(GeneratorExp_annotations);
2962
0
            return 0;
2963
0
        }
2964
12
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2965
12
                                    type) == 0;
2966
12
        Py_DECREF(type);
2967
12
        if (!cond) {
2968
0
            Py_DECREF(GeneratorExp_annotations);
2969
0
            return 0;
2970
0
        }
2971
12
    }
2972
12
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2973
12
                                  GeneratorExp_annotations) == 0;
2974
12
    if (!cond) {
2975
0
        Py_DECREF(GeneratorExp_annotations);
2976
0
        return 0;
2977
0
    }
2978
12
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2979
12
                                  GeneratorExp_annotations) == 0;
2980
12
    if (!cond) {
2981
0
        Py_DECREF(GeneratorExp_annotations);
2982
0
        return 0;
2983
0
    }
2984
12
    Py_DECREF(GeneratorExp_annotations);
2985
12
    PyObject *Await_annotations = PyDict_New();
2986
12
    if (!Await_annotations) return 0;
2987
12
    {
2988
12
        PyObject *type = state->expr_type;
2989
12
        Py_INCREF(type);
2990
12
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2991
12
        Py_DECREF(type);
2992
12
        if (!cond) {
2993
0
            Py_DECREF(Await_annotations);
2994
0
            return 0;
2995
0
        }
2996
12
    }
2997
12
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2998
12
                                  Await_annotations) == 0;
2999
12
    if (!cond) {
3000
0
        Py_DECREF(Await_annotations);
3001
0
        return 0;
3002
0
    }
3003
12
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
3004
12
                                  Await_annotations) == 0;
3005
12
    if (!cond) {
3006
0
        Py_DECREF(Await_annotations);
3007
0
        return 0;
3008
0
    }
3009
12
    Py_DECREF(Await_annotations);
3010
12
    PyObject *Yield_annotations = PyDict_New();
3011
12
    if (!Yield_annotations) return 0;
3012
12
    {
3013
12
        PyObject *type = state->expr_type;
3014
12
        type = _Py_union_type_or(type, Py_None);
3015
12
        cond = type != NULL;
3016
12
        if (!cond) {
3017
0
            Py_DECREF(Yield_annotations);
3018
0
            return 0;
3019
0
        }
3020
12
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
3021
12
        Py_DECREF(type);
3022
12
        if (!cond) {
3023
0
            Py_DECREF(Yield_annotations);
3024
0
            return 0;
3025
0
        }
3026
12
    }
3027
12
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
3028
12
                                  Yield_annotations) == 0;
3029
12
    if (!cond) {
3030
0
        Py_DECREF(Yield_annotations);
3031
0
        return 0;
3032
0
    }
3033
12
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
3034
12
                                  Yield_annotations) == 0;
3035
12
    if (!cond) {
3036
0
        Py_DECREF(Yield_annotations);
3037
0
        return 0;
3038
0
    }
3039
12
    Py_DECREF(Yield_annotations);
3040
12
    PyObject *YieldFrom_annotations = PyDict_New();
3041
12
    if (!YieldFrom_annotations) return 0;
3042
12
    {
3043
12
        PyObject *type = state->expr_type;
3044
12
        Py_INCREF(type);
3045
12
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3046
12
        Py_DECREF(type);
3047
12
        if (!cond) {
3048
0
            Py_DECREF(YieldFrom_annotations);
3049
0
            return 0;
3050
0
        }
3051
12
    }
3052
12
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3053
12
                                  YieldFrom_annotations) == 0;
3054
12
    if (!cond) {
3055
0
        Py_DECREF(YieldFrom_annotations);
3056
0
        return 0;
3057
0
    }
3058
12
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3059
12
                                  YieldFrom_annotations) == 0;
3060
12
    if (!cond) {
3061
0
        Py_DECREF(YieldFrom_annotations);
3062
0
        return 0;
3063
0
    }
3064
12
    Py_DECREF(YieldFrom_annotations);
3065
12
    PyObject *Compare_annotations = PyDict_New();
3066
12
    if (!Compare_annotations) return 0;
3067
12
    {
3068
12
        PyObject *type = state->expr_type;
3069
12
        Py_INCREF(type);
3070
12
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3071
12
        Py_DECREF(type);
3072
12
        if (!cond) {
3073
0
            Py_DECREF(Compare_annotations);
3074
0
            return 0;
3075
0
        }
3076
12
    }
3077
12
    {
3078
12
        PyObject *type = state->cmpop_type;
3079
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3080
12
        cond = type != NULL;
3081
12
        if (!cond) {
3082
0
            Py_DECREF(Compare_annotations);
3083
0
            return 0;
3084
0
        }
3085
12
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3086
12
        Py_DECREF(type);
3087
12
        if (!cond) {
3088
0
            Py_DECREF(Compare_annotations);
3089
0
            return 0;
3090
0
        }
3091
12
    }
3092
12
    {
3093
12
        PyObject *type = state->expr_type;
3094
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3095
12
        cond = type != NULL;
3096
12
        if (!cond) {
3097
0
            Py_DECREF(Compare_annotations);
3098
0
            return 0;
3099
0
        }
3100
12
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3101
12
                                    == 0;
3102
12
        Py_DECREF(type);
3103
12
        if (!cond) {
3104
0
            Py_DECREF(Compare_annotations);
3105
0
            return 0;
3106
0
        }
3107
12
    }
3108
12
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3109
12
                                  Compare_annotations) == 0;
3110
12
    if (!cond) {
3111
0
        Py_DECREF(Compare_annotations);
3112
0
        return 0;
3113
0
    }
3114
12
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3115
12
                                  Compare_annotations) == 0;
3116
12
    if (!cond) {
3117
0
        Py_DECREF(Compare_annotations);
3118
0
        return 0;
3119
0
    }
3120
12
    Py_DECREF(Compare_annotations);
3121
12
    PyObject *Call_annotations = PyDict_New();
3122
12
    if (!Call_annotations) return 0;
3123
12
    {
3124
12
        PyObject *type = state->expr_type;
3125
12
        Py_INCREF(type);
3126
12
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3127
12
        Py_DECREF(type);
3128
12
        if (!cond) {
3129
0
            Py_DECREF(Call_annotations);
3130
0
            return 0;
3131
0
        }
3132
12
    }
3133
12
    {
3134
12
        PyObject *type = state->expr_type;
3135
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3136
12
        cond = type != NULL;
3137
12
        if (!cond) {
3138
0
            Py_DECREF(Call_annotations);
3139
0
            return 0;
3140
0
        }
3141
12
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3142
12
        Py_DECREF(type);
3143
12
        if (!cond) {
3144
0
            Py_DECREF(Call_annotations);
3145
0
            return 0;
3146
0
        }
3147
12
    }
3148
12
    {
3149
12
        PyObject *type = state->keyword_type;
3150
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3151
12
        cond = type != NULL;
3152
12
        if (!cond) {
3153
0
            Py_DECREF(Call_annotations);
3154
0
            return 0;
3155
0
        }
3156
12
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3157
12
        Py_DECREF(type);
3158
12
        if (!cond) {
3159
0
            Py_DECREF(Call_annotations);
3160
0
            return 0;
3161
0
        }
3162
12
    }
3163
12
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3164
12
                                  Call_annotations) == 0;
3165
12
    if (!cond) {
3166
0
        Py_DECREF(Call_annotations);
3167
0
        return 0;
3168
0
    }
3169
12
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3170
12
                                  Call_annotations) == 0;
3171
12
    if (!cond) {
3172
0
        Py_DECREF(Call_annotations);
3173
0
        return 0;
3174
0
    }
3175
12
    Py_DECREF(Call_annotations);
3176
12
    PyObject *FormattedValue_annotations = PyDict_New();
3177
12
    if (!FormattedValue_annotations) return 0;
3178
12
    {
3179
12
        PyObject *type = state->expr_type;
3180
12
        Py_INCREF(type);
3181
12
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3182
12
                                    == 0;
3183
12
        Py_DECREF(type);
3184
12
        if (!cond) {
3185
0
            Py_DECREF(FormattedValue_annotations);
3186
0
            return 0;
3187
0
        }
3188
12
    }
3189
12
    {
3190
12
        PyObject *type = (PyObject *)&PyLong_Type;
3191
12
        Py_INCREF(type);
3192
12
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3193
12
                                    type) == 0;
3194
12
        Py_DECREF(type);
3195
12
        if (!cond) {
3196
0
            Py_DECREF(FormattedValue_annotations);
3197
0
            return 0;
3198
0
        }
3199
12
    }
3200
12
    {
3201
12
        PyObject *type = state->expr_type;
3202
12
        type = _Py_union_type_or(type, Py_None);
3203
12
        cond = type != NULL;
3204
12
        if (!cond) {
3205
0
            Py_DECREF(FormattedValue_annotations);
3206
0
            return 0;
3207
0
        }
3208
12
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3209
12
                                    type) == 0;
3210
12
        Py_DECREF(type);
3211
12
        if (!cond) {
3212
0
            Py_DECREF(FormattedValue_annotations);
3213
0
            return 0;
3214
0
        }
3215
12
    }
3216
12
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3217
12
                                  FormattedValue_annotations) == 0;
3218
12
    if (!cond) {
3219
0
        Py_DECREF(FormattedValue_annotations);
3220
0
        return 0;
3221
0
    }
3222
12
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3223
12
                                  "__annotations__",
3224
12
                                  FormattedValue_annotations) == 0;
3225
12
    if (!cond) {
3226
0
        Py_DECREF(FormattedValue_annotations);
3227
0
        return 0;
3228
0
    }
3229
12
    Py_DECREF(FormattedValue_annotations);
3230
12
    PyObject *Interpolation_annotations = PyDict_New();
3231
12
    if (!Interpolation_annotations) return 0;
3232
12
    {
3233
12
        PyObject *type = state->expr_type;
3234
12
        Py_INCREF(type);
3235
12
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3236
12
                                    == 0;
3237
12
        Py_DECREF(type);
3238
12
        if (!cond) {
3239
0
            Py_DECREF(Interpolation_annotations);
3240
0
            return 0;
3241
0
        }
3242
12
    }
3243
12
    {
3244
12
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3245
12
        Py_INCREF(type);
3246
12
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3247
12
                                    0;
3248
12
        Py_DECREF(type);
3249
12
        if (!cond) {
3250
0
            Py_DECREF(Interpolation_annotations);
3251
0
            return 0;
3252
0
        }
3253
12
    }
3254
12
    {
3255
12
        PyObject *type = (PyObject *)&PyLong_Type;
3256
12
        Py_INCREF(type);
3257
12
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3258
12
                                    type) == 0;
3259
12
        Py_DECREF(type);
3260
12
        if (!cond) {
3261
0
            Py_DECREF(Interpolation_annotations);
3262
0
            return 0;
3263
0
        }
3264
12
    }
3265
12
    {
3266
12
        PyObject *type = state->expr_type;
3267
12
        type = _Py_union_type_or(type, Py_None);
3268
12
        cond = type != NULL;
3269
12
        if (!cond) {
3270
0
            Py_DECREF(Interpolation_annotations);
3271
0
            return 0;
3272
0
        }
3273
12
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3274
12
                                    type) == 0;
3275
12
        Py_DECREF(type);
3276
12
        if (!cond) {
3277
0
            Py_DECREF(Interpolation_annotations);
3278
0
            return 0;
3279
0
        }
3280
12
    }
3281
12
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3282
12
                                  Interpolation_annotations) == 0;
3283
12
    if (!cond) {
3284
0
        Py_DECREF(Interpolation_annotations);
3285
0
        return 0;
3286
0
    }
3287
12
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3288
12
                                  Interpolation_annotations) == 0;
3289
12
    if (!cond) {
3290
0
        Py_DECREF(Interpolation_annotations);
3291
0
        return 0;
3292
0
    }
3293
12
    Py_DECREF(Interpolation_annotations);
3294
12
    PyObject *JoinedStr_annotations = PyDict_New();
3295
12
    if (!JoinedStr_annotations) return 0;
3296
12
    {
3297
12
        PyObject *type = state->expr_type;
3298
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3299
12
        cond = type != NULL;
3300
12
        if (!cond) {
3301
0
            Py_DECREF(JoinedStr_annotations);
3302
0
            return 0;
3303
0
        }
3304
12
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3305
12
        Py_DECREF(type);
3306
12
        if (!cond) {
3307
0
            Py_DECREF(JoinedStr_annotations);
3308
0
            return 0;
3309
0
        }
3310
12
    }
3311
12
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3312
12
                                  JoinedStr_annotations) == 0;
3313
12
    if (!cond) {
3314
0
        Py_DECREF(JoinedStr_annotations);
3315
0
        return 0;
3316
0
    }
3317
12
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3318
12
                                  JoinedStr_annotations) == 0;
3319
12
    if (!cond) {
3320
0
        Py_DECREF(JoinedStr_annotations);
3321
0
        return 0;
3322
0
    }
3323
12
    Py_DECREF(JoinedStr_annotations);
3324
12
    PyObject *TemplateStr_annotations = PyDict_New();
3325
12
    if (!TemplateStr_annotations) return 0;
3326
12
    {
3327
12
        PyObject *type = state->expr_type;
3328
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3329
12
        cond = type != NULL;
3330
12
        if (!cond) {
3331
0
            Py_DECREF(TemplateStr_annotations);
3332
0
            return 0;
3333
0
        }
3334
12
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3335
12
                                    0;
3336
12
        Py_DECREF(type);
3337
12
        if (!cond) {
3338
0
            Py_DECREF(TemplateStr_annotations);
3339
0
            return 0;
3340
0
        }
3341
12
    }
3342
12
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3343
12
                                  TemplateStr_annotations) == 0;
3344
12
    if (!cond) {
3345
0
        Py_DECREF(TemplateStr_annotations);
3346
0
        return 0;
3347
0
    }
3348
12
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3349
12
                                  TemplateStr_annotations) == 0;
3350
12
    if (!cond) {
3351
0
        Py_DECREF(TemplateStr_annotations);
3352
0
        return 0;
3353
0
    }
3354
12
    Py_DECREF(TemplateStr_annotations);
3355
12
    PyObject *Constant_annotations = PyDict_New();
3356
12
    if (!Constant_annotations) return 0;
3357
12
    {
3358
12
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3359
12
        Py_INCREF(type);
3360
12
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3361
12
        Py_DECREF(type);
3362
12
        if (!cond) {
3363
0
            Py_DECREF(Constant_annotations);
3364
0
            return 0;
3365
0
        }
3366
12
    }
3367
12
    {
3368
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
3369
12
        type = _Py_union_type_or(type, Py_None);
3370
12
        cond = type != NULL;
3371
12
        if (!cond) {
3372
0
            Py_DECREF(Constant_annotations);
3373
0
            return 0;
3374
0
        }
3375
12
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3376
12
        Py_DECREF(type);
3377
12
        if (!cond) {
3378
0
            Py_DECREF(Constant_annotations);
3379
0
            return 0;
3380
0
        }
3381
12
    }
3382
12
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3383
12
                                  Constant_annotations) == 0;
3384
12
    if (!cond) {
3385
0
        Py_DECREF(Constant_annotations);
3386
0
        return 0;
3387
0
    }
3388
12
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3389
12
                                  Constant_annotations) == 0;
3390
12
    if (!cond) {
3391
0
        Py_DECREF(Constant_annotations);
3392
0
        return 0;
3393
0
    }
3394
12
    Py_DECREF(Constant_annotations);
3395
12
    PyObject *Attribute_annotations = PyDict_New();
3396
12
    if (!Attribute_annotations) return 0;
3397
12
    {
3398
12
        PyObject *type = state->expr_type;
3399
12
        Py_INCREF(type);
3400
12
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3401
12
        Py_DECREF(type);
3402
12
        if (!cond) {
3403
0
            Py_DECREF(Attribute_annotations);
3404
0
            return 0;
3405
0
        }
3406
12
    }
3407
12
    {
3408
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
3409
12
        Py_INCREF(type);
3410
12
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3411
12
        Py_DECREF(type);
3412
12
        if (!cond) {
3413
0
            Py_DECREF(Attribute_annotations);
3414
0
            return 0;
3415
0
        }
3416
12
    }
3417
12
    {
3418
12
        PyObject *type = state->expr_context_type;
3419
12
        Py_INCREF(type);
3420
12
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3421
12
        Py_DECREF(type);
3422
12
        if (!cond) {
3423
0
            Py_DECREF(Attribute_annotations);
3424
0
            return 0;
3425
0
        }
3426
12
    }
3427
12
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3428
12
                                  Attribute_annotations) == 0;
3429
12
    if (!cond) {
3430
0
        Py_DECREF(Attribute_annotations);
3431
0
        return 0;
3432
0
    }
3433
12
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3434
12
                                  Attribute_annotations) == 0;
3435
12
    if (!cond) {
3436
0
        Py_DECREF(Attribute_annotations);
3437
0
        return 0;
3438
0
    }
3439
12
    Py_DECREF(Attribute_annotations);
3440
12
    PyObject *Subscript_annotations = PyDict_New();
3441
12
    if (!Subscript_annotations) return 0;
3442
12
    {
3443
12
        PyObject *type = state->expr_type;
3444
12
        Py_INCREF(type);
3445
12
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3446
12
        Py_DECREF(type);
3447
12
        if (!cond) {
3448
0
            Py_DECREF(Subscript_annotations);
3449
0
            return 0;
3450
0
        }
3451
12
    }
3452
12
    {
3453
12
        PyObject *type = state->expr_type;
3454
12
        Py_INCREF(type);
3455
12
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3456
12
        Py_DECREF(type);
3457
12
        if (!cond) {
3458
0
            Py_DECREF(Subscript_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(Subscript_annotations, "ctx", type) == 0;
3466
12
        Py_DECREF(type);
3467
12
        if (!cond) {
3468
0
            Py_DECREF(Subscript_annotations);
3469
0
            return 0;
3470
0
        }
3471
12
    }
3472
12
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3473
12
                                  Subscript_annotations) == 0;
3474
12
    if (!cond) {
3475
0
        Py_DECREF(Subscript_annotations);
3476
0
        return 0;
3477
0
    }
3478
12
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3479
12
                                  Subscript_annotations) == 0;
3480
12
    if (!cond) {
3481
0
        Py_DECREF(Subscript_annotations);
3482
0
        return 0;
3483
0
    }
3484
12
    Py_DECREF(Subscript_annotations);
3485
12
    PyObject *Starred_annotations = PyDict_New();
3486
12
    if (!Starred_annotations) return 0;
3487
12
    {
3488
12
        PyObject *type = state->expr_type;
3489
12
        Py_INCREF(type);
3490
12
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3491
12
        Py_DECREF(type);
3492
12
        if (!cond) {
3493
0
            Py_DECREF(Starred_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(Starred_annotations, "ctx", type) == 0;
3501
12
        Py_DECREF(type);
3502
12
        if (!cond) {
3503
0
            Py_DECREF(Starred_annotations);
3504
0
            return 0;
3505
0
        }
3506
12
    }
3507
12
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3508
12
                                  Starred_annotations) == 0;
3509
12
    if (!cond) {
3510
0
        Py_DECREF(Starred_annotations);
3511
0
        return 0;
3512
0
    }
3513
12
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3514
12
                                  Starred_annotations) == 0;
3515
12
    if (!cond) {
3516
0
        Py_DECREF(Starred_annotations);
3517
0
        return 0;
3518
0
    }
3519
12
    Py_DECREF(Starred_annotations);
3520
12
    PyObject *Name_annotations = PyDict_New();
3521
12
    if (!Name_annotations) return 0;
3522
12
    {
3523
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
3524
12
        Py_INCREF(type);
3525
12
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3526
12
        Py_DECREF(type);
3527
12
        if (!cond) {
3528
0
            Py_DECREF(Name_annotations);
3529
0
            return 0;
3530
0
        }
3531
12
    }
3532
12
    {
3533
12
        PyObject *type = state->expr_context_type;
3534
12
        Py_INCREF(type);
3535
12
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3536
12
        Py_DECREF(type);
3537
12
        if (!cond) {
3538
0
            Py_DECREF(Name_annotations);
3539
0
            return 0;
3540
0
        }
3541
12
    }
3542
12
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3543
12
                                  Name_annotations) == 0;
3544
12
    if (!cond) {
3545
0
        Py_DECREF(Name_annotations);
3546
0
        return 0;
3547
0
    }
3548
12
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3549
12
                                  Name_annotations) == 0;
3550
12
    if (!cond) {
3551
0
        Py_DECREF(Name_annotations);
3552
0
        return 0;
3553
0
    }
3554
12
    Py_DECREF(Name_annotations);
3555
12
    PyObject *List_annotations = PyDict_New();
3556
12
    if (!List_annotations) return 0;
3557
12
    {
3558
12
        PyObject *type = state->expr_type;
3559
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3560
12
        cond = type != NULL;
3561
12
        if (!cond) {
3562
0
            Py_DECREF(List_annotations);
3563
0
            return 0;
3564
0
        }
3565
12
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3566
12
        Py_DECREF(type);
3567
12
        if (!cond) {
3568
0
            Py_DECREF(List_annotations);
3569
0
            return 0;
3570
0
        }
3571
12
    }
3572
12
    {
3573
12
        PyObject *type = state->expr_context_type;
3574
12
        Py_INCREF(type);
3575
12
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3576
12
        Py_DECREF(type);
3577
12
        if (!cond) {
3578
0
            Py_DECREF(List_annotations);
3579
0
            return 0;
3580
0
        }
3581
12
    }
3582
12
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3583
12
                                  List_annotations) == 0;
3584
12
    if (!cond) {
3585
0
        Py_DECREF(List_annotations);
3586
0
        return 0;
3587
0
    }
3588
12
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3589
12
                                  List_annotations) == 0;
3590
12
    if (!cond) {
3591
0
        Py_DECREF(List_annotations);
3592
0
        return 0;
3593
0
    }
3594
12
    Py_DECREF(List_annotations);
3595
12
    PyObject *Tuple_annotations = PyDict_New();
3596
12
    if (!Tuple_annotations) return 0;
3597
12
    {
3598
12
        PyObject *type = state->expr_type;
3599
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3600
12
        cond = type != NULL;
3601
12
        if (!cond) {
3602
0
            Py_DECREF(Tuple_annotations);
3603
0
            return 0;
3604
0
        }
3605
12
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3606
12
        Py_DECREF(type);
3607
12
        if (!cond) {
3608
0
            Py_DECREF(Tuple_annotations);
3609
0
            return 0;
3610
0
        }
3611
12
    }
3612
12
    {
3613
12
        PyObject *type = state->expr_context_type;
3614
12
        Py_INCREF(type);
3615
12
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3616
12
        Py_DECREF(type);
3617
12
        if (!cond) {
3618
0
            Py_DECREF(Tuple_annotations);
3619
0
            return 0;
3620
0
        }
3621
12
    }
3622
12
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3623
12
                                  Tuple_annotations) == 0;
3624
12
    if (!cond) {
3625
0
        Py_DECREF(Tuple_annotations);
3626
0
        return 0;
3627
0
    }
3628
12
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3629
12
                                  Tuple_annotations) == 0;
3630
12
    if (!cond) {
3631
0
        Py_DECREF(Tuple_annotations);
3632
0
        return 0;
3633
0
    }
3634
12
    Py_DECREF(Tuple_annotations);
3635
12
    PyObject *Slice_annotations = PyDict_New();
3636
12
    if (!Slice_annotations) return 0;
3637
12
    {
3638
12
        PyObject *type = state->expr_type;
3639
12
        type = _Py_union_type_or(type, Py_None);
3640
12
        cond = type != NULL;
3641
12
        if (!cond) {
3642
0
            Py_DECREF(Slice_annotations);
3643
0
            return 0;
3644
0
        }
3645
12
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3646
12
        Py_DECREF(type);
3647
12
        if (!cond) {
3648
0
            Py_DECREF(Slice_annotations);
3649
0
            return 0;
3650
0
        }
3651
12
    }
3652
12
    {
3653
12
        PyObject *type = state->expr_type;
3654
12
        type = _Py_union_type_or(type, Py_None);
3655
12
        cond = type != NULL;
3656
12
        if (!cond) {
3657
0
            Py_DECREF(Slice_annotations);
3658
0
            return 0;
3659
0
        }
3660
12
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3661
12
        Py_DECREF(type);
3662
12
        if (!cond) {
3663
0
            Py_DECREF(Slice_annotations);
3664
0
            return 0;
3665
0
        }
3666
12
    }
3667
12
    {
3668
12
        PyObject *type = state->expr_type;
3669
12
        type = _Py_union_type_or(type, Py_None);
3670
12
        cond = type != NULL;
3671
12
        if (!cond) {
3672
0
            Py_DECREF(Slice_annotations);
3673
0
            return 0;
3674
0
        }
3675
12
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3676
12
        Py_DECREF(type);
3677
12
        if (!cond) {
3678
0
            Py_DECREF(Slice_annotations);
3679
0
            return 0;
3680
0
        }
3681
12
    }
3682
12
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3683
12
                                  Slice_annotations) == 0;
3684
12
    if (!cond) {
3685
0
        Py_DECREF(Slice_annotations);
3686
0
        return 0;
3687
0
    }
3688
12
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3689
12
                                  Slice_annotations) == 0;
3690
12
    if (!cond) {
3691
0
        Py_DECREF(Slice_annotations);
3692
0
        return 0;
3693
0
    }
3694
12
    Py_DECREF(Slice_annotations);
3695
12
    PyObject *Load_annotations = PyDict_New();
3696
12
    if (!Load_annotations) return 0;
3697
12
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3698
12
                                  Load_annotations) == 0;
3699
12
    if (!cond) {
3700
0
        Py_DECREF(Load_annotations);
3701
0
        return 0;
3702
0
    }
3703
12
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3704
12
                                  Load_annotations) == 0;
3705
12
    if (!cond) {
3706
0
        Py_DECREF(Load_annotations);
3707
0
        return 0;
3708
0
    }
3709
12
    Py_DECREF(Load_annotations);
3710
12
    PyObject *Store_annotations = PyDict_New();
3711
12
    if (!Store_annotations) return 0;
3712
12
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3713
12
                                  Store_annotations) == 0;
3714
12
    if (!cond) {
3715
0
        Py_DECREF(Store_annotations);
3716
0
        return 0;
3717
0
    }
3718
12
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3719
12
                                  Store_annotations) == 0;
3720
12
    if (!cond) {
3721
0
        Py_DECREF(Store_annotations);
3722
0
        return 0;
3723
0
    }
3724
12
    Py_DECREF(Store_annotations);
3725
12
    PyObject *Del_annotations = PyDict_New();
3726
12
    if (!Del_annotations) return 0;
3727
12
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3728
12
                                  Del_annotations) == 0;
3729
12
    if (!cond) {
3730
0
        Py_DECREF(Del_annotations);
3731
0
        return 0;
3732
0
    }
3733
12
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3734
12
                                  Del_annotations) == 0;
3735
12
    if (!cond) {
3736
0
        Py_DECREF(Del_annotations);
3737
0
        return 0;
3738
0
    }
3739
12
    Py_DECREF(Del_annotations);
3740
12
    PyObject *And_annotations = PyDict_New();
3741
12
    if (!And_annotations) return 0;
3742
12
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3743
12
                                  And_annotations) == 0;
3744
12
    if (!cond) {
3745
0
        Py_DECREF(And_annotations);
3746
0
        return 0;
3747
0
    }
3748
12
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3749
12
                                  And_annotations) == 0;
3750
12
    if (!cond) {
3751
0
        Py_DECREF(And_annotations);
3752
0
        return 0;
3753
0
    }
3754
12
    Py_DECREF(And_annotations);
3755
12
    PyObject *Or_annotations = PyDict_New();
3756
12
    if (!Or_annotations) return 0;
3757
12
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3758
12
                                  Or_annotations) == 0;
3759
12
    if (!cond) {
3760
0
        Py_DECREF(Or_annotations);
3761
0
        return 0;
3762
0
    }
3763
12
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3764
12
                                  Or_annotations) == 0;
3765
12
    if (!cond) {
3766
0
        Py_DECREF(Or_annotations);
3767
0
        return 0;
3768
0
    }
3769
12
    Py_DECREF(Or_annotations);
3770
12
    PyObject *Add_annotations = PyDict_New();
3771
12
    if (!Add_annotations) return 0;
3772
12
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3773
12
                                  Add_annotations) == 0;
3774
12
    if (!cond) {
3775
0
        Py_DECREF(Add_annotations);
3776
0
        return 0;
3777
0
    }
3778
12
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3779
12
                                  Add_annotations) == 0;
3780
12
    if (!cond) {
3781
0
        Py_DECREF(Add_annotations);
3782
0
        return 0;
3783
0
    }
3784
12
    Py_DECREF(Add_annotations);
3785
12
    PyObject *Sub_annotations = PyDict_New();
3786
12
    if (!Sub_annotations) return 0;
3787
12
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3788
12
                                  Sub_annotations) == 0;
3789
12
    if (!cond) {
3790
0
        Py_DECREF(Sub_annotations);
3791
0
        return 0;
3792
0
    }
3793
12
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3794
12
                                  Sub_annotations) == 0;
3795
12
    if (!cond) {
3796
0
        Py_DECREF(Sub_annotations);
3797
0
        return 0;
3798
0
    }
3799
12
    Py_DECREF(Sub_annotations);
3800
12
    PyObject *Mult_annotations = PyDict_New();
3801
12
    if (!Mult_annotations) return 0;
3802
12
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3803
12
                                  Mult_annotations) == 0;
3804
12
    if (!cond) {
3805
0
        Py_DECREF(Mult_annotations);
3806
0
        return 0;
3807
0
    }
3808
12
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3809
12
                                  Mult_annotations) == 0;
3810
12
    if (!cond) {
3811
0
        Py_DECREF(Mult_annotations);
3812
0
        return 0;
3813
0
    }
3814
12
    Py_DECREF(Mult_annotations);
3815
12
    PyObject *MatMult_annotations = PyDict_New();
3816
12
    if (!MatMult_annotations) return 0;
3817
12
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3818
12
                                  MatMult_annotations) == 0;
3819
12
    if (!cond) {
3820
0
        Py_DECREF(MatMult_annotations);
3821
0
        return 0;
3822
0
    }
3823
12
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3824
12
                                  MatMult_annotations) == 0;
3825
12
    if (!cond) {
3826
0
        Py_DECREF(MatMult_annotations);
3827
0
        return 0;
3828
0
    }
3829
12
    Py_DECREF(MatMult_annotations);
3830
12
    PyObject *Div_annotations = PyDict_New();
3831
12
    if (!Div_annotations) return 0;
3832
12
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3833
12
                                  Div_annotations) == 0;
3834
12
    if (!cond) {
3835
0
        Py_DECREF(Div_annotations);
3836
0
        return 0;
3837
0
    }
3838
12
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3839
12
                                  Div_annotations) == 0;
3840
12
    if (!cond) {
3841
0
        Py_DECREF(Div_annotations);
3842
0
        return 0;
3843
0
    }
3844
12
    Py_DECREF(Div_annotations);
3845
12
    PyObject *Mod_annotations = PyDict_New();
3846
12
    if (!Mod_annotations) return 0;
3847
12
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3848
12
                                  Mod_annotations) == 0;
3849
12
    if (!cond) {
3850
0
        Py_DECREF(Mod_annotations);
3851
0
        return 0;
3852
0
    }
3853
12
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3854
12
                                  Mod_annotations) == 0;
3855
12
    if (!cond) {
3856
0
        Py_DECREF(Mod_annotations);
3857
0
        return 0;
3858
0
    }
3859
12
    Py_DECREF(Mod_annotations);
3860
12
    PyObject *Pow_annotations = PyDict_New();
3861
12
    if (!Pow_annotations) return 0;
3862
12
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3863
12
                                  Pow_annotations) == 0;
3864
12
    if (!cond) {
3865
0
        Py_DECREF(Pow_annotations);
3866
0
        return 0;
3867
0
    }
3868
12
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3869
12
                                  Pow_annotations) == 0;
3870
12
    if (!cond) {
3871
0
        Py_DECREF(Pow_annotations);
3872
0
        return 0;
3873
0
    }
3874
12
    Py_DECREF(Pow_annotations);
3875
12
    PyObject *LShift_annotations = PyDict_New();
3876
12
    if (!LShift_annotations) return 0;
3877
12
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3878
12
                                  LShift_annotations) == 0;
3879
12
    if (!cond) {
3880
0
        Py_DECREF(LShift_annotations);
3881
0
        return 0;
3882
0
    }
3883
12
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3884
12
                                  LShift_annotations) == 0;
3885
12
    if (!cond) {
3886
0
        Py_DECREF(LShift_annotations);
3887
0
        return 0;
3888
0
    }
3889
12
    Py_DECREF(LShift_annotations);
3890
12
    PyObject *RShift_annotations = PyDict_New();
3891
12
    if (!RShift_annotations) return 0;
3892
12
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3893
12
                                  RShift_annotations) == 0;
3894
12
    if (!cond) {
3895
0
        Py_DECREF(RShift_annotations);
3896
0
        return 0;
3897
0
    }
3898
12
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3899
12
                                  RShift_annotations) == 0;
3900
12
    if (!cond) {
3901
0
        Py_DECREF(RShift_annotations);
3902
0
        return 0;
3903
0
    }
3904
12
    Py_DECREF(RShift_annotations);
3905
12
    PyObject *BitOr_annotations = PyDict_New();
3906
12
    if (!BitOr_annotations) return 0;
3907
12
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3908
12
                                  BitOr_annotations) == 0;
3909
12
    if (!cond) {
3910
0
        Py_DECREF(BitOr_annotations);
3911
0
        return 0;
3912
0
    }
3913
12
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3914
12
                                  BitOr_annotations) == 0;
3915
12
    if (!cond) {
3916
0
        Py_DECREF(BitOr_annotations);
3917
0
        return 0;
3918
0
    }
3919
12
    Py_DECREF(BitOr_annotations);
3920
12
    PyObject *BitXor_annotations = PyDict_New();
3921
12
    if (!BitXor_annotations) return 0;
3922
12
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3923
12
                                  BitXor_annotations) == 0;
3924
12
    if (!cond) {
3925
0
        Py_DECREF(BitXor_annotations);
3926
0
        return 0;
3927
0
    }
3928
12
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3929
12
                                  BitXor_annotations) == 0;
3930
12
    if (!cond) {
3931
0
        Py_DECREF(BitXor_annotations);
3932
0
        return 0;
3933
0
    }
3934
12
    Py_DECREF(BitXor_annotations);
3935
12
    PyObject *BitAnd_annotations = PyDict_New();
3936
12
    if (!BitAnd_annotations) return 0;
3937
12
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3938
12
                                  BitAnd_annotations) == 0;
3939
12
    if (!cond) {
3940
0
        Py_DECREF(BitAnd_annotations);
3941
0
        return 0;
3942
0
    }
3943
12
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3944
12
                                  BitAnd_annotations) == 0;
3945
12
    if (!cond) {
3946
0
        Py_DECREF(BitAnd_annotations);
3947
0
        return 0;
3948
0
    }
3949
12
    Py_DECREF(BitAnd_annotations);
3950
12
    PyObject *FloorDiv_annotations = PyDict_New();
3951
12
    if (!FloorDiv_annotations) return 0;
3952
12
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3953
12
                                  FloorDiv_annotations) == 0;
3954
12
    if (!cond) {
3955
0
        Py_DECREF(FloorDiv_annotations);
3956
0
        return 0;
3957
0
    }
3958
12
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3959
12
                                  FloorDiv_annotations) == 0;
3960
12
    if (!cond) {
3961
0
        Py_DECREF(FloorDiv_annotations);
3962
0
        return 0;
3963
0
    }
3964
12
    Py_DECREF(FloorDiv_annotations);
3965
12
    PyObject *Invert_annotations = PyDict_New();
3966
12
    if (!Invert_annotations) return 0;
3967
12
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3968
12
                                  Invert_annotations) == 0;
3969
12
    if (!cond) {
3970
0
        Py_DECREF(Invert_annotations);
3971
0
        return 0;
3972
0
    }
3973
12
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3974
12
                                  Invert_annotations) == 0;
3975
12
    if (!cond) {
3976
0
        Py_DECREF(Invert_annotations);
3977
0
        return 0;
3978
0
    }
3979
12
    Py_DECREF(Invert_annotations);
3980
12
    PyObject *Not_annotations = PyDict_New();
3981
12
    if (!Not_annotations) return 0;
3982
12
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3983
12
                                  Not_annotations) == 0;
3984
12
    if (!cond) {
3985
0
        Py_DECREF(Not_annotations);
3986
0
        return 0;
3987
0
    }
3988
12
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3989
12
                                  Not_annotations) == 0;
3990
12
    if (!cond) {
3991
0
        Py_DECREF(Not_annotations);
3992
0
        return 0;
3993
0
    }
3994
12
    Py_DECREF(Not_annotations);
3995
12
    PyObject *UAdd_annotations = PyDict_New();
3996
12
    if (!UAdd_annotations) return 0;
3997
12
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3998
12
                                  UAdd_annotations) == 0;
3999
12
    if (!cond) {
4000
0
        Py_DECREF(UAdd_annotations);
4001
0
        return 0;
4002
0
    }
4003
12
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
4004
12
                                  UAdd_annotations) == 0;
4005
12
    if (!cond) {
4006
0
        Py_DECREF(UAdd_annotations);
4007
0
        return 0;
4008
0
    }
4009
12
    Py_DECREF(UAdd_annotations);
4010
12
    PyObject *USub_annotations = PyDict_New();
4011
12
    if (!USub_annotations) return 0;
4012
12
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
4013
12
                                  USub_annotations) == 0;
4014
12
    if (!cond) {
4015
0
        Py_DECREF(USub_annotations);
4016
0
        return 0;
4017
0
    }
4018
12
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
4019
12
                                  USub_annotations) == 0;
4020
12
    if (!cond) {
4021
0
        Py_DECREF(USub_annotations);
4022
0
        return 0;
4023
0
    }
4024
12
    Py_DECREF(USub_annotations);
4025
12
    PyObject *Eq_annotations = PyDict_New();
4026
12
    if (!Eq_annotations) return 0;
4027
12
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
4028
12
                                  Eq_annotations) == 0;
4029
12
    if (!cond) {
4030
0
        Py_DECREF(Eq_annotations);
4031
0
        return 0;
4032
0
    }
4033
12
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
4034
12
                                  Eq_annotations) == 0;
4035
12
    if (!cond) {
4036
0
        Py_DECREF(Eq_annotations);
4037
0
        return 0;
4038
0
    }
4039
12
    Py_DECREF(Eq_annotations);
4040
12
    PyObject *NotEq_annotations = PyDict_New();
4041
12
    if (!NotEq_annotations) return 0;
4042
12
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4043
12
                                  NotEq_annotations) == 0;
4044
12
    if (!cond) {
4045
0
        Py_DECREF(NotEq_annotations);
4046
0
        return 0;
4047
0
    }
4048
12
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4049
12
                                  NotEq_annotations) == 0;
4050
12
    if (!cond) {
4051
0
        Py_DECREF(NotEq_annotations);
4052
0
        return 0;
4053
0
    }
4054
12
    Py_DECREF(NotEq_annotations);
4055
12
    PyObject *Lt_annotations = PyDict_New();
4056
12
    if (!Lt_annotations) return 0;
4057
12
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4058
12
                                  Lt_annotations) == 0;
4059
12
    if (!cond) {
4060
0
        Py_DECREF(Lt_annotations);
4061
0
        return 0;
4062
0
    }
4063
12
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4064
12
                                  Lt_annotations) == 0;
4065
12
    if (!cond) {
4066
0
        Py_DECREF(Lt_annotations);
4067
0
        return 0;
4068
0
    }
4069
12
    Py_DECREF(Lt_annotations);
4070
12
    PyObject *LtE_annotations = PyDict_New();
4071
12
    if (!LtE_annotations) return 0;
4072
12
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4073
12
                                  LtE_annotations) == 0;
4074
12
    if (!cond) {
4075
0
        Py_DECREF(LtE_annotations);
4076
0
        return 0;
4077
0
    }
4078
12
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4079
12
                                  LtE_annotations) == 0;
4080
12
    if (!cond) {
4081
0
        Py_DECREF(LtE_annotations);
4082
0
        return 0;
4083
0
    }
4084
12
    Py_DECREF(LtE_annotations);
4085
12
    PyObject *Gt_annotations = PyDict_New();
4086
12
    if (!Gt_annotations) return 0;
4087
12
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4088
12
                                  Gt_annotations) == 0;
4089
12
    if (!cond) {
4090
0
        Py_DECREF(Gt_annotations);
4091
0
        return 0;
4092
0
    }
4093
12
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4094
12
                                  Gt_annotations) == 0;
4095
12
    if (!cond) {
4096
0
        Py_DECREF(Gt_annotations);
4097
0
        return 0;
4098
0
    }
4099
12
    Py_DECREF(Gt_annotations);
4100
12
    PyObject *GtE_annotations = PyDict_New();
4101
12
    if (!GtE_annotations) return 0;
4102
12
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4103
12
                                  GtE_annotations) == 0;
4104
12
    if (!cond) {
4105
0
        Py_DECREF(GtE_annotations);
4106
0
        return 0;
4107
0
    }
4108
12
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4109
12
                                  GtE_annotations) == 0;
4110
12
    if (!cond) {
4111
0
        Py_DECREF(GtE_annotations);
4112
0
        return 0;
4113
0
    }
4114
12
    Py_DECREF(GtE_annotations);
4115
12
    PyObject *Is_annotations = PyDict_New();
4116
12
    if (!Is_annotations) return 0;
4117
12
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4118
12
                                  Is_annotations) == 0;
4119
12
    if (!cond) {
4120
0
        Py_DECREF(Is_annotations);
4121
0
        return 0;
4122
0
    }
4123
12
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4124
12
                                  Is_annotations) == 0;
4125
12
    if (!cond) {
4126
0
        Py_DECREF(Is_annotations);
4127
0
        return 0;
4128
0
    }
4129
12
    Py_DECREF(Is_annotations);
4130
12
    PyObject *IsNot_annotations = PyDict_New();
4131
12
    if (!IsNot_annotations) return 0;
4132
12
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4133
12
                                  IsNot_annotations) == 0;
4134
12
    if (!cond) {
4135
0
        Py_DECREF(IsNot_annotations);
4136
0
        return 0;
4137
0
    }
4138
12
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4139
12
                                  IsNot_annotations) == 0;
4140
12
    if (!cond) {
4141
0
        Py_DECREF(IsNot_annotations);
4142
0
        return 0;
4143
0
    }
4144
12
    Py_DECREF(IsNot_annotations);
4145
12
    PyObject *In_annotations = PyDict_New();
4146
12
    if (!In_annotations) return 0;
4147
12
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4148
12
                                  In_annotations) == 0;
4149
12
    if (!cond) {
4150
0
        Py_DECREF(In_annotations);
4151
0
        return 0;
4152
0
    }
4153
12
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4154
12
                                  In_annotations) == 0;
4155
12
    if (!cond) {
4156
0
        Py_DECREF(In_annotations);
4157
0
        return 0;
4158
0
    }
4159
12
    Py_DECREF(In_annotations);
4160
12
    PyObject *NotIn_annotations = PyDict_New();
4161
12
    if (!NotIn_annotations) return 0;
4162
12
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4163
12
                                  NotIn_annotations) == 0;
4164
12
    if (!cond) {
4165
0
        Py_DECREF(NotIn_annotations);
4166
0
        return 0;
4167
0
    }
4168
12
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4169
12
                                  NotIn_annotations) == 0;
4170
12
    if (!cond) {
4171
0
        Py_DECREF(NotIn_annotations);
4172
0
        return 0;
4173
0
    }
4174
12
    Py_DECREF(NotIn_annotations);
4175
12
    PyObject *comprehension_annotations = PyDict_New();
4176
12
    if (!comprehension_annotations) return 0;
4177
12
    {
4178
12
        PyObject *type = state->expr_type;
4179
12
        Py_INCREF(type);
4180
12
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4181
12
                                    == 0;
4182
12
        Py_DECREF(type);
4183
12
        if (!cond) {
4184
0
            Py_DECREF(comprehension_annotations);
4185
0
            return 0;
4186
0
        }
4187
12
    }
4188
12
    {
4189
12
        PyObject *type = state->expr_type;
4190
12
        Py_INCREF(type);
4191
12
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4192
12
                                    0;
4193
12
        Py_DECREF(type);
4194
12
        if (!cond) {
4195
0
            Py_DECREF(comprehension_annotations);
4196
0
            return 0;
4197
0
        }
4198
12
    }
4199
12
    {
4200
12
        PyObject *type = state->expr_type;
4201
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4202
12
        cond = type != NULL;
4203
12
        if (!cond) {
4204
0
            Py_DECREF(comprehension_annotations);
4205
0
            return 0;
4206
0
        }
4207
12
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4208
12
                                    0;
4209
12
        Py_DECREF(type);
4210
12
        if (!cond) {
4211
0
            Py_DECREF(comprehension_annotations);
4212
0
            return 0;
4213
0
        }
4214
12
    }
4215
12
    {
4216
12
        PyObject *type = (PyObject *)&PyLong_Type;
4217
12
        Py_INCREF(type);
4218
12
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4219
12
                                    type) == 0;
4220
12
        Py_DECREF(type);
4221
12
        if (!cond) {
4222
0
            Py_DECREF(comprehension_annotations);
4223
0
            return 0;
4224
0
        }
4225
12
    }
4226
12
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4227
12
                                  comprehension_annotations) == 0;
4228
12
    if (!cond) {
4229
0
        Py_DECREF(comprehension_annotations);
4230
0
        return 0;
4231
0
    }
4232
12
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4233
12
                                  comprehension_annotations) == 0;
4234
12
    if (!cond) {
4235
0
        Py_DECREF(comprehension_annotations);
4236
0
        return 0;
4237
0
    }
4238
12
    Py_DECREF(comprehension_annotations);
4239
12
    PyObject *ExceptHandler_annotations = PyDict_New();
4240
12
    if (!ExceptHandler_annotations) return 0;
4241
12
    {
4242
12
        PyObject *type = state->expr_type;
4243
12
        type = _Py_union_type_or(type, Py_None);
4244
12
        cond = type != NULL;
4245
12
        if (!cond) {
4246
0
            Py_DECREF(ExceptHandler_annotations);
4247
0
            return 0;
4248
0
        }
4249
12
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4250
12
                                    0;
4251
12
        Py_DECREF(type);
4252
12
        if (!cond) {
4253
0
            Py_DECREF(ExceptHandler_annotations);
4254
0
            return 0;
4255
0
        }
4256
12
    }
4257
12
    {
4258
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4259
12
        type = _Py_union_type_or(type, Py_None);
4260
12
        cond = type != NULL;
4261
12
        if (!cond) {
4262
0
            Py_DECREF(ExceptHandler_annotations);
4263
0
            return 0;
4264
0
        }
4265
12
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4266
12
                                    0;
4267
12
        Py_DECREF(type);
4268
12
        if (!cond) {
4269
0
            Py_DECREF(ExceptHandler_annotations);
4270
0
            return 0;
4271
0
        }
4272
12
    }
4273
12
    {
4274
12
        PyObject *type = state->stmt_type;
4275
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4276
12
        cond = type != NULL;
4277
12
        if (!cond) {
4278
0
            Py_DECREF(ExceptHandler_annotations);
4279
0
            return 0;
4280
0
        }
4281
12
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4282
12
                                    0;
4283
12
        Py_DECREF(type);
4284
12
        if (!cond) {
4285
0
            Py_DECREF(ExceptHandler_annotations);
4286
0
            return 0;
4287
0
        }
4288
12
    }
4289
12
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4290
12
                                  ExceptHandler_annotations) == 0;
4291
12
    if (!cond) {
4292
0
        Py_DECREF(ExceptHandler_annotations);
4293
0
        return 0;
4294
0
    }
4295
12
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4296
12
                                  ExceptHandler_annotations) == 0;
4297
12
    if (!cond) {
4298
0
        Py_DECREF(ExceptHandler_annotations);
4299
0
        return 0;
4300
0
    }
4301
12
    Py_DECREF(ExceptHandler_annotations);
4302
12
    PyObject *arguments_annotations = PyDict_New();
4303
12
    if (!arguments_annotations) return 0;
4304
12
    {
4305
12
        PyObject *type = state->arg_type;
4306
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4307
12
        cond = type != NULL;
4308
12
        if (!cond) {
4309
0
            Py_DECREF(arguments_annotations);
4310
0
            return 0;
4311
0
        }
4312
12
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4313
12
                                    == 0;
4314
12
        Py_DECREF(type);
4315
12
        if (!cond) {
4316
0
            Py_DECREF(arguments_annotations);
4317
0
            return 0;
4318
0
        }
4319
12
    }
4320
12
    {
4321
12
        PyObject *type = state->arg_type;
4322
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4323
12
        cond = type != NULL;
4324
12
        if (!cond) {
4325
0
            Py_DECREF(arguments_annotations);
4326
0
            return 0;
4327
0
        }
4328
12
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4329
12
        Py_DECREF(type);
4330
12
        if (!cond) {
4331
0
            Py_DECREF(arguments_annotations);
4332
0
            return 0;
4333
0
        }
4334
12
    }
4335
12
    {
4336
12
        PyObject *type = state->arg_type;
4337
12
        type = _Py_union_type_or(type, Py_None);
4338
12
        cond = type != NULL;
4339
12
        if (!cond) {
4340
0
            Py_DECREF(arguments_annotations);
4341
0
            return 0;
4342
0
        }
4343
12
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4344
12
        Py_DECREF(type);
4345
12
        if (!cond) {
4346
0
            Py_DECREF(arguments_annotations);
4347
0
            return 0;
4348
0
        }
4349
12
    }
4350
12
    {
4351
12
        PyObject *type = state->arg_type;
4352
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4353
12
        cond = type != NULL;
4354
12
        if (!cond) {
4355
0
            Py_DECREF(arguments_annotations);
4356
0
            return 0;
4357
0
        }
4358
12
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4359
12
                                    == 0;
4360
12
        Py_DECREF(type);
4361
12
        if (!cond) {
4362
0
            Py_DECREF(arguments_annotations);
4363
0
            return 0;
4364
0
        }
4365
12
    }
4366
12
    {
4367
12
        PyObject *type = state->expr_type;
4368
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4369
12
        cond = type != NULL;
4370
12
        if (!cond) {
4371
0
            Py_DECREF(arguments_annotations);
4372
0
            return 0;
4373
0
        }
4374
12
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4375
12
                                    == 0;
4376
12
        Py_DECREF(type);
4377
12
        if (!cond) {
4378
0
            Py_DECREF(arguments_annotations);
4379
0
            return 0;
4380
0
        }
4381
12
    }
4382
12
    {
4383
12
        PyObject *type = state->arg_type;
4384
12
        type = _Py_union_type_or(type, Py_None);
4385
12
        cond = type != NULL;
4386
12
        if (!cond) {
4387
0
            Py_DECREF(arguments_annotations);
4388
0
            return 0;
4389
0
        }
4390
12
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4391
12
        Py_DECREF(type);
4392
12
        if (!cond) {
4393
0
            Py_DECREF(arguments_annotations);
4394
0
            return 0;
4395
0
        }
4396
12
    }
4397
12
    {
4398
12
        PyObject *type = state->expr_type;
4399
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4400
12
        cond = type != NULL;
4401
12
        if (!cond) {
4402
0
            Py_DECREF(arguments_annotations);
4403
0
            return 0;
4404
0
        }
4405
12
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4406
12
                                    0;
4407
12
        Py_DECREF(type);
4408
12
        if (!cond) {
4409
0
            Py_DECREF(arguments_annotations);
4410
0
            return 0;
4411
0
        }
4412
12
    }
4413
12
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4414
12
                                  arguments_annotations) == 0;
4415
12
    if (!cond) {
4416
0
        Py_DECREF(arguments_annotations);
4417
0
        return 0;
4418
0
    }
4419
12
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4420
12
                                  arguments_annotations) == 0;
4421
12
    if (!cond) {
4422
0
        Py_DECREF(arguments_annotations);
4423
0
        return 0;
4424
0
    }
4425
12
    Py_DECREF(arguments_annotations);
4426
12
    PyObject *arg_annotations = PyDict_New();
4427
12
    if (!arg_annotations) return 0;
4428
12
    {
4429
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4430
12
        Py_INCREF(type);
4431
12
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4432
12
        Py_DECREF(type);
4433
12
        if (!cond) {
4434
0
            Py_DECREF(arg_annotations);
4435
0
            return 0;
4436
0
        }
4437
12
    }
4438
12
    {
4439
12
        PyObject *type = state->expr_type;
4440
12
        type = _Py_union_type_or(type, Py_None);
4441
12
        cond = type != NULL;
4442
12
        if (!cond) {
4443
0
            Py_DECREF(arg_annotations);
4444
0
            return 0;
4445
0
        }
4446
12
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4447
12
        Py_DECREF(type);
4448
12
        if (!cond) {
4449
0
            Py_DECREF(arg_annotations);
4450
0
            return 0;
4451
0
        }
4452
12
    }
4453
12
    {
4454
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4455
12
        type = _Py_union_type_or(type, Py_None);
4456
12
        cond = type != NULL;
4457
12
        if (!cond) {
4458
0
            Py_DECREF(arg_annotations);
4459
0
            return 0;
4460
0
        }
4461
12
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4462
12
        Py_DECREF(type);
4463
12
        if (!cond) {
4464
0
            Py_DECREF(arg_annotations);
4465
0
            return 0;
4466
0
        }
4467
12
    }
4468
12
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4469
12
                                  arg_annotations) == 0;
4470
12
    if (!cond) {
4471
0
        Py_DECREF(arg_annotations);
4472
0
        return 0;
4473
0
    }
4474
12
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4475
12
                                  arg_annotations) == 0;
4476
12
    if (!cond) {
4477
0
        Py_DECREF(arg_annotations);
4478
0
        return 0;
4479
0
    }
4480
12
    Py_DECREF(arg_annotations);
4481
12
    PyObject *keyword_annotations = PyDict_New();
4482
12
    if (!keyword_annotations) return 0;
4483
12
    {
4484
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4485
12
        type = _Py_union_type_or(type, Py_None);
4486
12
        cond = type != NULL;
4487
12
        if (!cond) {
4488
0
            Py_DECREF(keyword_annotations);
4489
0
            return 0;
4490
0
        }
4491
12
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4492
12
        Py_DECREF(type);
4493
12
        if (!cond) {
4494
0
            Py_DECREF(keyword_annotations);
4495
0
            return 0;
4496
0
        }
4497
12
    }
4498
12
    {
4499
12
        PyObject *type = state->expr_type;
4500
12
        Py_INCREF(type);
4501
12
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4502
12
        Py_DECREF(type);
4503
12
        if (!cond) {
4504
0
            Py_DECREF(keyword_annotations);
4505
0
            return 0;
4506
0
        }
4507
12
    }
4508
12
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4509
12
                                  keyword_annotations) == 0;
4510
12
    if (!cond) {
4511
0
        Py_DECREF(keyword_annotations);
4512
0
        return 0;
4513
0
    }
4514
12
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4515
12
                                  keyword_annotations) == 0;
4516
12
    if (!cond) {
4517
0
        Py_DECREF(keyword_annotations);
4518
0
        return 0;
4519
0
    }
4520
12
    Py_DECREF(keyword_annotations);
4521
12
    PyObject *alias_annotations = PyDict_New();
4522
12
    if (!alias_annotations) return 0;
4523
12
    {
4524
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4525
12
        Py_INCREF(type);
4526
12
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4527
12
        Py_DECREF(type);
4528
12
        if (!cond) {
4529
0
            Py_DECREF(alias_annotations);
4530
0
            return 0;
4531
0
        }
4532
12
    }
4533
12
    {
4534
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4535
12
        type = _Py_union_type_or(type, Py_None);
4536
12
        cond = type != NULL;
4537
12
        if (!cond) {
4538
0
            Py_DECREF(alias_annotations);
4539
0
            return 0;
4540
0
        }
4541
12
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4542
12
        Py_DECREF(type);
4543
12
        if (!cond) {
4544
0
            Py_DECREF(alias_annotations);
4545
0
            return 0;
4546
0
        }
4547
12
    }
4548
12
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4549
12
                                  alias_annotations) == 0;
4550
12
    if (!cond) {
4551
0
        Py_DECREF(alias_annotations);
4552
0
        return 0;
4553
0
    }
4554
12
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4555
12
                                  alias_annotations) == 0;
4556
12
    if (!cond) {
4557
0
        Py_DECREF(alias_annotations);
4558
0
        return 0;
4559
0
    }
4560
12
    Py_DECREF(alias_annotations);
4561
12
    PyObject *withitem_annotations = PyDict_New();
4562
12
    if (!withitem_annotations) return 0;
4563
12
    {
4564
12
        PyObject *type = state->expr_type;
4565
12
        Py_INCREF(type);
4566
12
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4567
12
                                    == 0;
4568
12
        Py_DECREF(type);
4569
12
        if (!cond) {
4570
0
            Py_DECREF(withitem_annotations);
4571
0
            return 0;
4572
0
        }
4573
12
    }
4574
12
    {
4575
12
        PyObject *type = state->expr_type;
4576
12
        type = _Py_union_type_or(type, Py_None);
4577
12
        cond = type != NULL;
4578
12
        if (!cond) {
4579
0
            Py_DECREF(withitem_annotations);
4580
0
            return 0;
4581
0
        }
4582
12
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4583
12
                                    type) == 0;
4584
12
        Py_DECREF(type);
4585
12
        if (!cond) {
4586
0
            Py_DECREF(withitem_annotations);
4587
0
            return 0;
4588
0
        }
4589
12
    }
4590
12
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4591
12
                                  withitem_annotations) == 0;
4592
12
    if (!cond) {
4593
0
        Py_DECREF(withitem_annotations);
4594
0
        return 0;
4595
0
    }
4596
12
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4597
12
                                  withitem_annotations) == 0;
4598
12
    if (!cond) {
4599
0
        Py_DECREF(withitem_annotations);
4600
0
        return 0;
4601
0
    }
4602
12
    Py_DECREF(withitem_annotations);
4603
12
    PyObject *match_case_annotations = PyDict_New();
4604
12
    if (!match_case_annotations) return 0;
4605
12
    {
4606
12
        PyObject *type = state->pattern_type;
4607
12
        Py_INCREF(type);
4608
12
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4609
12
                                    0;
4610
12
        Py_DECREF(type);
4611
12
        if (!cond) {
4612
0
            Py_DECREF(match_case_annotations);
4613
0
            return 0;
4614
0
        }
4615
12
    }
4616
12
    {
4617
12
        PyObject *type = state->expr_type;
4618
12
        type = _Py_union_type_or(type, Py_None);
4619
12
        cond = type != NULL;
4620
12
        if (!cond) {
4621
0
            Py_DECREF(match_case_annotations);
4622
0
            return 0;
4623
0
        }
4624
12
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4625
12
        Py_DECREF(type);
4626
12
        if (!cond) {
4627
0
            Py_DECREF(match_case_annotations);
4628
0
            return 0;
4629
0
        }
4630
12
    }
4631
12
    {
4632
12
        PyObject *type = state->stmt_type;
4633
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4634
12
        cond = type != NULL;
4635
12
        if (!cond) {
4636
0
            Py_DECREF(match_case_annotations);
4637
0
            return 0;
4638
0
        }
4639
12
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4640
12
        Py_DECREF(type);
4641
12
        if (!cond) {
4642
0
            Py_DECREF(match_case_annotations);
4643
0
            return 0;
4644
0
        }
4645
12
    }
4646
12
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4647
12
                                  match_case_annotations) == 0;
4648
12
    if (!cond) {
4649
0
        Py_DECREF(match_case_annotations);
4650
0
        return 0;
4651
0
    }
4652
12
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4653
12
                                  match_case_annotations) == 0;
4654
12
    if (!cond) {
4655
0
        Py_DECREF(match_case_annotations);
4656
0
        return 0;
4657
0
    }
4658
12
    Py_DECREF(match_case_annotations);
4659
12
    PyObject *MatchValue_annotations = PyDict_New();
4660
12
    if (!MatchValue_annotations) return 0;
4661
12
    {
4662
12
        PyObject *type = state->expr_type;
4663
12
        Py_INCREF(type);
4664
12
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4665
12
        Py_DECREF(type);
4666
12
        if (!cond) {
4667
0
            Py_DECREF(MatchValue_annotations);
4668
0
            return 0;
4669
0
        }
4670
12
    }
4671
12
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4672
12
                                  MatchValue_annotations) == 0;
4673
12
    if (!cond) {
4674
0
        Py_DECREF(MatchValue_annotations);
4675
0
        return 0;
4676
0
    }
4677
12
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4678
12
                                  MatchValue_annotations) == 0;
4679
12
    if (!cond) {
4680
0
        Py_DECREF(MatchValue_annotations);
4681
0
        return 0;
4682
0
    }
4683
12
    Py_DECREF(MatchValue_annotations);
4684
12
    PyObject *MatchSingleton_annotations = PyDict_New();
4685
12
    if (!MatchSingleton_annotations) return 0;
4686
12
    {
4687
12
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4688
12
        Py_INCREF(type);
4689
12
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4690
12
                                    == 0;
4691
12
        Py_DECREF(type);
4692
12
        if (!cond) {
4693
0
            Py_DECREF(MatchSingleton_annotations);
4694
0
            return 0;
4695
0
        }
4696
12
    }
4697
12
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4698
12
                                  MatchSingleton_annotations) == 0;
4699
12
    if (!cond) {
4700
0
        Py_DECREF(MatchSingleton_annotations);
4701
0
        return 0;
4702
0
    }
4703
12
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4704
12
                                  "__annotations__",
4705
12
                                  MatchSingleton_annotations) == 0;
4706
12
    if (!cond) {
4707
0
        Py_DECREF(MatchSingleton_annotations);
4708
0
        return 0;
4709
0
    }
4710
12
    Py_DECREF(MatchSingleton_annotations);
4711
12
    PyObject *MatchSequence_annotations = PyDict_New();
4712
12
    if (!MatchSequence_annotations) return 0;
4713
12
    {
4714
12
        PyObject *type = state->pattern_type;
4715
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4716
12
        cond = type != NULL;
4717
12
        if (!cond) {
4718
0
            Py_DECREF(MatchSequence_annotations);
4719
0
            return 0;
4720
0
        }
4721
12
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4722
12
                                    type) == 0;
4723
12
        Py_DECREF(type);
4724
12
        if (!cond) {
4725
0
            Py_DECREF(MatchSequence_annotations);
4726
0
            return 0;
4727
0
        }
4728
12
    }
4729
12
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4730
12
                                  MatchSequence_annotations) == 0;
4731
12
    if (!cond) {
4732
0
        Py_DECREF(MatchSequence_annotations);
4733
0
        return 0;
4734
0
    }
4735
12
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4736
12
                                  MatchSequence_annotations) == 0;
4737
12
    if (!cond) {
4738
0
        Py_DECREF(MatchSequence_annotations);
4739
0
        return 0;
4740
0
    }
4741
12
    Py_DECREF(MatchSequence_annotations);
4742
12
    PyObject *MatchMapping_annotations = PyDict_New();
4743
12
    if (!MatchMapping_annotations) return 0;
4744
12
    {
4745
12
        PyObject *type = state->expr_type;
4746
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4747
12
        cond = type != NULL;
4748
12
        if (!cond) {
4749
0
            Py_DECREF(MatchMapping_annotations);
4750
0
            return 0;
4751
0
        }
4752
12
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4753
12
                                    0;
4754
12
        Py_DECREF(type);
4755
12
        if (!cond) {
4756
0
            Py_DECREF(MatchMapping_annotations);
4757
0
            return 0;
4758
0
        }
4759
12
    }
4760
12
    {
4761
12
        PyObject *type = state->pattern_type;
4762
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4763
12
        cond = type != NULL;
4764
12
        if (!cond) {
4765
0
            Py_DECREF(MatchMapping_annotations);
4766
0
            return 0;
4767
0
        }
4768
12
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4769
12
                                    == 0;
4770
12
        Py_DECREF(type);
4771
12
        if (!cond) {
4772
0
            Py_DECREF(MatchMapping_annotations);
4773
0
            return 0;
4774
0
        }
4775
12
    }
4776
12
    {
4777
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4778
12
        type = _Py_union_type_or(type, Py_None);
4779
12
        cond = type != NULL;
4780
12
        if (!cond) {
4781
0
            Py_DECREF(MatchMapping_annotations);
4782
0
            return 0;
4783
0
        }
4784
12
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4785
12
                                    0;
4786
12
        Py_DECREF(type);
4787
12
        if (!cond) {
4788
0
            Py_DECREF(MatchMapping_annotations);
4789
0
            return 0;
4790
0
        }
4791
12
    }
4792
12
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4793
12
                                  MatchMapping_annotations) == 0;
4794
12
    if (!cond) {
4795
0
        Py_DECREF(MatchMapping_annotations);
4796
0
        return 0;
4797
0
    }
4798
12
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4799
12
                                  MatchMapping_annotations) == 0;
4800
12
    if (!cond) {
4801
0
        Py_DECREF(MatchMapping_annotations);
4802
0
        return 0;
4803
0
    }
4804
12
    Py_DECREF(MatchMapping_annotations);
4805
12
    PyObject *MatchClass_annotations = PyDict_New();
4806
12
    if (!MatchClass_annotations) return 0;
4807
12
    {
4808
12
        PyObject *type = state->expr_type;
4809
12
        Py_INCREF(type);
4810
12
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4811
12
        Py_DECREF(type);
4812
12
        if (!cond) {
4813
0
            Py_DECREF(MatchClass_annotations);
4814
0
            return 0;
4815
0
        }
4816
12
    }
4817
12
    {
4818
12
        PyObject *type = state->pattern_type;
4819
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4820
12
        cond = type != NULL;
4821
12
        if (!cond) {
4822
0
            Py_DECREF(MatchClass_annotations);
4823
0
            return 0;
4824
0
        }
4825
12
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4826
12
                                    == 0;
4827
12
        Py_DECREF(type);
4828
12
        if (!cond) {
4829
0
            Py_DECREF(MatchClass_annotations);
4830
0
            return 0;
4831
0
        }
4832
12
    }
4833
12
    {
4834
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4835
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4836
12
        cond = type != NULL;
4837
12
        if (!cond) {
4838
0
            Py_DECREF(MatchClass_annotations);
4839
0
            return 0;
4840
0
        }
4841
12
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4842
12
                                    == 0;
4843
12
        Py_DECREF(type);
4844
12
        if (!cond) {
4845
0
            Py_DECREF(MatchClass_annotations);
4846
0
            return 0;
4847
0
        }
4848
12
    }
4849
12
    {
4850
12
        PyObject *type = state->pattern_type;
4851
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4852
12
        cond = type != NULL;
4853
12
        if (!cond) {
4854
0
            Py_DECREF(MatchClass_annotations);
4855
0
            return 0;
4856
0
        }
4857
12
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4858
12
                                    type) == 0;
4859
12
        Py_DECREF(type);
4860
12
        if (!cond) {
4861
0
            Py_DECREF(MatchClass_annotations);
4862
0
            return 0;
4863
0
        }
4864
12
    }
4865
12
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4866
12
                                  MatchClass_annotations) == 0;
4867
12
    if (!cond) {
4868
0
        Py_DECREF(MatchClass_annotations);
4869
0
        return 0;
4870
0
    }
4871
12
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4872
12
                                  MatchClass_annotations) == 0;
4873
12
    if (!cond) {
4874
0
        Py_DECREF(MatchClass_annotations);
4875
0
        return 0;
4876
0
    }
4877
12
    Py_DECREF(MatchClass_annotations);
4878
12
    PyObject *MatchStar_annotations = PyDict_New();
4879
12
    if (!MatchStar_annotations) return 0;
4880
12
    {
4881
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4882
12
        type = _Py_union_type_or(type, Py_None);
4883
12
        cond = type != NULL;
4884
12
        if (!cond) {
4885
0
            Py_DECREF(MatchStar_annotations);
4886
0
            return 0;
4887
0
        }
4888
12
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4889
12
        Py_DECREF(type);
4890
12
        if (!cond) {
4891
0
            Py_DECREF(MatchStar_annotations);
4892
0
            return 0;
4893
0
        }
4894
12
    }
4895
12
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4896
12
                                  MatchStar_annotations) == 0;
4897
12
    if (!cond) {
4898
0
        Py_DECREF(MatchStar_annotations);
4899
0
        return 0;
4900
0
    }
4901
12
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4902
12
                                  MatchStar_annotations) == 0;
4903
12
    if (!cond) {
4904
0
        Py_DECREF(MatchStar_annotations);
4905
0
        return 0;
4906
0
    }
4907
12
    Py_DECREF(MatchStar_annotations);
4908
12
    PyObject *MatchAs_annotations = PyDict_New();
4909
12
    if (!MatchAs_annotations) return 0;
4910
12
    {
4911
12
        PyObject *type = state->pattern_type;
4912
12
        type = _Py_union_type_or(type, Py_None);
4913
12
        cond = type != NULL;
4914
12
        if (!cond) {
4915
0
            Py_DECREF(MatchAs_annotations);
4916
0
            return 0;
4917
0
        }
4918
12
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4919
12
        Py_DECREF(type);
4920
12
        if (!cond) {
4921
0
            Py_DECREF(MatchAs_annotations);
4922
0
            return 0;
4923
0
        }
4924
12
    }
4925
12
    {
4926
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4927
12
        type = _Py_union_type_or(type, Py_None);
4928
12
        cond = type != NULL;
4929
12
        if (!cond) {
4930
0
            Py_DECREF(MatchAs_annotations);
4931
0
            return 0;
4932
0
        }
4933
12
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4934
12
        Py_DECREF(type);
4935
12
        if (!cond) {
4936
0
            Py_DECREF(MatchAs_annotations);
4937
0
            return 0;
4938
0
        }
4939
12
    }
4940
12
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4941
12
                                  MatchAs_annotations) == 0;
4942
12
    if (!cond) {
4943
0
        Py_DECREF(MatchAs_annotations);
4944
0
        return 0;
4945
0
    }
4946
12
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4947
12
                                  MatchAs_annotations) == 0;
4948
12
    if (!cond) {
4949
0
        Py_DECREF(MatchAs_annotations);
4950
0
        return 0;
4951
0
    }
4952
12
    Py_DECREF(MatchAs_annotations);
4953
12
    PyObject *MatchOr_annotations = PyDict_New();
4954
12
    if (!MatchOr_annotations) return 0;
4955
12
    {
4956
12
        PyObject *type = state->pattern_type;
4957
12
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4958
12
        cond = type != NULL;
4959
12
        if (!cond) {
4960
0
            Py_DECREF(MatchOr_annotations);
4961
0
            return 0;
4962
0
        }
4963
12
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4964
12
        Py_DECREF(type);
4965
12
        if (!cond) {
4966
0
            Py_DECREF(MatchOr_annotations);
4967
0
            return 0;
4968
0
        }
4969
12
    }
4970
12
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4971
12
                                  MatchOr_annotations) == 0;
4972
12
    if (!cond) {
4973
0
        Py_DECREF(MatchOr_annotations);
4974
0
        return 0;
4975
0
    }
4976
12
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4977
12
                                  MatchOr_annotations) == 0;
4978
12
    if (!cond) {
4979
0
        Py_DECREF(MatchOr_annotations);
4980
0
        return 0;
4981
0
    }
4982
12
    Py_DECREF(MatchOr_annotations);
4983
12
    PyObject *TypeIgnore_annotations = PyDict_New();
4984
12
    if (!TypeIgnore_annotations) return 0;
4985
12
    {
4986
12
        PyObject *type = (PyObject *)&PyLong_Type;
4987
12
        Py_INCREF(type);
4988
12
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4989
12
                                    0;
4990
12
        Py_DECREF(type);
4991
12
        if (!cond) {
4992
0
            Py_DECREF(TypeIgnore_annotations);
4993
0
            return 0;
4994
0
        }
4995
12
    }
4996
12
    {
4997
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
4998
12
        Py_INCREF(type);
4999
12
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
5000
12
        Py_DECREF(type);
5001
12
        if (!cond) {
5002
0
            Py_DECREF(TypeIgnore_annotations);
5003
0
            return 0;
5004
0
        }
5005
12
    }
5006
12
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
5007
12
                                  TypeIgnore_annotations) == 0;
5008
12
    if (!cond) {
5009
0
        Py_DECREF(TypeIgnore_annotations);
5010
0
        return 0;
5011
0
    }
5012
12
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
5013
12
                                  TypeIgnore_annotations) == 0;
5014
12
    if (!cond) {
5015
0
        Py_DECREF(TypeIgnore_annotations);
5016
0
        return 0;
5017
0
    }
5018
12
    Py_DECREF(TypeIgnore_annotations);
5019
12
    PyObject *TypeVar_annotations = PyDict_New();
5020
12
    if (!TypeVar_annotations) return 0;
5021
12
    {
5022
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
5023
12
        Py_INCREF(type);
5024
12
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
5025
12
        Py_DECREF(type);
5026
12
        if (!cond) {
5027
0
            Py_DECREF(TypeVar_annotations);
5028
0
            return 0;
5029
0
        }
5030
12
    }
5031
12
    {
5032
12
        PyObject *type = state->expr_type;
5033
12
        type = _Py_union_type_or(type, Py_None);
5034
12
        cond = type != NULL;
5035
12
        if (!cond) {
5036
0
            Py_DECREF(TypeVar_annotations);
5037
0
            return 0;
5038
0
        }
5039
12
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5040
12
        Py_DECREF(type);
5041
12
        if (!cond) {
5042
0
            Py_DECREF(TypeVar_annotations);
5043
0
            return 0;
5044
0
        }
5045
12
    }
5046
12
    {
5047
12
        PyObject *type = state->expr_type;
5048
12
        type = _Py_union_type_or(type, Py_None);
5049
12
        cond = type != NULL;
5050
12
        if (!cond) {
5051
0
            Py_DECREF(TypeVar_annotations);
5052
0
            return 0;
5053
0
        }
5054
12
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5055
12
                                    == 0;
5056
12
        Py_DECREF(type);
5057
12
        if (!cond) {
5058
0
            Py_DECREF(TypeVar_annotations);
5059
0
            return 0;
5060
0
        }
5061
12
    }
5062
12
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5063
12
                                  TypeVar_annotations) == 0;
5064
12
    if (!cond) {
5065
0
        Py_DECREF(TypeVar_annotations);
5066
0
        return 0;
5067
0
    }
5068
12
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5069
12
                                  TypeVar_annotations) == 0;
5070
12
    if (!cond) {
5071
0
        Py_DECREF(TypeVar_annotations);
5072
0
        return 0;
5073
0
    }
5074
12
    Py_DECREF(TypeVar_annotations);
5075
12
    PyObject *ParamSpec_annotations = PyDict_New();
5076
12
    if (!ParamSpec_annotations) return 0;
5077
12
    {
5078
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
5079
12
        Py_INCREF(type);
5080
12
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5081
12
        Py_DECREF(type);
5082
12
        if (!cond) {
5083
0
            Py_DECREF(ParamSpec_annotations);
5084
0
            return 0;
5085
0
        }
5086
12
    }
5087
12
    {
5088
12
        PyObject *type = state->expr_type;
5089
12
        type = _Py_union_type_or(type, Py_None);
5090
12
        cond = type != NULL;
5091
12
        if (!cond) {
5092
0
            Py_DECREF(ParamSpec_annotations);
5093
0
            return 0;
5094
0
        }
5095
12
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5096
12
                                    type) == 0;
5097
12
        Py_DECREF(type);
5098
12
        if (!cond) {
5099
0
            Py_DECREF(ParamSpec_annotations);
5100
0
            return 0;
5101
0
        }
5102
12
    }
5103
12
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5104
12
                                  ParamSpec_annotations) == 0;
5105
12
    if (!cond) {
5106
0
        Py_DECREF(ParamSpec_annotations);
5107
0
        return 0;
5108
0
    }
5109
12
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5110
12
                                  ParamSpec_annotations) == 0;
5111
12
    if (!cond) {
5112
0
        Py_DECREF(ParamSpec_annotations);
5113
0
        return 0;
5114
0
    }
5115
12
    Py_DECREF(ParamSpec_annotations);
5116
12
    PyObject *TypeVarTuple_annotations = PyDict_New();
5117
12
    if (!TypeVarTuple_annotations) return 0;
5118
12
    {
5119
12
        PyObject *type = (PyObject *)&PyUnicode_Type;
5120
12
        Py_INCREF(type);
5121
12
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5122
12
                                    0;
5123
12
        Py_DECREF(type);
5124
12
        if (!cond) {
5125
0
            Py_DECREF(TypeVarTuple_annotations);
5126
0
            return 0;
5127
0
        }
5128
12
    }
5129
12
    {
5130
12
        PyObject *type = state->expr_type;
5131
12
        type = _Py_union_type_or(type, Py_None);
5132
12
        cond = type != NULL;
5133
12
        if (!cond) {
5134
0
            Py_DECREF(TypeVarTuple_annotations);
5135
0
            return 0;
5136
0
        }
5137
12
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5138
12
                                    type) == 0;
5139
12
        Py_DECREF(type);
5140
12
        if (!cond) {
5141
0
            Py_DECREF(TypeVarTuple_annotations);
5142
0
            return 0;
5143
0
        }
5144
12
    }
5145
12
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5146
12
                                  TypeVarTuple_annotations) == 0;
5147
12
    if (!cond) {
5148
0
        Py_DECREF(TypeVarTuple_annotations);
5149
0
        return 0;
5150
0
    }
5151
12
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5152
12
                                  TypeVarTuple_annotations) == 0;
5153
12
    if (!cond) {
5154
0
        Py_DECREF(TypeVarTuple_annotations);
5155
0
        return 0;
5156
0
    }
5157
12
    Py_DECREF(TypeVarTuple_annotations);
5158
5159
12
    return 1;
5160
12
}
5161
5162
5163
5164
typedef struct {
5165
    PyObject_HEAD
5166
    PyObject *dict;
5167
} AST_object;
5168
5169
static void
5170
ast_dealloc(PyObject *op)
5171
285k
{
5172
285k
    AST_object *self = (AST_object*)op;
5173
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5174
285k
    PyTypeObject *tp = Py_TYPE(self);
5175
285k
    PyObject_GC_UnTrack(self);
5176
285k
    Py_CLEAR(self->dict);
5177
285k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5178
285k
    assert(free_func != NULL);
5179
285k
    free_func(self);
5180
285k
    Py_DECREF(tp);
5181
285k
}
5182
5183
static int
5184
ast_traverse(PyObject *op, visitproc visit, void *arg)
5185
80.7k
{
5186
80.7k
    AST_object *self = (AST_object*)op;
5187
80.7k
    Py_VISIT(Py_TYPE(self));
5188
80.7k
    Py_VISIT(self->dict);
5189
80.7k
    return 0;
5190
80.7k
}
5191
5192
static int
5193
ast_clear(PyObject *op)
5194
0
{
5195
0
    AST_object *self = (AST_object*)op;
5196
0
    Py_CLEAR(self->dict);
5197
0
    return 0;
5198
0
}
5199
5200
static int
5201
ast_type_init(PyObject *self, PyObject *args, PyObject *kw)
5202
208
{
5203
208
    struct ast_state *state = get_ast_state();
5204
208
    if (state == NULL) {
5205
0
        return -1;
5206
0
    }
5207
5208
208
    Py_ssize_t i, numfields = 0;
5209
208
    int res = -1;
5210
208
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5211
5212
208
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5213
208
    if (fields == NULL) {
5214
0
        goto cleanup;
5215
0
    }
5216
5217
208
    numfields = PySequence_Size(fields);
5218
208
    if (numfields == -1) {
5219
0
        goto cleanup;
5220
0
    }
5221
208
    remaining_fields = PySet_New(fields);
5222
208
    if (remaining_fields == NULL) {
5223
0
        goto cleanup;
5224
0
    }
5225
5226
208
    res = 0; /* if no error occurs, this stays 0 to the end */
5227
208
    if (numfields < PyTuple_GET_SIZE(args)) {
5228
0
        PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
5229
0
                     "%zd positional argument%s",
5230
0
                     _PyType_Name(Py_TYPE(self)),
5231
0
                     numfields, numfields == 1 ? "" : "s");
5232
0
        res = -1;
5233
0
        goto cleanup;
5234
0
    }
5235
252
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5236
        /* cannot be reached when fields is NULL */
5237
44
        PyObject *name = PySequence_GetItem(fields, i);
5238
44
        if (!name) {
5239
0
            res = -1;
5240
0
            goto cleanup;
5241
0
        }
5242
44
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5243
44
        if (PySet_Discard(remaining_fields, name) < 0) {
5244
0
            res = -1;
5245
0
            Py_DECREF(name);
5246
0
            goto cleanup;
5247
0
        }
5248
44
        Py_DECREF(name);
5249
44
        if (res < 0) {
5250
0
            goto cleanup;
5251
0
        }
5252
44
    }
5253
208
    if (kw) {
5254
44
        i = 0;  /* needed by PyDict_Next */
5255
88
        while (PyDict_Next(kw, &i, &key, &value)) {
5256
44
            int contains = PySequence_Contains(fields, key);
5257
44
            if (contains == -1) {
5258
0
                res = -1;
5259
0
                goto cleanup;
5260
0
            }
5261
44
            else if (contains == 1) {
5262
44
                int p = PySet_Discard(remaining_fields, key);
5263
44
                if (p == -1) {
5264
0
                    res = -1;
5265
0
                    goto cleanup;
5266
0
                }
5267
44
                if (p == 0) {
5268
0
                    PyErr_Format(PyExc_TypeError,
5269
0
                        "%.400s got multiple values for argument %R",
5270
0
                        Py_TYPE(self)->tp_name, key);
5271
0
                    res = -1;
5272
0
                    goto cleanup;
5273
0
                }
5274
44
            }
5275
0
            else {
5276
                // Lazily initialize "attributes"
5277
0
                if (attributes == NULL) {
5278
0
                    attributes = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_attributes);
5279
0
                    if (attributes == NULL) {
5280
0
                        res = -1;
5281
0
                        goto cleanup;
5282
0
                    }
5283
0
                }
5284
0
                int contains = PySequence_Contains(attributes, key);
5285
0
                if (contains == -1) {
5286
0
                    res = -1;
5287
0
                    goto cleanup;
5288
0
                }
5289
0
                else if (contains == 0) {
5290
0
                    if (PyErr_WarnFormat(
5291
0
                        PyExc_DeprecationWarning, 1,
5292
0
                        "%.400s.__init__ got an unexpected keyword argument %R. "
5293
0
                        "Support for arbitrary keyword arguments is deprecated "
5294
0
                        "and will be removed in Python 3.15.",
5295
0
                        Py_TYPE(self)->tp_name, key
5296
0
                    ) < 0) {
5297
0
                        res = -1;
5298
0
                        goto cleanup;
5299
0
                    }
5300
0
                }
5301
0
            }
5302
44
            res = PyObject_SetAttr(self, key, value);
5303
44
            if (res < 0) {
5304
0
                goto cleanup;
5305
0
            }
5306
44
        }
5307
44
    }
5308
208
    Py_ssize_t size = PySet_Size(remaining_fields);
5309
208
    PyObject *field_types = NULL, *remaining_list = NULL;
5310
208
    if (size > 0) {
5311
68
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5312
68
                                     &field_types) < 0) {
5313
0
            res = -1;
5314
0
            goto cleanup;
5315
0
        }
5316
68
        if (field_types == NULL) {
5317
            // Probably a user-defined subclass of AST that lacks _field_types.
5318
            // This will continue to work as it did before 3.13; i.e., attributes
5319
            // that are not passed in simply do not exist on the instance.
5320
0
            goto cleanup;
5321
0
        }
5322
68
        remaining_list = PySequence_List(remaining_fields);
5323
68
        if (!remaining_list) {
5324
0
            goto set_remaining_cleanup;
5325
0
        }
5326
136
        for (Py_ssize_t i = 0; i < size; i++) {
5327
68
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5328
68
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5329
68
            if (!type) {
5330
0
                if (PyErr_Occurred()) {
5331
0
                    goto set_remaining_cleanup;
5332
0
                }
5333
0
                else {
5334
0
                    if (PyErr_WarnFormat(
5335
0
                        PyExc_DeprecationWarning, 1,
5336
0
                        "Field %R is missing from %.400s._field_types. "
5337
0
                        "This will become an error in Python 3.15.",
5338
0
                        name, Py_TYPE(self)->tp_name
5339
0
                    ) < 0) {
5340
0
                        goto set_remaining_cleanup;
5341
0
                    }
5342
0
                }
5343
0
            }
5344
68
            else if (_PyUnion_Check(type)) {
5345
                // optional field
5346
                // do nothing, we'll have set a None default on the class
5347
8
            }
5348
60
            else if (Py_IS_TYPE(type, &Py_GenericAliasType)) {
5349
                // list field
5350
0
                PyObject *empty = PyList_New(0);
5351
0
                if (!empty) {
5352
0
                    goto set_remaining_cleanup;
5353
0
                }
5354
0
                res = PyObject_SetAttr(self, name, empty);
5355
0
                Py_DECREF(empty);
5356
0
                if (res < 0) {
5357
0
                    goto set_remaining_cleanup;
5358
0
                }
5359
0
            }
5360
60
            else if (type == state->expr_context_type) {
5361
                // special case for expr_context: default to Load()
5362
60
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5363
60
                if (res < 0) {
5364
0
                    goto set_remaining_cleanup;
5365
0
                }
5366
60
            }
5367
0
            else {
5368
                // simple field (e.g., identifier)
5369
0
                if (PyErr_WarnFormat(
5370
0
                    PyExc_DeprecationWarning, 1,
5371
0
                    "%.400s.__init__ missing 1 required positional argument: %R. "
5372
0
                    "This will become an error in Python 3.15.",
5373
0
                    Py_TYPE(self)->tp_name, name
5374
0
                ) < 0) {
5375
0
                    goto set_remaining_cleanup;
5376
0
                }
5377
0
            }
5378
68
        }
5379
68
        Py_DECREF(remaining_list);
5380
68
        Py_DECREF(field_types);
5381
68
    }
5382
208
  cleanup:
5383
208
    Py_XDECREF(attributes);
5384
208
    Py_XDECREF(fields);
5385
208
    Py_XDECREF(remaining_fields);
5386
208
    return res;
5387
0
  set_remaining_cleanup:
5388
0
    Py_XDECREF(remaining_list);
5389
0
    Py_XDECREF(field_types);
5390
0
    res = -1;
5391
0
    goto cleanup;
5392
208
}
5393
5394
/* Pickling support */
5395
static PyObject *
5396
ast_type_reduce(PyObject *self, PyObject *unused)
5397
0
{
5398
0
    struct ast_state *state = get_ast_state();
5399
0
    if (state == NULL) {
5400
0
        return NULL;
5401
0
    }
5402
5403
0
    PyObject *dict = NULL, *fields = NULL, *positional_args = NULL;
5404
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5405
0
        return NULL;
5406
0
    }
5407
0
    PyObject *result = NULL;
5408
0
    if (dict) {
5409
        // Unpickling (or copying) works as follows:
5410
        // - Construct the object with only positional arguments
5411
        // - Set the fields from the dict
5412
        // We have two constraints:
5413
        // - We must set all the required fields in the initial constructor call,
5414
        //   or the unpickling or deepcopying of the object will trigger DeprecationWarnings.
5415
        // - We must not include child nodes in the positional args, because
5416
        //   that may trigger runaway recursion during copying (gh-120108).
5417
        // To satisfy both constraints, we set all the fields to None in the
5418
        // initial list of positional args, and then set the fields from the dict.
5419
0
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), state->_fields, &fields) < 0) {
5420
0
            goto cleanup;
5421
0
        }
5422
0
        if (fields) {
5423
0
            Py_ssize_t numfields = PySequence_Size(fields);
5424
0
            if (numfields == -1) {
5425
0
                Py_DECREF(dict);
5426
0
                goto cleanup;
5427
0
            }
5428
0
            positional_args = PyList_New(0);
5429
0
            if (!positional_args) {
5430
0
                goto cleanup;
5431
0
            }
5432
0
            for (Py_ssize_t i = 0; i < numfields; i++) {
5433
0
                PyObject *name = PySequence_GetItem(fields, i);
5434
0
                if (!name) {
5435
0
                    goto cleanup;
5436
0
                }
5437
0
                PyObject *value;
5438
0
                int rc = PyDict_GetItemRef(dict, name, &value);
5439
0
                Py_DECREF(name);
5440
0
                if (rc < 0) {
5441
0
                    goto cleanup;
5442
0
                }
5443
0
                if (!value) {
5444
0
                    break;
5445
0
                }
5446
0
                rc = PyList_Append(positional_args, Py_None);
5447
0
                Py_DECREF(value);
5448
0
                if (rc < 0) {
5449
0
                    goto cleanup;
5450
0
                }
5451
0
            }
5452
0
            PyObject *args_tuple = PyList_AsTuple(positional_args);
5453
0
            if (!args_tuple) {
5454
0
                goto cleanup;
5455
0
            }
5456
0
            result = Py_BuildValue("ONN", Py_TYPE(self), args_tuple, dict);
5457
0
        }
5458
0
        else {
5459
0
            result = Py_BuildValue("O()N", Py_TYPE(self), dict);
5460
0
        }
5461
0
    }
5462
0
    else {
5463
0
        result = Py_BuildValue("O()", Py_TYPE(self));
5464
0
    }
5465
0
cleanup:
5466
0
    Py_XDECREF(fields);
5467
0
    Py_XDECREF(positional_args);
5468
0
    return result;
5469
0
}
5470
5471
/*
5472
 * Perform the following validations:
5473
 *
5474
 *   - All keyword arguments are known 'fields' or 'attributes'.
5475
 *   - No field or attribute would be left unfilled after copy.replace().
5476
 *
5477
 * On success, this returns 1. Otherwise, set a TypeError
5478
 * exception and returns -1 (no exception is set if some
5479
 * other internal errors occur).
5480
 *
5481
 * Parameters
5482
 *
5483
 *      self          The AST node instance.
5484
 *      dict          The AST node instance dictionary (self.__dict__).
5485
 *      fields        The list of fields (self._fields).
5486
 *      attributes    The list of attributes (self._attributes).
5487
 *      kwargs        Keyword arguments passed to ast_type_replace().
5488
 *
5489
 * The 'dict', 'fields', 'attributes' and 'kwargs' arguments can be NULL.
5490
 *
5491
 * Note: this function can be removed in 3.15 since the verification
5492
 *       will be done inside the constructor.
5493
 */
5494
static inline int
5495
ast_type_replace_check(PyObject *self,
5496
                       PyObject *dict,
5497
                       PyObject *fields,
5498
                       PyObject *attributes,
5499
                       PyObject *kwargs)
5500
0
{
5501
    // While it is possible to make some fast paths that would avoid
5502
    // allocating objects on the stack, this would cost us readability.
5503
    // For instance, if 'fields' and 'attributes' are both empty, and
5504
    // 'kwargs' is not empty, we could raise a TypeError immediately.
5505
0
    PyObject *expecting = PySet_New(fields);
5506
0
    if (expecting == NULL) {
5507
0
        return -1;
5508
0
    }
5509
0
    if (attributes) {
5510
0
        if (_PySet_Update(expecting, attributes) < 0) {
5511
0
            Py_DECREF(expecting);
5512
0
            return -1;
5513
0
        }
5514
0
    }
5515
    // Any keyword argument that is neither a field nor attribute is rejected.
5516
    // We first need to check whether a keyword argument is accepted or not.
5517
    // If all keyword arguments are accepted, we compute the required fields
5518
    // and attributes. A field or attribute is not needed if:
5519
    //
5520
    //  1) it is given in 'kwargs', or
5521
    //  2) it already exists on 'self'.
5522
0
    if (kwargs) {
5523
0
        Py_ssize_t pos = 0;
5524
0
        PyObject *key, *value;
5525
0
        while (PyDict_Next(kwargs, &pos, &key, &value)) {
5526
0
            int rc = PySet_Discard(expecting, key);
5527
0
            if (rc < 0) {
5528
0
                Py_DECREF(expecting);
5529
0
                return -1;
5530
0
            }
5531
0
            if (rc == 0) {
5532
0
                PyErr_Format(PyExc_TypeError,
5533
0
                             "%.400s.__replace__ got an unexpected keyword "
5534
0
                             "argument %R.", Py_TYPE(self)->tp_name, key);
5535
0
                Py_DECREF(expecting);
5536
0
                return -1;
5537
0
            }
5538
0
        }
5539
0
    }
5540
    // check that the remaining fields or attributes would be filled
5541
0
    if (dict) {
5542
0
        Py_ssize_t pos = 0;
5543
0
        PyObject *key, *value;
5544
0
        while (PyDict_Next(dict, &pos, &key, &value)) {
5545
            // Mark fields or attributes that are found on the instance
5546
            // as non-mandatory. If they are not given in 'kwargs', they
5547
            // will be shallow-coied; otherwise, they would be replaced
5548
            // (not in this function).
5549
0
            if (PySet_Discard(expecting, key) < 0) {
5550
0
                Py_DECREF(expecting);
5551
0
                return -1;
5552
0
            }
5553
0
        }
5554
0
        if (attributes) {
5555
            // Some attributes may or may not be present at runtime.
5556
            // In particular, now that we checked whether 'kwargs'
5557
            // is correct or not, we allow any attribute to be missing.
5558
            //
5559
            // Note that fields must still be entirely determined when
5560
            // calling the constructor later.
5561
0
            PyObject *unused = PyObject_CallMethodOneArg(expecting,
5562
0
                                                         &_Py_ID(difference_update),
5563
0
                                                         attributes);
5564
0
            if (unused == NULL) {
5565
0
                Py_DECREF(expecting);
5566
0
                return -1;
5567
0
            }
5568
0
            Py_DECREF(unused);
5569
0
        }
5570
0
    }
5571
5572
    // Discard fields from 'expecting' that default to None
5573
0
    PyObject *field_types = NULL;
5574
0
    if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self),
5575
0
                                 &_Py_ID(_field_types),
5576
0
                                 &field_types) < 0)
5577
0
    {
5578
0
        Py_DECREF(expecting);
5579
0
        return -1;
5580
0
    }
5581
0
    if (field_types != NULL) {
5582
0
        Py_ssize_t pos = 0;
5583
0
        PyObject *field_name, *field_type;
5584
0
        while (PyDict_Next(field_types, &pos, &field_name, &field_type)) {
5585
0
            if (_PyUnion_Check(field_type)) {
5586
                // optional field
5587
0
                if (PySet_Discard(expecting, field_name) < 0) {
5588
0
                    Py_DECREF(expecting);
5589
0
                    Py_DECREF(field_types);
5590
0
                    return -1;
5591
0
                }
5592
0
            }
5593
0
        }
5594
0
        Py_DECREF(field_types);
5595
0
    }
5596
5597
    // Now 'expecting' contains the fields or attributes
5598
    // that would not be filled inside ast_type_replace().
5599
0
    Py_ssize_t m = PySet_GET_SIZE(expecting);
5600
0
    if (m > 0) {
5601
0
        PyObject *names = PyList_New(m);
5602
0
        if (names == NULL) {
5603
0
            Py_DECREF(expecting);
5604
0
            return -1;
5605
0
        }
5606
0
        Py_ssize_t i = 0, pos = 0;
5607
0
        PyObject *item;
5608
0
        Py_hash_t hash;
5609
0
        while (_PySet_NextEntry(expecting, &pos, &item, &hash)) {
5610
0
            PyObject *name = PyObject_Repr(item);
5611
0
            if (name == NULL) {
5612
0
                Py_DECREF(expecting);
5613
0
                Py_DECREF(names);
5614
0
                return -1;
5615
0
            }
5616
            // steal the reference 'name'
5617
0
            PyList_SET_ITEM(names, i++, name);
5618
0
        }
5619
0
        Py_DECREF(expecting);
5620
0
        if (PyList_Sort(names) < 0) {
5621
0
            Py_DECREF(names);
5622
0
            return -1;
5623
0
        }
5624
0
        PyObject *sep = PyUnicode_FromString(", ");
5625
0
        if (sep == NULL) {
5626
0
            Py_DECREF(names);
5627
0
            return -1;
5628
0
        }
5629
0
        PyObject *str_names = PyUnicode_Join(sep, names);
5630
0
        Py_DECREF(sep);
5631
0
        Py_DECREF(names);
5632
0
        if (str_names == NULL) {
5633
0
            return -1;
5634
0
        }
5635
0
        PyErr_Format(PyExc_TypeError,
5636
0
                     "%.400s.__replace__ missing %ld keyword argument%s: %U.",
5637
0
                     Py_TYPE(self)->tp_name, m, m == 1 ? "" : "s", str_names);
5638
0
        Py_DECREF(str_names);
5639
0
        return -1;
5640
0
    }
5641
0
    else {
5642
0
        Py_DECREF(expecting);
5643
0
        return 1;
5644
0
    }
5645
0
}
5646
5647
/*
5648
 * Python equivalent:
5649
 *
5650
 *   for key in keys:
5651
 *       if hasattr(self, key):
5652
 *           payload[key] = getattr(self, key)
5653
 *
5654
 * The 'keys' argument is a sequence corresponding to
5655
 * the '_fields' or the '_attributes' of an AST node.
5656
 *
5657
 * This returns -1 if an error occurs and 0 otherwise.
5658
 *
5659
 * Parameters
5660
 *
5661
 *      payload   A dictionary to fill.
5662
 *      keys      A sequence of keys or NULL for an empty sequence.
5663
 *      dict      The AST node instance dictionary (must not be NULL).
5664
 */
5665
static inline int
5666
ast_type_replace_update_payload(PyObject *payload,
5667
                                PyObject *keys,
5668
                                PyObject *dict)
5669
0
{
5670
0
    assert(dict != NULL);
5671
0
    if (keys == NULL) {
5672
0
        return 0;
5673
0
    }
5674
0
    Py_ssize_t n = PySequence_Size(keys);
5675
0
    if (n == -1) {
5676
0
        return -1;
5677
0
    }
5678
0
    for (Py_ssize_t i = 0; i < n; i++) {
5679
0
        PyObject *key = PySequence_GetItem(keys, i);
5680
0
        if (key == NULL) {
5681
0
            return -1;
5682
0
        }
5683
0
        PyObject *value;
5684
0
        if (PyDict_GetItemRef(dict, key, &value) < 0) {
5685
0
            Py_DECREF(key);
5686
0
            return -1;
5687
0
        }
5688
0
        if (value == NULL) {
5689
0
            Py_DECREF(key);
5690
            // If a field or attribute is not present at runtime, it should
5691
            // be explicitly given in 'kwargs'. If not, the constructor will
5692
            // issue a warning (which becomes an error in 3.15).
5693
0
            continue;
5694
0
        }
5695
0
        int rc = PyDict_SetItem(payload, key, value);
5696
0
        Py_DECREF(key);
5697
0
        Py_DECREF(value);
5698
0
        if (rc < 0) {
5699
0
            return -1;
5700
0
        }
5701
0
    }
5702
0
    return 0;
5703
0
}
5704
5705
/* copy.replace() support (shallow copy) */
5706
static PyObject *
5707
ast_type_replace(PyObject *self, PyObject *args, PyObject *kwargs)
5708
0
{
5709
0
    if (!_PyArg_NoPositional("__replace__", args)) {
5710
0
        return NULL;
5711
0
    }
5712
5713
0
    struct ast_state *state = get_ast_state();
5714
0
    if (state == NULL) {
5715
0
        return NULL;
5716
0
    }
5717
5718
0
    PyObject *result = NULL;
5719
    // known AST class fields and attributes
5720
0
    PyObject *fields = NULL, *attributes = NULL;
5721
    // current instance dictionary
5722
0
    PyObject *dict = NULL;
5723
    // constructor positional and keyword arguments
5724
0
    PyObject *empty_tuple = NULL, *payload = NULL;
5725
5726
0
    PyObject *type = (PyObject *)Py_TYPE(self);
5727
0
    if (PyObject_GetOptionalAttr(type, state->_fields, &fields) < 0) {
5728
0
        goto cleanup;
5729
0
    }
5730
0
    if (PyObject_GetOptionalAttr(type, state->_attributes, &attributes) < 0) {
5731
0
        goto cleanup;
5732
0
    }
5733
0
    if (PyObject_GetOptionalAttr(self, state->__dict__, &dict) < 0) {
5734
0
        goto cleanup;
5735
0
    }
5736
0
    if (ast_type_replace_check(self, dict, fields, attributes, kwargs) < 0) {
5737
0
        goto cleanup;
5738
0
    }
5739
0
    empty_tuple = PyTuple_New(0);
5740
0
    if (empty_tuple == NULL) {
5741
0
        goto cleanup;
5742
0
    }
5743
0
    payload = PyDict_New();
5744
0
    if (payload == NULL) {
5745
0
        goto cleanup;
5746
0
    }
5747
0
    if (dict) { // in case __dict__ is missing (for some obscure reason)
5748
        // copy the instance's fields (possibly NULL)
5749
0
        if (ast_type_replace_update_payload(payload, fields, dict) < 0) {
5750
0
            goto cleanup;
5751
0
        }
5752
        // copy the instance's attributes (possibly NULL)
5753
0
        if (ast_type_replace_update_payload(payload, attributes, dict) < 0) {
5754
0
            goto cleanup;
5755
0
        }
5756
0
    }
5757
0
    if (kwargs && PyDict_Update(payload, kwargs) < 0) {
5758
0
        goto cleanup;
5759
0
    }
5760
0
    result = PyObject_Call(type, empty_tuple, payload);
5761
0
cleanup:
5762
0
    Py_XDECREF(payload);
5763
0
    Py_XDECREF(empty_tuple);
5764
0
    Py_XDECREF(dict);
5765
0
    Py_XDECREF(attributes);
5766
0
    Py_XDECREF(fields);
5767
0
    return result;
5768
0
}
5769
5770
static PyMemberDef ast_type_members[] = {
5771
    {"__dictoffset__", Py_T_PYSSIZET, offsetof(AST_object, dict), Py_READONLY},
5772
    {NULL}  /* Sentinel */
5773
};
5774
5775
static PyMethodDef ast_type_methods[] = {
5776
    {"__reduce__", ast_type_reduce, METH_NOARGS, NULL},
5777
    {"__replace__", _PyCFunction_CAST(ast_type_replace), METH_VARARGS | METH_KEYWORDS,
5778
     PyDoc_STR("__replace__($self, /, **fields)\n--\n\n"
5779
               "Return a copy of the AST node with new values "
5780
               "for the specified fields.")},
5781
    {NULL}
5782
};
5783
5784
static PyGetSetDef ast_type_getsets[] = {
5785
    {"__dict__", PyObject_GenericGetDict, PyObject_GenericSetDict},
5786
    {NULL}
5787
};
5788
5789
static PyObject *
5790
ast_repr_max_depth(AST_object *self, int depth);
5791
5792
/* Format list and tuple properties of AST nodes.
5793
   Note that, only the first and last elements are shown.
5794
   Anything in between is represented with an ellipsis ('...').
5795
   For example, the list [1, 2, 3] is formatted as
5796
   'List(elts=[Constant(1), ..., Constant(3)])'. */
5797
static PyObject *
5798
ast_repr_list(PyObject *list, int depth)
5799
0
{
5800
0
    assert(PyList_Check(list) || PyTuple_Check(list));
5801
5802
0
    struct ast_state *state = get_ast_state();
5803
0
    if (state == NULL) {
5804
0
        return NULL;
5805
0
    }
5806
5807
0
    Py_ssize_t length = PySequence_Size(list);
5808
0
    if (length < 0) {
5809
0
        return NULL;
5810
0
    }
5811
0
    else if (length == 0) {
5812
0
        return PyObject_Repr(list);
5813
0
    }
5814
5815
0
    PyObject *items[2] = {NULL, NULL};
5816
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5817
0
    if (writer == NULL) {
5818
0
        goto error;
5819
0
    }
5820
5821
0
    items[0] = PySequence_GetItem(list, 0);
5822
0
    if (!items[0]) {
5823
0
        goto error;
5824
0
    }
5825
0
    if (length > 1) {
5826
0
        items[1] = PySequence_GetItem(list, length - 1);
5827
0
        if (!items[1]) {
5828
0
            goto error;
5829
0
        }
5830
0
    }
5831
5832
0
    bool is_list = PyList_Check(list);
5833
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? '[' : '(') < 0) {
5834
0
        goto error;
5835
0
    }
5836
5837
0
    for (Py_ssize_t i = 0; i < Py_MIN(length, 2); i++) {
5838
0
        if (i > 0) {
5839
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5840
0
                goto error;
5841
0
            }
5842
0
        }
5843
5844
0
        PyObject *item = items[i];
5845
0
        if (PyType_IsSubtype(Py_TYPE(item), (PyTypeObject *)state->AST_type)) {
5846
0
            PyObject *item_repr;
5847
0
            item_repr = ast_repr_max_depth((AST_object*)item, depth - 1);
5848
0
            if (!item_repr) {
5849
0
                goto error;
5850
0
            }
5851
0
            if (PyUnicodeWriter_WriteStr(writer, item_repr) < 0) {
5852
0
                Py_DECREF(item_repr);
5853
0
                goto error;
5854
0
            }
5855
0
            Py_DECREF(item_repr);
5856
0
        } else {
5857
0
            if (PyUnicodeWriter_WriteRepr(writer, item) < 0) {
5858
0
                goto error;
5859
0
            }
5860
0
        }
5861
5862
0
        if (i == 0 && length > 2) {
5863
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ...", 5) < 0) {
5864
0
                goto error;
5865
0
            }
5866
0
        }
5867
0
    }
5868
5869
0
    if (PyUnicodeWriter_WriteChar(writer, is_list ? ']' : ')') < 0) {
5870
0
        goto error;
5871
0
    }
5872
5873
0
    Py_XDECREF(items[0]);
5874
0
    Py_XDECREF(items[1]);
5875
0
    return PyUnicodeWriter_Finish(writer);
5876
5877
0
error:
5878
0
    Py_XDECREF(items[0]);
5879
0
    Py_XDECREF(items[1]);
5880
0
    PyUnicodeWriter_Discard(writer);
5881
0
    return NULL;
5882
0
}
5883
5884
static PyObject *
5885
ast_repr_max_depth(AST_object *self, int depth)
5886
0
{
5887
0
    struct ast_state *state = get_ast_state();
5888
0
    if (state == NULL) {
5889
0
        return NULL;
5890
0
    }
5891
5892
0
    if (depth <= 0) {
5893
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5894
0
    }
5895
5896
0
    int status = Py_ReprEnter((PyObject *)self);
5897
0
    if (status != 0) {
5898
0
        if (status < 0) {
5899
0
            return NULL;
5900
0
        }
5901
0
        return PyUnicode_FromFormat("%s(...)", Py_TYPE(self)->tp_name);
5902
0
    }
5903
5904
0
    PyObject *fields;
5905
0
    if (PyObject_GetOptionalAttr((PyObject *)Py_TYPE(self), state->_fields, &fields) < 0) {
5906
0
        Py_ReprLeave((PyObject *)self);
5907
0
        return NULL;
5908
0
    }
5909
5910
0
    Py_ssize_t numfields = PySequence_Size(fields);
5911
0
    if (numfields < 0) {
5912
0
        Py_ReprLeave((PyObject *)self);
5913
0
        Py_DECREF(fields);
5914
0
        return NULL;
5915
0
    }
5916
5917
0
    if (numfields == 0) {
5918
0
        Py_ReprLeave((PyObject *)self);
5919
0
        Py_DECREF(fields);
5920
0
        return PyUnicode_FromFormat("%s()", Py_TYPE(self)->tp_name);
5921
0
    }
5922
5923
0
    const char* tp_name = Py_TYPE(self)->tp_name;
5924
0
    PyUnicodeWriter *writer = PyUnicodeWriter_Create(0);
5925
0
    if (writer == NULL) {
5926
0
        goto error;
5927
0
    }
5928
5929
0
    if (PyUnicodeWriter_WriteUTF8(writer, tp_name, -1) < 0) {
5930
0
        goto error;
5931
0
    }
5932
0
    if (PyUnicodeWriter_WriteChar(writer, '(') < 0) {
5933
0
        goto error;
5934
0
    }
5935
5936
0
    for (Py_ssize_t i = 0; i < numfields; i++) {
5937
0
        PyObject *name = PySequence_GetItem(fields, i);
5938
0
        if (!name) {
5939
0
            goto error;
5940
0
        }
5941
5942
0
        PyObject *value = PyObject_GetAttr((PyObject *)self, name);
5943
0
        if (!value) {
5944
0
            Py_DECREF(name);
5945
0
            goto error;
5946
0
        }
5947
5948
0
        PyObject *value_repr;
5949
0
        if (PyList_Check(value) || PyTuple_Check(value)) {
5950
0
            value_repr = ast_repr_list(value, depth);
5951
0
        }
5952
0
        else if (PyType_IsSubtype(Py_TYPE(value), (PyTypeObject *)state->AST_type)) {
5953
0
            value_repr = ast_repr_max_depth((AST_object*)value, depth - 1);
5954
0
        }
5955
0
        else {
5956
0
            value_repr = PyObject_Repr(value);
5957
0
        }
5958
5959
0
        Py_DECREF(value);
5960
5961
0
        if (!value_repr) {
5962
0
            Py_DECREF(name);
5963
0
            goto error;
5964
0
        }
5965
5966
0
        if (i > 0) {
5967
0
            if (PyUnicodeWriter_WriteASCII(writer, ", ", 2) < 0) {
5968
0
                Py_DECREF(name);
5969
0
                Py_DECREF(value_repr);
5970
0
                goto error;
5971
0
            }
5972
0
        }
5973
0
        if (PyUnicodeWriter_WriteStr(writer, name) < 0) {
5974
0
            Py_DECREF(name);
5975
0
            Py_DECREF(value_repr);
5976
0
            goto error;
5977
0
        }
5978
5979
0
        Py_DECREF(name);
5980
5981
0
        if (PyUnicodeWriter_WriteChar(writer, '=') < 0) {
5982
0
            Py_DECREF(value_repr);
5983
0
            goto error;
5984
0
        }
5985
0
        if (PyUnicodeWriter_WriteStr(writer, value_repr) < 0) {
5986
0
            Py_DECREF(value_repr);
5987
0
            goto error;
5988
0
        }
5989
5990
0
        Py_DECREF(value_repr);
5991
0
    }
5992
5993
0
    if (PyUnicodeWriter_WriteChar(writer, ')') < 0) {
5994
0
        goto error;
5995
0
    }
5996
0
    Py_ReprLeave((PyObject *)self);
5997
0
    Py_DECREF(fields);
5998
0
    return PyUnicodeWriter_Finish(writer);
5999
6000
0
error:
6001
0
    Py_ReprLeave((PyObject *)self);
6002
0
    Py_DECREF(fields);
6003
0
    PyUnicodeWriter_Discard(writer);
6004
0
    return NULL;
6005
0
}
6006
6007
static PyObject *
6008
ast_repr(PyObject *self)
6009
0
{
6010
0
    return ast_repr_max_depth((AST_object*)self, 3);
6011
0
}
6012
6013
static PyType_Slot AST_type_slots[] = {
6014
    {Py_tp_dealloc, ast_dealloc},
6015
    {Py_tp_repr, ast_repr},
6016
    {Py_tp_getattro, PyObject_GenericGetAttr},
6017
    {Py_tp_setattro, PyObject_GenericSetAttr},
6018
    {Py_tp_traverse, ast_traverse},
6019
    {Py_tp_clear, ast_clear},
6020
    {Py_tp_members, ast_type_members},
6021
    {Py_tp_methods, ast_type_methods},
6022
    {Py_tp_getset, ast_type_getsets},
6023
    {Py_tp_init, ast_type_init},
6024
    {Py_tp_alloc, PyType_GenericAlloc},
6025
    {Py_tp_new, PyType_GenericNew},
6026
    {Py_tp_free, PyObject_GC_Del},
6027
    {0, 0},
6028
};
6029
6030
static PyType_Spec AST_type_spec = {
6031
    "ast.AST",
6032
    sizeof(AST_object),
6033
    0,
6034
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC,
6035
    AST_type_slots
6036
};
6037
6038
static PyObject *
6039
make_type(struct ast_state *state, const char *type, PyObject* base,
6040
          const char* const* fields, int num_fields, const char *doc)
6041
1.50k
{
6042
1.50k
    PyObject *fnames, *result;
6043
1.50k
    int i;
6044
1.50k
    fnames = PyTuple_New(num_fields);
6045
1.50k
    if (!fnames) return NULL;
6046
3.87k
    for (i = 0; i < num_fields; i++) {
6047
2.37k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
6048
2.37k
        if (!field) {
6049
0
            Py_DECREF(fnames);
6050
0
            return NULL;
6051
0
        }
6052
2.37k
        PyTuple_SET_ITEM(fnames, i, field);
6053
2.37k
    }
6054
1.50k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
6055
1.50k
                    type, base,
6056
1.50k
                    state->_fields, fnames,
6057
1.50k
                    state->__match_args__, fnames,
6058
1.50k
                    state->__module__,
6059
1.50k
                    state->ast,
6060
1.50k
                    state->__doc__, doc);
6061
1.50k
    Py_DECREF(fnames);
6062
1.50k
    return result;
6063
1.50k
}
6064
6065
static int
6066
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
6067
228
{
6068
228
    int i, result;
6069
228
    PyObject *s, *l = PyTuple_New(num_fields);
6070
228
    if (!l)
6071
0
        return -1;
6072
612
    for (i = 0; i < num_fields; i++) {
6073
384
        s = PyUnicode_InternFromString(attrs[i]);
6074
384
        if (!s) {
6075
0
            Py_DECREF(l);
6076
0
            return -1;
6077
0
        }
6078
384
        PyTuple_SET_ITEM(l, i, s);
6079
384
    }
6080
228
    result = PyObject_SetAttr(type, state->_attributes, l);
6081
228
    Py_DECREF(l);
6082
228
    return result;
6083
228
}
6084
6085
/* Conversion AST -> Python */
6086
6087
static PyObject* ast2obj_list(struct ast_state *state, asdl_seq *seq,
6088
                              PyObject* (*func)(struct ast_state *state, void*))
6089
77.4k
{
6090
77.4k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
6091
77.4k
    PyObject *result = PyList_New(n);
6092
77.4k
    PyObject *value;
6093
77.4k
    if (!result)
6094
0
        return NULL;
6095
210k
    for (i = 0; i < n; i++) {
6096
133k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6097
133k
        if (!value) {
6098
0
            Py_DECREF(result);
6099
0
            return NULL;
6100
0
        }
6101
133k
        PyList_SET_ITEM(result, i, value);
6102
133k
    }
6103
77.4k
    return result;
6104
77.4k
}
6105
6106
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6107
210k
{
6108
210k
    PyObject *op = (PyObject*)o;
6109
210k
    if (!op) {
6110
71.5k
        op = Py_None;
6111
71.5k
    }
6112
210k
    return Py_NewRef(op);
6113
210k
}
6114
51.7k
#define ast2obj_constant ast2obj_object
6115
95.6k
#define ast2obj_identifier ast2obj_object
6116
63.1k
#define ast2obj_string ast2obj_object
6117
6118
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6119
1.12M
{
6120
1.12M
    return PyLong_FromLong(b);
6121
1.12M
}
6122
6123
/* Conversion Python -> AST */
6124
6125
static int obj2ast_object(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6126
0
{
6127
0
    if (obj == Py_None)
6128
0
        obj = NULL;
6129
0
    if (obj) {
6130
0
        if (_PyArena_AddPyObject(arena, obj) < 0) {
6131
0
            *out = NULL;
6132
0
            return -1;
6133
0
        }
6134
0
        *out = Py_NewRef(obj);
6135
0
    }
6136
0
    else {
6137
0
        *out = NULL;
6138
0
    }
6139
0
    return 0;
6140
0
}
6141
6142
static int obj2ast_constant(struct ast_state *Py_UNUSED(state), PyObject* obj, PyObject** out, PyArena* arena)
6143
0
{
6144
0
    if (_PyArena_AddPyObject(arena, obj) < 0) {
6145
0
        *out = NULL;
6146
0
        return -1;
6147
0
    }
6148
0
    *out = Py_NewRef(obj);
6149
0
    return 0;
6150
0
}
6151
6152
static int obj2ast_identifier(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6153
0
{
6154
0
    if (!PyUnicode_CheckExact(obj) && obj != Py_None) {
6155
0
        PyErr_SetString(PyExc_TypeError, "AST identifier must be of type str");
6156
0
        return -1;
6157
0
    }
6158
0
    return obj2ast_object(state, obj, out, arena);
6159
0
}
6160
6161
static int obj2ast_string(struct ast_state *state, PyObject* obj, PyObject** out, PyArena* arena)
6162
0
{
6163
0
    if (!PyUnicode_CheckExact(obj) && !PyBytes_CheckExact(obj)) {
6164
0
        PyErr_SetString(PyExc_TypeError, "AST string must be of type str");
6165
0
        return -1;
6166
0
    }
6167
0
    return obj2ast_object(state, obj, out, arena);
6168
0
}
6169
6170
static int obj2ast_int(struct ast_state* Py_UNUSED(state), PyObject* obj, int* out, PyArena* arena)
6171
0
{
6172
0
    int i;
6173
0
    if (!PyLong_Check(obj)) {
6174
0
        PyErr_Format(PyExc_ValueError, "invalid integer value: %R", obj);
6175
0
        return -1;
6176
0
    }
6177
6178
0
    i = PyLong_AsInt(obj);
6179
0
    if (i == -1 && PyErr_Occurred())
6180
0
        return -1;
6181
0
    *out = i;
6182
0
    return 0;
6183
0
}
6184
6185
static int add_ast_fields(struct ast_state *state)
6186
12
{
6187
12
    PyObject *empty_tuple;
6188
12
    empty_tuple = PyTuple_New(0);
6189
12
    if (!empty_tuple ||
6190
12
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6191
12
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6192
12
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6193
0
        Py_XDECREF(empty_tuple);
6194
0
        return -1;
6195
0
    }
6196
12
    Py_DECREF(empty_tuple);
6197
12
    return 0;
6198
12
}
6199
6200
6201
6202
static int
6203
init_types(void *arg)
6204
12
{
6205
12
    struct ast_state *state = arg;
6206
12
    if (init_identifiers(state) < 0) {
6207
0
        return -1;
6208
0
    }
6209
12
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6210
12
    if (!state->AST_type) {
6211
0
        return -1;
6212
0
    }
6213
12
    if (add_ast_fields(state) < 0) {
6214
0
        return -1;
6215
0
    }
6216
12
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6217
12
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6218
12
        "    | Interactive(stmt* body)\n"
6219
12
        "    | Expression(expr body)\n"
6220
12
        "    | FunctionType(expr* argtypes, expr returns)");
6221
12
    if (!state->mod_type) return -1;
6222
12
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6223
12
    state->Module_type = make_type(state, "Module", state->mod_type,
6224
12
                                   Module_fields, 2,
6225
12
        "Module(stmt* body, type_ignore* type_ignores)");
6226
12
    if (!state->Module_type) return -1;
6227
12
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6228
12
                                        Interactive_fields, 1,
6229
12
        "Interactive(stmt* body)");
6230
12
    if (!state->Interactive_type) return -1;
6231
12
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6232
12
                                       Expression_fields, 1,
6233
12
        "Expression(expr body)");
6234
12
    if (!state->Expression_type) return -1;
6235
12
    state->FunctionType_type = make_type(state, "FunctionType",
6236
12
                                         state->mod_type, FunctionType_fields,
6237
12
                                         2,
6238
12
        "FunctionType(expr* argtypes, expr returns)");
6239
12
    if (!state->FunctionType_type) return -1;
6240
12
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6241
12
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6242
12
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6243
12
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6244
12
        "     | Return(expr? value)\n"
6245
12
        "     | Delete(expr* targets)\n"
6246
12
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6247
12
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6248
12
        "     | AugAssign(expr target, operator op, expr value)\n"
6249
12
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6250
12
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6251
12
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6252
12
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6253
12
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6254
12
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6255
12
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6256
12
        "     | Match(expr subject, match_case* cases)\n"
6257
12
        "     | Raise(expr? exc, expr? cause)\n"
6258
12
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6259
12
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6260
12
        "     | Assert(expr test, expr? msg)\n"
6261
12
        "     | Import(alias* names, int? is_lazy)\n"
6262
12
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
6263
12
        "     | Global(identifier* names)\n"
6264
12
        "     | Nonlocal(identifier* names)\n"
6265
12
        "     | Expr(expr value)\n"
6266
12
        "     | Pass\n"
6267
12
        "     | Break\n"
6268
12
        "     | Continue");
6269
12
    if (!state->stmt_type) return -1;
6270
12
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6271
0
        -1;
6272
12
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6273
0
        return -1;
6274
12
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6275
12
        -1)
6276
0
        return -1;
6277
12
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6278
12
                                        FunctionDef_fields, 7,
6279
12
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6280
12
    if (!state->FunctionDef_type) return -1;
6281
12
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6282
12
        -1)
6283
0
        return -1;
6284
12
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6285
12
        == -1)
6286
0
        return -1;
6287
12
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6288
12
                                             state->stmt_type,
6289
12
                                             AsyncFunctionDef_fields, 7,
6290
12
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6291
12
    if (!state->AsyncFunctionDef_type) return -1;
6292
12
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6293
12
        == -1)
6294
0
        return -1;
6295
12
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6296
12
        Py_None) == -1)
6297
0
        return -1;
6298
12
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6299
12
                                     ClassDef_fields, 6,
6300
12
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6301
12
    if (!state->ClassDef_type) return -1;
6302
12
    state->Return_type = make_type(state, "Return", state->stmt_type,
6303
12
                                   Return_fields, 1,
6304
12
        "Return(expr? value)");
6305
12
    if (!state->Return_type) return -1;
6306
12
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6307
0
        return -1;
6308
12
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6309
12
                                   Delete_fields, 1,
6310
12
        "Delete(expr* targets)");
6311
12
    if (!state->Delete_type) return -1;
6312
12
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6313
12
                                   Assign_fields, 3,
6314
12
        "Assign(expr* targets, expr value, string? type_comment)");
6315
12
    if (!state->Assign_type) return -1;
6316
12
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6317
12
        -1)
6318
0
        return -1;
6319
12
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6320
12
                                      TypeAlias_fields, 3,
6321
12
        "TypeAlias(expr name, type_param* type_params, expr value)");
6322
12
    if (!state->TypeAlias_type) return -1;
6323
12
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6324
12
                                      AugAssign_fields, 3,
6325
12
        "AugAssign(expr target, operator op, expr value)");
6326
12
    if (!state->AugAssign_type) return -1;
6327
12
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6328
12
                                      AnnAssign_fields, 4,
6329
12
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6330
12
    if (!state->AnnAssign_type) return -1;
6331
12
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6332
0
        return -1;
6333
12
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6334
12
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6335
12
    if (!state->For_type) return -1;
6336
12
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6337
0
        return -1;
6338
12
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6339
12
                                     AsyncFor_fields, 5,
6340
12
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6341
12
    if (!state->AsyncFor_type) return -1;
6342
12
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6343
12
        -1)
6344
0
        return -1;
6345
12
    state->While_type = make_type(state, "While", state->stmt_type,
6346
12
                                  While_fields, 3,
6347
12
        "While(expr test, stmt* body, stmt* orelse)");
6348
12
    if (!state->While_type) return -1;
6349
12
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6350
12
        "If(expr test, stmt* body, stmt* orelse)");
6351
12
    if (!state->If_type) return -1;
6352
12
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6353
12
                                 3,
6354
12
        "With(withitem* items, stmt* body, string? type_comment)");
6355
12
    if (!state->With_type) return -1;
6356
12
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6357
0
        return -1;
6358
12
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6359
12
                                      AsyncWith_fields, 3,
6360
12
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6361
12
    if (!state->AsyncWith_type) return -1;
6362
12
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6363
12
        == -1)
6364
0
        return -1;
6365
12
    state->Match_type = make_type(state, "Match", state->stmt_type,
6366
12
                                  Match_fields, 2,
6367
12
        "Match(expr subject, match_case* cases)");
6368
12
    if (!state->Match_type) return -1;
6369
12
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6370
12
                                  Raise_fields, 2,
6371
12
        "Raise(expr? exc, expr? cause)");
6372
12
    if (!state->Raise_type) return -1;
6373
12
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6374
0
        return -1;
6375
12
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6376
0
        return -1;
6377
12
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6378
12
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6379
12
    if (!state->Try_type) return -1;
6380
12
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6381
12
                                    TryStar_fields, 4,
6382
12
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6383
12
    if (!state->TryStar_type) return -1;
6384
12
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6385
12
                                   Assert_fields, 2,
6386
12
        "Assert(expr test, expr? msg)");
6387
12
    if (!state->Assert_type) return -1;
6388
12
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6389
0
        return -1;
6390
12
    state->Import_type = make_type(state, "Import", state->stmt_type,
6391
12
                                   Import_fields, 2,
6392
12
        "Import(alias* names, int? is_lazy)");
6393
12
    if (!state->Import_type) return -1;
6394
12
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
6395
0
        return -1;
6396
12
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6397
12
                                       ImportFrom_fields, 4,
6398
12
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
6399
12
    if (!state->ImportFrom_type) return -1;
6400
12
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6401
0
        return -1;
6402
12
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6403
0
        return -1;
6404
12
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
6405
0
        return -1;
6406
12
    state->Global_type = make_type(state, "Global", state->stmt_type,
6407
12
                                   Global_fields, 1,
6408
12
        "Global(identifier* names)");
6409
12
    if (!state->Global_type) return -1;
6410
12
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6411
12
                                     Nonlocal_fields, 1,
6412
12
        "Nonlocal(identifier* names)");
6413
12
    if (!state->Nonlocal_type) return -1;
6414
12
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6415
12
                                 1,
6416
12
        "Expr(expr value)");
6417
12
    if (!state->Expr_type) return -1;
6418
12
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6419
12
        "Pass");
6420
12
    if (!state->Pass_type) return -1;
6421
12
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6422
12
        "Break");
6423
12
    if (!state->Break_type) return -1;
6424
12
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6425
12
                                     0,
6426
12
        "Continue");
6427
12
    if (!state->Continue_type) return -1;
6428
12
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6429
12
        "expr = BoolOp(boolop op, expr* values)\n"
6430
12
        "     | NamedExpr(expr target, expr value)\n"
6431
12
        "     | BinOp(expr left, operator op, expr right)\n"
6432
12
        "     | UnaryOp(unaryop op, expr operand)\n"
6433
12
        "     | Lambda(arguments args, expr body)\n"
6434
12
        "     | IfExp(expr test, expr body, expr orelse)\n"
6435
12
        "     | Dict(expr?* keys, expr* values)\n"
6436
12
        "     | Set(expr* elts)\n"
6437
12
        "     | ListComp(expr elt, comprehension* generators)\n"
6438
12
        "     | SetComp(expr elt, comprehension* generators)\n"
6439
12
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6440
12
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6441
12
        "     | Await(expr value)\n"
6442
12
        "     | Yield(expr? value)\n"
6443
12
        "     | YieldFrom(expr value)\n"
6444
12
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6445
12
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6446
12
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6447
12
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6448
12
        "     | JoinedStr(expr* values)\n"
6449
12
        "     | TemplateStr(expr* values)\n"
6450
12
        "     | Constant(constant value, string? kind)\n"
6451
12
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6452
12
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6453
12
        "     | Starred(expr value, expr_context ctx)\n"
6454
12
        "     | Name(identifier id, expr_context ctx)\n"
6455
12
        "     | List(expr* elts, expr_context ctx)\n"
6456
12
        "     | Tuple(expr* elts, expr_context ctx)\n"
6457
12
        "     | Slice(expr? lower, expr? upper, expr? step)");
6458
12
    if (!state->expr_type) return -1;
6459
12
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6460
0
        -1;
6461
12
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6462
0
        return -1;
6463
12
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6464
12
        -1)
6465
0
        return -1;
6466
12
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6467
12
                                   BoolOp_fields, 2,
6468
12
        "BoolOp(boolop op, expr* values)");
6469
12
    if (!state->BoolOp_type) return -1;
6470
12
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6471
12
                                      NamedExpr_fields, 2,
6472
12
        "NamedExpr(expr target, expr value)");
6473
12
    if (!state->NamedExpr_type) return -1;
6474
12
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6475
12
                                  BinOp_fields, 3,
6476
12
        "BinOp(expr left, operator op, expr right)");
6477
12
    if (!state->BinOp_type) return -1;
6478
12
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6479
12
                                    UnaryOp_fields, 2,
6480
12
        "UnaryOp(unaryop op, expr operand)");
6481
12
    if (!state->UnaryOp_type) return -1;
6482
12
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6483
12
                                   Lambda_fields, 2,
6484
12
        "Lambda(arguments args, expr body)");
6485
12
    if (!state->Lambda_type) return -1;
6486
12
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6487
12
                                  IfExp_fields, 3,
6488
12
        "IfExp(expr test, expr body, expr orelse)");
6489
12
    if (!state->IfExp_type) return -1;
6490
12
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6491
12
                                 2,
6492
12
        "Dict(expr?* keys, expr* values)");
6493
12
    if (!state->Dict_type) return -1;
6494
12
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6495
12
        "Set(expr* elts)");
6496
12
    if (!state->Set_type) return -1;
6497
12
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6498
12
                                     ListComp_fields, 2,
6499
12
        "ListComp(expr elt, comprehension* generators)");
6500
12
    if (!state->ListComp_type) return -1;
6501
12
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6502
12
                                    SetComp_fields, 2,
6503
12
        "SetComp(expr elt, comprehension* generators)");
6504
12
    if (!state->SetComp_type) return -1;
6505
12
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6506
12
                                     DictComp_fields, 3,
6507
12
        "DictComp(expr key, expr? value, comprehension* generators)");
6508
12
    if (!state->DictComp_type) return -1;
6509
12
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6510
0
        return -1;
6511
12
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6512
12
                                         state->expr_type, GeneratorExp_fields,
6513
12
                                         2,
6514
12
        "GeneratorExp(expr elt, comprehension* generators)");
6515
12
    if (!state->GeneratorExp_type) return -1;
6516
12
    state->Await_type = make_type(state, "Await", state->expr_type,
6517
12
                                  Await_fields, 1,
6518
12
        "Await(expr value)");
6519
12
    if (!state->Await_type) return -1;
6520
12
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6521
12
                                  Yield_fields, 1,
6522
12
        "Yield(expr? value)");
6523
12
    if (!state->Yield_type) return -1;
6524
12
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6525
0
        return -1;
6526
12
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6527
12
                                      YieldFrom_fields, 1,
6528
12
        "YieldFrom(expr value)");
6529
12
    if (!state->YieldFrom_type) return -1;
6530
12
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6531
12
                                    Compare_fields, 3,
6532
12
        "Compare(expr left, cmpop* ops, expr* comparators)");
6533
12
    if (!state->Compare_type) return -1;
6534
12
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6535
12
                                 3,
6536
12
        "Call(expr func, expr* args, keyword* keywords)");
6537
12
    if (!state->Call_type) return -1;
6538
12
    state->FormattedValue_type = make_type(state, "FormattedValue",
6539
12
                                           state->expr_type,
6540
12
                                           FormattedValue_fields, 3,
6541
12
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6542
12
    if (!state->FormattedValue_type) return -1;
6543
12
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6544
12
        Py_None) == -1)
6545
0
        return -1;
6546
12
    state->Interpolation_type = make_type(state, "Interpolation",
6547
12
                                          state->expr_type,
6548
12
                                          Interpolation_fields, 4,
6549
12
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6550
12
    if (!state->Interpolation_type) return -1;
6551
12
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6552
12
        Py_None) == -1)
6553
0
        return -1;
6554
12
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6555
12
                                      JoinedStr_fields, 1,
6556
12
        "JoinedStr(expr* values)");
6557
12
    if (!state->JoinedStr_type) return -1;
6558
12
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6559
12
                                        TemplateStr_fields, 1,
6560
12
        "TemplateStr(expr* values)");
6561
12
    if (!state->TemplateStr_type) return -1;
6562
12
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6563
12
                                     Constant_fields, 2,
6564
12
        "Constant(constant value, string? kind)");
6565
12
    if (!state->Constant_type) return -1;
6566
12
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6567
0
        return -1;
6568
12
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6569
12
                                      Attribute_fields, 3,
6570
12
        "Attribute(expr value, identifier attr, expr_context ctx)");
6571
12
    if (!state->Attribute_type) return -1;
6572
12
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6573
12
                                      Subscript_fields, 3,
6574
12
        "Subscript(expr value, expr slice, expr_context ctx)");
6575
12
    if (!state->Subscript_type) return -1;
6576
12
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6577
12
                                    Starred_fields, 2,
6578
12
        "Starred(expr value, expr_context ctx)");
6579
12
    if (!state->Starred_type) return -1;
6580
12
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6581
12
                                 2,
6582
12
        "Name(identifier id, expr_context ctx)");
6583
12
    if (!state->Name_type) return -1;
6584
12
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6585
12
                                 2,
6586
12
        "List(expr* elts, expr_context ctx)");
6587
12
    if (!state->List_type) return -1;
6588
12
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6589
12
                                  Tuple_fields, 2,
6590
12
        "Tuple(expr* elts, expr_context ctx)");
6591
12
    if (!state->Tuple_type) return -1;
6592
12
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6593
12
                                  Slice_fields, 3,
6594
12
        "Slice(expr? lower, expr? upper, expr? step)");
6595
12
    if (!state->Slice_type) return -1;
6596
12
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6597
0
        return -1;
6598
12
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6599
0
        return -1;
6600
12
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6601
0
        return -1;
6602
12
    state->expr_context_type = make_type(state, "expr_context",
6603
12
                                         state->AST_type, NULL, 0,
6604
12
        "expr_context = Load | Store | Del");
6605
12
    if (!state->expr_context_type) return -1;
6606
12
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6607
12
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6608
12
                                 0,
6609
12
        "Load");
6610
12
    if (!state->Load_type) return -1;
6611
12
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6612
12
                                              NULL, NULL);
6613
12
    if (!state->Load_singleton) return -1;
6614
12
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6615
12
                                  NULL, 0,
6616
12
        "Store");
6617
12
    if (!state->Store_type) return -1;
6618
12
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6619
12
                                               *)state->Store_type, NULL, NULL);
6620
12
    if (!state->Store_singleton) return -1;
6621
12
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6622
12
        "Del");
6623
12
    if (!state->Del_type) return -1;
6624
12
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6625
12
                                             NULL, NULL);
6626
12
    if (!state->Del_singleton) return -1;
6627
12
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6628
12
        "boolop = And | Or");
6629
12
    if (!state->boolop_type) return -1;
6630
12
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6631
12
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6632
12
        "And");
6633
12
    if (!state->And_type) return -1;
6634
12
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6635
12
                                             NULL, NULL);
6636
12
    if (!state->And_singleton) return -1;
6637
12
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6638
12
        "Or");
6639
12
    if (!state->Or_type) return -1;
6640
12
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6641
12
                                            NULL, NULL);
6642
12
    if (!state->Or_singleton) return -1;
6643
12
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6644
12
                                     0,
6645
12
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6646
12
    if (!state->operator_type) return -1;
6647
12
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6648
12
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6649
12
        "Add");
6650
12
    if (!state->Add_type) return -1;
6651
12
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6652
12
                                             NULL, NULL);
6653
12
    if (!state->Add_singleton) return -1;
6654
12
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6655
12
        "Sub");
6656
12
    if (!state->Sub_type) return -1;
6657
12
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6658
12
                                             NULL, NULL);
6659
12
    if (!state->Sub_singleton) return -1;
6660
12
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6661
12
        "Mult");
6662
12
    if (!state->Mult_type) return -1;
6663
12
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6664
12
                                              NULL, NULL);
6665
12
    if (!state->Mult_singleton) return -1;
6666
12
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6667
12
                                    NULL, 0,
6668
12
        "MatMult");
6669
12
    if (!state->MatMult_type) return -1;
6670
12
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6671
12
                                                 *)state->MatMult_type, NULL,
6672
12
                                                 NULL);
6673
12
    if (!state->MatMult_singleton) return -1;
6674
12
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6675
12
        "Div");
6676
12
    if (!state->Div_type) return -1;
6677
12
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6678
12
                                             NULL, NULL);
6679
12
    if (!state->Div_singleton) return -1;
6680
12
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6681
12
        "Mod");
6682
12
    if (!state->Mod_type) return -1;
6683
12
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6684
12
                                             NULL, NULL);
6685
12
    if (!state->Mod_singleton) return -1;
6686
12
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6687
12
        "Pow");
6688
12
    if (!state->Pow_type) return -1;
6689
12
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6690
12
                                             NULL, NULL);
6691
12
    if (!state->Pow_singleton) return -1;
6692
12
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6693
12
                                   0,
6694
12
        "LShift");
6695
12
    if (!state->LShift_type) return -1;
6696
12
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6697
12
                                                *)state->LShift_type, NULL,
6698
12
                                                NULL);
6699
12
    if (!state->LShift_singleton) return -1;
6700
12
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6701
12
                                   0,
6702
12
        "RShift");
6703
12
    if (!state->RShift_type) return -1;
6704
12
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6705
12
                                                *)state->RShift_type, NULL,
6706
12
                                                NULL);
6707
12
    if (!state->RShift_singleton) return -1;
6708
12
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6709
12
        "BitOr");
6710
12
    if (!state->BitOr_type) return -1;
6711
12
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6712
12
                                               *)state->BitOr_type, NULL, NULL);
6713
12
    if (!state->BitOr_singleton) return -1;
6714
12
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6715
12
                                   0,
6716
12
        "BitXor");
6717
12
    if (!state->BitXor_type) return -1;
6718
12
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6719
12
                                                *)state->BitXor_type, NULL,
6720
12
                                                NULL);
6721
12
    if (!state->BitXor_singleton) return -1;
6722
12
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6723
12
                                   0,
6724
12
        "BitAnd");
6725
12
    if (!state->BitAnd_type) return -1;
6726
12
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6727
12
                                                *)state->BitAnd_type, NULL,
6728
12
                                                NULL);
6729
12
    if (!state->BitAnd_singleton) return -1;
6730
12
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6731
12
                                     NULL, 0,
6732
12
        "FloorDiv");
6733
12
    if (!state->FloorDiv_type) return -1;
6734
12
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6735
12
                                                  *)state->FloorDiv_type, NULL,
6736
12
                                                  NULL);
6737
12
    if (!state->FloorDiv_singleton) return -1;
6738
12
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6739
12
        "unaryop = Invert | Not | UAdd | USub");
6740
12
    if (!state->unaryop_type) return -1;
6741
12
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6742
12
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6743
12
                                   0,
6744
12
        "Invert");
6745
12
    if (!state->Invert_type) return -1;
6746
12
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6747
12
                                                *)state->Invert_type, NULL,
6748
12
                                                NULL);
6749
12
    if (!state->Invert_singleton) return -1;
6750
12
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6751
12
        "Not");
6752
12
    if (!state->Not_type) return -1;
6753
12
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6754
12
                                             NULL, NULL);
6755
12
    if (!state->Not_singleton) return -1;
6756
12
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6757
12
        "UAdd");
6758
12
    if (!state->UAdd_type) return -1;
6759
12
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6760
12
                                              NULL, NULL);
6761
12
    if (!state->UAdd_singleton) return -1;
6762
12
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6763
12
        "USub");
6764
12
    if (!state->USub_type) return -1;
6765
12
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6766
12
                                              NULL, NULL);
6767
12
    if (!state->USub_singleton) return -1;
6768
12
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6769
12
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6770
12
    if (!state->cmpop_type) return -1;
6771
12
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6772
12
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6773
12
        "Eq");
6774
12
    if (!state->Eq_type) return -1;
6775
12
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6776
12
                                            NULL, NULL);
6777
12
    if (!state->Eq_singleton) return -1;
6778
12
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6779
12
        "NotEq");
6780
12
    if (!state->NotEq_type) return -1;
6781
12
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6782
12
                                               *)state->NotEq_type, NULL, NULL);
6783
12
    if (!state->NotEq_singleton) return -1;
6784
12
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6785
12
        "Lt");
6786
12
    if (!state->Lt_type) return -1;
6787
12
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6788
12
                                            NULL, NULL);
6789
12
    if (!state->Lt_singleton) return -1;
6790
12
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6791
12
        "LtE");
6792
12
    if (!state->LtE_type) return -1;
6793
12
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6794
12
                                             NULL, NULL);
6795
12
    if (!state->LtE_singleton) return -1;
6796
12
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6797
12
        "Gt");
6798
12
    if (!state->Gt_type) return -1;
6799
12
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6800
12
                                            NULL, NULL);
6801
12
    if (!state->Gt_singleton) return -1;
6802
12
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6803
12
        "GtE");
6804
12
    if (!state->GtE_type) return -1;
6805
12
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6806
12
                                             NULL, NULL);
6807
12
    if (!state->GtE_singleton) return -1;
6808
12
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6809
12
        "Is");
6810
12
    if (!state->Is_type) return -1;
6811
12
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6812
12
                                            NULL, NULL);
6813
12
    if (!state->Is_singleton) return -1;
6814
12
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6815
12
        "IsNot");
6816
12
    if (!state->IsNot_type) return -1;
6817
12
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6818
12
                                               *)state->IsNot_type, NULL, NULL);
6819
12
    if (!state->IsNot_singleton) return -1;
6820
12
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6821
12
        "In");
6822
12
    if (!state->In_type) return -1;
6823
12
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6824
12
                                            NULL, NULL);
6825
12
    if (!state->In_singleton) return -1;
6826
12
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6827
12
        "NotIn");
6828
12
    if (!state->NotIn_type) return -1;
6829
12
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6830
12
                                               *)state->NotIn_type, NULL, NULL);
6831
12
    if (!state->NotIn_singleton) return -1;
6832
12
    state->comprehension_type = make_type(state, "comprehension",
6833
12
                                          state->AST_type,
6834
12
                                          comprehension_fields, 4,
6835
12
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6836
12
    if (!state->comprehension_type) return -1;
6837
12
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6838
0
        -1;
6839
12
    state->excepthandler_type = make_type(state, "excepthandler",
6840
12
                                          state->AST_type, NULL, 0,
6841
12
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6842
12
    if (!state->excepthandler_type) return -1;
6843
12
    if (add_attributes(state, state->excepthandler_type,
6844
12
        excepthandler_attributes, 4) < 0) return -1;
6845
12
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6846
12
        == -1)
6847
0
        return -1;
6848
12
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6849
12
        Py_None) == -1)
6850
0
        return -1;
6851
12
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6852
12
                                          state->excepthandler_type,
6853
12
                                          ExceptHandler_fields, 3,
6854
12
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6855
12
    if (!state->ExceptHandler_type) return -1;
6856
12
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6857
0
        return -1;
6858
12
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6859
0
        return -1;
6860
12
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6861
12
                                      arguments_fields, 7,
6862
12
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6863
12
    if (!state->arguments_type) return -1;
6864
12
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6865
12
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6866
0
        return -1;
6867
12
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6868
0
        return -1;
6869
12
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6870
12
        "arg(identifier arg, expr? annotation, string? type_comment)");
6871
12
    if (!state->arg_type) return -1;
6872
12
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6873
0
        -1;
6874
12
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6875
0
        return -1;
6876
12
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6877
0
        return -1;
6878
12
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6879
0
        return -1;
6880
12
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6881
0
        return -1;
6882
12
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6883
12
                                    keyword_fields, 2,
6884
12
        "keyword(identifier? arg, expr value)");
6885
12
    if (!state->keyword_type) return -1;
6886
12
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6887
0
        return -1;
6888
12
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6889
0
        return -1;
6890
12
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6891
0
        return -1;
6892
12
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6893
12
        == -1)
6894
0
        return -1;
6895
12
    state->alias_type = make_type(state, "alias", state->AST_type,
6896
12
                                  alias_fields, 2,
6897
12
        "alias(identifier name, identifier? asname)");
6898
12
    if (!state->alias_type) return -1;
6899
12
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6900
0
        return -1;
6901
12
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6902
0
        return -1;
6903
12
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6904
0
        return -1;
6905
12
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6906
12
        -1)
6907
0
        return -1;
6908
12
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6909
12
                                     withitem_fields, 2,
6910
12
        "withitem(expr context_expr, expr? optional_vars)");
6911
12
    if (!state->withitem_type) return -1;
6912
12
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6913
12
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6914
12
        == -1)
6915
0
        return -1;
6916
12
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6917
12
                                       match_case_fields, 3,
6918
12
        "match_case(pattern pattern, expr? guard, stmt* body)");
6919
12
    if (!state->match_case_type) return -1;
6920
12
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6921
12
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6922
0
        return -1;
6923
12
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6924
12
        "pattern = MatchValue(expr value)\n"
6925
12
        "        | MatchSingleton(constant value)\n"
6926
12
        "        | MatchSequence(pattern* patterns)\n"
6927
12
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6928
12
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6929
12
        "        | MatchStar(identifier? name)\n"
6930
12
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6931
12
        "        | MatchOr(pattern* patterns)");
6932
12
    if (!state->pattern_type) return -1;
6933
12
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6934
0
        return -1;
6935
12
    state->MatchValue_type = make_type(state, "MatchValue",
6936
12
                                       state->pattern_type, MatchValue_fields,
6937
12
                                       1,
6938
12
        "MatchValue(expr value)");
6939
12
    if (!state->MatchValue_type) return -1;
6940
12
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6941
12
                                           state->pattern_type,
6942
12
                                           MatchSingleton_fields, 1,
6943
12
        "MatchSingleton(constant value)");
6944
12
    if (!state->MatchSingleton_type) return -1;
6945
12
    state->MatchSequence_type = make_type(state, "MatchSequence",
6946
12
                                          state->pattern_type,
6947
12
                                          MatchSequence_fields, 1,
6948
12
        "MatchSequence(pattern* patterns)");
6949
12
    if (!state->MatchSequence_type) return -1;
6950
12
    state->MatchMapping_type = make_type(state, "MatchMapping",
6951
12
                                         state->pattern_type,
6952
12
                                         MatchMapping_fields, 3,
6953
12
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6954
12
    if (!state->MatchMapping_type) return -1;
6955
12
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6956
0
        return -1;
6957
12
    state->MatchClass_type = make_type(state, "MatchClass",
6958
12
                                       state->pattern_type, MatchClass_fields,
6959
12
                                       4,
6960
12
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6961
12
    if (!state->MatchClass_type) return -1;
6962
12
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6963
12
                                      MatchStar_fields, 1,
6964
12
        "MatchStar(identifier? name)");
6965
12
    if (!state->MatchStar_type) return -1;
6966
12
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6967
0
        return -1;
6968
12
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6969
12
                                    MatchAs_fields, 2,
6970
12
        "MatchAs(pattern? pattern, identifier? name)");
6971
12
    if (!state->MatchAs_type) return -1;
6972
12
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6973
0
        return -1;
6974
12
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6975
0
        return -1;
6976
12
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6977
12
                                    MatchOr_fields, 1,
6978
12
        "MatchOr(pattern* patterns)");
6979
12
    if (!state->MatchOr_type) return -1;
6980
12
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6981
12
                                        NULL, 0,
6982
12
        "type_ignore = TypeIgnore(int lineno, string tag)");
6983
12
    if (!state->type_ignore_type) return -1;
6984
12
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6985
12
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6986
12
                                       state->type_ignore_type,
6987
12
                                       TypeIgnore_fields, 2,
6988
12
        "TypeIgnore(int lineno, string tag)");
6989
12
    if (!state->TypeIgnore_type) return -1;
6990
12
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6991
12
                                       NULL, 0,
6992
12
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6993
12
        "           | ParamSpec(identifier name, expr? default_value)\n"
6994
12
        "           | TypeVarTuple(identifier name, expr? default_value)");
6995
12
    if (!state->type_param_type) return -1;
6996
12
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6997
12
        < 0) return -1;
6998
12
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6999
12
                                    TypeVar_fields, 3,
7000
12
        "TypeVar(identifier name, expr? bound, expr? default_value)");
7001
12
    if (!state->TypeVar_type) return -1;
7002
12
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
7003
0
        return -1;
7004
12
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
7005
12
        -1)
7006
0
        return -1;
7007
12
    state->ParamSpec_type = make_type(state, "ParamSpec",
7008
12
                                      state->type_param_type, ParamSpec_fields,
7009
12
                                      2,
7010
12
        "ParamSpec(identifier name, expr? default_value)");
7011
12
    if (!state->ParamSpec_type) return -1;
7012
12
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
7013
12
        == -1)
7014
0
        return -1;
7015
12
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
7016
12
                                         state->type_param_type,
7017
12
                                         TypeVarTuple_fields, 2,
7018
12
        "TypeVarTuple(identifier name, expr? default_value)");
7019
12
    if (!state->TypeVarTuple_type) return -1;
7020
12
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
7021
12
        Py_None) == -1)
7022
0
        return -1;
7023
7024
12
    if (!add_ast_annotations(state)) {
7025
0
        return -1;
7026
0
    }
7027
12
    return 0;
7028
12
}
7029
7030
static int obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out,
7031
                       PyArena* arena);
7032
static int obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out,
7033
                        PyArena* arena);
7034
static int obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out,
7035
                        PyArena* arena);
7036
static int obj2ast_expr_context(struct ast_state *state, PyObject* obj,
7037
                                expr_context_ty* out, PyArena* arena);
7038
static int obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty*
7039
                          out, PyArena* arena);
7040
static int obj2ast_operator(struct ast_state *state, PyObject* obj,
7041
                            operator_ty* out, PyArena* arena);
7042
static int obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty*
7043
                           out, PyArena* arena);
7044
static int obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out,
7045
                         PyArena* arena);
7046
static int obj2ast_comprehension(struct ast_state *state, PyObject* obj,
7047
                                 comprehension_ty* out, PyArena* arena);
7048
static int obj2ast_excepthandler(struct ast_state *state, PyObject* obj,
7049
                                 excepthandler_ty* out, PyArena* arena);
7050
static int obj2ast_arguments(struct ast_state *state, PyObject* obj,
7051
                             arguments_ty* out, PyArena* arena);
7052
static int obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out,
7053
                       PyArena* arena);
7054
static int obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty*
7055
                           out, PyArena* arena);
7056
static int obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out,
7057
                         PyArena* arena);
7058
static int obj2ast_withitem(struct ast_state *state, PyObject* obj,
7059
                            withitem_ty* out, PyArena* arena);
7060
static int obj2ast_match_case(struct ast_state *state, PyObject* obj,
7061
                              match_case_ty* out, PyArena* arena);
7062
static int obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty*
7063
                           out, PyArena* arena);
7064
static int obj2ast_type_ignore(struct ast_state *state, PyObject* obj,
7065
                               type_ignore_ty* out, PyArena* arena);
7066
static int obj2ast_type_param(struct ast_state *state, PyObject* obj,
7067
                              type_param_ty* out, PyArena* arena);
7068
7069
mod_ty
7070
_PyAST_Module(asdl_stmt_seq * body, asdl_type_ignore_seq * type_ignores,
7071
              PyArena *arena)
7072
5.43k
{
7073
5.43k
    mod_ty p;
7074
5.43k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7075
5.43k
    if (!p)
7076
0
        return NULL;
7077
5.43k
    p->kind = Module_kind;
7078
5.43k
    p->v.Module.body = body;
7079
5.43k
    p->v.Module.type_ignores = type_ignores;
7080
5.43k
    return p;
7081
5.43k
}
7082
7083
mod_ty
7084
_PyAST_Interactive(asdl_stmt_seq * body, PyArena *arena)
7085
0
{
7086
0
    mod_ty p;
7087
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7088
0
    if (!p)
7089
0
        return NULL;
7090
0
    p->kind = Interactive_kind;
7091
0
    p->v.Interactive.body = body;
7092
0
    return p;
7093
0
}
7094
7095
mod_ty
7096
_PyAST_Expression(expr_ty body, PyArena *arena)
7097
166
{
7098
166
    mod_ty p;
7099
166
    if (!body) {
7100
0
        PyErr_SetString(PyExc_ValueError,
7101
0
                        "field 'body' is required for Expression");
7102
0
        return NULL;
7103
0
    }
7104
166
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7105
166
    if (!p)
7106
0
        return NULL;
7107
166
    p->kind = Expression_kind;
7108
166
    p->v.Expression.body = body;
7109
166
    return p;
7110
166
}
7111
7112
mod_ty
7113
_PyAST_FunctionType(asdl_expr_seq * argtypes, expr_ty returns, PyArena *arena)
7114
0
{
7115
0
    mod_ty p;
7116
0
    if (!returns) {
7117
0
        PyErr_SetString(PyExc_ValueError,
7118
0
                        "field 'returns' is required for FunctionType");
7119
0
        return NULL;
7120
0
    }
7121
0
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7122
0
    if (!p)
7123
0
        return NULL;
7124
0
    p->kind = FunctionType_kind;
7125
0
    p->v.FunctionType.argtypes = argtypes;
7126
0
    p->v.FunctionType.returns = returns;
7127
0
    return p;
7128
0
}
7129
7130
stmt_ty
7131
_PyAST_FunctionDef(identifier name, arguments_ty args, asdl_stmt_seq * body,
7132
                   asdl_expr_seq * decorator_list, expr_ty returns, string
7133
                   type_comment, asdl_type_param_seq * type_params, int lineno,
7134
                   int col_offset, int end_lineno, int end_col_offset, PyArena
7135
                   *arena)
7136
6.34k
{
7137
6.34k
    stmt_ty p;
7138
6.34k
    if (!name) {
7139
0
        PyErr_SetString(PyExc_ValueError,
7140
0
                        "field 'name' is required for FunctionDef");
7141
0
        return NULL;
7142
0
    }
7143
6.34k
    if (!args) {
7144
0
        PyErr_SetString(PyExc_ValueError,
7145
0
                        "field 'args' is required for FunctionDef");
7146
0
        return NULL;
7147
0
    }
7148
6.34k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7149
6.34k
    if (!p)
7150
0
        return NULL;
7151
6.34k
    p->kind = FunctionDef_kind;
7152
6.34k
    p->v.FunctionDef.name = name;
7153
6.34k
    p->v.FunctionDef.args = args;
7154
6.34k
    p->v.FunctionDef.body = body;
7155
6.34k
    p->v.FunctionDef.decorator_list = decorator_list;
7156
6.34k
    p->v.FunctionDef.returns = returns;
7157
6.34k
    p->v.FunctionDef.type_comment = type_comment;
7158
6.34k
    p->v.FunctionDef.type_params = type_params;
7159
6.34k
    p->lineno = lineno;
7160
6.34k
    p->col_offset = col_offset;
7161
6.34k
    p->end_lineno = end_lineno;
7162
6.34k
    p->end_col_offset = end_col_offset;
7163
6.34k
    return p;
7164
6.34k
}
7165
7166
stmt_ty
7167
_PyAST_AsyncFunctionDef(identifier name, arguments_ty args, asdl_stmt_seq *
7168
                        body, asdl_expr_seq * decorator_list, expr_ty returns,
7169
                        string type_comment, asdl_type_param_seq * type_params,
7170
                        int lineno, int col_offset, int end_lineno, int
7171
                        end_col_offset, PyArena *arena)
7172
385
{
7173
385
    stmt_ty p;
7174
385
    if (!name) {
7175
0
        PyErr_SetString(PyExc_ValueError,
7176
0
                        "field 'name' is required for AsyncFunctionDef");
7177
0
        return NULL;
7178
0
    }
7179
385
    if (!args) {
7180
0
        PyErr_SetString(PyExc_ValueError,
7181
0
                        "field 'args' is required for AsyncFunctionDef");
7182
0
        return NULL;
7183
0
    }
7184
385
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7185
385
    if (!p)
7186
0
        return NULL;
7187
385
    p->kind = AsyncFunctionDef_kind;
7188
385
    p->v.AsyncFunctionDef.name = name;
7189
385
    p->v.AsyncFunctionDef.args = args;
7190
385
    p->v.AsyncFunctionDef.body = body;
7191
385
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7192
385
    p->v.AsyncFunctionDef.returns = returns;
7193
385
    p->v.AsyncFunctionDef.type_comment = type_comment;
7194
385
    p->v.AsyncFunctionDef.type_params = type_params;
7195
385
    p->lineno = lineno;
7196
385
    p->col_offset = col_offset;
7197
385
    p->end_lineno = end_lineno;
7198
385
    p->end_col_offset = end_col_offset;
7199
385
    return p;
7200
385
}
7201
7202
stmt_ty
7203
_PyAST_ClassDef(identifier name, asdl_expr_seq * bases, asdl_keyword_seq *
7204
                keywords, asdl_stmt_seq * body, asdl_expr_seq * decorator_list,
7205
                asdl_type_param_seq * type_params, int lineno, int col_offset,
7206
                int end_lineno, int end_col_offset, PyArena *arena)
7207
3.57k
{
7208
3.57k
    stmt_ty p;
7209
3.57k
    if (!name) {
7210
0
        PyErr_SetString(PyExc_ValueError,
7211
0
                        "field 'name' is required for ClassDef");
7212
0
        return NULL;
7213
0
    }
7214
3.57k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7215
3.57k
    if (!p)
7216
0
        return NULL;
7217
3.57k
    p->kind = ClassDef_kind;
7218
3.57k
    p->v.ClassDef.name = name;
7219
3.57k
    p->v.ClassDef.bases = bases;
7220
3.57k
    p->v.ClassDef.keywords = keywords;
7221
3.57k
    p->v.ClassDef.body = body;
7222
3.57k
    p->v.ClassDef.decorator_list = decorator_list;
7223
3.57k
    p->v.ClassDef.type_params = type_params;
7224
3.57k
    p->lineno = lineno;
7225
3.57k
    p->col_offset = col_offset;
7226
3.57k
    p->end_lineno = end_lineno;
7227
3.57k
    p->end_col_offset = end_col_offset;
7228
3.57k
    return p;
7229
3.57k
}
7230
7231
stmt_ty
7232
_PyAST_Return(expr_ty value, int lineno, int col_offset, int end_lineno, int
7233
              end_col_offset, PyArena *arena)
7234
3.15k
{
7235
3.15k
    stmt_ty p;
7236
3.15k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7237
3.15k
    if (!p)
7238
0
        return NULL;
7239
3.15k
    p->kind = Return_kind;
7240
3.15k
    p->v.Return.value = value;
7241
3.15k
    p->lineno = lineno;
7242
3.15k
    p->col_offset = col_offset;
7243
3.15k
    p->end_lineno = end_lineno;
7244
3.15k
    p->end_col_offset = end_col_offset;
7245
3.15k
    return p;
7246
3.15k
}
7247
7248
stmt_ty
7249
_PyAST_Delete(asdl_expr_seq * targets, int lineno, int col_offset, int
7250
              end_lineno, int end_col_offset, PyArena *arena)
7251
566
{
7252
566
    stmt_ty p;
7253
566
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7254
566
    if (!p)
7255
0
        return NULL;
7256
566
    p->kind = Delete_kind;
7257
566
    p->v.Delete.targets = targets;
7258
566
    p->lineno = lineno;
7259
566
    p->col_offset = col_offset;
7260
566
    p->end_lineno = end_lineno;
7261
566
    p->end_col_offset = end_col_offset;
7262
566
    return p;
7263
566
}
7264
7265
stmt_ty
7266
_PyAST_Assign(asdl_expr_seq * targets, expr_ty value, string type_comment, int
7267
              lineno, int col_offset, int end_lineno, int end_col_offset,
7268
              PyArena *arena)
7269
6.52k
{
7270
6.52k
    stmt_ty p;
7271
6.52k
    if (!value) {
7272
0
        PyErr_SetString(PyExc_ValueError,
7273
0
                        "field 'value' is required for Assign");
7274
0
        return NULL;
7275
0
    }
7276
6.52k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7277
6.52k
    if (!p)
7278
0
        return NULL;
7279
6.52k
    p->kind = Assign_kind;
7280
6.52k
    p->v.Assign.targets = targets;
7281
6.52k
    p->v.Assign.value = value;
7282
6.52k
    p->v.Assign.type_comment = type_comment;
7283
6.52k
    p->lineno = lineno;
7284
6.52k
    p->col_offset = col_offset;
7285
6.52k
    p->end_lineno = end_lineno;
7286
6.52k
    p->end_col_offset = end_col_offset;
7287
6.52k
    return p;
7288
6.52k
}
7289
7290
stmt_ty
7291
_PyAST_TypeAlias(expr_ty name, asdl_type_param_seq * type_params, expr_ty
7292
                 value, int lineno, int col_offset, int end_lineno, int
7293
                 end_col_offset, PyArena *arena)
7294
233
{
7295
233
    stmt_ty p;
7296
233
    if (!name) {
7297
0
        PyErr_SetString(PyExc_ValueError,
7298
0
                        "field 'name' is required for TypeAlias");
7299
0
        return NULL;
7300
0
    }
7301
233
    if (!value) {
7302
0
        PyErr_SetString(PyExc_ValueError,
7303
0
                        "field 'value' is required for TypeAlias");
7304
0
        return NULL;
7305
0
    }
7306
233
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7307
233
    if (!p)
7308
0
        return NULL;
7309
233
    p->kind = TypeAlias_kind;
7310
233
    p->v.TypeAlias.name = name;
7311
233
    p->v.TypeAlias.type_params = type_params;
7312
233
    p->v.TypeAlias.value = value;
7313
233
    p->lineno = lineno;
7314
233
    p->col_offset = col_offset;
7315
233
    p->end_lineno = end_lineno;
7316
233
    p->end_col_offset = end_col_offset;
7317
233
    return p;
7318
233
}
7319
7320
stmt_ty
7321
_PyAST_AugAssign(expr_ty target, operator_ty op, expr_ty value, int lineno, int
7322
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7323
2.44k
{
7324
2.44k
    stmt_ty p;
7325
2.44k
    if (!target) {
7326
0
        PyErr_SetString(PyExc_ValueError,
7327
0
                        "field 'target' is required for AugAssign");
7328
0
        return NULL;
7329
0
    }
7330
2.44k
    if (!op) {
7331
0
        PyErr_SetString(PyExc_ValueError,
7332
0
                        "field 'op' is required for AugAssign");
7333
0
        return NULL;
7334
0
    }
7335
2.44k
    if (!value) {
7336
0
        PyErr_SetString(PyExc_ValueError,
7337
0
                        "field 'value' is required for AugAssign");
7338
0
        return NULL;
7339
0
    }
7340
2.44k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7341
2.44k
    if (!p)
7342
0
        return NULL;
7343
2.44k
    p->kind = AugAssign_kind;
7344
2.44k
    p->v.AugAssign.target = target;
7345
2.44k
    p->v.AugAssign.op = op;
7346
2.44k
    p->v.AugAssign.value = value;
7347
2.44k
    p->lineno = lineno;
7348
2.44k
    p->col_offset = col_offset;
7349
2.44k
    p->end_lineno = end_lineno;
7350
2.44k
    p->end_col_offset = end_col_offset;
7351
2.44k
    return p;
7352
2.44k
}
7353
7354
stmt_ty
7355
_PyAST_AnnAssign(expr_ty target, expr_ty annotation, expr_ty value, int simple,
7356
                 int lineno, int col_offset, int end_lineno, int
7357
                 end_col_offset, PyArena *arena)
7358
2.47k
{
7359
2.47k
    stmt_ty p;
7360
2.47k
    if (!target) {
7361
0
        PyErr_SetString(PyExc_ValueError,
7362
0
                        "field 'target' is required for AnnAssign");
7363
0
        return NULL;
7364
0
    }
7365
2.47k
    if (!annotation) {
7366
0
        PyErr_SetString(PyExc_ValueError,
7367
0
                        "field 'annotation' is required for AnnAssign");
7368
0
        return NULL;
7369
0
    }
7370
2.47k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7371
2.47k
    if (!p)
7372
0
        return NULL;
7373
2.47k
    p->kind = AnnAssign_kind;
7374
2.47k
    p->v.AnnAssign.target = target;
7375
2.47k
    p->v.AnnAssign.annotation = annotation;
7376
2.47k
    p->v.AnnAssign.value = value;
7377
2.47k
    p->v.AnnAssign.simple = simple;
7378
2.47k
    p->lineno = lineno;
7379
2.47k
    p->col_offset = col_offset;
7380
2.47k
    p->end_lineno = end_lineno;
7381
2.47k
    p->end_col_offset = end_col_offset;
7382
2.47k
    return p;
7383
2.47k
}
7384
7385
stmt_ty
7386
_PyAST_For(expr_ty target, expr_ty iter, asdl_stmt_seq * body, asdl_stmt_seq *
7387
           orelse, string type_comment, int lineno, int col_offset, int
7388
           end_lineno, int end_col_offset, PyArena *arena)
7389
1.17k
{
7390
1.17k
    stmt_ty p;
7391
1.17k
    if (!target) {
7392
0
        PyErr_SetString(PyExc_ValueError,
7393
0
                        "field 'target' is required for For");
7394
0
        return NULL;
7395
0
    }
7396
1.17k
    if (!iter) {
7397
0
        PyErr_SetString(PyExc_ValueError,
7398
0
                        "field 'iter' is required for For");
7399
0
        return NULL;
7400
0
    }
7401
1.17k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7402
1.17k
    if (!p)
7403
0
        return NULL;
7404
1.17k
    p->kind = For_kind;
7405
1.17k
    p->v.For.target = target;
7406
1.17k
    p->v.For.iter = iter;
7407
1.17k
    p->v.For.body = body;
7408
1.17k
    p->v.For.orelse = orelse;
7409
1.17k
    p->v.For.type_comment = type_comment;
7410
1.17k
    p->lineno = lineno;
7411
1.17k
    p->col_offset = col_offset;
7412
1.17k
    p->end_lineno = end_lineno;
7413
1.17k
    p->end_col_offset = end_col_offset;
7414
1.17k
    return p;
7415
1.17k
}
7416
7417
stmt_ty
7418
_PyAST_AsyncFor(expr_ty target, expr_ty iter, asdl_stmt_seq * body,
7419
                asdl_stmt_seq * orelse, string type_comment, int lineno, int
7420
                col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7421
196
{
7422
196
    stmt_ty p;
7423
196
    if (!target) {
7424
0
        PyErr_SetString(PyExc_ValueError,
7425
0
                        "field 'target' is required for AsyncFor");
7426
0
        return NULL;
7427
0
    }
7428
196
    if (!iter) {
7429
0
        PyErr_SetString(PyExc_ValueError,
7430
0
                        "field 'iter' is required for AsyncFor");
7431
0
        return NULL;
7432
0
    }
7433
196
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7434
196
    if (!p)
7435
0
        return NULL;
7436
196
    p->kind = AsyncFor_kind;
7437
196
    p->v.AsyncFor.target = target;
7438
196
    p->v.AsyncFor.iter = iter;
7439
196
    p->v.AsyncFor.body = body;
7440
196
    p->v.AsyncFor.orelse = orelse;
7441
196
    p->v.AsyncFor.type_comment = type_comment;
7442
196
    p->lineno = lineno;
7443
196
    p->col_offset = col_offset;
7444
196
    p->end_lineno = end_lineno;
7445
196
    p->end_col_offset = end_col_offset;
7446
196
    return p;
7447
196
}
7448
7449
stmt_ty
7450
_PyAST_While(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7451
             lineno, int col_offset, int end_lineno, int end_col_offset,
7452
             PyArena *arena)
7453
733
{
7454
733
    stmt_ty p;
7455
733
    if (!test) {
7456
0
        PyErr_SetString(PyExc_ValueError,
7457
0
                        "field 'test' is required for While");
7458
0
        return NULL;
7459
0
    }
7460
733
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7461
733
    if (!p)
7462
0
        return NULL;
7463
733
    p->kind = While_kind;
7464
733
    p->v.While.test = test;
7465
733
    p->v.While.body = body;
7466
733
    p->v.While.orelse = orelse;
7467
733
    p->lineno = lineno;
7468
733
    p->col_offset = col_offset;
7469
733
    p->end_lineno = end_lineno;
7470
733
    p->end_col_offset = end_col_offset;
7471
733
    return p;
7472
733
}
7473
7474
stmt_ty
7475
_PyAST_If(expr_ty test, asdl_stmt_seq * body, asdl_stmt_seq * orelse, int
7476
          lineno, int col_offset, int end_lineno, int end_col_offset, PyArena
7477
          *arena)
7478
4.69k
{
7479
4.69k
    stmt_ty p;
7480
4.69k
    if (!test) {
7481
0
        PyErr_SetString(PyExc_ValueError,
7482
0
                        "field 'test' is required for If");
7483
0
        return NULL;
7484
0
    }
7485
4.69k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7486
4.69k
    if (!p)
7487
0
        return NULL;
7488
4.69k
    p->kind = If_kind;
7489
4.69k
    p->v.If.test = test;
7490
4.69k
    p->v.If.body = body;
7491
4.69k
    p->v.If.orelse = orelse;
7492
4.69k
    p->lineno = lineno;
7493
4.69k
    p->col_offset = col_offset;
7494
4.69k
    p->end_lineno = end_lineno;
7495
4.69k
    p->end_col_offset = end_col_offset;
7496
4.69k
    return p;
7497
4.69k
}
7498
7499
stmt_ty
7500
_PyAST_With(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7501
            type_comment, int lineno, int col_offset, int end_lineno, int
7502
            end_col_offset, PyArena *arena)
7503
1.10k
{
7504
1.10k
    stmt_ty p;
7505
1.10k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7506
1.10k
    if (!p)
7507
0
        return NULL;
7508
1.10k
    p->kind = With_kind;
7509
1.10k
    p->v.With.items = items;
7510
1.10k
    p->v.With.body = body;
7511
1.10k
    p->v.With.type_comment = type_comment;
7512
1.10k
    p->lineno = lineno;
7513
1.10k
    p->col_offset = col_offset;
7514
1.10k
    p->end_lineno = end_lineno;
7515
1.10k
    p->end_col_offset = end_col_offset;
7516
1.10k
    return p;
7517
1.10k
}
7518
7519
stmt_ty
7520
_PyAST_AsyncWith(asdl_withitem_seq * items, asdl_stmt_seq * body, string
7521
                 type_comment, int lineno, int col_offset, int end_lineno, int
7522
                 end_col_offset, PyArena *arena)
7523
674
{
7524
674
    stmt_ty p;
7525
674
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7526
674
    if (!p)
7527
0
        return NULL;
7528
674
    p->kind = AsyncWith_kind;
7529
674
    p->v.AsyncWith.items = items;
7530
674
    p->v.AsyncWith.body = body;
7531
674
    p->v.AsyncWith.type_comment = type_comment;
7532
674
    p->lineno = lineno;
7533
674
    p->col_offset = col_offset;
7534
674
    p->end_lineno = end_lineno;
7535
674
    p->end_col_offset = end_col_offset;
7536
674
    return p;
7537
674
}
7538
7539
stmt_ty
7540
_PyAST_Match(expr_ty subject, asdl_match_case_seq * cases, int lineno, int
7541
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7542
336
{
7543
336
    stmt_ty p;
7544
336
    if (!subject) {
7545
0
        PyErr_SetString(PyExc_ValueError,
7546
0
                        "field 'subject' is required for Match");
7547
0
        return NULL;
7548
0
    }
7549
336
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7550
336
    if (!p)
7551
0
        return NULL;
7552
336
    p->kind = Match_kind;
7553
336
    p->v.Match.subject = subject;
7554
336
    p->v.Match.cases = cases;
7555
336
    p->lineno = lineno;
7556
336
    p->col_offset = col_offset;
7557
336
    p->end_lineno = end_lineno;
7558
336
    p->end_col_offset = end_col_offset;
7559
336
    return p;
7560
336
}
7561
7562
stmt_ty
7563
_PyAST_Raise(expr_ty exc, expr_ty cause, int lineno, int col_offset, int
7564
             end_lineno, int end_col_offset, PyArena *arena)
7565
2.12k
{
7566
2.12k
    stmt_ty p;
7567
2.12k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7568
2.12k
    if (!p)
7569
0
        return NULL;
7570
2.12k
    p->kind = Raise_kind;
7571
2.12k
    p->v.Raise.exc = exc;
7572
2.12k
    p->v.Raise.cause = cause;
7573
2.12k
    p->lineno = lineno;
7574
2.12k
    p->col_offset = col_offset;
7575
2.12k
    p->end_lineno = end_lineno;
7576
2.12k
    p->end_col_offset = end_col_offset;
7577
2.12k
    return p;
7578
2.12k
}
7579
7580
stmt_ty
7581
_PyAST_Try(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7582
           asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno, int
7583
           col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7584
3.34k
{
7585
3.34k
    stmt_ty p;
7586
3.34k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7587
3.34k
    if (!p)
7588
0
        return NULL;
7589
3.34k
    p->kind = Try_kind;
7590
3.34k
    p->v.Try.body = body;
7591
3.34k
    p->v.Try.handlers = handlers;
7592
3.34k
    p->v.Try.orelse = orelse;
7593
3.34k
    p->v.Try.finalbody = finalbody;
7594
3.34k
    p->lineno = lineno;
7595
3.34k
    p->col_offset = col_offset;
7596
3.34k
    p->end_lineno = end_lineno;
7597
3.34k
    p->end_col_offset = end_col_offset;
7598
3.34k
    return p;
7599
3.34k
}
7600
7601
stmt_ty
7602
_PyAST_TryStar(asdl_stmt_seq * body, asdl_excepthandler_seq * handlers,
7603
               asdl_stmt_seq * orelse, asdl_stmt_seq * finalbody, int lineno,
7604
               int col_offset, int end_lineno, int end_col_offset, PyArena
7605
               *arena)
7606
1.23k
{
7607
1.23k
    stmt_ty p;
7608
1.23k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7609
1.23k
    if (!p)
7610
0
        return NULL;
7611
1.23k
    p->kind = TryStar_kind;
7612
1.23k
    p->v.TryStar.body = body;
7613
1.23k
    p->v.TryStar.handlers = handlers;
7614
1.23k
    p->v.TryStar.orelse = orelse;
7615
1.23k
    p->v.TryStar.finalbody = finalbody;
7616
1.23k
    p->lineno = lineno;
7617
1.23k
    p->col_offset = col_offset;
7618
1.23k
    p->end_lineno = end_lineno;
7619
1.23k
    p->end_col_offset = end_col_offset;
7620
1.23k
    return p;
7621
1.23k
}
7622
7623
stmt_ty
7624
_PyAST_Assert(expr_ty test, expr_ty msg, int lineno, int col_offset, int
7625
              end_lineno, int end_col_offset, PyArena *arena)
7626
1.20k
{
7627
1.20k
    stmt_ty p;
7628
1.20k
    if (!test) {
7629
0
        PyErr_SetString(PyExc_ValueError,
7630
0
                        "field 'test' is required for Assert");
7631
0
        return NULL;
7632
0
    }
7633
1.20k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7634
1.20k
    if (!p)
7635
0
        return NULL;
7636
1.20k
    p->kind = Assert_kind;
7637
1.20k
    p->v.Assert.test = test;
7638
1.20k
    p->v.Assert.msg = msg;
7639
1.20k
    p->lineno = lineno;
7640
1.20k
    p->col_offset = col_offset;
7641
1.20k
    p->end_lineno = end_lineno;
7642
1.20k
    p->end_col_offset = end_col_offset;
7643
1.20k
    return p;
7644
1.20k
}
7645
7646
stmt_ty
7647
_PyAST_Import(asdl_alias_seq * names, int is_lazy, int lineno, int col_offset,
7648
              int end_lineno, int end_col_offset, PyArena *arena)
7649
2.19k
{
7650
2.19k
    stmt_ty p;
7651
2.19k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7652
2.19k
    if (!p)
7653
0
        return NULL;
7654
2.19k
    p->kind = Import_kind;
7655
2.19k
    p->v.Import.names = names;
7656
2.19k
    p->v.Import.is_lazy = is_lazy;
7657
2.19k
    p->lineno = lineno;
7658
2.19k
    p->col_offset = col_offset;
7659
2.19k
    p->end_lineno = end_lineno;
7660
2.19k
    p->end_col_offset = end_col_offset;
7661
2.19k
    return p;
7662
2.19k
}
7663
7664
stmt_ty
7665
_PyAST_ImportFrom(identifier module, asdl_alias_seq * names, int level, int
7666
                  is_lazy, int lineno, int col_offset, int end_lineno, int
7667
                  end_col_offset, PyArena *arena)
7668
2.60k
{
7669
2.60k
    stmt_ty p;
7670
2.60k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7671
2.60k
    if (!p)
7672
0
        return NULL;
7673
2.60k
    p->kind = ImportFrom_kind;
7674
2.60k
    p->v.ImportFrom.module = module;
7675
2.60k
    p->v.ImportFrom.names = names;
7676
2.60k
    p->v.ImportFrom.level = level;
7677
2.60k
    p->v.ImportFrom.is_lazy = is_lazy;
7678
2.60k
    p->lineno = lineno;
7679
2.60k
    p->col_offset = col_offset;
7680
2.60k
    p->end_lineno = end_lineno;
7681
2.60k
    p->end_col_offset = end_col_offset;
7682
2.60k
    return p;
7683
2.60k
}
7684
7685
stmt_ty
7686
_PyAST_Global(asdl_identifier_seq * names, int lineno, int col_offset, int
7687
              end_lineno, int end_col_offset, PyArena *arena)
7688
421
{
7689
421
    stmt_ty p;
7690
421
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7691
421
    if (!p)
7692
0
        return NULL;
7693
421
    p->kind = Global_kind;
7694
421
    p->v.Global.names = names;
7695
421
    p->lineno = lineno;
7696
421
    p->col_offset = col_offset;
7697
421
    p->end_lineno = end_lineno;
7698
421
    p->end_col_offset = end_col_offset;
7699
421
    return p;
7700
421
}
7701
7702
stmt_ty
7703
_PyAST_Nonlocal(asdl_identifier_seq * names, int lineno, int col_offset, int
7704
                end_lineno, int end_col_offset, PyArena *arena)
7705
87
{
7706
87
    stmt_ty p;
7707
87
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7708
87
    if (!p)
7709
0
        return NULL;
7710
87
    p->kind = Nonlocal_kind;
7711
87
    p->v.Nonlocal.names = names;
7712
87
    p->lineno = lineno;
7713
87
    p->col_offset = col_offset;
7714
87
    p->end_lineno = end_lineno;
7715
87
    p->end_col_offset = end_col_offset;
7716
87
    return p;
7717
87
}
7718
7719
stmt_ty
7720
_PyAST_Expr(expr_ty value, int lineno, int col_offset, int end_lineno, int
7721
            end_col_offset, PyArena *arena)
7722
70.7k
{
7723
70.7k
    stmt_ty p;
7724
70.7k
    if (!value) {
7725
0
        PyErr_SetString(PyExc_ValueError,
7726
0
                        "field 'value' is required for Expr");
7727
0
        return NULL;
7728
0
    }
7729
70.7k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7730
70.7k
    if (!p)
7731
0
        return NULL;
7732
70.7k
    p->kind = Expr_kind;
7733
70.7k
    p->v.Expr.value = value;
7734
70.7k
    p->lineno = lineno;
7735
70.7k
    p->col_offset = col_offset;
7736
70.7k
    p->end_lineno = end_lineno;
7737
70.7k
    p->end_col_offset = end_col_offset;
7738
70.7k
    return p;
7739
70.7k
}
7740
7741
stmt_ty
7742
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7743
            PyArena *arena)
7744
1.63k
{
7745
1.63k
    stmt_ty p;
7746
1.63k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7747
1.63k
    if (!p)
7748
0
        return NULL;
7749
1.63k
    p->kind = Pass_kind;
7750
1.63k
    p->lineno = lineno;
7751
1.63k
    p->col_offset = col_offset;
7752
1.63k
    p->end_lineno = end_lineno;
7753
1.63k
    p->end_col_offset = end_col_offset;
7754
1.63k
    return p;
7755
1.63k
}
7756
7757
stmt_ty
7758
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7759
             PyArena *arena)
7760
1.58k
{
7761
1.58k
    stmt_ty p;
7762
1.58k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7763
1.58k
    if (!p)
7764
0
        return NULL;
7765
1.58k
    p->kind = Break_kind;
7766
1.58k
    p->lineno = lineno;
7767
1.58k
    p->col_offset = col_offset;
7768
1.58k
    p->end_lineno = end_lineno;
7769
1.58k
    p->end_col_offset = end_col_offset;
7770
1.58k
    return p;
7771
1.58k
}
7772
7773
stmt_ty
7774
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7775
                PyArena *arena)
7776
1.31k
{
7777
1.31k
    stmt_ty p;
7778
1.31k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7779
1.31k
    if (!p)
7780
0
        return NULL;
7781
1.31k
    p->kind = Continue_kind;
7782
1.31k
    p->lineno = lineno;
7783
1.31k
    p->col_offset = col_offset;
7784
1.31k
    p->end_lineno = end_lineno;
7785
1.31k
    p->end_col_offset = end_col_offset;
7786
1.31k
    return p;
7787
1.31k
}
7788
7789
expr_ty
7790
_PyAST_BoolOp(boolop_ty op, asdl_expr_seq * values, int lineno, int col_offset,
7791
              int end_lineno, int end_col_offset, PyArena *arena)
7792
1.59k
{
7793
1.59k
    expr_ty p;
7794
1.59k
    if (!op) {
7795
0
        PyErr_SetString(PyExc_ValueError,
7796
0
                        "field 'op' is required for BoolOp");
7797
0
        return NULL;
7798
0
    }
7799
1.59k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7800
1.59k
    if (!p)
7801
0
        return NULL;
7802
1.59k
    p->kind = BoolOp_kind;
7803
1.59k
    p->v.BoolOp.op = op;
7804
1.59k
    p->v.BoolOp.values = values;
7805
1.59k
    p->lineno = lineno;
7806
1.59k
    p->col_offset = col_offset;
7807
1.59k
    p->end_lineno = end_lineno;
7808
1.59k
    p->end_col_offset = end_col_offset;
7809
1.59k
    return p;
7810
1.59k
}
7811
7812
expr_ty
7813
_PyAST_NamedExpr(expr_ty target, expr_ty value, int lineno, int col_offset, int
7814
                 end_lineno, int end_col_offset, PyArena *arena)
7815
1.41k
{
7816
1.41k
    expr_ty p;
7817
1.41k
    if (!target) {
7818
0
        PyErr_SetString(PyExc_ValueError,
7819
0
                        "field 'target' is required for NamedExpr");
7820
0
        return NULL;
7821
0
    }
7822
1.41k
    if (!value) {
7823
0
        PyErr_SetString(PyExc_ValueError,
7824
0
                        "field 'value' is required for NamedExpr");
7825
0
        return NULL;
7826
0
    }
7827
1.41k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7828
1.41k
    if (!p)
7829
0
        return NULL;
7830
1.41k
    p->kind = NamedExpr_kind;
7831
1.41k
    p->v.NamedExpr.target = target;
7832
1.41k
    p->v.NamedExpr.value = value;
7833
1.41k
    p->lineno = lineno;
7834
1.41k
    p->col_offset = col_offset;
7835
1.41k
    p->end_lineno = end_lineno;
7836
1.41k
    p->end_col_offset = end_col_offset;
7837
1.41k
    return p;
7838
1.41k
}
7839
7840
expr_ty
7841
_PyAST_BinOp(expr_ty left, operator_ty op, expr_ty right, int lineno, int
7842
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7843
32.1k
{
7844
32.1k
    expr_ty p;
7845
32.1k
    if (!left) {
7846
0
        PyErr_SetString(PyExc_ValueError,
7847
0
                        "field 'left' is required for BinOp");
7848
0
        return NULL;
7849
0
    }
7850
32.1k
    if (!op) {
7851
0
        PyErr_SetString(PyExc_ValueError,
7852
0
                        "field 'op' is required for BinOp");
7853
0
        return NULL;
7854
0
    }
7855
32.1k
    if (!right) {
7856
0
        PyErr_SetString(PyExc_ValueError,
7857
0
                        "field 'right' is required for BinOp");
7858
0
        return NULL;
7859
0
    }
7860
32.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7861
32.1k
    if (!p)
7862
0
        return NULL;
7863
32.1k
    p->kind = BinOp_kind;
7864
32.1k
    p->v.BinOp.left = left;
7865
32.1k
    p->v.BinOp.op = op;
7866
32.1k
    p->v.BinOp.right = right;
7867
32.1k
    p->lineno = lineno;
7868
32.1k
    p->col_offset = col_offset;
7869
32.1k
    p->end_lineno = end_lineno;
7870
32.1k
    p->end_col_offset = end_col_offset;
7871
32.1k
    return p;
7872
32.1k
}
7873
7874
expr_ty
7875
_PyAST_UnaryOp(unaryop_ty op, expr_ty operand, int lineno, int col_offset, int
7876
               end_lineno, int end_col_offset, PyArena *arena)
7877
49.6k
{
7878
49.6k
    expr_ty p;
7879
49.6k
    if (!op) {
7880
0
        PyErr_SetString(PyExc_ValueError,
7881
0
                        "field 'op' is required for UnaryOp");
7882
0
        return NULL;
7883
0
    }
7884
49.6k
    if (!operand) {
7885
0
        PyErr_SetString(PyExc_ValueError,
7886
0
                        "field 'operand' is required for UnaryOp");
7887
0
        return NULL;
7888
0
    }
7889
49.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7890
49.6k
    if (!p)
7891
0
        return NULL;
7892
49.6k
    p->kind = UnaryOp_kind;
7893
49.6k
    p->v.UnaryOp.op = op;
7894
49.6k
    p->v.UnaryOp.operand = operand;
7895
49.6k
    p->lineno = lineno;
7896
49.6k
    p->col_offset = col_offset;
7897
49.6k
    p->end_lineno = end_lineno;
7898
49.6k
    p->end_col_offset = end_col_offset;
7899
49.6k
    return p;
7900
49.6k
}
7901
7902
expr_ty
7903
_PyAST_Lambda(arguments_ty args, expr_ty body, int lineno, int col_offset, int
7904
              end_lineno, int end_col_offset, PyArena *arena)
7905
2.40k
{
7906
2.40k
    expr_ty p;
7907
2.40k
    if (!args) {
7908
0
        PyErr_SetString(PyExc_ValueError,
7909
0
                        "field 'args' is required for Lambda");
7910
0
        return NULL;
7911
0
    }
7912
2.40k
    if (!body) {
7913
0
        PyErr_SetString(PyExc_ValueError,
7914
0
                        "field 'body' is required for Lambda");
7915
0
        return NULL;
7916
0
    }
7917
2.40k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7918
2.40k
    if (!p)
7919
0
        return NULL;
7920
2.40k
    p->kind = Lambda_kind;
7921
2.40k
    p->v.Lambda.args = args;
7922
2.40k
    p->v.Lambda.body = body;
7923
2.40k
    p->lineno = lineno;
7924
2.40k
    p->col_offset = col_offset;
7925
2.40k
    p->end_lineno = end_lineno;
7926
2.40k
    p->end_col_offset = end_col_offset;
7927
2.40k
    return p;
7928
2.40k
}
7929
7930
expr_ty
7931
_PyAST_IfExp(expr_ty test, expr_ty body, expr_ty orelse, int lineno, int
7932
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7933
997
{
7934
997
    expr_ty p;
7935
997
    if (!test) {
7936
0
        PyErr_SetString(PyExc_ValueError,
7937
0
                        "field 'test' is required for IfExp");
7938
0
        return NULL;
7939
0
    }
7940
997
    if (!body) {
7941
0
        PyErr_SetString(PyExc_ValueError,
7942
0
                        "field 'body' is required for IfExp");
7943
0
        return NULL;
7944
0
    }
7945
997
    if (!orelse) {
7946
0
        PyErr_SetString(PyExc_ValueError,
7947
0
                        "field 'orelse' is required for IfExp");
7948
0
        return NULL;
7949
0
    }
7950
997
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7951
997
    if (!p)
7952
0
        return NULL;
7953
997
    p->kind = IfExp_kind;
7954
997
    p->v.IfExp.test = test;
7955
997
    p->v.IfExp.body = body;
7956
997
    p->v.IfExp.orelse = orelse;
7957
997
    p->lineno = lineno;
7958
997
    p->col_offset = col_offset;
7959
997
    p->end_lineno = end_lineno;
7960
997
    p->end_col_offset = end_col_offset;
7961
997
    return p;
7962
997
}
7963
7964
expr_ty
7965
_PyAST_Dict(asdl_expr_seq * keys, asdl_expr_seq * values, int lineno, int
7966
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
7967
4.37k
{
7968
4.37k
    expr_ty p;
7969
4.37k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7970
4.37k
    if (!p)
7971
0
        return NULL;
7972
4.37k
    p->kind = Dict_kind;
7973
4.37k
    p->v.Dict.keys = keys;
7974
4.37k
    p->v.Dict.values = values;
7975
4.37k
    p->lineno = lineno;
7976
4.37k
    p->col_offset = col_offset;
7977
4.37k
    p->end_lineno = end_lineno;
7978
4.37k
    p->end_col_offset = end_col_offset;
7979
4.37k
    return p;
7980
4.37k
}
7981
7982
expr_ty
7983
_PyAST_Set(asdl_expr_seq * elts, int lineno, int col_offset, int end_lineno,
7984
           int end_col_offset, PyArena *arena)
7985
1.67k
{
7986
1.67k
    expr_ty p;
7987
1.67k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7988
1.67k
    if (!p)
7989
0
        return NULL;
7990
1.67k
    p->kind = Set_kind;
7991
1.67k
    p->v.Set.elts = elts;
7992
1.67k
    p->lineno = lineno;
7993
1.67k
    p->col_offset = col_offset;
7994
1.67k
    p->end_lineno = end_lineno;
7995
1.67k
    p->end_col_offset = end_col_offset;
7996
1.67k
    return p;
7997
1.67k
}
7998
7999
expr_ty
8000
_PyAST_ListComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
8001
                int col_offset, int end_lineno, int end_col_offset, PyArena
8002
                *arena)
8003
1.07k
{
8004
1.07k
    expr_ty p;
8005
1.07k
    if (!elt) {
8006
0
        PyErr_SetString(PyExc_ValueError,
8007
0
                        "field 'elt' is required for ListComp");
8008
0
        return NULL;
8009
0
    }
8010
1.07k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8011
1.07k
    if (!p)
8012
0
        return NULL;
8013
1.07k
    p->kind = ListComp_kind;
8014
1.07k
    p->v.ListComp.elt = elt;
8015
1.07k
    p->v.ListComp.generators = generators;
8016
1.07k
    p->lineno = lineno;
8017
1.07k
    p->col_offset = col_offset;
8018
1.07k
    p->end_lineno = end_lineno;
8019
1.07k
    p->end_col_offset = end_col_offset;
8020
1.07k
    return p;
8021
1.07k
}
8022
8023
expr_ty
8024
_PyAST_SetComp(expr_ty elt, asdl_comprehension_seq * generators, int lineno,
8025
               int col_offset, int end_lineno, int end_col_offset, PyArena
8026
               *arena)
8027
892
{
8028
892
    expr_ty p;
8029
892
    if (!elt) {
8030
0
        PyErr_SetString(PyExc_ValueError,
8031
0
                        "field 'elt' is required for SetComp");
8032
0
        return NULL;
8033
0
    }
8034
892
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8035
892
    if (!p)
8036
0
        return NULL;
8037
892
    p->kind = SetComp_kind;
8038
892
    p->v.SetComp.elt = elt;
8039
892
    p->v.SetComp.generators = generators;
8040
892
    p->lineno = lineno;
8041
892
    p->col_offset = col_offset;
8042
892
    p->end_lineno = end_lineno;
8043
892
    p->end_col_offset = end_col_offset;
8044
892
    return p;
8045
892
}
8046
8047
expr_ty
8048
_PyAST_DictComp(expr_ty key, expr_ty value, asdl_comprehension_seq *
8049
                generators, int lineno, int col_offset, int end_lineno, int
8050
                end_col_offset, PyArena *arena)
8051
626
{
8052
626
    expr_ty p;
8053
626
    if (!key) {
8054
0
        PyErr_SetString(PyExc_ValueError,
8055
0
                        "field 'key' is required for DictComp");
8056
0
        return NULL;
8057
0
    }
8058
626
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8059
626
    if (!p)
8060
0
        return NULL;
8061
626
    p->kind = DictComp_kind;
8062
626
    p->v.DictComp.key = key;
8063
626
    p->v.DictComp.value = value;
8064
626
    p->v.DictComp.generators = generators;
8065
626
    p->lineno = lineno;
8066
626
    p->col_offset = col_offset;
8067
626
    p->end_lineno = end_lineno;
8068
626
    p->end_col_offset = end_col_offset;
8069
626
    return p;
8070
626
}
8071
8072
expr_ty
8073
_PyAST_GeneratorExp(expr_ty elt, asdl_comprehension_seq * generators, int
8074
                    lineno, int col_offset, int end_lineno, int end_col_offset,
8075
                    PyArena *arena)
8076
3.38k
{
8077
3.38k
    expr_ty p;
8078
3.38k
    if (!elt) {
8079
0
        PyErr_SetString(PyExc_ValueError,
8080
0
                        "field 'elt' is required for GeneratorExp");
8081
0
        return NULL;
8082
0
    }
8083
3.38k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8084
3.38k
    if (!p)
8085
0
        return NULL;
8086
3.38k
    p->kind = GeneratorExp_kind;
8087
3.38k
    p->v.GeneratorExp.elt = elt;
8088
3.38k
    p->v.GeneratorExp.generators = generators;
8089
3.38k
    p->lineno = lineno;
8090
3.38k
    p->col_offset = col_offset;
8091
3.38k
    p->end_lineno = end_lineno;
8092
3.38k
    p->end_col_offset = end_col_offset;
8093
3.38k
    return p;
8094
3.38k
}
8095
8096
expr_ty
8097
_PyAST_Await(expr_ty value, int lineno, int col_offset, int end_lineno, int
8098
             end_col_offset, PyArena *arena)
8099
481
{
8100
481
    expr_ty p;
8101
481
    if (!value) {
8102
0
        PyErr_SetString(PyExc_ValueError,
8103
0
                        "field 'value' is required for Await");
8104
0
        return NULL;
8105
0
    }
8106
481
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8107
481
    if (!p)
8108
0
        return NULL;
8109
481
    p->kind = Await_kind;
8110
481
    p->v.Await.value = value;
8111
481
    p->lineno = lineno;
8112
481
    p->col_offset = col_offset;
8113
481
    p->end_lineno = end_lineno;
8114
481
    p->end_col_offset = end_col_offset;
8115
481
    return p;
8116
481
}
8117
8118
expr_ty
8119
_PyAST_Yield(expr_ty value, int lineno, int col_offset, int end_lineno, int
8120
             end_col_offset, PyArena *arena)
8121
2.40k
{
8122
2.40k
    expr_ty p;
8123
2.40k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8124
2.40k
    if (!p)
8125
0
        return NULL;
8126
2.40k
    p->kind = Yield_kind;
8127
2.40k
    p->v.Yield.value = value;
8128
2.40k
    p->lineno = lineno;
8129
2.40k
    p->col_offset = col_offset;
8130
2.40k
    p->end_lineno = end_lineno;
8131
2.40k
    p->end_col_offset = end_col_offset;
8132
2.40k
    return p;
8133
2.40k
}
8134
8135
expr_ty
8136
_PyAST_YieldFrom(expr_ty value, int lineno, int col_offset, int end_lineno, int
8137
                 end_col_offset, PyArena *arena)
8138
249
{
8139
249
    expr_ty p;
8140
249
    if (!value) {
8141
0
        PyErr_SetString(PyExc_ValueError,
8142
0
                        "field 'value' is required for YieldFrom");
8143
0
        return NULL;
8144
0
    }
8145
249
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8146
249
    if (!p)
8147
0
        return NULL;
8148
249
    p->kind = YieldFrom_kind;
8149
249
    p->v.YieldFrom.value = value;
8150
249
    p->lineno = lineno;
8151
249
    p->col_offset = col_offset;
8152
249
    p->end_lineno = end_lineno;
8153
249
    p->end_col_offset = end_col_offset;
8154
249
    return p;
8155
249
}
8156
8157
expr_ty
8158
_PyAST_Compare(expr_ty left, asdl_int_seq * ops, asdl_expr_seq * comparators,
8159
               int lineno, int col_offset, int end_lineno, int end_col_offset,
8160
               PyArena *arena)
8161
4.87k
{
8162
4.87k
    expr_ty p;
8163
4.87k
    if (!left) {
8164
0
        PyErr_SetString(PyExc_ValueError,
8165
0
                        "field 'left' is required for Compare");
8166
0
        return NULL;
8167
0
    }
8168
4.87k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8169
4.87k
    if (!p)
8170
0
        return NULL;
8171
4.87k
    p->kind = Compare_kind;
8172
4.87k
    p->v.Compare.left = left;
8173
4.87k
    p->v.Compare.ops = ops;
8174
4.87k
    p->v.Compare.comparators = comparators;
8175
4.87k
    p->lineno = lineno;
8176
4.87k
    p->col_offset = col_offset;
8177
4.87k
    p->end_lineno = end_lineno;
8178
4.87k
    p->end_col_offset = end_col_offset;
8179
4.87k
    return p;
8180
4.87k
}
8181
8182
expr_ty
8183
_PyAST_Call(expr_ty func, asdl_expr_seq * args, asdl_keyword_seq * keywords,
8184
            int lineno, int col_offset, int end_lineno, int end_col_offset,
8185
            PyArena *arena)
8186
46.8k
{
8187
46.8k
    expr_ty p;
8188
46.8k
    if (!func) {
8189
0
        PyErr_SetString(PyExc_ValueError,
8190
0
                        "field 'func' is required for Call");
8191
0
        return NULL;
8192
0
    }
8193
46.8k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8194
46.8k
    if (!p)
8195
0
        return NULL;
8196
46.8k
    p->kind = Call_kind;
8197
46.8k
    p->v.Call.func = func;
8198
46.8k
    p->v.Call.args = args;
8199
46.8k
    p->v.Call.keywords = keywords;
8200
46.8k
    p->lineno = lineno;
8201
46.8k
    p->col_offset = col_offset;
8202
46.8k
    p->end_lineno = end_lineno;
8203
46.8k
    p->end_col_offset = end_col_offset;
8204
46.8k
    return p;
8205
46.8k
}
8206
8207
expr_ty
8208
_PyAST_FormattedValue(expr_ty value, int conversion, expr_ty format_spec, int
8209
                      lineno, int col_offset, int end_lineno, int
8210
                      end_col_offset, PyArena *arena)
8211
23.0k
{
8212
23.0k
    expr_ty p;
8213
23.0k
    if (!value) {
8214
0
        PyErr_SetString(PyExc_ValueError,
8215
0
                        "field 'value' is required for FormattedValue");
8216
0
        return NULL;
8217
0
    }
8218
23.0k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8219
23.0k
    if (!p)
8220
0
        return NULL;
8221
23.0k
    p->kind = FormattedValue_kind;
8222
23.0k
    p->v.FormattedValue.value = value;
8223
23.0k
    p->v.FormattedValue.conversion = conversion;
8224
23.0k
    p->v.FormattedValue.format_spec = format_spec;
8225
23.0k
    p->lineno = lineno;
8226
23.0k
    p->col_offset = col_offset;
8227
23.0k
    p->end_lineno = end_lineno;
8228
23.0k
    p->end_col_offset = end_col_offset;
8229
23.0k
    return p;
8230
23.0k
}
8231
8232
expr_ty
8233
_PyAST_Interpolation(expr_ty value, constant str, int conversion, expr_ty
8234
                     format_spec, int lineno, int col_offset, int end_lineno,
8235
                     int end_col_offset, PyArena *arena)
8236
4.20k
{
8237
4.20k
    expr_ty p;
8238
4.20k
    if (!value) {
8239
0
        PyErr_SetString(PyExc_ValueError,
8240
0
                        "field 'value' is required for Interpolation");
8241
0
        return NULL;
8242
0
    }
8243
4.20k
    if (!str) {
8244
0
        PyErr_SetString(PyExc_ValueError,
8245
0
                        "field 'str' is required for Interpolation");
8246
0
        return NULL;
8247
0
    }
8248
4.20k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8249
4.20k
    if (!p)
8250
0
        return NULL;
8251
4.20k
    p->kind = Interpolation_kind;
8252
4.20k
    p->v.Interpolation.value = value;
8253
4.20k
    p->v.Interpolation.str = str;
8254
4.20k
    p->v.Interpolation.conversion = conversion;
8255
4.20k
    p->v.Interpolation.format_spec = format_spec;
8256
4.20k
    p->lineno = lineno;
8257
4.20k
    p->col_offset = col_offset;
8258
4.20k
    p->end_lineno = end_lineno;
8259
4.20k
    p->end_col_offset = end_col_offset;
8260
4.20k
    return p;
8261
4.20k
}
8262
8263
expr_ty
8264
_PyAST_JoinedStr(asdl_expr_seq * values, int lineno, int col_offset, int
8265
                 end_lineno, int end_col_offset, PyArena *arena)
8266
32.2k
{
8267
32.2k
    expr_ty p;
8268
32.2k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8269
32.2k
    if (!p)
8270
0
        return NULL;
8271
32.2k
    p->kind = JoinedStr_kind;
8272
32.2k
    p->v.JoinedStr.values = values;
8273
32.2k
    p->lineno = lineno;
8274
32.2k
    p->col_offset = col_offset;
8275
32.2k
    p->end_lineno = end_lineno;
8276
32.2k
    p->end_col_offset = end_col_offset;
8277
32.2k
    return p;
8278
32.2k
}
8279
8280
expr_ty
8281
_PyAST_TemplateStr(asdl_expr_seq * values, int lineno, int col_offset, int
8282
                   end_lineno, int end_col_offset, PyArena *arena)
8283
6.68k
{
8284
6.68k
    expr_ty p;
8285
6.68k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8286
6.68k
    if (!p)
8287
0
        return NULL;
8288
6.68k
    p->kind = TemplateStr_kind;
8289
6.68k
    p->v.TemplateStr.values = values;
8290
6.68k
    p->lineno = lineno;
8291
6.68k
    p->col_offset = col_offset;
8292
6.68k
    p->end_lineno = end_lineno;
8293
6.68k
    p->end_col_offset = end_col_offset;
8294
6.68k
    return p;
8295
6.68k
}
8296
8297
expr_ty
8298
_PyAST_Constant(constant value, string kind, int lineno, int col_offset, int
8299
                end_lineno, int end_col_offset, PyArena *arena)
8300
313k
{
8301
313k
    expr_ty p;
8302
313k
    if (!value) {
8303
2
        PyErr_SetString(PyExc_ValueError,
8304
2
                        "field 'value' is required for Constant");
8305
2
        return NULL;
8306
2
    }
8307
313k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8308
313k
    if (!p)
8309
0
        return NULL;
8310
313k
    p->kind = Constant_kind;
8311
313k
    p->v.Constant.value = value;
8312
313k
    p->v.Constant.kind = kind;
8313
313k
    p->lineno = lineno;
8314
313k
    p->col_offset = col_offset;
8315
313k
    p->end_lineno = end_lineno;
8316
313k
    p->end_col_offset = end_col_offset;
8317
313k
    return p;
8318
313k
}
8319
8320
expr_ty
8321
_PyAST_Attribute(expr_ty value, identifier attr, expr_context_ty ctx, int
8322
                 lineno, int col_offset, int end_lineno, int end_col_offset,
8323
                 PyArena *arena)
8324
32.1k
{
8325
32.1k
    expr_ty p;
8326
32.1k
    if (!value) {
8327
0
        PyErr_SetString(PyExc_ValueError,
8328
0
                        "field 'value' is required for Attribute");
8329
0
        return NULL;
8330
0
    }
8331
32.1k
    if (!attr) {
8332
0
        PyErr_SetString(PyExc_ValueError,
8333
0
                        "field 'attr' is required for Attribute");
8334
0
        return NULL;
8335
0
    }
8336
32.1k
    if (!ctx) {
8337
0
        PyErr_SetString(PyExc_ValueError,
8338
0
                        "field 'ctx' is required for Attribute");
8339
0
        return NULL;
8340
0
    }
8341
32.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8342
32.1k
    if (!p)
8343
0
        return NULL;
8344
32.1k
    p->kind = Attribute_kind;
8345
32.1k
    p->v.Attribute.value = value;
8346
32.1k
    p->v.Attribute.attr = attr;
8347
32.1k
    p->v.Attribute.ctx = ctx;
8348
32.1k
    p->lineno = lineno;
8349
32.1k
    p->col_offset = col_offset;
8350
32.1k
    p->end_lineno = end_lineno;
8351
32.1k
    p->end_col_offset = end_col_offset;
8352
32.1k
    return p;
8353
32.1k
}
8354
8355
expr_ty
8356
_PyAST_Subscript(expr_ty value, expr_ty slice, expr_context_ty ctx, int lineno,
8357
                 int col_offset, int end_lineno, int end_col_offset, PyArena
8358
                 *arena)
8359
4.07k
{
8360
4.07k
    expr_ty p;
8361
4.07k
    if (!value) {
8362
0
        PyErr_SetString(PyExc_ValueError,
8363
0
                        "field 'value' is required for Subscript");
8364
0
        return NULL;
8365
0
    }
8366
4.07k
    if (!slice) {
8367
0
        PyErr_SetString(PyExc_ValueError,
8368
0
                        "field 'slice' is required for Subscript");
8369
0
        return NULL;
8370
0
    }
8371
4.07k
    if (!ctx) {
8372
0
        PyErr_SetString(PyExc_ValueError,
8373
0
                        "field 'ctx' is required for Subscript");
8374
0
        return NULL;
8375
0
    }
8376
4.07k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8377
4.07k
    if (!p)
8378
0
        return NULL;
8379
4.07k
    p->kind = Subscript_kind;
8380
4.07k
    p->v.Subscript.value = value;
8381
4.07k
    p->v.Subscript.slice = slice;
8382
4.07k
    p->v.Subscript.ctx = ctx;
8383
4.07k
    p->lineno = lineno;
8384
4.07k
    p->col_offset = col_offset;
8385
4.07k
    p->end_lineno = end_lineno;
8386
4.07k
    p->end_col_offset = end_col_offset;
8387
4.07k
    return p;
8388
4.07k
}
8389
8390
expr_ty
8391
_PyAST_Starred(expr_ty value, expr_context_ty ctx, int lineno, int col_offset,
8392
               int end_lineno, int end_col_offset, PyArena *arena)
8393
16.7k
{
8394
16.7k
    expr_ty p;
8395
16.7k
    if (!value) {
8396
0
        PyErr_SetString(PyExc_ValueError,
8397
0
                        "field 'value' is required for Starred");
8398
0
        return NULL;
8399
0
    }
8400
16.7k
    if (!ctx) {
8401
0
        PyErr_SetString(PyExc_ValueError,
8402
0
                        "field 'ctx' is required for Starred");
8403
0
        return NULL;
8404
0
    }
8405
16.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8406
16.7k
    if (!p)
8407
0
        return NULL;
8408
16.7k
    p->kind = Starred_kind;
8409
16.7k
    p->v.Starred.value = value;
8410
16.7k
    p->v.Starred.ctx = ctx;
8411
16.7k
    p->lineno = lineno;
8412
16.7k
    p->col_offset = col_offset;
8413
16.7k
    p->end_lineno = end_lineno;
8414
16.7k
    p->end_col_offset = end_col_offset;
8415
16.7k
    return p;
8416
16.7k
}
8417
8418
expr_ty
8419
_PyAST_Name(identifier id, expr_context_ty ctx, int lineno, int col_offset, int
8420
            end_lineno, int end_col_offset, PyArena *arena)
8421
1.84M
{
8422
1.84M
    expr_ty p;
8423
1.84M
    if (!id) {
8424
0
        PyErr_SetString(PyExc_ValueError,
8425
0
                        "field 'id' is required for Name");
8426
0
        return NULL;
8427
0
    }
8428
1.84M
    if (!ctx) {
8429
0
        PyErr_SetString(PyExc_ValueError,
8430
0
                        "field 'ctx' is required for Name");
8431
0
        return NULL;
8432
0
    }
8433
1.84M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8434
1.84M
    if (!p)
8435
0
        return NULL;
8436
1.84M
    p->kind = Name_kind;
8437
1.84M
    p->v.Name.id = id;
8438
1.84M
    p->v.Name.ctx = ctx;
8439
1.84M
    p->lineno = lineno;
8440
1.84M
    p->col_offset = col_offset;
8441
1.84M
    p->end_lineno = end_lineno;
8442
1.84M
    p->end_col_offset = end_col_offset;
8443
1.84M
    return p;
8444
1.84M
}
8445
8446
expr_ty
8447
_PyAST_List(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8448
            col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8449
13.6k
{
8450
13.6k
    expr_ty p;
8451
13.6k
    if (!ctx) {
8452
0
        PyErr_SetString(PyExc_ValueError,
8453
0
                        "field 'ctx' is required for List");
8454
0
        return NULL;
8455
0
    }
8456
13.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8457
13.6k
    if (!p)
8458
0
        return NULL;
8459
13.6k
    p->kind = List_kind;
8460
13.6k
    p->v.List.elts = elts;
8461
13.6k
    p->v.List.ctx = ctx;
8462
13.6k
    p->lineno = lineno;
8463
13.6k
    p->col_offset = col_offset;
8464
13.6k
    p->end_lineno = end_lineno;
8465
13.6k
    p->end_col_offset = end_col_offset;
8466
13.6k
    return p;
8467
13.6k
}
8468
8469
expr_ty
8470
_PyAST_Tuple(asdl_expr_seq * elts, expr_context_ty ctx, int lineno, int
8471
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8472
60.3k
{
8473
60.3k
    expr_ty p;
8474
60.3k
    if (!ctx) {
8475
0
        PyErr_SetString(PyExc_ValueError,
8476
0
                        "field 'ctx' is required for Tuple");
8477
0
        return NULL;
8478
0
    }
8479
60.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8480
60.3k
    if (!p)
8481
0
        return NULL;
8482
60.3k
    p->kind = Tuple_kind;
8483
60.3k
    p->v.Tuple.elts = elts;
8484
60.3k
    p->v.Tuple.ctx = ctx;
8485
60.3k
    p->lineno = lineno;
8486
60.3k
    p->col_offset = col_offset;
8487
60.3k
    p->end_lineno = end_lineno;
8488
60.3k
    p->end_col_offset = end_col_offset;
8489
60.3k
    return p;
8490
60.3k
}
8491
8492
expr_ty
8493
_PyAST_Slice(expr_ty lower, expr_ty upper, expr_ty step, int lineno, int
8494
             col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8495
9.96k
{
8496
9.96k
    expr_ty p;
8497
9.96k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8498
9.96k
    if (!p)
8499
0
        return NULL;
8500
9.96k
    p->kind = Slice_kind;
8501
9.96k
    p->v.Slice.lower = lower;
8502
9.96k
    p->v.Slice.upper = upper;
8503
9.96k
    p->v.Slice.step = step;
8504
9.96k
    p->lineno = lineno;
8505
9.96k
    p->col_offset = col_offset;
8506
9.96k
    p->end_lineno = end_lineno;
8507
9.96k
    p->end_col_offset = end_col_offset;
8508
9.96k
    return p;
8509
9.96k
}
8510
8511
comprehension_ty
8512
_PyAST_comprehension(expr_ty target, expr_ty iter, asdl_expr_seq * ifs, int
8513
                     is_async, PyArena *arena)
8514
8.28k
{
8515
8.28k
    comprehension_ty p;
8516
8.28k
    if (!target) {
8517
0
        PyErr_SetString(PyExc_ValueError,
8518
0
                        "field 'target' is required for comprehension");
8519
0
        return NULL;
8520
0
    }
8521
8.28k
    if (!iter) {
8522
0
        PyErr_SetString(PyExc_ValueError,
8523
0
                        "field 'iter' is required for comprehension");
8524
0
        return NULL;
8525
0
    }
8526
8.28k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8527
8.28k
    if (!p)
8528
0
        return NULL;
8529
8.28k
    p->target = target;
8530
8.28k
    p->iter = iter;
8531
8.28k
    p->ifs = ifs;
8532
8.28k
    p->is_async = is_async;
8533
8.28k
    return p;
8534
8.28k
}
8535
8536
excepthandler_ty
8537
_PyAST_ExceptHandler(expr_ty type, identifier name, asdl_stmt_seq * body, int
8538
                     lineno, int col_offset, int end_lineno, int
8539
                     end_col_offset, PyArena *arena)
8540
7.80k
{
8541
7.80k
    excepthandler_ty p;
8542
7.80k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8543
7.80k
    if (!p)
8544
0
        return NULL;
8545
7.80k
    p->kind = ExceptHandler_kind;
8546
7.80k
    p->v.ExceptHandler.type = type;
8547
7.80k
    p->v.ExceptHandler.name = name;
8548
7.80k
    p->v.ExceptHandler.body = body;
8549
7.80k
    p->lineno = lineno;
8550
7.80k
    p->col_offset = col_offset;
8551
7.80k
    p->end_lineno = end_lineno;
8552
7.80k
    p->end_col_offset = end_col_offset;
8553
7.80k
    return p;
8554
7.80k
}
8555
8556
arguments_ty
8557
_PyAST_arguments(asdl_arg_seq * posonlyargs, asdl_arg_seq * args, arg_ty
8558
                 vararg, asdl_arg_seq * kwonlyargs, asdl_expr_seq *
8559
                 kw_defaults, arg_ty kwarg, asdl_expr_seq * defaults, PyArena
8560
                 *arena)
8561
15.4k
{
8562
15.4k
    arguments_ty p;
8563
15.4k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8564
15.4k
    if (!p)
8565
0
        return NULL;
8566
15.4k
    p->posonlyargs = posonlyargs;
8567
15.4k
    p->args = args;
8568
15.4k
    p->vararg = vararg;
8569
15.4k
    p->kwonlyargs = kwonlyargs;
8570
15.4k
    p->kw_defaults = kw_defaults;
8571
15.4k
    p->kwarg = kwarg;
8572
15.4k
    p->defaults = defaults;
8573
15.4k
    return p;
8574
15.4k
}
8575
8576
arg_ty
8577
_PyAST_arg(identifier arg, expr_ty annotation, string type_comment, int lineno,
8578
           int col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8579
403k
{
8580
403k
    arg_ty p;
8581
403k
    if (!arg) {
8582
0
        PyErr_SetString(PyExc_ValueError,
8583
0
                        "field 'arg' is required for arg");
8584
0
        return NULL;
8585
0
    }
8586
403k
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8587
403k
    if (!p)
8588
0
        return NULL;
8589
403k
    p->arg = arg;
8590
403k
    p->annotation = annotation;
8591
403k
    p->type_comment = type_comment;
8592
403k
    p->lineno = lineno;
8593
403k
    p->col_offset = col_offset;
8594
403k
    p->end_lineno = end_lineno;
8595
403k
    p->end_col_offset = end_col_offset;
8596
403k
    return p;
8597
403k
}
8598
8599
keyword_ty
8600
_PyAST_keyword(identifier arg, expr_ty value, int lineno, int col_offset, int
8601
               end_lineno, int end_col_offset, PyArena *arena)
8602
29.3k
{
8603
29.3k
    keyword_ty p;
8604
29.3k
    if (!value) {
8605
0
        PyErr_SetString(PyExc_ValueError,
8606
0
                        "field 'value' is required for keyword");
8607
0
        return NULL;
8608
0
    }
8609
29.3k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8610
29.3k
    if (!p)
8611
0
        return NULL;
8612
29.3k
    p->arg = arg;
8613
29.3k
    p->value = value;
8614
29.3k
    p->lineno = lineno;
8615
29.3k
    p->col_offset = col_offset;
8616
29.3k
    p->end_lineno = end_lineno;
8617
29.3k
    p->end_col_offset = end_col_offset;
8618
29.3k
    return p;
8619
29.3k
}
8620
8621
alias_ty
8622
_PyAST_alias(identifier name, identifier asname, int lineno, int col_offset,
8623
             int end_lineno, int end_col_offset, PyArena *arena)
8624
12.0k
{
8625
12.0k
    alias_ty p;
8626
12.0k
    if (!name) {
8627
0
        PyErr_SetString(PyExc_ValueError,
8628
0
                        "field 'name' is required for alias");
8629
0
        return NULL;
8630
0
    }
8631
12.0k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8632
12.0k
    if (!p)
8633
0
        return NULL;
8634
12.0k
    p->name = name;
8635
12.0k
    p->asname = asname;
8636
12.0k
    p->lineno = lineno;
8637
12.0k
    p->col_offset = col_offset;
8638
12.0k
    p->end_lineno = end_lineno;
8639
12.0k
    p->end_col_offset = end_col_offset;
8640
12.0k
    return p;
8641
12.0k
}
8642
8643
withitem_ty
8644
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8645
5.64k
{
8646
5.64k
    withitem_ty p;
8647
5.64k
    if (!context_expr) {
8648
0
        PyErr_SetString(PyExc_ValueError,
8649
0
                        "field 'context_expr' is required for withitem");
8650
0
        return NULL;
8651
0
    }
8652
5.64k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8653
5.64k
    if (!p)
8654
0
        return NULL;
8655
5.64k
    p->context_expr = context_expr;
8656
5.64k
    p->optional_vars = optional_vars;
8657
5.64k
    return p;
8658
5.64k
}
8659
8660
match_case_ty
8661
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8662
                  PyArena *arena)
8663
2.02k
{
8664
2.02k
    match_case_ty p;
8665
2.02k
    if (!pattern) {
8666
0
        PyErr_SetString(PyExc_ValueError,
8667
0
                        "field 'pattern' is required for match_case");
8668
0
        return NULL;
8669
0
    }
8670
2.02k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8671
2.02k
    if (!p)
8672
0
        return NULL;
8673
2.02k
    p->pattern = pattern;
8674
2.02k
    p->guard = guard;
8675
2.02k
    p->body = body;
8676
2.02k
    return p;
8677
2.02k
}
8678
8679
pattern_ty
8680
_PyAST_MatchValue(expr_ty value, int lineno, int col_offset, int end_lineno,
8681
                  int end_col_offset, PyArena *arena)
8682
2.49k
{
8683
2.49k
    pattern_ty p;
8684
2.49k
    if (!value) {
8685
0
        PyErr_SetString(PyExc_ValueError,
8686
0
                        "field 'value' is required for MatchValue");
8687
0
        return NULL;
8688
0
    }
8689
2.49k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8690
2.49k
    if (!p)
8691
0
        return NULL;
8692
2.49k
    p->kind = MatchValue_kind;
8693
2.49k
    p->v.MatchValue.value = value;
8694
2.49k
    p->lineno = lineno;
8695
2.49k
    p->col_offset = col_offset;
8696
2.49k
    p->end_lineno = end_lineno;
8697
2.49k
    p->end_col_offset = end_col_offset;
8698
2.49k
    return p;
8699
2.49k
}
8700
8701
pattern_ty
8702
_PyAST_MatchSingleton(constant value, int lineno, int col_offset, int
8703
                      end_lineno, int end_col_offset, PyArena *arena)
8704
596
{
8705
596
    pattern_ty p;
8706
596
    if (!value) {
8707
0
        PyErr_SetString(PyExc_ValueError,
8708
0
                        "field 'value' is required for MatchSingleton");
8709
0
        return NULL;
8710
0
    }
8711
596
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8712
596
    if (!p)
8713
0
        return NULL;
8714
596
    p->kind = MatchSingleton_kind;
8715
596
    p->v.MatchSingleton.value = value;
8716
596
    p->lineno = lineno;
8717
596
    p->col_offset = col_offset;
8718
596
    p->end_lineno = end_lineno;
8719
596
    p->end_col_offset = end_col_offset;
8720
596
    return p;
8721
596
}
8722
8723
pattern_ty
8724
_PyAST_MatchSequence(asdl_pattern_seq * patterns, int lineno, int col_offset,
8725
                     int end_lineno, int end_col_offset, PyArena *arena)
8726
2.36k
{
8727
2.36k
    pattern_ty p;
8728
2.36k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8729
2.36k
    if (!p)
8730
0
        return NULL;
8731
2.36k
    p->kind = MatchSequence_kind;
8732
2.36k
    p->v.MatchSequence.patterns = patterns;
8733
2.36k
    p->lineno = lineno;
8734
2.36k
    p->col_offset = col_offset;
8735
2.36k
    p->end_lineno = end_lineno;
8736
2.36k
    p->end_col_offset = end_col_offset;
8737
2.36k
    return p;
8738
2.36k
}
8739
8740
pattern_ty
8741
_PyAST_MatchMapping(asdl_expr_seq * keys, asdl_pattern_seq * patterns,
8742
                    identifier rest, int lineno, int col_offset, int
8743
                    end_lineno, int end_col_offset, PyArena *arena)
8744
732
{
8745
732
    pattern_ty p;
8746
732
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8747
732
    if (!p)
8748
0
        return NULL;
8749
732
    p->kind = MatchMapping_kind;
8750
732
    p->v.MatchMapping.keys = keys;
8751
732
    p->v.MatchMapping.patterns = patterns;
8752
732
    p->v.MatchMapping.rest = rest;
8753
732
    p->lineno = lineno;
8754
732
    p->col_offset = col_offset;
8755
732
    p->end_lineno = end_lineno;
8756
732
    p->end_col_offset = end_col_offset;
8757
732
    return p;
8758
732
}
8759
8760
pattern_ty
8761
_PyAST_MatchClass(expr_ty cls, asdl_pattern_seq * patterns, asdl_identifier_seq
8762
                  * kwd_attrs, asdl_pattern_seq * kwd_patterns, int lineno, int
8763
                  col_offset, int end_lineno, int end_col_offset, PyArena
8764
                  *arena)
8765
2.01k
{
8766
2.01k
    pattern_ty p;
8767
2.01k
    if (!cls) {
8768
0
        PyErr_SetString(PyExc_ValueError,
8769
0
                        "field 'cls' is required for MatchClass");
8770
0
        return NULL;
8771
0
    }
8772
2.01k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8773
2.01k
    if (!p)
8774
0
        return NULL;
8775
2.01k
    p->kind = MatchClass_kind;
8776
2.01k
    p->v.MatchClass.cls = cls;
8777
2.01k
    p->v.MatchClass.patterns = patterns;
8778
2.01k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8779
2.01k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8780
2.01k
    p->lineno = lineno;
8781
2.01k
    p->col_offset = col_offset;
8782
2.01k
    p->end_lineno = end_lineno;
8783
2.01k
    p->end_col_offset = end_col_offset;
8784
2.01k
    return p;
8785
2.01k
}
8786
8787
pattern_ty
8788
_PyAST_MatchStar(identifier name, int lineno, int col_offset, int end_lineno,
8789
                 int end_col_offset, PyArena *arena)
8790
1.28k
{
8791
1.28k
    pattern_ty p;
8792
1.28k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8793
1.28k
    if (!p)
8794
0
        return NULL;
8795
1.28k
    p->kind = MatchStar_kind;
8796
1.28k
    p->v.MatchStar.name = name;
8797
1.28k
    p->lineno = lineno;
8798
1.28k
    p->col_offset = col_offset;
8799
1.28k
    p->end_lineno = end_lineno;
8800
1.28k
    p->end_col_offset = end_col_offset;
8801
1.28k
    return p;
8802
1.28k
}
8803
8804
pattern_ty
8805
_PyAST_MatchAs(pattern_ty pattern, identifier name, int lineno, int col_offset,
8806
               int end_lineno, int end_col_offset, PyArena *arena)
8807
18.6k
{
8808
18.6k
    pattern_ty p;
8809
18.6k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8810
18.6k
    if (!p)
8811
0
        return NULL;
8812
18.6k
    p->kind = MatchAs_kind;
8813
18.6k
    p->v.MatchAs.pattern = pattern;
8814
18.6k
    p->v.MatchAs.name = name;
8815
18.6k
    p->lineno = lineno;
8816
18.6k
    p->col_offset = col_offset;
8817
18.6k
    p->end_lineno = end_lineno;
8818
18.6k
    p->end_col_offset = end_col_offset;
8819
18.6k
    return p;
8820
18.6k
}
8821
8822
pattern_ty
8823
_PyAST_MatchOr(asdl_pattern_seq * patterns, int lineno, int col_offset, int
8824
               end_lineno, int end_col_offset, PyArena *arena)
8825
5.24k
{
8826
5.24k
    pattern_ty p;
8827
5.24k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8828
5.24k
    if (!p)
8829
0
        return NULL;
8830
5.24k
    p->kind = MatchOr_kind;
8831
5.24k
    p->v.MatchOr.patterns = patterns;
8832
5.24k
    p->lineno = lineno;
8833
5.24k
    p->col_offset = col_offset;
8834
5.24k
    p->end_lineno = end_lineno;
8835
5.24k
    p->end_col_offset = end_col_offset;
8836
5.24k
    return p;
8837
5.24k
}
8838
8839
type_ignore_ty
8840
_PyAST_TypeIgnore(int lineno, string tag, PyArena *arena)
8841
0
{
8842
0
    type_ignore_ty p;
8843
0
    if (!tag) {
8844
0
        PyErr_SetString(PyExc_ValueError,
8845
0
                        "field 'tag' is required for TypeIgnore");
8846
0
        return NULL;
8847
0
    }
8848
0
    p = (type_ignore_ty)_PyArena_Malloc(arena, sizeof(*p));
8849
0
    if (!p)
8850
0
        return NULL;
8851
0
    p->kind = TypeIgnore_kind;
8852
0
    p->v.TypeIgnore.lineno = lineno;
8853
0
    p->v.TypeIgnore.tag = tag;
8854
0
    return p;
8855
0
}
8856
8857
type_param_ty
8858
_PyAST_TypeVar(identifier name, expr_ty bound, expr_ty default_value, int
8859
               lineno, int col_offset, int end_lineno, int end_col_offset,
8860
               PyArena *arena)
8861
5.59k
{
8862
5.59k
    type_param_ty p;
8863
5.59k
    if (!name) {
8864
0
        PyErr_SetString(PyExc_ValueError,
8865
0
                        "field 'name' is required for TypeVar");
8866
0
        return NULL;
8867
0
    }
8868
5.59k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8869
5.59k
    if (!p)
8870
0
        return NULL;
8871
5.59k
    p->kind = TypeVar_kind;
8872
5.59k
    p->v.TypeVar.name = name;
8873
5.59k
    p->v.TypeVar.bound = bound;
8874
5.59k
    p->v.TypeVar.default_value = default_value;
8875
5.59k
    p->lineno = lineno;
8876
5.59k
    p->col_offset = col_offset;
8877
5.59k
    p->end_lineno = end_lineno;
8878
5.59k
    p->end_col_offset = end_col_offset;
8879
5.59k
    return p;
8880
5.59k
}
8881
8882
type_param_ty
8883
_PyAST_ParamSpec(identifier name, expr_ty default_value, int lineno, int
8884
                 col_offset, int end_lineno, int end_col_offset, PyArena *arena)
8885
953
{
8886
953
    type_param_ty p;
8887
953
    if (!name) {
8888
0
        PyErr_SetString(PyExc_ValueError,
8889
0
                        "field 'name' is required for ParamSpec");
8890
0
        return NULL;
8891
0
    }
8892
953
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8893
953
    if (!p)
8894
0
        return NULL;
8895
953
    p->kind = ParamSpec_kind;
8896
953
    p->v.ParamSpec.name = name;
8897
953
    p->v.ParamSpec.default_value = default_value;
8898
953
    p->lineno = lineno;
8899
953
    p->col_offset = col_offset;
8900
953
    p->end_lineno = end_lineno;
8901
953
    p->end_col_offset = end_col_offset;
8902
953
    return p;
8903
953
}
8904
8905
type_param_ty
8906
_PyAST_TypeVarTuple(identifier name, expr_ty default_value, int lineno, int
8907
                    col_offset, int end_lineno, int end_col_offset, PyArena
8908
                    *arena)
8909
1.72k
{
8910
1.72k
    type_param_ty p;
8911
1.72k
    if (!name) {
8912
0
        PyErr_SetString(PyExc_ValueError,
8913
0
                        "field 'name' is required for TypeVarTuple");
8914
0
        return NULL;
8915
0
    }
8916
1.72k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8917
1.72k
    if (!p)
8918
0
        return NULL;
8919
1.72k
    p->kind = TypeVarTuple_kind;
8920
1.72k
    p->v.TypeVarTuple.name = name;
8921
1.72k
    p->v.TypeVarTuple.default_value = default_value;
8922
1.72k
    p->lineno = lineno;
8923
1.72k
    p->col_offset = col_offset;
8924
1.72k
    p->end_lineno = end_lineno;
8925
1.72k
    p->end_col_offset = end_col_offset;
8926
1.72k
    return p;
8927
1.72k
}
8928
8929
8930
PyObject*
8931
ast2obj_mod(struct ast_state *state, void* _o)
8932
4.99k
{
8933
4.99k
    mod_ty o = (mod_ty)_o;
8934
4.99k
    PyObject *result = NULL, *value = NULL;
8935
4.99k
    PyTypeObject *tp;
8936
4.99k
    if (!o) {
8937
0
        Py_RETURN_NONE;
8938
0
    }
8939
4.99k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8940
0
        return NULL;
8941
0
    }
8942
4.99k
    switch (o->kind) {
8943
4.99k
    case Module_kind:
8944
4.99k
        tp = (PyTypeObject *)state->Module_type;
8945
4.99k
        result = PyType_GenericNew(tp, NULL, NULL);
8946
4.99k
        if (!result) goto failed;
8947
4.99k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8948
4.99k
        if (!value) goto failed;
8949
4.99k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8950
0
            goto failed;
8951
4.99k
        Py_DECREF(value);
8952
4.99k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8953
4.99k
                             ast2obj_type_ignore);
8954
4.99k
        if (!value) goto failed;
8955
4.99k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8956
0
            goto failed;
8957
4.99k
        Py_DECREF(value);
8958
4.99k
        break;
8959
0
    case Interactive_kind:
8960
0
        tp = (PyTypeObject *)state->Interactive_type;
8961
0
        result = PyType_GenericNew(tp, NULL, NULL);
8962
0
        if (!result) goto failed;
8963
0
        value = ast2obj_list(state, (asdl_seq*)o->v.Interactive.body,
8964
0
                             ast2obj_stmt);
8965
0
        if (!value) goto failed;
8966
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8967
0
            goto failed;
8968
0
        Py_DECREF(value);
8969
0
        break;
8970
0
    case Expression_kind:
8971
0
        tp = (PyTypeObject *)state->Expression_type;
8972
0
        result = PyType_GenericNew(tp, NULL, NULL);
8973
0
        if (!result) goto failed;
8974
0
        value = ast2obj_expr(state, o->v.Expression.body);
8975
0
        if (!value) goto failed;
8976
0
        if (PyObject_SetAttr(result, state->body, value) == -1)
8977
0
            goto failed;
8978
0
        Py_DECREF(value);
8979
0
        break;
8980
0
    case FunctionType_kind:
8981
0
        tp = (PyTypeObject *)state->FunctionType_type;
8982
0
        result = PyType_GenericNew(tp, NULL, NULL);
8983
0
        if (!result) goto failed;
8984
0
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionType.argtypes,
8985
0
                             ast2obj_expr);
8986
0
        if (!value) goto failed;
8987
0
        if (PyObject_SetAttr(result, state->argtypes, value) == -1)
8988
0
            goto failed;
8989
0
        Py_DECREF(value);
8990
0
        value = ast2obj_expr(state, o->v.FunctionType.returns);
8991
0
        if (!value) goto failed;
8992
0
        if (PyObject_SetAttr(result, state->returns, value) == -1)
8993
0
            goto failed;
8994
0
        Py_DECREF(value);
8995
0
        break;
8996
4.99k
    }
8997
4.99k
    Py_LeaveRecursiveCall();
8998
4.99k
    return result;
8999
0
failed:
9000
0
    Py_LeaveRecursiveCall();
9001
0
    Py_XDECREF(value);
9002
0
    Py_XDECREF(result);
9003
0
    return NULL;
9004
4.99k
}
9005
9006
PyObject*
9007
ast2obj_stmt(struct ast_state *state, void* _o)
9008
34.8k
{
9009
34.8k
    stmt_ty o = (stmt_ty)_o;
9010
34.8k
    PyObject *result = NULL, *value = NULL;
9011
34.8k
    PyTypeObject *tp;
9012
34.8k
    if (!o) {
9013
0
        Py_RETURN_NONE;
9014
0
    }
9015
34.8k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9016
0
        return NULL;
9017
0
    }
9018
34.8k
    switch (o->kind) {
9019
1.56k
    case FunctionDef_kind:
9020
1.56k
        tp = (PyTypeObject *)state->FunctionDef_type;
9021
1.56k
        result = PyType_GenericNew(tp, NULL, NULL);
9022
1.56k
        if (!result) goto failed;
9023
1.56k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
9024
1.56k
        if (!value) goto failed;
9025
1.56k
        if (PyObject_SetAttr(result, state->name, value) == -1)
9026
0
            goto failed;
9027
1.56k
        Py_DECREF(value);
9028
1.56k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
9029
1.56k
        if (!value) goto failed;
9030
1.56k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9031
0
            goto failed;
9032
1.56k
        Py_DECREF(value);
9033
1.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
9034
1.56k
                             ast2obj_stmt);
9035
1.56k
        if (!value) goto failed;
9036
1.56k
        if (PyObject_SetAttr(result, state->body, value) == -1)
9037
0
            goto failed;
9038
1.56k
        Py_DECREF(value);
9039
1.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
9040
1.56k
                             ast2obj_expr);
9041
1.56k
        if (!value) goto failed;
9042
1.56k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9043
0
            goto failed;
9044
1.56k
        Py_DECREF(value);
9045
1.56k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
9046
1.56k
        if (!value) goto failed;
9047
1.56k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9048
0
            goto failed;
9049
1.56k
        Py_DECREF(value);
9050
1.56k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
9051
1.56k
        if (!value) goto failed;
9052
1.56k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9053
0
            goto failed;
9054
1.56k
        Py_DECREF(value);
9055
1.56k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
9056
1.56k
                             ast2obj_type_param);
9057
1.56k
        if (!value) goto failed;
9058
1.56k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9059
0
            goto failed;
9060
1.56k
        Py_DECREF(value);
9061
1.56k
        break;
9062
84
    case AsyncFunctionDef_kind:
9063
84
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9064
84
        result = PyType_GenericNew(tp, NULL, NULL);
9065
84
        if (!result) goto failed;
9066
84
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9067
84
        if (!value) goto failed;
9068
84
        if (PyObject_SetAttr(result, state->name, value) == -1)
9069
0
            goto failed;
9070
84
        Py_DECREF(value);
9071
84
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9072
84
        if (!value) goto failed;
9073
84
        if (PyObject_SetAttr(result, state->args, value) == -1)
9074
0
            goto failed;
9075
84
        Py_DECREF(value);
9076
84
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9077
84
                             ast2obj_stmt);
9078
84
        if (!value) goto failed;
9079
84
        if (PyObject_SetAttr(result, state->body, value) == -1)
9080
0
            goto failed;
9081
84
        Py_DECREF(value);
9082
84
        value = ast2obj_list(state,
9083
84
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9084
84
                             ast2obj_expr);
9085
84
        if (!value) goto failed;
9086
84
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9087
0
            goto failed;
9088
84
        Py_DECREF(value);
9089
84
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9090
84
        if (!value) goto failed;
9091
84
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9092
0
            goto failed;
9093
84
        Py_DECREF(value);
9094
84
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9095
84
        if (!value) goto failed;
9096
84
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9097
0
            goto failed;
9098
84
        Py_DECREF(value);
9099
84
        value = ast2obj_list(state,
9100
84
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9101
84
                             ast2obj_type_param);
9102
84
        if (!value) goto failed;
9103
84
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9104
0
            goto failed;
9105
84
        Py_DECREF(value);
9106
84
        break;
9107
631
    case ClassDef_kind:
9108
631
        tp = (PyTypeObject *)state->ClassDef_type;
9109
631
        result = PyType_GenericNew(tp, NULL, NULL);
9110
631
        if (!result) goto failed;
9111
631
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9112
631
        if (!value) goto failed;
9113
631
        if (PyObject_SetAttr(result, state->name, value) == -1)
9114
0
            goto failed;
9115
631
        Py_DECREF(value);
9116
631
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9117
631
                             ast2obj_expr);
9118
631
        if (!value) goto failed;
9119
631
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9120
0
            goto failed;
9121
631
        Py_DECREF(value);
9122
631
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9123
631
                             ast2obj_keyword);
9124
631
        if (!value) goto failed;
9125
631
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9126
0
            goto failed;
9127
631
        Py_DECREF(value);
9128
631
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9129
631
                             ast2obj_stmt);
9130
631
        if (!value) goto failed;
9131
631
        if (PyObject_SetAttr(result, state->body, value) == -1)
9132
0
            goto failed;
9133
631
        Py_DECREF(value);
9134
631
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9135
631
                             ast2obj_expr);
9136
631
        if (!value) goto failed;
9137
631
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9138
0
            goto failed;
9139
631
        Py_DECREF(value);
9140
631
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9141
631
                             ast2obj_type_param);
9142
631
        if (!value) goto failed;
9143
631
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9144
0
            goto failed;
9145
631
        Py_DECREF(value);
9146
631
        break;
9147
579
    case Return_kind:
9148
579
        tp = (PyTypeObject *)state->Return_type;
9149
579
        result = PyType_GenericNew(tp, NULL, NULL);
9150
579
        if (!result) goto failed;
9151
579
        value = ast2obj_expr(state, o->v.Return.value);
9152
579
        if (!value) goto failed;
9153
579
        if (PyObject_SetAttr(result, state->value, value) == -1)
9154
0
            goto failed;
9155
579
        Py_DECREF(value);
9156
579
        break;
9157
225
    case Delete_kind:
9158
225
        tp = (PyTypeObject *)state->Delete_type;
9159
225
        result = PyType_GenericNew(tp, NULL, NULL);
9160
225
        if (!result) goto failed;
9161
225
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9162
225
                             ast2obj_expr);
9163
225
        if (!value) goto failed;
9164
225
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9165
0
            goto failed;
9166
225
        Py_DECREF(value);
9167
225
        break;
9168
1.18k
    case Assign_kind:
9169
1.18k
        tp = (PyTypeObject *)state->Assign_type;
9170
1.18k
        result = PyType_GenericNew(tp, NULL, NULL);
9171
1.18k
        if (!result) goto failed;
9172
1.18k
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9173
1.18k
                             ast2obj_expr);
9174
1.18k
        if (!value) goto failed;
9175
1.18k
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9176
0
            goto failed;
9177
1.18k
        Py_DECREF(value);
9178
1.18k
        value = ast2obj_expr(state, o->v.Assign.value);
9179
1.18k
        if (!value) goto failed;
9180
1.18k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9181
0
            goto failed;
9182
1.18k
        Py_DECREF(value);
9183
1.18k
        value = ast2obj_string(state, o->v.Assign.type_comment);
9184
1.18k
        if (!value) goto failed;
9185
1.18k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9186
0
            goto failed;
9187
1.18k
        Py_DECREF(value);
9188
1.18k
        break;
9189
39
    case TypeAlias_kind:
9190
39
        tp = (PyTypeObject *)state->TypeAlias_type;
9191
39
        result = PyType_GenericNew(tp, NULL, NULL);
9192
39
        if (!result) goto failed;
9193
39
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9194
39
        if (!value) goto failed;
9195
39
        if (PyObject_SetAttr(result, state->name, value) == -1)
9196
0
            goto failed;
9197
39
        Py_DECREF(value);
9198
39
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9199
39
                             ast2obj_type_param);
9200
39
        if (!value) goto failed;
9201
39
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9202
0
            goto failed;
9203
39
        Py_DECREF(value);
9204
39
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9205
39
        if (!value) goto failed;
9206
39
        if (PyObject_SetAttr(result, state->value, value) == -1)
9207
0
            goto failed;
9208
39
        Py_DECREF(value);
9209
39
        break;
9210
385
    case AugAssign_kind:
9211
385
        tp = (PyTypeObject *)state->AugAssign_type;
9212
385
        result = PyType_GenericNew(tp, NULL, NULL);
9213
385
        if (!result) goto failed;
9214
385
        value = ast2obj_expr(state, o->v.AugAssign.target);
9215
385
        if (!value) goto failed;
9216
385
        if (PyObject_SetAttr(result, state->target, value) == -1)
9217
0
            goto failed;
9218
385
        Py_DECREF(value);
9219
385
        value = ast2obj_operator(state, o->v.AugAssign.op);
9220
385
        if (!value) goto failed;
9221
385
        if (PyObject_SetAttr(result, state->op, value) == -1)
9222
0
            goto failed;
9223
385
        Py_DECREF(value);
9224
385
        value = ast2obj_expr(state, o->v.AugAssign.value);
9225
385
        if (!value) goto failed;
9226
385
        if (PyObject_SetAttr(result, state->value, value) == -1)
9227
0
            goto failed;
9228
385
        Py_DECREF(value);
9229
385
        break;
9230
1.12k
    case AnnAssign_kind:
9231
1.12k
        tp = (PyTypeObject *)state->AnnAssign_type;
9232
1.12k
        result = PyType_GenericNew(tp, NULL, NULL);
9233
1.12k
        if (!result) goto failed;
9234
1.12k
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9235
1.12k
        if (!value) goto failed;
9236
1.12k
        if (PyObject_SetAttr(result, state->target, value) == -1)
9237
0
            goto failed;
9238
1.12k
        Py_DECREF(value);
9239
1.12k
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9240
1.12k
        if (!value) goto failed;
9241
1.12k
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9242
0
            goto failed;
9243
1.12k
        Py_DECREF(value);
9244
1.12k
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9245
1.12k
        if (!value) goto failed;
9246
1.12k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9247
0
            goto failed;
9248
1.12k
        Py_DECREF(value);
9249
1.12k
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9250
1.12k
        if (!value) goto failed;
9251
1.12k
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9252
0
            goto failed;
9253
1.12k
        Py_DECREF(value);
9254
1.12k
        break;
9255
370
    case For_kind:
9256
370
        tp = (PyTypeObject *)state->For_type;
9257
370
        result = PyType_GenericNew(tp, NULL, NULL);
9258
370
        if (!result) goto failed;
9259
370
        value = ast2obj_expr(state, o->v.For.target);
9260
370
        if (!value) goto failed;
9261
370
        if (PyObject_SetAttr(result, state->target, value) == -1)
9262
0
            goto failed;
9263
370
        Py_DECREF(value);
9264
370
        value = ast2obj_expr(state, o->v.For.iter);
9265
370
        if (!value) goto failed;
9266
370
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9267
0
            goto failed;
9268
370
        Py_DECREF(value);
9269
370
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9270
370
        if (!value) goto failed;
9271
370
        if (PyObject_SetAttr(result, state->body, value) == -1)
9272
0
            goto failed;
9273
370
        Py_DECREF(value);
9274
370
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9275
370
        if (!value) goto failed;
9276
370
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9277
0
            goto failed;
9278
370
        Py_DECREF(value);
9279
370
        value = ast2obj_string(state, o->v.For.type_comment);
9280
370
        if (!value) goto failed;
9281
370
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9282
0
            goto failed;
9283
370
        Py_DECREF(value);
9284
370
        break;
9285
70
    case AsyncFor_kind:
9286
70
        tp = (PyTypeObject *)state->AsyncFor_type;
9287
70
        result = PyType_GenericNew(tp, NULL, NULL);
9288
70
        if (!result) goto failed;
9289
70
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9290
70
        if (!value) goto failed;
9291
70
        if (PyObject_SetAttr(result, state->target, value) == -1)
9292
0
            goto failed;
9293
70
        Py_DECREF(value);
9294
70
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9295
70
        if (!value) goto failed;
9296
70
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9297
0
            goto failed;
9298
70
        Py_DECREF(value);
9299
70
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9300
70
                             ast2obj_stmt);
9301
70
        if (!value) goto failed;
9302
70
        if (PyObject_SetAttr(result, state->body, value) == -1)
9303
0
            goto failed;
9304
70
        Py_DECREF(value);
9305
70
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9306
70
                             ast2obj_stmt);
9307
70
        if (!value) goto failed;
9308
70
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9309
0
            goto failed;
9310
70
        Py_DECREF(value);
9311
70
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9312
70
        if (!value) goto failed;
9313
70
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9314
0
            goto failed;
9315
70
        Py_DECREF(value);
9316
70
        break;
9317
168
    case While_kind:
9318
168
        tp = (PyTypeObject *)state->While_type;
9319
168
        result = PyType_GenericNew(tp, NULL, NULL);
9320
168
        if (!result) goto failed;
9321
168
        value = ast2obj_expr(state, o->v.While.test);
9322
168
        if (!value) goto failed;
9323
168
        if (PyObject_SetAttr(result, state->test, value) == -1)
9324
0
            goto failed;
9325
168
        Py_DECREF(value);
9326
168
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9327
168
        if (!value) goto failed;
9328
168
        if (PyObject_SetAttr(result, state->body, value) == -1)
9329
0
            goto failed;
9330
168
        Py_DECREF(value);
9331
168
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9332
168
        if (!value) goto failed;
9333
168
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9334
0
            goto failed;
9335
168
        Py_DECREF(value);
9336
168
        break;
9337
535
    case If_kind:
9338
535
        tp = (PyTypeObject *)state->If_type;
9339
535
        result = PyType_GenericNew(tp, NULL, NULL);
9340
535
        if (!result) goto failed;
9341
535
        value = ast2obj_expr(state, o->v.If.test);
9342
535
        if (!value) goto failed;
9343
535
        if (PyObject_SetAttr(result, state->test, value) == -1)
9344
0
            goto failed;
9345
535
        Py_DECREF(value);
9346
535
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9347
535
        if (!value) goto failed;
9348
535
        if (PyObject_SetAttr(result, state->body, value) == -1)
9349
0
            goto failed;
9350
535
        Py_DECREF(value);
9351
535
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9352
535
        if (!value) goto failed;
9353
535
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9354
0
            goto failed;
9355
535
        Py_DECREF(value);
9356
535
        break;
9357
137
    case With_kind:
9358
137
        tp = (PyTypeObject *)state->With_type;
9359
137
        result = PyType_GenericNew(tp, NULL, NULL);
9360
137
        if (!result) goto failed;
9361
137
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9362
137
                             ast2obj_withitem);
9363
137
        if (!value) goto failed;
9364
137
        if (PyObject_SetAttr(result, state->items, value) == -1)
9365
0
            goto failed;
9366
137
        Py_DECREF(value);
9367
137
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9368
137
        if (!value) goto failed;
9369
137
        if (PyObject_SetAttr(result, state->body, value) == -1)
9370
0
            goto failed;
9371
137
        Py_DECREF(value);
9372
137
        value = ast2obj_string(state, o->v.With.type_comment);
9373
137
        if (!value) goto failed;
9374
137
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9375
0
            goto failed;
9376
137
        Py_DECREF(value);
9377
137
        break;
9378
159
    case AsyncWith_kind:
9379
159
        tp = (PyTypeObject *)state->AsyncWith_type;
9380
159
        result = PyType_GenericNew(tp, NULL, NULL);
9381
159
        if (!result) goto failed;
9382
159
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9383
159
                             ast2obj_withitem);
9384
159
        if (!value) goto failed;
9385
159
        if (PyObject_SetAttr(result, state->items, value) == -1)
9386
0
            goto failed;
9387
159
        Py_DECREF(value);
9388
159
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9389
159
                             ast2obj_stmt);
9390
159
        if (!value) goto failed;
9391
159
        if (PyObject_SetAttr(result, state->body, value) == -1)
9392
0
            goto failed;
9393
159
        Py_DECREF(value);
9394
159
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9395
159
        if (!value) goto failed;
9396
159
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9397
0
            goto failed;
9398
159
        Py_DECREF(value);
9399
159
        break;
9400
171
    case Match_kind:
9401
171
        tp = (PyTypeObject *)state->Match_type;
9402
171
        result = PyType_GenericNew(tp, NULL, NULL);
9403
171
        if (!result) goto failed;
9404
171
        value = ast2obj_expr(state, o->v.Match.subject);
9405
171
        if (!value) goto failed;
9406
171
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9407
0
            goto failed;
9408
171
        Py_DECREF(value);
9409
171
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9410
171
                             ast2obj_match_case);
9411
171
        if (!value) goto failed;
9412
171
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9413
0
            goto failed;
9414
171
        Py_DECREF(value);
9415
171
        break;
9416
356
    case Raise_kind:
9417
356
        tp = (PyTypeObject *)state->Raise_type;
9418
356
        result = PyType_GenericNew(tp, NULL, NULL);
9419
356
        if (!result) goto failed;
9420
356
        value = ast2obj_expr(state, o->v.Raise.exc);
9421
356
        if (!value) goto failed;
9422
356
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9423
0
            goto failed;
9424
356
        Py_DECREF(value);
9425
356
        value = ast2obj_expr(state, o->v.Raise.cause);
9426
356
        if (!value) goto failed;
9427
356
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9428
0
            goto failed;
9429
356
        Py_DECREF(value);
9430
356
        break;
9431
524
    case Try_kind:
9432
524
        tp = (PyTypeObject *)state->Try_type;
9433
524
        result = PyType_GenericNew(tp, NULL, NULL);
9434
524
        if (!result) goto failed;
9435
524
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9436
524
        if (!value) goto failed;
9437
524
        if (PyObject_SetAttr(result, state->body, value) == -1)
9438
0
            goto failed;
9439
524
        Py_DECREF(value);
9440
524
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9441
524
                             ast2obj_excepthandler);
9442
524
        if (!value) goto failed;
9443
524
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9444
0
            goto failed;
9445
524
        Py_DECREF(value);
9446
524
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9447
524
        if (!value) goto failed;
9448
524
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9449
0
            goto failed;
9450
524
        Py_DECREF(value);
9451
524
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9452
524
                             ast2obj_stmt);
9453
524
        if (!value) goto failed;
9454
524
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9455
0
            goto failed;
9456
524
        Py_DECREF(value);
9457
524
        break;
9458
316
    case TryStar_kind:
9459
316
        tp = (PyTypeObject *)state->TryStar_type;
9460
316
        result = PyType_GenericNew(tp, NULL, NULL);
9461
316
        if (!result) goto failed;
9462
316
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9463
316
        if (!value) goto failed;
9464
316
        if (PyObject_SetAttr(result, state->body, value) == -1)
9465
0
            goto failed;
9466
316
        Py_DECREF(value);
9467
316
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9468
316
                             ast2obj_excepthandler);
9469
316
        if (!value) goto failed;
9470
316
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9471
0
            goto failed;
9472
316
        Py_DECREF(value);
9473
316
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9474
316
                             ast2obj_stmt);
9475
316
        if (!value) goto failed;
9476
316
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9477
0
            goto failed;
9478
316
        Py_DECREF(value);
9479
316
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9480
316
                             ast2obj_stmt);
9481
316
        if (!value) goto failed;
9482
316
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9483
0
            goto failed;
9484
316
        Py_DECREF(value);
9485
316
        break;
9486
290
    case Assert_kind:
9487
290
        tp = (PyTypeObject *)state->Assert_type;
9488
290
        result = PyType_GenericNew(tp, NULL, NULL);
9489
290
        if (!result) goto failed;
9490
290
        value = ast2obj_expr(state, o->v.Assert.test);
9491
290
        if (!value) goto failed;
9492
290
        if (PyObject_SetAttr(result, state->test, value) == -1)
9493
0
            goto failed;
9494
290
        Py_DECREF(value);
9495
290
        value = ast2obj_expr(state, o->v.Assert.msg);
9496
290
        if (!value) goto failed;
9497
290
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9498
0
            goto failed;
9499
290
        Py_DECREF(value);
9500
290
        break;
9501
703
    case Import_kind:
9502
703
        tp = (PyTypeObject *)state->Import_type;
9503
703
        result = PyType_GenericNew(tp, NULL, NULL);
9504
703
        if (!result) goto failed;
9505
703
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9506
703
                             ast2obj_alias);
9507
703
        if (!value) goto failed;
9508
703
        if (PyObject_SetAttr(result, state->names, value) == -1)
9509
0
            goto failed;
9510
703
        Py_DECREF(value);
9511
703
        value = ast2obj_int(state, o->v.Import.is_lazy);
9512
703
        if (!value) goto failed;
9513
703
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9514
0
            goto failed;
9515
703
        Py_DECREF(value);
9516
703
        break;
9517
907
    case ImportFrom_kind:
9518
907
        tp = (PyTypeObject *)state->ImportFrom_type;
9519
907
        result = PyType_GenericNew(tp, NULL, NULL);
9520
907
        if (!result) goto failed;
9521
907
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9522
907
        if (!value) goto failed;
9523
907
        if (PyObject_SetAttr(result, state->module, value) == -1)
9524
0
            goto failed;
9525
907
        Py_DECREF(value);
9526
907
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9527
907
                             ast2obj_alias);
9528
907
        if (!value) goto failed;
9529
907
        if (PyObject_SetAttr(result, state->names, value) == -1)
9530
0
            goto failed;
9531
907
        Py_DECREF(value);
9532
907
        value = ast2obj_int(state, o->v.ImportFrom.level);
9533
907
        if (!value) goto failed;
9534
907
        if (PyObject_SetAttr(result, state->level, value) == -1)
9535
0
            goto failed;
9536
907
        Py_DECREF(value);
9537
907
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
9538
907
        if (!value) goto failed;
9539
907
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9540
0
            goto failed;
9541
907
        Py_DECREF(value);
9542
907
        break;
9543
108
    case Global_kind:
9544
108
        tp = (PyTypeObject *)state->Global_type;
9545
108
        result = PyType_GenericNew(tp, NULL, NULL);
9546
108
        if (!result) goto failed;
9547
108
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9548
108
                             ast2obj_identifier);
9549
108
        if (!value) goto failed;
9550
108
        if (PyObject_SetAttr(result, state->names, value) == -1)
9551
0
            goto failed;
9552
108
        Py_DECREF(value);
9553
108
        break;
9554
57
    case Nonlocal_kind:
9555
57
        tp = (PyTypeObject *)state->Nonlocal_type;
9556
57
        result = PyType_GenericNew(tp, NULL, NULL);
9557
57
        if (!result) goto failed;
9558
57
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9559
57
                             ast2obj_identifier);
9560
57
        if (!value) goto failed;
9561
57
        if (PyObject_SetAttr(result, state->names, value) == -1)
9562
0
            goto failed;
9563
57
        Py_DECREF(value);
9564
57
        break;
9565
23.5k
    case Expr_kind:
9566
23.5k
        tp = (PyTypeObject *)state->Expr_type;
9567
23.5k
        result = PyType_GenericNew(tp, NULL, NULL);
9568
23.5k
        if (!result) goto failed;
9569
23.5k
        value = ast2obj_expr(state, o->v.Expr.value);
9570
23.5k
        if (!value) goto failed;
9571
23.5k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9572
0
            goto failed;
9573
23.5k
        Py_DECREF(value);
9574
23.5k
        break;
9575
141
    case Pass_kind:
9576
141
        tp = (PyTypeObject *)state->Pass_type;
9577
141
        result = PyType_GenericNew(tp, NULL, NULL);
9578
141
        if (!result) goto failed;
9579
141
        break;
9580
309
    case Break_kind:
9581
309
        tp = (PyTypeObject *)state->Break_type;
9582
309
        result = PyType_GenericNew(tp, NULL, NULL);
9583
309
        if (!result) goto failed;
9584
309
        break;
9585
309
    case Continue_kind:
9586
85
        tp = (PyTypeObject *)state->Continue_type;
9587
85
        result = PyType_GenericNew(tp, NULL, NULL);
9588
85
        if (!result) goto failed;
9589
85
        break;
9590
34.8k
    }
9591
34.8k
    value = ast2obj_int(state, o->lineno);
9592
34.8k
    if (!value) goto failed;
9593
34.8k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
9594
0
        goto failed;
9595
34.8k
    Py_DECREF(value);
9596
34.8k
    value = ast2obj_int(state, o->col_offset);
9597
34.8k
    if (!value) goto failed;
9598
34.8k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
9599
0
        goto failed;
9600
34.8k
    Py_DECREF(value);
9601
34.8k
    value = ast2obj_int(state, o->end_lineno);
9602
34.8k
    if (!value) goto failed;
9603
34.8k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
9604
0
        goto failed;
9605
34.8k
    Py_DECREF(value);
9606
34.8k
    value = ast2obj_int(state, o->end_col_offset);
9607
34.8k
    if (!value) goto failed;
9608
34.8k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
9609
0
        goto failed;
9610
34.8k
    Py_DECREF(value);
9611
34.8k
    Py_LeaveRecursiveCall();
9612
34.8k
    return result;
9613
0
failed:
9614
0
    Py_LeaveRecursiveCall();
9615
0
    Py_XDECREF(value);
9616
0
    Py_XDECREF(result);
9617
0
    return NULL;
9618
34.8k
}
9619
9620
PyObject*
9621
ast2obj_expr(struct ast_state *state, void* _o)
9622
247k
{
9623
247k
    expr_ty o = (expr_ty)_o;
9624
247k
    PyObject *result = NULL, *value = NULL;
9625
247k
    PyTypeObject *tp;
9626
247k
    if (!o) {
9627
39.2k
        Py_RETURN_NONE;
9628
39.2k
    }
9629
208k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9630
0
        return NULL;
9631
0
    }
9632
208k
    switch (o->kind) {
9633
327
    case BoolOp_kind:
9634
327
        tp = (PyTypeObject *)state->BoolOp_type;
9635
327
        result = PyType_GenericNew(tp, NULL, NULL);
9636
327
        if (!result) goto failed;
9637
327
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9638
327
        if (!value) goto failed;
9639
327
        if (PyObject_SetAttr(result, state->op, value) == -1)
9640
0
            goto failed;
9641
327
        Py_DECREF(value);
9642
327
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9643
327
                             ast2obj_expr);
9644
327
        if (!value) goto failed;
9645
327
        if (PyObject_SetAttr(result, state->values, value) == -1)
9646
0
            goto failed;
9647
327
        Py_DECREF(value);
9648
327
        break;
9649
37
    case NamedExpr_kind:
9650
37
        tp = (PyTypeObject *)state->NamedExpr_type;
9651
37
        result = PyType_GenericNew(tp, NULL, NULL);
9652
37
        if (!result) goto failed;
9653
37
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9654
37
        if (!value) goto failed;
9655
37
        if (PyObject_SetAttr(result, state->target, value) == -1)
9656
0
            goto failed;
9657
37
        Py_DECREF(value);
9658
37
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9659
37
        if (!value) goto failed;
9660
37
        if (PyObject_SetAttr(result, state->value, value) == -1)
9661
0
            goto failed;
9662
37
        Py_DECREF(value);
9663
37
        break;
9664
17.1k
    case BinOp_kind:
9665
17.1k
        tp = (PyTypeObject *)state->BinOp_type;
9666
17.1k
        result = PyType_GenericNew(tp, NULL, NULL);
9667
17.1k
        if (!result) goto failed;
9668
17.1k
        value = ast2obj_expr(state, o->v.BinOp.left);
9669
17.1k
        if (!value) goto failed;
9670
17.1k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9671
0
            goto failed;
9672
17.1k
        Py_DECREF(value);
9673
17.1k
        value = ast2obj_operator(state, o->v.BinOp.op);
9674
17.1k
        if (!value) goto failed;
9675
17.1k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9676
0
            goto failed;
9677
17.1k
        Py_DECREF(value);
9678
17.1k
        value = ast2obj_expr(state, o->v.BinOp.right);
9679
17.1k
        if (!value) goto failed;
9680
17.1k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9681
0
            goto failed;
9682
17.1k
        Py_DECREF(value);
9683
17.1k
        break;
9684
39.3k
    case UnaryOp_kind:
9685
39.3k
        tp = (PyTypeObject *)state->UnaryOp_type;
9686
39.3k
        result = PyType_GenericNew(tp, NULL, NULL);
9687
39.3k
        if (!result) goto failed;
9688
39.3k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9689
39.3k
        if (!value) goto failed;
9690
39.3k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9691
0
            goto failed;
9692
39.3k
        Py_DECREF(value);
9693
39.3k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9694
39.3k
        if (!value) goto failed;
9695
39.3k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9696
0
            goto failed;
9697
39.3k
        Py_DECREF(value);
9698
39.3k
        break;
9699
825
    case Lambda_kind:
9700
825
        tp = (PyTypeObject *)state->Lambda_type;
9701
825
        result = PyType_GenericNew(tp, NULL, NULL);
9702
825
        if (!result) goto failed;
9703
825
        value = ast2obj_arguments(state, o->v.Lambda.args);
9704
825
        if (!value) goto failed;
9705
825
        if (PyObject_SetAttr(result, state->args, value) == -1)
9706
0
            goto failed;
9707
825
        Py_DECREF(value);
9708
825
        value = ast2obj_expr(state, o->v.Lambda.body);
9709
825
        if (!value) goto failed;
9710
825
        if (PyObject_SetAttr(result, state->body, value) == -1)
9711
0
            goto failed;
9712
825
        Py_DECREF(value);
9713
825
        break;
9714
174
    case IfExp_kind:
9715
174
        tp = (PyTypeObject *)state->IfExp_type;
9716
174
        result = PyType_GenericNew(tp, NULL, NULL);
9717
174
        if (!result) goto failed;
9718
174
        value = ast2obj_expr(state, o->v.IfExp.test);
9719
174
        if (!value) goto failed;
9720
174
        if (PyObject_SetAttr(result, state->test, value) == -1)
9721
0
            goto failed;
9722
174
        Py_DECREF(value);
9723
174
        value = ast2obj_expr(state, o->v.IfExp.body);
9724
174
        if (!value) goto failed;
9725
174
        if (PyObject_SetAttr(result, state->body, value) == -1)
9726
0
            goto failed;
9727
174
        Py_DECREF(value);
9728
174
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9729
174
        if (!value) goto failed;
9730
174
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9731
0
            goto failed;
9732
174
        Py_DECREF(value);
9733
174
        break;
9734
1.63k
    case Dict_kind:
9735
1.63k
        tp = (PyTypeObject *)state->Dict_type;
9736
1.63k
        result = PyType_GenericNew(tp, NULL, NULL);
9737
1.63k
        if (!result) goto failed;
9738
1.63k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9739
1.63k
        if (!value) goto failed;
9740
1.63k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9741
0
            goto failed;
9742
1.63k
        Py_DECREF(value);
9743
1.63k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9744
1.63k
        if (!value) goto failed;
9745
1.63k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9746
0
            goto failed;
9747
1.63k
        Py_DECREF(value);
9748
1.63k
        break;
9749
509
    case Set_kind:
9750
509
        tp = (PyTypeObject *)state->Set_type;
9751
509
        result = PyType_GenericNew(tp, NULL, NULL);
9752
509
        if (!result) goto failed;
9753
509
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9754
509
        if (!value) goto failed;
9755
509
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9756
0
            goto failed;
9757
509
        Py_DECREF(value);
9758
509
        break;
9759
388
    case ListComp_kind:
9760
388
        tp = (PyTypeObject *)state->ListComp_type;
9761
388
        result = PyType_GenericNew(tp, NULL, NULL);
9762
388
        if (!result) goto failed;
9763
388
        value = ast2obj_expr(state, o->v.ListComp.elt);
9764
388
        if (!value) goto failed;
9765
388
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9766
0
            goto failed;
9767
388
        Py_DECREF(value);
9768
388
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9769
388
                             ast2obj_comprehension);
9770
388
        if (!value) goto failed;
9771
388
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9772
0
            goto failed;
9773
388
        Py_DECREF(value);
9774
388
        break;
9775
315
    case SetComp_kind:
9776
315
        tp = (PyTypeObject *)state->SetComp_type;
9777
315
        result = PyType_GenericNew(tp, NULL, NULL);
9778
315
        if (!result) goto failed;
9779
315
        value = ast2obj_expr(state, o->v.SetComp.elt);
9780
315
        if (!value) goto failed;
9781
315
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9782
0
            goto failed;
9783
315
        Py_DECREF(value);
9784
315
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9785
315
                             ast2obj_comprehension);
9786
315
        if (!value) goto failed;
9787
315
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9788
0
            goto failed;
9789
315
        Py_DECREF(value);
9790
315
        break;
9791
229
    case DictComp_kind:
9792
229
        tp = (PyTypeObject *)state->DictComp_type;
9793
229
        result = PyType_GenericNew(tp, NULL, NULL);
9794
229
        if (!result) goto failed;
9795
229
        value = ast2obj_expr(state, o->v.DictComp.key);
9796
229
        if (!value) goto failed;
9797
229
        if (PyObject_SetAttr(result, state->key, value) == -1)
9798
0
            goto failed;
9799
229
        Py_DECREF(value);
9800
229
        value = ast2obj_expr(state, o->v.DictComp.value);
9801
229
        if (!value) goto failed;
9802
229
        if (PyObject_SetAttr(result, state->value, value) == -1)
9803
0
            goto failed;
9804
229
        Py_DECREF(value);
9805
229
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9806
229
                             ast2obj_comprehension);
9807
229
        if (!value) goto failed;
9808
229
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9809
0
            goto failed;
9810
229
        Py_DECREF(value);
9811
229
        break;
9812
399
    case GeneratorExp_kind:
9813
399
        tp = (PyTypeObject *)state->GeneratorExp_type;
9814
399
        result = PyType_GenericNew(tp, NULL, NULL);
9815
399
        if (!result) goto failed;
9816
399
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9817
399
        if (!value) goto failed;
9818
399
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9819
0
            goto failed;
9820
399
        Py_DECREF(value);
9821
399
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9822
399
                             ast2obj_comprehension);
9823
399
        if (!value) goto failed;
9824
399
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9825
0
            goto failed;
9826
399
        Py_DECREF(value);
9827
399
        break;
9828
93
    case Await_kind:
9829
93
        tp = (PyTypeObject *)state->Await_type;
9830
93
        result = PyType_GenericNew(tp, NULL, NULL);
9831
93
        if (!result) goto failed;
9832
93
        value = ast2obj_expr(state, o->v.Await.value);
9833
93
        if (!value) goto failed;
9834
93
        if (PyObject_SetAttr(result, state->value, value) == -1)
9835
0
            goto failed;
9836
93
        Py_DECREF(value);
9837
93
        break;
9838
717
    case Yield_kind:
9839
717
        tp = (PyTypeObject *)state->Yield_type;
9840
717
        result = PyType_GenericNew(tp, NULL, NULL);
9841
717
        if (!result) goto failed;
9842
717
        value = ast2obj_expr(state, o->v.Yield.value);
9843
717
        if (!value) goto failed;
9844
717
        if (PyObject_SetAttr(result, state->value, value) == -1)
9845
0
            goto failed;
9846
717
        Py_DECREF(value);
9847
717
        break;
9848
50
    case YieldFrom_kind:
9849
50
        tp = (PyTypeObject *)state->YieldFrom_type;
9850
50
        result = PyType_GenericNew(tp, NULL, NULL);
9851
50
        if (!result) goto failed;
9852
50
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9853
50
        if (!value) goto failed;
9854
50
        if (PyObject_SetAttr(result, state->value, value) == -1)
9855
0
            goto failed;
9856
50
        Py_DECREF(value);
9857
50
        break;
9858
1.10k
    case Compare_kind:
9859
1.10k
        tp = (PyTypeObject *)state->Compare_type;
9860
1.10k
        result = PyType_GenericNew(tp, NULL, NULL);
9861
1.10k
        if (!result) goto failed;
9862
1.10k
        value = ast2obj_expr(state, o->v.Compare.left);
9863
1.10k
        if (!value) goto failed;
9864
1.10k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9865
0
            goto failed;
9866
1.10k
        Py_DECREF(value);
9867
1.10k
        {
9868
1.10k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9869
1.10k
            value = PyList_New(n);
9870
1.10k
            if (!value) goto failed;
9871
5.69k
            for(i = 0; i < n; i++)
9872
4.58k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9873
1.10k
        }
9874
1.10k
        if (!value) goto failed;
9875
1.10k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9876
0
            goto failed;
9877
1.10k
        Py_DECREF(value);
9878
1.10k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9879
1.10k
                             ast2obj_expr);
9880
1.10k
        if (!value) goto failed;
9881
1.10k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9882
0
            goto failed;
9883
1.10k
        Py_DECREF(value);
9884
1.10k
        break;
9885
4.38k
    case Call_kind:
9886
4.38k
        tp = (PyTypeObject *)state->Call_type;
9887
4.38k
        result = PyType_GenericNew(tp, NULL, NULL);
9888
4.38k
        if (!result) goto failed;
9889
4.38k
        value = ast2obj_expr(state, o->v.Call.func);
9890
4.38k
        if (!value) goto failed;
9891
4.38k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9892
0
            goto failed;
9893
4.38k
        Py_DECREF(value);
9894
4.38k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9895
4.38k
        if (!value) goto failed;
9896
4.38k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9897
0
            goto failed;
9898
4.38k
        Py_DECREF(value);
9899
4.38k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9900
4.38k
                             ast2obj_keyword);
9901
4.38k
        if (!value) goto failed;
9902
4.38k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9903
0
            goto failed;
9904
4.38k
        Py_DECREF(value);
9905
4.38k
        break;
9906
13.7k
    case FormattedValue_kind:
9907
13.7k
        tp = (PyTypeObject *)state->FormattedValue_type;
9908
13.7k
        result = PyType_GenericNew(tp, NULL, NULL);
9909
13.7k
        if (!result) goto failed;
9910
13.7k
        value = ast2obj_expr(state, o->v.FormattedValue.value);
9911
13.7k
        if (!value) goto failed;
9912
13.7k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9913
0
            goto failed;
9914
13.7k
        Py_DECREF(value);
9915
13.7k
        value = ast2obj_int(state, o->v.FormattedValue.conversion);
9916
13.7k
        if (!value) goto failed;
9917
13.7k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9918
0
            goto failed;
9919
13.7k
        Py_DECREF(value);
9920
13.7k
        value = ast2obj_expr(state, o->v.FormattedValue.format_spec);
9921
13.7k
        if (!value) goto failed;
9922
13.7k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9923
0
            goto failed;
9924
13.7k
        Py_DECREF(value);
9925
13.7k
        break;
9926
1.34k
    case Interpolation_kind:
9927
1.34k
        tp = (PyTypeObject *)state->Interpolation_type;
9928
1.34k
        result = PyType_GenericNew(tp, NULL, NULL);
9929
1.34k
        if (!result) goto failed;
9930
1.34k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9931
1.34k
        if (!value) goto failed;
9932
1.34k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9933
0
            goto failed;
9934
1.34k
        Py_DECREF(value);
9935
1.34k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9936
1.34k
        if (!value) goto failed;
9937
1.34k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9938
0
            goto failed;
9939
1.34k
        Py_DECREF(value);
9940
1.34k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9941
1.34k
        if (!value) goto failed;
9942
1.34k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9943
0
            goto failed;
9944
1.34k
        Py_DECREF(value);
9945
1.34k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9946
1.34k
        if (!value) goto failed;
9947
1.34k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9948
0
            goto failed;
9949
1.34k
        Py_DECREF(value);
9950
1.34k
        break;
9951
5.87k
    case JoinedStr_kind:
9952
5.87k
        tp = (PyTypeObject *)state->JoinedStr_type;
9953
5.87k
        result = PyType_GenericNew(tp, NULL, NULL);
9954
5.87k
        if (!result) goto failed;
9955
5.87k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9956
5.87k
                             ast2obj_expr);
9957
5.87k
        if (!value) goto failed;
9958
5.87k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9959
0
            goto failed;
9960
5.87k
        Py_DECREF(value);
9961
5.87k
        break;
9962
246
    case TemplateStr_kind:
9963
246
        tp = (PyTypeObject *)state->TemplateStr_type;
9964
246
        result = PyType_GenericNew(tp, NULL, NULL);
9965
246
        if (!result) goto failed;
9966
246
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9967
246
                             ast2obj_expr);
9968
246
        if (!value) goto failed;
9969
246
        if (PyObject_SetAttr(result, state->values, value) == -1)
9970
0
            goto failed;
9971
246
        Py_DECREF(value);
9972
246
        break;
9973
50.2k
    case Constant_kind:
9974
50.2k
        tp = (PyTypeObject *)state->Constant_type;
9975
50.2k
        result = PyType_GenericNew(tp, NULL, NULL);
9976
50.2k
        if (!result) goto failed;
9977
50.2k
        value = ast2obj_constant(state, o->v.Constant.value);
9978
50.2k
        if (!value) goto failed;
9979
50.2k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9980
0
            goto failed;
9981
50.2k
        Py_DECREF(value);
9982
50.2k
        value = ast2obj_string(state, o->v.Constant.kind);
9983
50.2k
        if (!value) goto failed;
9984
50.2k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9985
0
            goto failed;
9986
50.2k
        Py_DECREF(value);
9987
50.2k
        break;
9988
2.69k
    case Attribute_kind:
9989
2.69k
        tp = (PyTypeObject *)state->Attribute_type;
9990
2.69k
        result = PyType_GenericNew(tp, NULL, NULL);
9991
2.69k
        if (!result) goto failed;
9992
2.69k
        value = ast2obj_expr(state, o->v.Attribute.value);
9993
2.69k
        if (!value) goto failed;
9994
2.69k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9995
0
            goto failed;
9996
2.69k
        Py_DECREF(value);
9997
2.69k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9998
2.69k
        if (!value) goto failed;
9999
2.69k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
10000
0
            goto failed;
10001
2.69k
        Py_DECREF(value);
10002
2.69k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
10003
2.69k
        if (!value) goto failed;
10004
2.69k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10005
0
            goto failed;
10006
2.69k
        Py_DECREF(value);
10007
2.69k
        break;
10008
490
    case Subscript_kind:
10009
490
        tp = (PyTypeObject *)state->Subscript_type;
10010
490
        result = PyType_GenericNew(tp, NULL, NULL);
10011
490
        if (!result) goto failed;
10012
490
        value = ast2obj_expr(state, o->v.Subscript.value);
10013
490
        if (!value) goto failed;
10014
490
        if (PyObject_SetAttr(result, state->value, value) == -1)
10015
0
            goto failed;
10016
490
        Py_DECREF(value);
10017
490
        value = ast2obj_expr(state, o->v.Subscript.slice);
10018
490
        if (!value) goto failed;
10019
490
        if (PyObject_SetAttr(result, state->slice, value) == -1)
10020
0
            goto failed;
10021
490
        Py_DECREF(value);
10022
490
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
10023
490
        if (!value) goto failed;
10024
490
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10025
0
            goto failed;
10026
490
        Py_DECREF(value);
10027
490
        break;
10028
652
    case Starred_kind:
10029
652
        tp = (PyTypeObject *)state->Starred_type;
10030
652
        result = PyType_GenericNew(tp, NULL, NULL);
10031
652
        if (!result) goto failed;
10032
652
        value = ast2obj_expr(state, o->v.Starred.value);
10033
652
        if (!value) goto failed;
10034
652
        if (PyObject_SetAttr(result, state->value, value) == -1)
10035
0
            goto failed;
10036
652
        Py_DECREF(value);
10037
652
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
10038
652
        if (!value) goto failed;
10039
652
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10040
0
            goto failed;
10041
652
        Py_DECREF(value);
10042
652
        break;
10043
56.7k
    case Name_kind:
10044
56.7k
        tp = (PyTypeObject *)state->Name_type;
10045
56.7k
        result = PyType_GenericNew(tp, NULL, NULL);
10046
56.7k
        if (!result) goto failed;
10047
56.7k
        value = ast2obj_identifier(state, o->v.Name.id);
10048
56.7k
        if (!value) goto failed;
10049
56.7k
        if (PyObject_SetAttr(result, state->id, value) == -1)
10050
0
            goto failed;
10051
56.7k
        Py_DECREF(value);
10052
56.7k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
10053
56.7k
        if (!value) goto failed;
10054
56.7k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10055
0
            goto failed;
10056
56.7k
        Py_DECREF(value);
10057
56.7k
        break;
10058
1.35k
    case List_kind:
10059
1.35k
        tp = (PyTypeObject *)state->List_type;
10060
1.35k
        result = PyType_GenericNew(tp, NULL, NULL);
10061
1.35k
        if (!result) goto failed;
10062
1.35k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10063
1.35k
        if (!value) goto failed;
10064
1.35k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10065
0
            goto failed;
10066
1.35k
        Py_DECREF(value);
10067
1.35k
        value = ast2obj_expr_context(state, o->v.List.ctx);
10068
1.35k
        if (!value) goto failed;
10069
1.35k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10070
0
            goto failed;
10071
1.35k
        Py_DECREF(value);
10072
1.35k
        break;
10073
5.77k
    case Tuple_kind:
10074
5.77k
        tp = (PyTypeObject *)state->Tuple_type;
10075
5.77k
        result = PyType_GenericNew(tp, NULL, NULL);
10076
5.77k
        if (!result) goto failed;
10077
5.77k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10078
5.77k
        if (!value) goto failed;
10079
5.77k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10080
0
            goto failed;
10081
5.77k
        Py_DECREF(value);
10082
5.77k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10083
5.77k
        if (!value) goto failed;
10084
5.77k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10085
0
            goto failed;
10086
5.77k
        Py_DECREF(value);
10087
5.77k
        break;
10088
1.63k
    case Slice_kind:
10089
1.63k
        tp = (PyTypeObject *)state->Slice_type;
10090
1.63k
        result = PyType_GenericNew(tp, NULL, NULL);
10091
1.63k
        if (!result) goto failed;
10092
1.63k
        value = ast2obj_expr(state, o->v.Slice.lower);
10093
1.63k
        if (!value) goto failed;
10094
1.63k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10095
0
            goto failed;
10096
1.63k
        Py_DECREF(value);
10097
1.63k
        value = ast2obj_expr(state, o->v.Slice.upper);
10098
1.63k
        if (!value) goto failed;
10099
1.63k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10100
0
            goto failed;
10101
1.63k
        Py_DECREF(value);
10102
1.63k
        value = ast2obj_expr(state, o->v.Slice.step);
10103
1.63k
        if (!value) goto failed;
10104
1.63k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10105
0
            goto failed;
10106
1.63k
        Py_DECREF(value);
10107
1.63k
        break;
10108
208k
    }
10109
208k
    value = ast2obj_int(state, o->lineno);
10110
208k
    if (!value) goto failed;
10111
208k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10112
0
        goto failed;
10113
208k
    Py_DECREF(value);
10114
208k
    value = ast2obj_int(state, o->col_offset);
10115
208k
    if (!value) goto failed;
10116
208k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10117
0
        goto failed;
10118
208k
    Py_DECREF(value);
10119
208k
    value = ast2obj_int(state, o->end_lineno);
10120
208k
    if (!value) goto failed;
10121
208k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10122
0
        goto failed;
10123
208k
    Py_DECREF(value);
10124
208k
    value = ast2obj_int(state, o->end_col_offset);
10125
208k
    if (!value) goto failed;
10126
208k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10127
0
        goto failed;
10128
208k
    Py_DECREF(value);
10129
208k
    Py_LeaveRecursiveCall();
10130
208k
    return result;
10131
0
failed:
10132
0
    Py_LeaveRecursiveCall();
10133
0
    Py_XDECREF(value);
10134
0
    Py_XDECREF(result);
10135
0
    return NULL;
10136
208k
}
10137
10138
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10139
67.7k
{
10140
67.7k
    switch(o) {
10141
61.7k
        case Load:
10142
61.7k
            return Py_NewRef(state->Load_singleton);
10143
5.70k
        case Store:
10144
5.70k
            return Py_NewRef(state->Store_singleton);
10145
286
        case Del:
10146
286
            return Py_NewRef(state->Del_singleton);
10147
67.7k
    }
10148
67.7k
    Py_UNREACHABLE();
10149
67.7k
}
10150
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10151
327
{
10152
327
    switch(o) {
10153
119
        case And:
10154
119
            return Py_NewRef(state->And_singleton);
10155
208
        case Or:
10156
208
            return Py_NewRef(state->Or_singleton);
10157
327
    }
10158
327
    Py_UNREACHABLE();
10159
327
}
10160
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10161
17.5k
{
10162
17.5k
    switch(o) {
10163
2.82k
        case Add:
10164
2.82k
            return Py_NewRef(state->Add_singleton);
10165
5.45k
        case Sub:
10166
5.45k
            return Py_NewRef(state->Sub_singleton);
10167
2.46k
        case Mult:
10168
2.46k
            return Py_NewRef(state->Mult_singleton);
10169
783
        case MatMult:
10170
783
            return Py_NewRef(state->MatMult_singleton);
10171
984
        case Div:
10172
984
            return Py_NewRef(state->Div_singleton);
10173
1.97k
        case Mod:
10174
1.97k
            return Py_NewRef(state->Mod_singleton);
10175
513
        case Pow:
10176
513
            return Py_NewRef(state->Pow_singleton);
10177
113
        case LShift:
10178
113
            return Py_NewRef(state->LShift_singleton);
10179
206
        case RShift:
10180
206
            return Py_NewRef(state->RShift_singleton);
10181
536
        case BitOr:
10182
536
            return Py_NewRef(state->BitOr_singleton);
10183
614
        case BitXor:
10184
614
            return Py_NewRef(state->BitXor_singleton);
10185
828
        case BitAnd:
10186
828
            return Py_NewRef(state->BitAnd_singleton);
10187
223
        case FloorDiv:
10188
223
            return Py_NewRef(state->FloorDiv_singleton);
10189
17.5k
    }
10190
17.5k
    Py_UNREACHABLE();
10191
17.5k
}
10192
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10193
39.3k
{
10194
39.3k
    switch(o) {
10195
5.64k
        case Invert:
10196
5.64k
            return Py_NewRef(state->Invert_singleton);
10197
114
        case Not:
10198
114
            return Py_NewRef(state->Not_singleton);
10199
13.3k
        case UAdd:
10200
13.3k
            return Py_NewRef(state->UAdd_singleton);
10201
20.2k
        case USub:
10202
20.2k
            return Py_NewRef(state->USub_singleton);
10203
39.3k
    }
10204
39.3k
    Py_UNREACHABLE();
10205
39.3k
}
10206
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10207
4.58k
{
10208
4.58k
    switch(o) {
10209
403
        case Eq:
10210
403
            return Py_NewRef(state->Eq_singleton);
10211
451
        case NotEq:
10212
451
            return Py_NewRef(state->NotEq_singleton);
10213
1.00k
        case Lt:
10214
1.00k
            return Py_NewRef(state->Lt_singleton);
10215
73
        case LtE:
10216
73
            return Py_NewRef(state->LtE_singleton);
10217
2.06k
        case Gt:
10218
2.06k
            return Py_NewRef(state->Gt_singleton);
10219
207
        case GtE:
10220
207
            return Py_NewRef(state->GtE_singleton);
10221
83
        case Is:
10222
83
            return Py_NewRef(state->Is_singleton);
10223
69
        case IsNot:
10224
69
            return Py_NewRef(state->IsNot_singleton);
10225
168
        case In:
10226
168
            return Py_NewRef(state->In_singleton);
10227
60
        case NotIn:
10228
60
            return Py_NewRef(state->NotIn_singleton);
10229
4.58k
    }
10230
4.58k
    Py_UNREACHABLE();
10231
4.58k
}
10232
PyObject*
10233
ast2obj_comprehension(struct ast_state *state, void* _o)
10234
1.38k
{
10235
1.38k
    comprehension_ty o = (comprehension_ty)_o;
10236
1.38k
    PyObject *result = NULL, *value = NULL;
10237
1.38k
    PyTypeObject *tp;
10238
1.38k
    if (!o) {
10239
0
        Py_RETURN_NONE;
10240
0
    }
10241
1.38k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10242
0
        return NULL;
10243
0
    }
10244
1.38k
    tp = (PyTypeObject *)state->comprehension_type;
10245
1.38k
    result = PyType_GenericNew(tp, NULL, NULL);
10246
1.38k
    if (!result) return NULL;
10247
1.38k
    value = ast2obj_expr(state, o->target);
10248
1.38k
    if (!value) goto failed;
10249
1.38k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10250
0
        goto failed;
10251
1.38k
    Py_DECREF(value);
10252
1.38k
    value = ast2obj_expr(state, o->iter);
10253
1.38k
    if (!value) goto failed;
10254
1.38k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10255
0
        goto failed;
10256
1.38k
    Py_DECREF(value);
10257
1.38k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10258
1.38k
    if (!value) goto failed;
10259
1.38k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10260
0
        goto failed;
10261
1.38k
    Py_DECREF(value);
10262
1.38k
    value = ast2obj_int(state, o->is_async);
10263
1.38k
    if (!value) goto failed;
10264
1.38k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10265
0
        goto failed;
10266
1.38k
    Py_DECREF(value);
10267
1.38k
    Py_LeaveRecursiveCall();
10268
1.38k
    return result;
10269
0
failed:
10270
0
    Py_LeaveRecursiveCall();
10271
0
    Py_XDECREF(value);
10272
0
    Py_XDECREF(result);
10273
0
    return NULL;
10274
1.38k
}
10275
10276
PyObject*
10277
ast2obj_excepthandler(struct ast_state *state, void* _o)
10278
976
{
10279
976
    excepthandler_ty o = (excepthandler_ty)_o;
10280
976
    PyObject *result = NULL, *value = NULL;
10281
976
    PyTypeObject *tp;
10282
976
    if (!o) {
10283
0
        Py_RETURN_NONE;
10284
0
    }
10285
976
    if (Py_EnterRecursiveCall("during  ast construction")) {
10286
0
        return NULL;
10287
0
    }
10288
976
    switch (o->kind) {
10289
976
    case ExceptHandler_kind:
10290
976
        tp = (PyTypeObject *)state->ExceptHandler_type;
10291
976
        result = PyType_GenericNew(tp, NULL, NULL);
10292
976
        if (!result) goto failed;
10293
976
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10294
976
        if (!value) goto failed;
10295
976
        if (PyObject_SetAttr(result, state->type, value) == -1)
10296
0
            goto failed;
10297
976
        Py_DECREF(value);
10298
976
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10299
976
        if (!value) goto failed;
10300
976
        if (PyObject_SetAttr(result, state->name, value) == -1)
10301
0
            goto failed;
10302
976
        Py_DECREF(value);
10303
976
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10304
976
                             ast2obj_stmt);
10305
976
        if (!value) goto failed;
10306
976
        if (PyObject_SetAttr(result, state->body, value) == -1)
10307
0
            goto failed;
10308
976
        Py_DECREF(value);
10309
976
        break;
10310
976
    }
10311
976
    value = ast2obj_int(state, o->lineno);
10312
976
    if (!value) goto failed;
10313
976
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10314
0
        goto failed;
10315
976
    Py_DECREF(value);
10316
976
    value = ast2obj_int(state, o->col_offset);
10317
976
    if (!value) goto failed;
10318
976
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10319
0
        goto failed;
10320
976
    Py_DECREF(value);
10321
976
    value = ast2obj_int(state, o->end_lineno);
10322
976
    if (!value) goto failed;
10323
976
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10324
0
        goto failed;
10325
976
    Py_DECREF(value);
10326
976
    value = ast2obj_int(state, o->end_col_offset);
10327
976
    if (!value) goto failed;
10328
976
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10329
0
        goto failed;
10330
976
    Py_DECREF(value);
10331
976
    Py_LeaveRecursiveCall();
10332
976
    return result;
10333
0
failed:
10334
0
    Py_LeaveRecursiveCall();
10335
0
    Py_XDECREF(value);
10336
0
    Py_XDECREF(result);
10337
0
    return NULL;
10338
976
}
10339
10340
PyObject*
10341
ast2obj_arguments(struct ast_state *state, void* _o)
10342
2.47k
{
10343
2.47k
    arguments_ty o = (arguments_ty)_o;
10344
2.47k
    PyObject *result = NULL, *value = NULL;
10345
2.47k
    PyTypeObject *tp;
10346
2.47k
    if (!o) {
10347
0
        Py_RETURN_NONE;
10348
0
    }
10349
2.47k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10350
0
        return NULL;
10351
0
    }
10352
2.47k
    tp = (PyTypeObject *)state->arguments_type;
10353
2.47k
    result = PyType_GenericNew(tp, NULL, NULL);
10354
2.47k
    if (!result) return NULL;
10355
2.47k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10356
2.47k
    if (!value) goto failed;
10357
2.47k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10358
0
        goto failed;
10359
2.47k
    Py_DECREF(value);
10360
2.47k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10361
2.47k
    if (!value) goto failed;
10362
2.47k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10363
0
        goto failed;
10364
2.47k
    Py_DECREF(value);
10365
2.47k
    value = ast2obj_arg(state, o->vararg);
10366
2.47k
    if (!value) goto failed;
10367
2.47k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10368
0
        goto failed;
10369
2.47k
    Py_DECREF(value);
10370
2.47k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10371
2.47k
    if (!value) goto failed;
10372
2.47k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10373
0
        goto failed;
10374
2.47k
    Py_DECREF(value);
10375
2.47k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10376
2.47k
    if (!value) goto failed;
10377
2.47k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10378
0
        goto failed;
10379
2.47k
    Py_DECREF(value);
10380
2.47k
    value = ast2obj_arg(state, o->kwarg);
10381
2.47k
    if (!value) goto failed;
10382
2.47k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10383
0
        goto failed;
10384
2.47k
    Py_DECREF(value);
10385
2.47k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10386
2.47k
    if (!value) goto failed;
10387
2.47k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10388
0
        goto failed;
10389
2.47k
    Py_DECREF(value);
10390
2.47k
    Py_LeaveRecursiveCall();
10391
2.47k
    return result;
10392
0
failed:
10393
0
    Py_LeaveRecursiveCall();
10394
0
    Py_XDECREF(value);
10395
0
    Py_XDECREF(result);
10396
0
    return NULL;
10397
2.47k
}
10398
10399
PyObject*
10400
ast2obj_arg(struct ast_state *state, void* _o)
10401
13.8k
{
10402
13.8k
    arg_ty o = (arg_ty)_o;
10403
13.8k
    PyObject *result = NULL, *value = NULL;
10404
13.8k
    PyTypeObject *tp;
10405
13.8k
    if (!o) {
10406
4.44k
        Py_RETURN_NONE;
10407
4.44k
    }
10408
9.37k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10409
0
        return NULL;
10410
0
    }
10411
9.37k
    tp = (PyTypeObject *)state->arg_type;
10412
9.37k
    result = PyType_GenericNew(tp, NULL, NULL);
10413
9.37k
    if (!result) return NULL;
10414
9.37k
    value = ast2obj_identifier(state, o->arg);
10415
9.37k
    if (!value) goto failed;
10416
9.37k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10417
0
        goto failed;
10418
9.37k
    Py_DECREF(value);
10419
9.37k
    value = ast2obj_expr(state, o->annotation);
10420
9.37k
    if (!value) goto failed;
10421
9.37k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10422
0
        goto failed;
10423
9.37k
    Py_DECREF(value);
10424
9.37k
    value = ast2obj_string(state, o->type_comment);
10425
9.37k
    if (!value) goto failed;
10426
9.37k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10427
0
        goto failed;
10428
9.37k
    Py_DECREF(value);
10429
9.37k
    value = ast2obj_int(state, o->lineno);
10430
9.37k
    if (!value) goto failed;
10431
9.37k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10432
0
        goto failed;
10433
9.37k
    Py_DECREF(value);
10434
9.37k
    value = ast2obj_int(state, o->col_offset);
10435
9.37k
    if (!value) goto failed;
10436
9.37k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10437
0
        goto failed;
10438
9.37k
    Py_DECREF(value);
10439
9.37k
    value = ast2obj_int(state, o->end_lineno);
10440
9.37k
    if (!value) goto failed;
10441
9.37k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10442
0
        goto failed;
10443
9.37k
    Py_DECREF(value);
10444
9.37k
    value = ast2obj_int(state, o->end_col_offset);
10445
9.37k
    if (!value) goto failed;
10446
9.37k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10447
0
        goto failed;
10448
9.37k
    Py_DECREF(value);
10449
9.37k
    Py_LeaveRecursiveCall();
10450
9.37k
    return result;
10451
0
failed:
10452
0
    Py_LeaveRecursiveCall();
10453
0
    Py_XDECREF(value);
10454
0
    Py_XDECREF(result);
10455
0
    return NULL;
10456
9.37k
}
10457
10458
PyObject*
10459
ast2obj_keyword(struct ast_state *state, void* _o)
10460
1.79k
{
10461
1.79k
    keyword_ty o = (keyword_ty)_o;
10462
1.79k
    PyObject *result = NULL, *value = NULL;
10463
1.79k
    PyTypeObject *tp;
10464
1.79k
    if (!o) {
10465
0
        Py_RETURN_NONE;
10466
0
    }
10467
1.79k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10468
0
        return NULL;
10469
0
    }
10470
1.79k
    tp = (PyTypeObject *)state->keyword_type;
10471
1.79k
    result = PyType_GenericNew(tp, NULL, NULL);
10472
1.79k
    if (!result) return NULL;
10473
1.79k
    value = ast2obj_identifier(state, o->arg);
10474
1.79k
    if (!value) goto failed;
10475
1.79k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10476
0
        goto failed;
10477
1.79k
    Py_DECREF(value);
10478
1.79k
    value = ast2obj_expr(state, o->value);
10479
1.79k
    if (!value) goto failed;
10480
1.79k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10481
0
        goto failed;
10482
1.79k
    Py_DECREF(value);
10483
1.79k
    value = ast2obj_int(state, o->lineno);
10484
1.79k
    if (!value) goto failed;
10485
1.79k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10486
0
        goto failed;
10487
1.79k
    Py_DECREF(value);
10488
1.79k
    value = ast2obj_int(state, o->col_offset);
10489
1.79k
    if (!value) goto failed;
10490
1.79k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10491
0
        goto failed;
10492
1.79k
    Py_DECREF(value);
10493
1.79k
    value = ast2obj_int(state, o->end_lineno);
10494
1.79k
    if (!value) goto failed;
10495
1.79k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10496
0
        goto failed;
10497
1.79k
    Py_DECREF(value);
10498
1.79k
    value = ast2obj_int(state, o->end_col_offset);
10499
1.79k
    if (!value) goto failed;
10500
1.79k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10501
0
        goto failed;
10502
1.79k
    Py_DECREF(value);
10503
1.79k
    Py_LeaveRecursiveCall();
10504
1.79k
    return result;
10505
0
failed:
10506
0
    Py_LeaveRecursiveCall();
10507
0
    Py_XDECREF(value);
10508
0
    Py_XDECREF(result);
10509
0
    return NULL;
10510
1.79k
}
10511
10512
PyObject*
10513
ast2obj_alias(struct ast_state *state, void* _o)
10514
3.92k
{
10515
3.92k
    alias_ty o = (alias_ty)_o;
10516
3.92k
    PyObject *result = NULL, *value = NULL;
10517
3.92k
    PyTypeObject *tp;
10518
3.92k
    if (!o) {
10519
0
        Py_RETURN_NONE;
10520
0
    }
10521
3.92k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10522
0
        return NULL;
10523
0
    }
10524
3.92k
    tp = (PyTypeObject *)state->alias_type;
10525
3.92k
    result = PyType_GenericNew(tp, NULL, NULL);
10526
3.92k
    if (!result) return NULL;
10527
3.92k
    value = ast2obj_identifier(state, o->name);
10528
3.92k
    if (!value) goto failed;
10529
3.92k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10530
0
        goto failed;
10531
3.92k
    Py_DECREF(value);
10532
3.92k
    value = ast2obj_identifier(state, o->asname);
10533
3.92k
    if (!value) goto failed;
10534
3.92k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10535
0
        goto failed;
10536
3.92k
    Py_DECREF(value);
10537
3.92k
    value = ast2obj_int(state, o->lineno);
10538
3.92k
    if (!value) goto failed;
10539
3.92k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10540
0
        goto failed;
10541
3.92k
    Py_DECREF(value);
10542
3.92k
    value = ast2obj_int(state, o->col_offset);
10543
3.92k
    if (!value) goto failed;
10544
3.92k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10545
0
        goto failed;
10546
3.92k
    Py_DECREF(value);
10547
3.92k
    value = ast2obj_int(state, o->end_lineno);
10548
3.92k
    if (!value) goto failed;
10549
3.92k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10550
0
        goto failed;
10551
3.92k
    Py_DECREF(value);
10552
3.92k
    value = ast2obj_int(state, o->end_col_offset);
10553
3.92k
    if (!value) goto failed;
10554
3.92k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10555
0
        goto failed;
10556
3.92k
    Py_DECREF(value);
10557
3.92k
    Py_LeaveRecursiveCall();
10558
3.92k
    return result;
10559
0
failed:
10560
0
    Py_LeaveRecursiveCall();
10561
0
    Py_XDECREF(value);
10562
0
    Py_XDECREF(result);
10563
0
    return NULL;
10564
3.92k
}
10565
10566
PyObject*
10567
ast2obj_withitem(struct ast_state *state, void* _o)
10568
1.08k
{
10569
1.08k
    withitem_ty o = (withitem_ty)_o;
10570
1.08k
    PyObject *result = NULL, *value = NULL;
10571
1.08k
    PyTypeObject *tp;
10572
1.08k
    if (!o) {
10573
0
        Py_RETURN_NONE;
10574
0
    }
10575
1.08k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10576
0
        return NULL;
10577
0
    }
10578
1.08k
    tp = (PyTypeObject *)state->withitem_type;
10579
1.08k
    result = PyType_GenericNew(tp, NULL, NULL);
10580
1.08k
    if (!result) return NULL;
10581
1.08k
    value = ast2obj_expr(state, o->context_expr);
10582
1.08k
    if (!value) goto failed;
10583
1.08k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10584
0
        goto failed;
10585
1.08k
    Py_DECREF(value);
10586
1.08k
    value = ast2obj_expr(state, o->optional_vars);
10587
1.08k
    if (!value) goto failed;
10588
1.08k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10589
0
        goto failed;
10590
1.08k
    Py_DECREF(value);
10591
1.08k
    Py_LeaveRecursiveCall();
10592
1.08k
    return result;
10593
0
failed:
10594
0
    Py_LeaveRecursiveCall();
10595
0
    Py_XDECREF(value);
10596
0
    Py_XDECREF(result);
10597
0
    return NULL;
10598
1.08k
}
10599
10600
PyObject*
10601
ast2obj_match_case(struct ast_state *state, void* _o)
10602
485
{
10603
485
    match_case_ty o = (match_case_ty)_o;
10604
485
    PyObject *result = NULL, *value = NULL;
10605
485
    PyTypeObject *tp;
10606
485
    if (!o) {
10607
0
        Py_RETURN_NONE;
10608
0
    }
10609
485
    if (Py_EnterRecursiveCall("during  ast construction")) {
10610
0
        return NULL;
10611
0
    }
10612
485
    tp = (PyTypeObject *)state->match_case_type;
10613
485
    result = PyType_GenericNew(tp, NULL, NULL);
10614
485
    if (!result) return NULL;
10615
485
    value = ast2obj_pattern(state, o->pattern);
10616
485
    if (!value) goto failed;
10617
485
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10618
0
        goto failed;
10619
485
    Py_DECREF(value);
10620
485
    value = ast2obj_expr(state, o->guard);
10621
485
    if (!value) goto failed;
10622
485
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10623
0
        goto failed;
10624
485
    Py_DECREF(value);
10625
485
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10626
485
    if (!value) goto failed;
10627
485
    if (PyObject_SetAttr(result, state->body, value) == -1)
10628
0
        goto failed;
10629
485
    Py_DECREF(value);
10630
485
    Py_LeaveRecursiveCall();
10631
485
    return result;
10632
0
failed:
10633
0
    Py_LeaveRecursiveCall();
10634
0
    Py_XDECREF(value);
10635
0
    Py_XDECREF(result);
10636
0
    return NULL;
10637
485
}
10638
10639
PyObject*
10640
ast2obj_pattern(struct ast_state *state, void* _o)
10641
17.5k
{
10642
17.5k
    pattern_ty o = (pattern_ty)_o;
10643
17.5k
    PyObject *result = NULL, *value = NULL;
10644
17.5k
    PyTypeObject *tp;
10645
17.5k
    if (!o) {
10646
6.59k
        Py_RETURN_NONE;
10647
6.59k
    }
10648
10.9k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10649
0
        return NULL;
10650
0
    }
10651
10.9k
    switch (o->kind) {
10652
290
    case MatchValue_kind:
10653
290
        tp = (PyTypeObject *)state->MatchValue_type;
10654
290
        result = PyType_GenericNew(tp, NULL, NULL);
10655
290
        if (!result) goto failed;
10656
290
        value = ast2obj_expr(state, o->v.MatchValue.value);
10657
290
        if (!value) goto failed;
10658
290
        if (PyObject_SetAttr(result, state->value, value) == -1)
10659
0
            goto failed;
10660
290
        Py_DECREF(value);
10661
290
        break;
10662
172
    case MatchSingleton_kind:
10663
172
        tp = (PyTypeObject *)state->MatchSingleton_type;
10664
172
        result = PyType_GenericNew(tp, NULL, NULL);
10665
172
        if (!result) goto failed;
10666
172
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10667
172
        if (!value) goto failed;
10668
172
        if (PyObject_SetAttr(result, state->value, value) == -1)
10669
0
            goto failed;
10670
172
        Py_DECREF(value);
10671
172
        break;
10672
353
    case MatchSequence_kind:
10673
353
        tp = (PyTypeObject *)state->MatchSequence_type;
10674
353
        result = PyType_GenericNew(tp, NULL, NULL);
10675
353
        if (!result) goto failed;
10676
353
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10677
353
                             ast2obj_pattern);
10678
353
        if (!value) goto failed;
10679
353
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10680
0
            goto failed;
10681
353
        Py_DECREF(value);
10682
353
        break;
10683
175
    case MatchMapping_kind:
10684
175
        tp = (PyTypeObject *)state->MatchMapping_type;
10685
175
        result = PyType_GenericNew(tp, NULL, NULL);
10686
175
        if (!result) goto failed;
10687
175
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10688
175
                             ast2obj_expr);
10689
175
        if (!value) goto failed;
10690
175
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10691
0
            goto failed;
10692
175
        Py_DECREF(value);
10693
175
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10694
175
                             ast2obj_pattern);
10695
175
        if (!value) goto failed;
10696
175
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10697
0
            goto failed;
10698
175
        Py_DECREF(value);
10699
175
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10700
175
        if (!value) goto failed;
10701
175
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10702
0
            goto failed;
10703
175
        Py_DECREF(value);
10704
175
        break;
10705
1.09k
    case MatchClass_kind:
10706
1.09k
        tp = (PyTypeObject *)state->MatchClass_type;
10707
1.09k
        result = PyType_GenericNew(tp, NULL, NULL);
10708
1.09k
        if (!result) goto failed;
10709
1.09k
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10710
1.09k
        if (!value) goto failed;
10711
1.09k
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10712
0
            goto failed;
10713
1.09k
        Py_DECREF(value);
10714
1.09k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10715
1.09k
                             ast2obj_pattern);
10716
1.09k
        if (!value) goto failed;
10717
1.09k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10718
0
            goto failed;
10719
1.09k
        Py_DECREF(value);
10720
1.09k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10721
1.09k
                             ast2obj_identifier);
10722
1.09k
        if (!value) goto failed;
10723
1.09k
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10724
0
            goto failed;
10725
1.09k
        Py_DECREF(value);
10726
1.09k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10727
1.09k
                             ast2obj_pattern);
10728
1.09k
        if (!value) goto failed;
10729
1.09k
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10730
0
            goto failed;
10731
1.09k
        Py_DECREF(value);
10732
1.09k
        break;
10733
190
    case MatchStar_kind:
10734
190
        tp = (PyTypeObject *)state->MatchStar_type;
10735
190
        result = PyType_GenericNew(tp, NULL, NULL);
10736
190
        if (!result) goto failed;
10737
190
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10738
190
        if (!value) goto failed;
10739
190
        if (PyObject_SetAttr(result, state->name, value) == -1)
10740
0
            goto failed;
10741
190
        Py_DECREF(value);
10742
190
        break;
10743
6.68k
    case MatchAs_kind:
10744
6.68k
        tp = (PyTypeObject *)state->MatchAs_type;
10745
6.68k
        result = PyType_GenericNew(tp, NULL, NULL);
10746
6.68k
        if (!result) goto failed;
10747
6.68k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10748
6.68k
        if (!value) goto failed;
10749
6.68k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10750
0
            goto failed;
10751
6.68k
        Py_DECREF(value);
10752
6.68k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10753
6.68k
        if (!value) goto failed;
10754
6.68k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10755
0
            goto failed;
10756
6.68k
        Py_DECREF(value);
10757
6.68k
        break;
10758
1.95k
    case MatchOr_kind:
10759
1.95k
        tp = (PyTypeObject *)state->MatchOr_type;
10760
1.95k
        result = PyType_GenericNew(tp, NULL, NULL);
10761
1.95k
        if (!result) goto failed;
10762
1.95k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10763
1.95k
                             ast2obj_pattern);
10764
1.95k
        if (!value) goto failed;
10765
1.95k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10766
0
            goto failed;
10767
1.95k
        Py_DECREF(value);
10768
1.95k
        break;
10769
10.9k
    }
10770
10.9k
    value = ast2obj_int(state, o->lineno);
10771
10.9k
    if (!value) goto failed;
10772
10.9k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10773
0
        goto failed;
10774
10.9k
    Py_DECREF(value);
10775
10.9k
    value = ast2obj_int(state, o->col_offset);
10776
10.9k
    if (!value) goto failed;
10777
10.9k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10778
0
        goto failed;
10779
10.9k
    Py_DECREF(value);
10780
10.9k
    value = ast2obj_int(state, o->end_lineno);
10781
10.9k
    if (!value) goto failed;
10782
10.9k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10783
0
        goto failed;
10784
10.9k
    Py_DECREF(value);
10785
10.9k
    value = ast2obj_int(state, o->end_col_offset);
10786
10.9k
    if (!value) goto failed;
10787
10.9k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10788
0
        goto failed;
10789
10.9k
    Py_DECREF(value);
10790
10.9k
    Py_LeaveRecursiveCall();
10791
10.9k
    return result;
10792
0
failed:
10793
0
    Py_LeaveRecursiveCall();
10794
0
    Py_XDECREF(value);
10795
0
    Py_XDECREF(result);
10796
0
    return NULL;
10797
10.9k
}
10798
10799
PyObject*
10800
ast2obj_type_ignore(struct ast_state *state, void* _o)
10801
0
{
10802
0
    type_ignore_ty o = (type_ignore_ty)_o;
10803
0
    PyObject *result = NULL, *value = NULL;
10804
0
    PyTypeObject *tp;
10805
0
    if (!o) {
10806
0
        Py_RETURN_NONE;
10807
0
    }
10808
0
    if (Py_EnterRecursiveCall("during  ast construction")) {
10809
0
        return NULL;
10810
0
    }
10811
0
    switch (o->kind) {
10812
0
    case TypeIgnore_kind:
10813
0
        tp = (PyTypeObject *)state->TypeIgnore_type;
10814
0
        result = PyType_GenericNew(tp, NULL, NULL);
10815
0
        if (!result) goto failed;
10816
0
        value = ast2obj_int(state, o->v.TypeIgnore.lineno);
10817
0
        if (!value) goto failed;
10818
0
        if (PyObject_SetAttr(result, state->lineno, value) == -1)
10819
0
            goto failed;
10820
0
        Py_DECREF(value);
10821
0
        value = ast2obj_string(state, o->v.TypeIgnore.tag);
10822
0
        if (!value) goto failed;
10823
0
        if (PyObject_SetAttr(result, state->tag, value) == -1)
10824
0
            goto failed;
10825
0
        Py_DECREF(value);
10826
0
        break;
10827
0
    }
10828
0
    Py_LeaveRecursiveCall();
10829
0
    return result;
10830
0
failed:
10831
0
    Py_LeaveRecursiveCall();
10832
0
    Py_XDECREF(value);
10833
0
    Py_XDECREF(result);
10834
0
    return NULL;
10835
0
}
10836
10837
PyObject*
10838
ast2obj_type_param(struct ast_state *state, void* _o)
10839
4.70k
{
10840
4.70k
    type_param_ty o = (type_param_ty)_o;
10841
4.70k
    PyObject *result = NULL, *value = NULL;
10842
4.70k
    PyTypeObject *tp;
10843
4.70k
    if (!o) {
10844
0
        Py_RETURN_NONE;
10845
0
    }
10846
4.70k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10847
0
        return NULL;
10848
0
    }
10849
4.70k
    switch (o->kind) {
10850
3.63k
    case TypeVar_kind:
10851
3.63k
        tp = (PyTypeObject *)state->TypeVar_type;
10852
3.63k
        result = PyType_GenericNew(tp, NULL, NULL);
10853
3.63k
        if (!result) goto failed;
10854
3.63k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10855
3.63k
        if (!value) goto failed;
10856
3.63k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10857
0
            goto failed;
10858
3.63k
        Py_DECREF(value);
10859
3.63k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10860
3.63k
        if (!value) goto failed;
10861
3.63k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10862
0
            goto failed;
10863
3.63k
        Py_DECREF(value);
10864
3.63k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10865
3.63k
        if (!value) goto failed;
10866
3.63k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10867
0
            goto failed;
10868
3.63k
        Py_DECREF(value);
10869
3.63k
        break;
10870
375
    case ParamSpec_kind:
10871
375
        tp = (PyTypeObject *)state->ParamSpec_type;
10872
375
        result = PyType_GenericNew(tp, NULL, NULL);
10873
375
        if (!result) goto failed;
10874
375
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10875
375
        if (!value) goto failed;
10876
375
        if (PyObject_SetAttr(result, state->name, value) == -1)
10877
0
            goto failed;
10878
375
        Py_DECREF(value);
10879
375
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10880
375
        if (!value) goto failed;
10881
375
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10882
0
            goto failed;
10883
375
        Py_DECREF(value);
10884
375
        break;
10885
693
    case TypeVarTuple_kind:
10886
693
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10887
693
        result = PyType_GenericNew(tp, NULL, NULL);
10888
693
        if (!result) goto failed;
10889
693
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10890
693
        if (!value) goto failed;
10891
693
        if (PyObject_SetAttr(result, state->name, value) == -1)
10892
0
            goto failed;
10893
693
        Py_DECREF(value);
10894
693
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10895
693
        if (!value) goto failed;
10896
693
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10897
0
            goto failed;
10898
693
        Py_DECREF(value);
10899
693
        break;
10900
4.70k
    }
10901
4.70k
    value = ast2obj_int(state, o->lineno);
10902
4.70k
    if (!value) goto failed;
10903
4.70k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10904
0
        goto failed;
10905
4.70k
    Py_DECREF(value);
10906
4.70k
    value = ast2obj_int(state, o->col_offset);
10907
4.70k
    if (!value) goto failed;
10908
4.70k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10909
0
        goto failed;
10910
4.70k
    Py_DECREF(value);
10911
4.70k
    value = ast2obj_int(state, o->end_lineno);
10912
4.70k
    if (!value) goto failed;
10913
4.70k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10914
0
        goto failed;
10915
4.70k
    Py_DECREF(value);
10916
4.70k
    value = ast2obj_int(state, o->end_col_offset);
10917
4.70k
    if (!value) goto failed;
10918
4.70k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10919
0
        goto failed;
10920
4.70k
    Py_DECREF(value);
10921
4.70k
    Py_LeaveRecursiveCall();
10922
4.70k
    return result;
10923
0
failed:
10924
0
    Py_LeaveRecursiveCall();
10925
0
    Py_XDECREF(value);
10926
0
    Py_XDECREF(result);
10927
0
    return NULL;
10928
4.70k
}
10929
10930
10931
int
10932
obj2ast_mod(struct ast_state *state, PyObject* obj, mod_ty* out, PyArena* arena)
10933
0
{
10934
0
    int isinstance;
10935
10936
0
    PyObject *tmp = NULL;
10937
0
    PyObject *tp;
10938
10939
0
    if (obj == Py_None) {
10940
0
        *out = NULL;
10941
0
        return 0;
10942
0
    }
10943
0
    tp = state->Module_type;
10944
0
    isinstance = PyObject_IsInstance(obj, tp);
10945
0
    if (isinstance == -1) {
10946
0
        return -1;
10947
0
    }
10948
0
    if (isinstance) {
10949
0
        asdl_stmt_seq* body;
10950
0
        asdl_type_ignore_seq* type_ignores;
10951
10952
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
10953
0
            return -1;
10954
0
        }
10955
0
        if (tmp == NULL) {
10956
0
            tmp = PyList_New(0);
10957
0
            if (tmp == NULL) {
10958
0
                return -1;
10959
0
            }
10960
0
        }
10961
0
        {
10962
0
            int res;
10963
0
            Py_ssize_t len;
10964
0
            Py_ssize_t i;
10965
0
            if (!PyList_Check(tmp)) {
10966
0
                PyErr_Format(PyExc_TypeError, "Module field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
10967
0
                goto failed;
10968
0
            }
10969
0
            len = PyList_GET_SIZE(tmp);
10970
0
            body = _Py_asdl_stmt_seq_new(len, arena);
10971
0
            if (body == NULL) goto failed;
10972
0
            for (i = 0; i < len; i++) {
10973
0
                stmt_ty val;
10974
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
10975
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
10976
0
                    goto failed;
10977
0
                }
10978
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
10979
0
                _Py_LeaveRecursiveCall();
10980
0
                Py_DECREF(tmp2);
10981
0
                if (res != 0) goto failed;
10982
0
                if (len != PyList_GET_SIZE(tmp)) {
10983
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"body\" changed size during iteration");
10984
0
                    goto failed;
10985
0
                }
10986
0
                asdl_seq_SET(body, i, val);
10987
0
            }
10988
0
            Py_CLEAR(tmp);
10989
0
        }
10990
0
        if (PyObject_GetOptionalAttr(obj, state->type_ignores, &tmp) < 0) {
10991
0
            return -1;
10992
0
        }
10993
0
        if (tmp == NULL) {
10994
0
            tmp = PyList_New(0);
10995
0
            if (tmp == NULL) {
10996
0
                return -1;
10997
0
            }
10998
0
        }
10999
0
        {
11000
0
            int res;
11001
0
            Py_ssize_t len;
11002
0
            Py_ssize_t i;
11003
0
            if (!PyList_Check(tmp)) {
11004
0
                PyErr_Format(PyExc_TypeError, "Module field \"type_ignores\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11005
0
                goto failed;
11006
0
            }
11007
0
            len = PyList_GET_SIZE(tmp);
11008
0
            type_ignores = _Py_asdl_type_ignore_seq_new(len, arena);
11009
0
            if (type_ignores == NULL) goto failed;
11010
0
            for (i = 0; i < len; i++) {
11011
0
                type_ignore_ty val;
11012
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11013
0
                if (_Py_EnterRecursiveCall(" while traversing 'Module' node")) {
11014
0
                    goto failed;
11015
0
                }
11016
0
                res = obj2ast_type_ignore(state, tmp2, &val, arena);
11017
0
                _Py_LeaveRecursiveCall();
11018
0
                Py_DECREF(tmp2);
11019
0
                if (res != 0) goto failed;
11020
0
                if (len != PyList_GET_SIZE(tmp)) {
11021
0
                    PyErr_SetString(PyExc_RuntimeError, "Module field \"type_ignores\" changed size during iteration");
11022
0
                    goto failed;
11023
0
                }
11024
0
                asdl_seq_SET(type_ignores, i, val);
11025
0
            }
11026
0
            Py_CLEAR(tmp);
11027
0
        }
11028
0
        *out = _PyAST_Module(body, type_ignores, arena);
11029
0
        if (*out == NULL) goto failed;
11030
0
        return 0;
11031
0
    }
11032
0
    tp = state->Interactive_type;
11033
0
    isinstance = PyObject_IsInstance(obj, tp);
11034
0
    if (isinstance == -1) {
11035
0
        return -1;
11036
0
    }
11037
0
    if (isinstance) {
11038
0
        asdl_stmt_seq* body;
11039
11040
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11041
0
            return -1;
11042
0
        }
11043
0
        if (tmp == NULL) {
11044
0
            tmp = PyList_New(0);
11045
0
            if (tmp == NULL) {
11046
0
                return -1;
11047
0
            }
11048
0
        }
11049
0
        {
11050
0
            int res;
11051
0
            Py_ssize_t len;
11052
0
            Py_ssize_t i;
11053
0
            if (!PyList_Check(tmp)) {
11054
0
                PyErr_Format(PyExc_TypeError, "Interactive field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11055
0
                goto failed;
11056
0
            }
11057
0
            len = PyList_GET_SIZE(tmp);
11058
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11059
0
            if (body == NULL) goto failed;
11060
0
            for (i = 0; i < len; i++) {
11061
0
                stmt_ty val;
11062
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11063
0
                if (_Py_EnterRecursiveCall(" while traversing 'Interactive' node")) {
11064
0
                    goto failed;
11065
0
                }
11066
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11067
0
                _Py_LeaveRecursiveCall();
11068
0
                Py_DECREF(tmp2);
11069
0
                if (res != 0) goto failed;
11070
0
                if (len != PyList_GET_SIZE(tmp)) {
11071
0
                    PyErr_SetString(PyExc_RuntimeError, "Interactive field \"body\" changed size during iteration");
11072
0
                    goto failed;
11073
0
                }
11074
0
                asdl_seq_SET(body, i, val);
11075
0
            }
11076
0
            Py_CLEAR(tmp);
11077
0
        }
11078
0
        *out = _PyAST_Interactive(body, arena);
11079
0
        if (*out == NULL) goto failed;
11080
0
        return 0;
11081
0
    }
11082
0
    tp = state->Expression_type;
11083
0
    isinstance = PyObject_IsInstance(obj, tp);
11084
0
    if (isinstance == -1) {
11085
0
        return -1;
11086
0
    }
11087
0
    if (isinstance) {
11088
0
        expr_ty body;
11089
11090
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11091
0
            return -1;
11092
0
        }
11093
0
        if (tmp == NULL) {
11094
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
11095
0
            return -1;
11096
0
        }
11097
0
        else {
11098
0
            int res;
11099
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expression' node")) {
11100
0
                goto failed;
11101
0
            }
11102
0
            res = obj2ast_expr(state, tmp, &body, arena);
11103
0
            _Py_LeaveRecursiveCall();
11104
0
            if (res != 0) goto failed;
11105
0
            Py_CLEAR(tmp);
11106
0
        }
11107
0
        *out = _PyAST_Expression(body, arena);
11108
0
        if (*out == NULL) goto failed;
11109
0
        return 0;
11110
0
    }
11111
0
    tp = state->FunctionType_type;
11112
0
    isinstance = PyObject_IsInstance(obj, tp);
11113
0
    if (isinstance == -1) {
11114
0
        return -1;
11115
0
    }
11116
0
    if (isinstance) {
11117
0
        asdl_expr_seq* argtypes;
11118
0
        expr_ty returns;
11119
11120
0
        if (PyObject_GetOptionalAttr(obj, state->argtypes, &tmp) < 0) {
11121
0
            return -1;
11122
0
        }
11123
0
        if (tmp == NULL) {
11124
0
            tmp = PyList_New(0);
11125
0
            if (tmp == NULL) {
11126
0
                return -1;
11127
0
            }
11128
0
        }
11129
0
        {
11130
0
            int res;
11131
0
            Py_ssize_t len;
11132
0
            Py_ssize_t i;
11133
0
            if (!PyList_Check(tmp)) {
11134
0
                PyErr_Format(PyExc_TypeError, "FunctionType field \"argtypes\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11135
0
                goto failed;
11136
0
            }
11137
0
            len = PyList_GET_SIZE(tmp);
11138
0
            argtypes = _Py_asdl_expr_seq_new(len, arena);
11139
0
            if (argtypes == NULL) goto failed;
11140
0
            for (i = 0; i < len; i++) {
11141
0
                expr_ty val;
11142
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11143
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11144
0
                    goto failed;
11145
0
                }
11146
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11147
0
                _Py_LeaveRecursiveCall();
11148
0
                Py_DECREF(tmp2);
11149
0
                if (res != 0) goto failed;
11150
0
                if (len != PyList_GET_SIZE(tmp)) {
11151
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionType field \"argtypes\" changed size during iteration");
11152
0
                    goto failed;
11153
0
                }
11154
0
                asdl_seq_SET(argtypes, i, val);
11155
0
            }
11156
0
            Py_CLEAR(tmp);
11157
0
        }
11158
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11159
0
            return -1;
11160
0
        }
11161
0
        if (tmp == NULL) {
11162
0
            PyErr_SetString(PyExc_TypeError, "required field \"returns\" missing from FunctionType");
11163
0
            return -1;
11164
0
        }
11165
0
        else {
11166
0
            int res;
11167
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionType' node")) {
11168
0
                goto failed;
11169
0
            }
11170
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11171
0
            _Py_LeaveRecursiveCall();
11172
0
            if (res != 0) goto failed;
11173
0
            Py_CLEAR(tmp);
11174
0
        }
11175
0
        *out = _PyAST_FunctionType(argtypes, returns, arena);
11176
0
        if (*out == NULL) goto failed;
11177
0
        return 0;
11178
0
    }
11179
11180
0
    PyErr_Format(PyExc_TypeError, "expected some sort of mod, but got %R", obj);
11181
0
    failed:
11182
0
    Py_XDECREF(tmp);
11183
0
    return -1;
11184
0
}
11185
11186
int
11187
obj2ast_stmt(struct ast_state *state, PyObject* obj, stmt_ty* out, PyArena*
11188
             arena)
11189
0
{
11190
0
    int isinstance;
11191
11192
0
    PyObject *tmp = NULL;
11193
0
    PyObject *tp;
11194
0
    int lineno;
11195
0
    int col_offset;
11196
0
    int end_lineno;
11197
0
    int end_col_offset;
11198
11199
0
    if (obj == Py_None) {
11200
0
        *out = NULL;
11201
0
        return 0;
11202
0
    }
11203
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
11204
0
        return -1;
11205
0
    }
11206
0
    if (tmp == NULL) {
11207
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
11208
0
        return -1;
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, &lineno, arena);
11216
0
        _Py_LeaveRecursiveCall();
11217
0
        if (res != 0) goto failed;
11218
0
        Py_CLEAR(tmp);
11219
0
    }
11220
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
11221
0
        return -1;
11222
0
    }
11223
0
    if (tmp == NULL) {
11224
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
11225
0
        return -1;
11226
0
    }
11227
0
    else {
11228
0
        int res;
11229
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11230
0
            goto failed;
11231
0
        }
11232
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
11233
0
        _Py_LeaveRecursiveCall();
11234
0
        if (res != 0) goto failed;
11235
0
        Py_CLEAR(tmp);
11236
0
    }
11237
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
11238
0
        return -1;
11239
0
    }
11240
0
    if (tmp == NULL || tmp == Py_None) {
11241
0
        Py_CLEAR(tmp);
11242
0
        end_lineno = lineno;
11243
0
    }
11244
0
    else {
11245
0
        int res;
11246
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11247
0
            goto failed;
11248
0
        }
11249
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
11250
0
        _Py_LeaveRecursiveCall();
11251
0
        if (res != 0) goto failed;
11252
0
        Py_CLEAR(tmp);
11253
0
    }
11254
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
11255
0
        return -1;
11256
0
    }
11257
0
    if (tmp == NULL || tmp == Py_None) {
11258
0
        Py_CLEAR(tmp);
11259
0
        end_col_offset = col_offset;
11260
0
    }
11261
0
    else {
11262
0
        int res;
11263
0
        if (_Py_EnterRecursiveCall(" while traversing 'stmt' node")) {
11264
0
            goto failed;
11265
0
        }
11266
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
11267
0
        _Py_LeaveRecursiveCall();
11268
0
        if (res != 0) goto failed;
11269
0
        Py_CLEAR(tmp);
11270
0
    }
11271
0
    tp = state->FunctionDef_type;
11272
0
    isinstance = PyObject_IsInstance(obj, tp);
11273
0
    if (isinstance == -1) {
11274
0
        return -1;
11275
0
    }
11276
0
    if (isinstance) {
11277
0
        identifier name;
11278
0
        arguments_ty args;
11279
0
        asdl_stmt_seq* body;
11280
0
        asdl_expr_seq* decorator_list;
11281
0
        expr_ty returns;
11282
0
        string type_comment;
11283
0
        asdl_type_param_seq* type_params;
11284
11285
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11286
0
            return -1;
11287
0
        }
11288
0
        if (tmp == NULL) {
11289
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
11290
0
            return -1;
11291
0
        }
11292
0
        else {
11293
0
            int res;
11294
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11295
0
                goto failed;
11296
0
            }
11297
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11298
0
            _Py_LeaveRecursiveCall();
11299
0
            if (res != 0) goto failed;
11300
0
            Py_CLEAR(tmp);
11301
0
        }
11302
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11303
0
            return -1;
11304
0
        }
11305
0
        if (tmp == NULL) {
11306
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
11307
0
            return -1;
11308
0
        }
11309
0
        else {
11310
0
            int res;
11311
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11312
0
                goto failed;
11313
0
            }
11314
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11315
0
            _Py_LeaveRecursiveCall();
11316
0
            if (res != 0) goto failed;
11317
0
            Py_CLEAR(tmp);
11318
0
        }
11319
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11320
0
            return -1;
11321
0
        }
11322
0
        if (tmp == NULL) {
11323
0
            tmp = PyList_New(0);
11324
0
            if (tmp == NULL) {
11325
0
                return -1;
11326
0
            }
11327
0
        }
11328
0
        {
11329
0
            int res;
11330
0
            Py_ssize_t len;
11331
0
            Py_ssize_t i;
11332
0
            if (!PyList_Check(tmp)) {
11333
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11334
0
                goto failed;
11335
0
            }
11336
0
            len = PyList_GET_SIZE(tmp);
11337
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11338
0
            if (body == NULL) goto failed;
11339
0
            for (i = 0; i < len; i++) {
11340
0
                stmt_ty val;
11341
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11342
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11343
0
                    goto failed;
11344
0
                }
11345
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11346
0
                _Py_LeaveRecursiveCall();
11347
0
                Py_DECREF(tmp2);
11348
0
                if (res != 0) goto failed;
11349
0
                if (len != PyList_GET_SIZE(tmp)) {
11350
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"body\" changed size during iteration");
11351
0
                    goto failed;
11352
0
                }
11353
0
                asdl_seq_SET(body, i, val);
11354
0
            }
11355
0
            Py_CLEAR(tmp);
11356
0
        }
11357
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11358
0
            return -1;
11359
0
        }
11360
0
        if (tmp == NULL) {
11361
0
            tmp = PyList_New(0);
11362
0
            if (tmp == NULL) {
11363
0
                return -1;
11364
0
            }
11365
0
        }
11366
0
        {
11367
0
            int res;
11368
0
            Py_ssize_t len;
11369
0
            Py_ssize_t i;
11370
0
            if (!PyList_Check(tmp)) {
11371
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11372
0
                goto failed;
11373
0
            }
11374
0
            len = PyList_GET_SIZE(tmp);
11375
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11376
0
            if (decorator_list == NULL) goto failed;
11377
0
            for (i = 0; i < len; i++) {
11378
0
                expr_ty val;
11379
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11380
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11381
0
                    goto failed;
11382
0
                }
11383
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11384
0
                _Py_LeaveRecursiveCall();
11385
0
                Py_DECREF(tmp2);
11386
0
                if (res != 0) goto failed;
11387
0
                if (len != PyList_GET_SIZE(tmp)) {
11388
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"decorator_list\" changed size during iteration");
11389
0
                    goto failed;
11390
0
                }
11391
0
                asdl_seq_SET(decorator_list, i, val);
11392
0
            }
11393
0
            Py_CLEAR(tmp);
11394
0
        }
11395
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11396
0
            return -1;
11397
0
        }
11398
0
        if (tmp == NULL || tmp == Py_None) {
11399
0
            Py_CLEAR(tmp);
11400
0
            returns = NULL;
11401
0
        }
11402
0
        else {
11403
0
            int res;
11404
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11405
0
                goto failed;
11406
0
            }
11407
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11408
0
            _Py_LeaveRecursiveCall();
11409
0
            if (res != 0) goto failed;
11410
0
            Py_CLEAR(tmp);
11411
0
        }
11412
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11413
0
            return -1;
11414
0
        }
11415
0
        if (tmp == NULL || tmp == Py_None) {
11416
0
            Py_CLEAR(tmp);
11417
0
            type_comment = NULL;
11418
0
        }
11419
0
        else {
11420
0
            int res;
11421
0
            if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11422
0
                goto failed;
11423
0
            }
11424
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11425
0
            _Py_LeaveRecursiveCall();
11426
0
            if (res != 0) goto failed;
11427
0
            Py_CLEAR(tmp);
11428
0
        }
11429
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11430
0
            return -1;
11431
0
        }
11432
0
        if (tmp == NULL) {
11433
0
            tmp = PyList_New(0);
11434
0
            if (tmp == NULL) {
11435
0
                return -1;
11436
0
            }
11437
0
        }
11438
0
        {
11439
0
            int res;
11440
0
            Py_ssize_t len;
11441
0
            Py_ssize_t i;
11442
0
            if (!PyList_Check(tmp)) {
11443
0
                PyErr_Format(PyExc_TypeError, "FunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11444
0
                goto failed;
11445
0
            }
11446
0
            len = PyList_GET_SIZE(tmp);
11447
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11448
0
            if (type_params == NULL) goto failed;
11449
0
            for (i = 0; i < len; i++) {
11450
0
                type_param_ty val;
11451
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11452
0
                if (_Py_EnterRecursiveCall(" while traversing 'FunctionDef' node")) {
11453
0
                    goto failed;
11454
0
                }
11455
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11456
0
                _Py_LeaveRecursiveCall();
11457
0
                Py_DECREF(tmp2);
11458
0
                if (res != 0) goto failed;
11459
0
                if (len != PyList_GET_SIZE(tmp)) {
11460
0
                    PyErr_SetString(PyExc_RuntimeError, "FunctionDef field \"type_params\" changed size during iteration");
11461
0
                    goto failed;
11462
0
                }
11463
0
                asdl_seq_SET(type_params, i, val);
11464
0
            }
11465
0
            Py_CLEAR(tmp);
11466
0
        }
11467
0
        *out = _PyAST_FunctionDef(name, args, body, decorator_list, returns,
11468
0
                                  type_comment, type_params, lineno,
11469
0
                                  col_offset, end_lineno, end_col_offset,
11470
0
                                  arena);
11471
0
        if (*out == NULL) goto failed;
11472
0
        return 0;
11473
0
    }
11474
0
    tp = state->AsyncFunctionDef_type;
11475
0
    isinstance = PyObject_IsInstance(obj, tp);
11476
0
    if (isinstance == -1) {
11477
0
        return -1;
11478
0
    }
11479
0
    if (isinstance) {
11480
0
        identifier name;
11481
0
        arguments_ty args;
11482
0
        asdl_stmt_seq* body;
11483
0
        asdl_expr_seq* decorator_list;
11484
0
        expr_ty returns;
11485
0
        string type_comment;
11486
0
        asdl_type_param_seq* type_params;
11487
11488
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11489
0
            return -1;
11490
0
        }
11491
0
        if (tmp == NULL) {
11492
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from AsyncFunctionDef");
11493
0
            return -1;
11494
0
        }
11495
0
        else {
11496
0
            int res;
11497
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11498
0
                goto failed;
11499
0
            }
11500
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11501
0
            _Py_LeaveRecursiveCall();
11502
0
            if (res != 0) goto failed;
11503
0
            Py_CLEAR(tmp);
11504
0
        }
11505
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
11506
0
            return -1;
11507
0
        }
11508
0
        if (tmp == NULL) {
11509
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from AsyncFunctionDef");
11510
0
            return -1;
11511
0
        }
11512
0
        else {
11513
0
            int res;
11514
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11515
0
                goto failed;
11516
0
            }
11517
0
            res = obj2ast_arguments(state, tmp, &args, arena);
11518
0
            _Py_LeaveRecursiveCall();
11519
0
            if (res != 0) goto failed;
11520
0
            Py_CLEAR(tmp);
11521
0
        }
11522
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11523
0
            return -1;
11524
0
        }
11525
0
        if (tmp == NULL) {
11526
0
            tmp = PyList_New(0);
11527
0
            if (tmp == NULL) {
11528
0
                return -1;
11529
0
            }
11530
0
        }
11531
0
        {
11532
0
            int res;
11533
0
            Py_ssize_t len;
11534
0
            Py_ssize_t i;
11535
0
            if (!PyList_Check(tmp)) {
11536
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11537
0
                goto failed;
11538
0
            }
11539
0
            len = PyList_GET_SIZE(tmp);
11540
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11541
0
            if (body == NULL) goto failed;
11542
0
            for (i = 0; i < len; i++) {
11543
0
                stmt_ty val;
11544
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11545
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11546
0
                    goto failed;
11547
0
                }
11548
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11549
0
                _Py_LeaveRecursiveCall();
11550
0
                Py_DECREF(tmp2);
11551
0
                if (res != 0) goto failed;
11552
0
                if (len != PyList_GET_SIZE(tmp)) {
11553
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"body\" changed size during iteration");
11554
0
                    goto failed;
11555
0
                }
11556
0
                asdl_seq_SET(body, i, val);
11557
0
            }
11558
0
            Py_CLEAR(tmp);
11559
0
        }
11560
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11561
0
            return -1;
11562
0
        }
11563
0
        if (tmp == NULL) {
11564
0
            tmp = PyList_New(0);
11565
0
            if (tmp == NULL) {
11566
0
                return -1;
11567
0
            }
11568
0
        }
11569
0
        {
11570
0
            int res;
11571
0
            Py_ssize_t len;
11572
0
            Py_ssize_t i;
11573
0
            if (!PyList_Check(tmp)) {
11574
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11575
0
                goto failed;
11576
0
            }
11577
0
            len = PyList_GET_SIZE(tmp);
11578
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11579
0
            if (decorator_list == NULL) goto failed;
11580
0
            for (i = 0; i < len; i++) {
11581
0
                expr_ty val;
11582
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11583
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11584
0
                    goto failed;
11585
0
                }
11586
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11587
0
                _Py_LeaveRecursiveCall();
11588
0
                Py_DECREF(tmp2);
11589
0
                if (res != 0) goto failed;
11590
0
                if (len != PyList_GET_SIZE(tmp)) {
11591
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"decorator_list\" changed size during iteration");
11592
0
                    goto failed;
11593
0
                }
11594
0
                asdl_seq_SET(decorator_list, i, val);
11595
0
            }
11596
0
            Py_CLEAR(tmp);
11597
0
        }
11598
0
        if (PyObject_GetOptionalAttr(obj, state->returns, &tmp) < 0) {
11599
0
            return -1;
11600
0
        }
11601
0
        if (tmp == NULL || tmp == Py_None) {
11602
0
            Py_CLEAR(tmp);
11603
0
            returns = NULL;
11604
0
        }
11605
0
        else {
11606
0
            int res;
11607
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11608
0
                goto failed;
11609
0
            }
11610
0
            res = obj2ast_expr(state, tmp, &returns, arena);
11611
0
            _Py_LeaveRecursiveCall();
11612
0
            if (res != 0) goto failed;
11613
0
            Py_CLEAR(tmp);
11614
0
        }
11615
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
11616
0
            return -1;
11617
0
        }
11618
0
        if (tmp == NULL || tmp == Py_None) {
11619
0
            Py_CLEAR(tmp);
11620
0
            type_comment = NULL;
11621
0
        }
11622
0
        else {
11623
0
            int res;
11624
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11625
0
                goto failed;
11626
0
            }
11627
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
11628
0
            _Py_LeaveRecursiveCall();
11629
0
            if (res != 0) goto failed;
11630
0
            Py_CLEAR(tmp);
11631
0
        }
11632
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11633
0
            return -1;
11634
0
        }
11635
0
        if (tmp == NULL) {
11636
0
            tmp = PyList_New(0);
11637
0
            if (tmp == NULL) {
11638
0
                return -1;
11639
0
            }
11640
0
        }
11641
0
        {
11642
0
            int res;
11643
0
            Py_ssize_t len;
11644
0
            Py_ssize_t i;
11645
0
            if (!PyList_Check(tmp)) {
11646
0
                PyErr_Format(PyExc_TypeError, "AsyncFunctionDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11647
0
                goto failed;
11648
0
            }
11649
0
            len = PyList_GET_SIZE(tmp);
11650
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11651
0
            if (type_params == NULL) goto failed;
11652
0
            for (i = 0; i < len; i++) {
11653
0
                type_param_ty val;
11654
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11655
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFunctionDef' node")) {
11656
0
                    goto failed;
11657
0
                }
11658
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11659
0
                _Py_LeaveRecursiveCall();
11660
0
                Py_DECREF(tmp2);
11661
0
                if (res != 0) goto failed;
11662
0
                if (len != PyList_GET_SIZE(tmp)) {
11663
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFunctionDef field \"type_params\" changed size during iteration");
11664
0
                    goto failed;
11665
0
                }
11666
0
                asdl_seq_SET(type_params, i, val);
11667
0
            }
11668
0
            Py_CLEAR(tmp);
11669
0
        }
11670
0
        *out = _PyAST_AsyncFunctionDef(name, args, body, decorator_list,
11671
0
                                       returns, type_comment, type_params,
11672
0
                                       lineno, col_offset, end_lineno,
11673
0
                                       end_col_offset, arena);
11674
0
        if (*out == NULL) goto failed;
11675
0
        return 0;
11676
0
    }
11677
0
    tp = state->ClassDef_type;
11678
0
    isinstance = PyObject_IsInstance(obj, tp);
11679
0
    if (isinstance == -1) {
11680
0
        return -1;
11681
0
    }
11682
0
    if (isinstance) {
11683
0
        identifier name;
11684
0
        asdl_expr_seq* bases;
11685
0
        asdl_keyword_seq* keywords;
11686
0
        asdl_stmt_seq* body;
11687
0
        asdl_expr_seq* decorator_list;
11688
0
        asdl_type_param_seq* type_params;
11689
11690
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
11691
0
            return -1;
11692
0
        }
11693
0
        if (tmp == NULL) {
11694
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
11695
0
            return -1;
11696
0
        }
11697
0
        else {
11698
0
            int res;
11699
0
            if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11700
0
                goto failed;
11701
0
            }
11702
0
            res = obj2ast_identifier(state, tmp, &name, arena);
11703
0
            _Py_LeaveRecursiveCall();
11704
0
            if (res != 0) goto failed;
11705
0
            Py_CLEAR(tmp);
11706
0
        }
11707
0
        if (PyObject_GetOptionalAttr(obj, state->bases, &tmp) < 0) {
11708
0
            return -1;
11709
0
        }
11710
0
        if (tmp == NULL) {
11711
0
            tmp = PyList_New(0);
11712
0
            if (tmp == NULL) {
11713
0
                return -1;
11714
0
            }
11715
0
        }
11716
0
        {
11717
0
            int res;
11718
0
            Py_ssize_t len;
11719
0
            Py_ssize_t i;
11720
0
            if (!PyList_Check(tmp)) {
11721
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"bases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11722
0
                goto failed;
11723
0
            }
11724
0
            len = PyList_GET_SIZE(tmp);
11725
0
            bases = _Py_asdl_expr_seq_new(len, arena);
11726
0
            if (bases == NULL) goto failed;
11727
0
            for (i = 0; i < len; i++) {
11728
0
                expr_ty val;
11729
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11730
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11731
0
                    goto failed;
11732
0
                }
11733
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11734
0
                _Py_LeaveRecursiveCall();
11735
0
                Py_DECREF(tmp2);
11736
0
                if (res != 0) goto failed;
11737
0
                if (len != PyList_GET_SIZE(tmp)) {
11738
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"bases\" changed size during iteration");
11739
0
                    goto failed;
11740
0
                }
11741
0
                asdl_seq_SET(bases, i, val);
11742
0
            }
11743
0
            Py_CLEAR(tmp);
11744
0
        }
11745
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
11746
0
            return -1;
11747
0
        }
11748
0
        if (tmp == NULL) {
11749
0
            tmp = PyList_New(0);
11750
0
            if (tmp == NULL) {
11751
0
                return -1;
11752
0
            }
11753
0
        }
11754
0
        {
11755
0
            int res;
11756
0
            Py_ssize_t len;
11757
0
            Py_ssize_t i;
11758
0
            if (!PyList_Check(tmp)) {
11759
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11760
0
                goto failed;
11761
0
            }
11762
0
            len = PyList_GET_SIZE(tmp);
11763
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
11764
0
            if (keywords == NULL) goto failed;
11765
0
            for (i = 0; i < len; i++) {
11766
0
                keyword_ty val;
11767
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11768
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11769
0
                    goto failed;
11770
0
                }
11771
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
11772
0
                _Py_LeaveRecursiveCall();
11773
0
                Py_DECREF(tmp2);
11774
0
                if (res != 0) goto failed;
11775
0
                if (len != PyList_GET_SIZE(tmp)) {
11776
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"keywords\" changed size during iteration");
11777
0
                    goto failed;
11778
0
                }
11779
0
                asdl_seq_SET(keywords, i, val);
11780
0
            }
11781
0
            Py_CLEAR(tmp);
11782
0
        }
11783
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
11784
0
            return -1;
11785
0
        }
11786
0
        if (tmp == NULL) {
11787
0
            tmp = PyList_New(0);
11788
0
            if (tmp == NULL) {
11789
0
                return -1;
11790
0
            }
11791
0
        }
11792
0
        {
11793
0
            int res;
11794
0
            Py_ssize_t len;
11795
0
            Py_ssize_t i;
11796
0
            if (!PyList_Check(tmp)) {
11797
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11798
0
                goto failed;
11799
0
            }
11800
0
            len = PyList_GET_SIZE(tmp);
11801
0
            body = _Py_asdl_stmt_seq_new(len, arena);
11802
0
            if (body == NULL) goto failed;
11803
0
            for (i = 0; i < len; i++) {
11804
0
                stmt_ty val;
11805
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11806
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11807
0
                    goto failed;
11808
0
                }
11809
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
11810
0
                _Py_LeaveRecursiveCall();
11811
0
                Py_DECREF(tmp2);
11812
0
                if (res != 0) goto failed;
11813
0
                if (len != PyList_GET_SIZE(tmp)) {
11814
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"body\" changed size during iteration");
11815
0
                    goto failed;
11816
0
                }
11817
0
                asdl_seq_SET(body, i, val);
11818
0
            }
11819
0
            Py_CLEAR(tmp);
11820
0
        }
11821
0
        if (PyObject_GetOptionalAttr(obj, state->decorator_list, &tmp) < 0) {
11822
0
            return -1;
11823
0
        }
11824
0
        if (tmp == NULL) {
11825
0
            tmp = PyList_New(0);
11826
0
            if (tmp == NULL) {
11827
0
                return -1;
11828
0
            }
11829
0
        }
11830
0
        {
11831
0
            int res;
11832
0
            Py_ssize_t len;
11833
0
            Py_ssize_t i;
11834
0
            if (!PyList_Check(tmp)) {
11835
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"decorator_list\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11836
0
                goto failed;
11837
0
            }
11838
0
            len = PyList_GET_SIZE(tmp);
11839
0
            decorator_list = _Py_asdl_expr_seq_new(len, arena);
11840
0
            if (decorator_list == NULL) goto failed;
11841
0
            for (i = 0; i < len; i++) {
11842
0
                expr_ty val;
11843
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11844
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11845
0
                    goto failed;
11846
0
                }
11847
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11848
0
                _Py_LeaveRecursiveCall();
11849
0
                Py_DECREF(tmp2);
11850
0
                if (res != 0) goto failed;
11851
0
                if (len != PyList_GET_SIZE(tmp)) {
11852
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"decorator_list\" changed size during iteration");
11853
0
                    goto failed;
11854
0
                }
11855
0
                asdl_seq_SET(decorator_list, i, val);
11856
0
            }
11857
0
            Py_CLEAR(tmp);
11858
0
        }
11859
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
11860
0
            return -1;
11861
0
        }
11862
0
        if (tmp == NULL) {
11863
0
            tmp = PyList_New(0);
11864
0
            if (tmp == NULL) {
11865
0
                return -1;
11866
0
            }
11867
0
        }
11868
0
        {
11869
0
            int res;
11870
0
            Py_ssize_t len;
11871
0
            Py_ssize_t i;
11872
0
            if (!PyList_Check(tmp)) {
11873
0
                PyErr_Format(PyExc_TypeError, "ClassDef field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11874
0
                goto failed;
11875
0
            }
11876
0
            len = PyList_GET_SIZE(tmp);
11877
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
11878
0
            if (type_params == NULL) goto failed;
11879
0
            for (i = 0; i < len; i++) {
11880
0
                type_param_ty val;
11881
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11882
0
                if (_Py_EnterRecursiveCall(" while traversing 'ClassDef' node")) {
11883
0
                    goto failed;
11884
0
                }
11885
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
11886
0
                _Py_LeaveRecursiveCall();
11887
0
                Py_DECREF(tmp2);
11888
0
                if (res != 0) goto failed;
11889
0
                if (len != PyList_GET_SIZE(tmp)) {
11890
0
                    PyErr_SetString(PyExc_RuntimeError, "ClassDef field \"type_params\" changed size during iteration");
11891
0
                    goto failed;
11892
0
                }
11893
0
                asdl_seq_SET(type_params, i, val);
11894
0
            }
11895
0
            Py_CLEAR(tmp);
11896
0
        }
11897
0
        *out = _PyAST_ClassDef(name, bases, keywords, body, decorator_list,
11898
0
                               type_params, lineno, col_offset, end_lineno,
11899
0
                               end_col_offset, arena);
11900
0
        if (*out == NULL) goto failed;
11901
0
        return 0;
11902
0
    }
11903
0
    tp = state->Return_type;
11904
0
    isinstance = PyObject_IsInstance(obj, tp);
11905
0
    if (isinstance == -1) {
11906
0
        return -1;
11907
0
    }
11908
0
    if (isinstance) {
11909
0
        expr_ty value;
11910
11911
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
11912
0
            return -1;
11913
0
        }
11914
0
        if (tmp == NULL || tmp == Py_None) {
11915
0
            Py_CLEAR(tmp);
11916
0
            value = NULL;
11917
0
        }
11918
0
        else {
11919
0
            int res;
11920
0
            if (_Py_EnterRecursiveCall(" while traversing 'Return' node")) {
11921
0
                goto failed;
11922
0
            }
11923
0
            res = obj2ast_expr(state, tmp, &value, arena);
11924
0
            _Py_LeaveRecursiveCall();
11925
0
            if (res != 0) goto failed;
11926
0
            Py_CLEAR(tmp);
11927
0
        }
11928
0
        *out = _PyAST_Return(value, 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->Delete_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
11941
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11942
0
            return -1;
11943
0
        }
11944
0
        if (tmp == NULL) {
11945
0
            tmp = PyList_New(0);
11946
0
            if (tmp == NULL) {
11947
0
                return -1;
11948
0
            }
11949
0
        }
11950
0
        {
11951
0
            int res;
11952
0
            Py_ssize_t len;
11953
0
            Py_ssize_t i;
11954
0
            if (!PyList_Check(tmp)) {
11955
0
                PyErr_Format(PyExc_TypeError, "Delete field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
11956
0
                goto failed;
11957
0
            }
11958
0
            len = PyList_GET_SIZE(tmp);
11959
0
            targets = _Py_asdl_expr_seq_new(len, arena);
11960
0
            if (targets == NULL) goto failed;
11961
0
            for (i = 0; i < len; i++) {
11962
0
                expr_ty val;
11963
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
11964
0
                if (_Py_EnterRecursiveCall(" while traversing 'Delete' node")) {
11965
0
                    goto failed;
11966
0
                }
11967
0
                res = obj2ast_expr(state, tmp2, &val, arena);
11968
0
                _Py_LeaveRecursiveCall();
11969
0
                Py_DECREF(tmp2);
11970
0
                if (res != 0) goto failed;
11971
0
                if (len != PyList_GET_SIZE(tmp)) {
11972
0
                    PyErr_SetString(PyExc_RuntimeError, "Delete field \"targets\" changed size during iteration");
11973
0
                    goto failed;
11974
0
                }
11975
0
                asdl_seq_SET(targets, i, val);
11976
0
            }
11977
0
            Py_CLEAR(tmp);
11978
0
        }
11979
0
        *out = _PyAST_Delete(targets, lineno, col_offset, end_lineno,
11980
0
                             end_col_offset, arena);
11981
0
        if (*out == NULL) goto failed;
11982
0
        return 0;
11983
0
    }
11984
0
    tp = state->Assign_type;
11985
0
    isinstance = PyObject_IsInstance(obj, tp);
11986
0
    if (isinstance == -1) {
11987
0
        return -1;
11988
0
    }
11989
0
    if (isinstance) {
11990
0
        asdl_expr_seq* targets;
11991
0
        expr_ty value;
11992
0
        string type_comment;
11993
11994
0
        if (PyObject_GetOptionalAttr(obj, state->targets, &tmp) < 0) {
11995
0
            return -1;
11996
0
        }
11997
0
        if (tmp == NULL) {
11998
0
            tmp = PyList_New(0);
11999
0
            if (tmp == NULL) {
12000
0
                return -1;
12001
0
            }
12002
0
        }
12003
0
        {
12004
0
            int res;
12005
0
            Py_ssize_t len;
12006
0
            Py_ssize_t i;
12007
0
            if (!PyList_Check(tmp)) {
12008
0
                PyErr_Format(PyExc_TypeError, "Assign field \"targets\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12009
0
                goto failed;
12010
0
            }
12011
0
            len = PyList_GET_SIZE(tmp);
12012
0
            targets = _Py_asdl_expr_seq_new(len, arena);
12013
0
            if (targets == NULL) goto failed;
12014
0
            for (i = 0; i < len; i++) {
12015
0
                expr_ty val;
12016
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12017
0
                if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12018
0
                    goto failed;
12019
0
                }
12020
0
                res = obj2ast_expr(state, tmp2, &val, arena);
12021
0
                _Py_LeaveRecursiveCall();
12022
0
                Py_DECREF(tmp2);
12023
0
                if (res != 0) goto failed;
12024
0
                if (len != PyList_GET_SIZE(tmp)) {
12025
0
                    PyErr_SetString(PyExc_RuntimeError, "Assign field \"targets\" changed size during iteration");
12026
0
                    goto failed;
12027
0
                }
12028
0
                asdl_seq_SET(targets, i, val);
12029
0
            }
12030
0
            Py_CLEAR(tmp);
12031
0
        }
12032
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12033
0
            return -1;
12034
0
        }
12035
0
        if (tmp == NULL) {
12036
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
12037
0
            return -1;
12038
0
        }
12039
0
        else {
12040
0
            int res;
12041
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12042
0
                goto failed;
12043
0
            }
12044
0
            res = obj2ast_expr(state, tmp, &value, arena);
12045
0
            _Py_LeaveRecursiveCall();
12046
0
            if (res != 0) goto failed;
12047
0
            Py_CLEAR(tmp);
12048
0
        }
12049
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12050
0
            return -1;
12051
0
        }
12052
0
        if (tmp == NULL || tmp == Py_None) {
12053
0
            Py_CLEAR(tmp);
12054
0
            type_comment = NULL;
12055
0
        }
12056
0
        else {
12057
0
            int res;
12058
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assign' node")) {
12059
0
                goto failed;
12060
0
            }
12061
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12062
0
            _Py_LeaveRecursiveCall();
12063
0
            if (res != 0) goto failed;
12064
0
            Py_CLEAR(tmp);
12065
0
        }
12066
0
        *out = _PyAST_Assign(targets, value, type_comment, lineno, col_offset,
12067
0
                             end_lineno, end_col_offset, arena);
12068
0
        if (*out == NULL) goto failed;
12069
0
        return 0;
12070
0
    }
12071
0
    tp = state->TypeAlias_type;
12072
0
    isinstance = PyObject_IsInstance(obj, tp);
12073
0
    if (isinstance == -1) {
12074
0
        return -1;
12075
0
    }
12076
0
    if (isinstance) {
12077
0
        expr_ty name;
12078
0
        asdl_type_param_seq* type_params;
12079
0
        expr_ty value;
12080
12081
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
12082
0
            return -1;
12083
0
        }
12084
0
        if (tmp == NULL) {
12085
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeAlias");
12086
0
            return -1;
12087
0
        }
12088
0
        else {
12089
0
            int res;
12090
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12091
0
                goto failed;
12092
0
            }
12093
0
            res = obj2ast_expr(state, tmp, &name, arena);
12094
0
            _Py_LeaveRecursiveCall();
12095
0
            if (res != 0) goto failed;
12096
0
            Py_CLEAR(tmp);
12097
0
        }
12098
0
        if (PyObject_GetOptionalAttr(obj, state->type_params, &tmp) < 0) {
12099
0
            return -1;
12100
0
        }
12101
0
        if (tmp == NULL) {
12102
0
            tmp = PyList_New(0);
12103
0
            if (tmp == NULL) {
12104
0
                return -1;
12105
0
            }
12106
0
        }
12107
0
        {
12108
0
            int res;
12109
0
            Py_ssize_t len;
12110
0
            Py_ssize_t i;
12111
0
            if (!PyList_Check(tmp)) {
12112
0
                PyErr_Format(PyExc_TypeError, "TypeAlias field \"type_params\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12113
0
                goto failed;
12114
0
            }
12115
0
            len = PyList_GET_SIZE(tmp);
12116
0
            type_params = _Py_asdl_type_param_seq_new(len, arena);
12117
0
            if (type_params == NULL) goto failed;
12118
0
            for (i = 0; i < len; i++) {
12119
0
                type_param_ty val;
12120
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12121
0
                if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12122
0
                    goto failed;
12123
0
                }
12124
0
                res = obj2ast_type_param(state, tmp2, &val, arena);
12125
0
                _Py_LeaveRecursiveCall();
12126
0
                Py_DECREF(tmp2);
12127
0
                if (res != 0) goto failed;
12128
0
                if (len != PyList_GET_SIZE(tmp)) {
12129
0
                    PyErr_SetString(PyExc_RuntimeError, "TypeAlias field \"type_params\" changed size during iteration");
12130
0
                    goto failed;
12131
0
                }
12132
0
                asdl_seq_SET(type_params, i, val);
12133
0
            }
12134
0
            Py_CLEAR(tmp);
12135
0
        }
12136
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12137
0
            return -1;
12138
0
        }
12139
0
        if (tmp == NULL) {
12140
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from TypeAlias");
12141
0
            return -1;
12142
0
        }
12143
0
        else {
12144
0
            int res;
12145
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeAlias' node")) {
12146
0
                goto failed;
12147
0
            }
12148
0
            res = obj2ast_expr(state, tmp, &value, arena);
12149
0
            _Py_LeaveRecursiveCall();
12150
0
            if (res != 0) goto failed;
12151
0
            Py_CLEAR(tmp);
12152
0
        }
12153
0
        *out = _PyAST_TypeAlias(name, type_params, value, lineno, col_offset,
12154
0
                                end_lineno, end_col_offset, arena);
12155
0
        if (*out == NULL) goto failed;
12156
0
        return 0;
12157
0
    }
12158
0
    tp = state->AugAssign_type;
12159
0
    isinstance = PyObject_IsInstance(obj, tp);
12160
0
    if (isinstance == -1) {
12161
0
        return -1;
12162
0
    }
12163
0
    if (isinstance) {
12164
0
        expr_ty target;
12165
0
        operator_ty op;
12166
0
        expr_ty value;
12167
12168
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12169
0
            return -1;
12170
0
        }
12171
0
        if (tmp == NULL) {
12172
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
12173
0
            return -1;
12174
0
        }
12175
0
        else {
12176
0
            int res;
12177
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12178
0
                goto failed;
12179
0
            }
12180
0
            res = obj2ast_expr(state, tmp, &target, arena);
12181
0
            _Py_LeaveRecursiveCall();
12182
0
            if (res != 0) goto failed;
12183
0
            Py_CLEAR(tmp);
12184
0
        }
12185
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
12186
0
            return -1;
12187
0
        }
12188
0
        if (tmp == NULL) {
12189
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
12190
0
            return -1;
12191
0
        }
12192
0
        else {
12193
0
            int res;
12194
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12195
0
                goto failed;
12196
0
            }
12197
0
            res = obj2ast_operator(state, tmp, &op, arena);
12198
0
            _Py_LeaveRecursiveCall();
12199
0
            if (res != 0) goto failed;
12200
0
            Py_CLEAR(tmp);
12201
0
        }
12202
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12203
0
            return -1;
12204
0
        }
12205
0
        if (tmp == NULL) {
12206
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
12207
0
            return -1;
12208
0
        }
12209
0
        else {
12210
0
            int res;
12211
0
            if (_Py_EnterRecursiveCall(" while traversing 'AugAssign' node")) {
12212
0
                goto failed;
12213
0
            }
12214
0
            res = obj2ast_expr(state, tmp, &value, arena);
12215
0
            _Py_LeaveRecursiveCall();
12216
0
            if (res != 0) goto failed;
12217
0
            Py_CLEAR(tmp);
12218
0
        }
12219
0
        *out = _PyAST_AugAssign(target, op, value, lineno, col_offset,
12220
0
                                end_lineno, end_col_offset, arena);
12221
0
        if (*out == NULL) goto failed;
12222
0
        return 0;
12223
0
    }
12224
0
    tp = state->AnnAssign_type;
12225
0
    isinstance = PyObject_IsInstance(obj, tp);
12226
0
    if (isinstance == -1) {
12227
0
        return -1;
12228
0
    }
12229
0
    if (isinstance) {
12230
0
        expr_ty target;
12231
0
        expr_ty annotation;
12232
0
        expr_ty value;
12233
0
        int simple;
12234
12235
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12236
0
            return -1;
12237
0
        }
12238
0
        if (tmp == NULL) {
12239
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" 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_expr(state, tmp, &target, arena);
12248
0
            _Py_LeaveRecursiveCall();
12249
0
            if (res != 0) goto failed;
12250
0
            Py_CLEAR(tmp);
12251
0
        }
12252
0
        if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
12253
0
            return -1;
12254
0
        }
12255
0
        if (tmp == NULL) {
12256
0
            PyErr_SetString(PyExc_TypeError, "required field \"annotation\" missing from AnnAssign");
12257
0
            return -1;
12258
0
        }
12259
0
        else {
12260
0
            int res;
12261
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12262
0
                goto failed;
12263
0
            }
12264
0
            res = obj2ast_expr(state, tmp, &annotation, arena);
12265
0
            _Py_LeaveRecursiveCall();
12266
0
            if (res != 0) goto failed;
12267
0
            Py_CLEAR(tmp);
12268
0
        }
12269
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
12270
0
            return -1;
12271
0
        }
12272
0
        if (tmp == NULL || tmp == Py_None) {
12273
0
            Py_CLEAR(tmp);
12274
0
            value = NULL;
12275
0
        }
12276
0
        else {
12277
0
            int res;
12278
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12279
0
                goto failed;
12280
0
            }
12281
0
            res = obj2ast_expr(state, tmp, &value, 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->simple, &tmp) < 0) {
12287
0
            return -1;
12288
0
        }
12289
0
        if (tmp == NULL) {
12290
0
            PyErr_SetString(PyExc_TypeError, "required field \"simple\" missing from AnnAssign");
12291
0
            return -1;
12292
0
        }
12293
0
        else {
12294
0
            int res;
12295
0
            if (_Py_EnterRecursiveCall(" while traversing 'AnnAssign' node")) {
12296
0
                goto failed;
12297
0
            }
12298
0
            res = obj2ast_int(state, tmp, &simple, arena);
12299
0
            _Py_LeaveRecursiveCall();
12300
0
            if (res != 0) goto failed;
12301
0
            Py_CLEAR(tmp);
12302
0
        }
12303
0
        *out = _PyAST_AnnAssign(target, annotation, value, simple, lineno,
12304
0
                                col_offset, end_lineno, end_col_offset, arena);
12305
0
        if (*out == NULL) goto failed;
12306
0
        return 0;
12307
0
    }
12308
0
    tp = state->For_type;
12309
0
    isinstance = PyObject_IsInstance(obj, tp);
12310
0
    if (isinstance == -1) {
12311
0
        return -1;
12312
0
    }
12313
0
    if (isinstance) {
12314
0
        expr_ty target;
12315
0
        expr_ty iter;
12316
0
        asdl_stmt_seq* body;
12317
0
        asdl_stmt_seq* orelse;
12318
0
        string type_comment;
12319
12320
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12321
0
            return -1;
12322
0
        }
12323
0
        if (tmp == NULL) {
12324
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
12325
0
            return -1;
12326
0
        }
12327
0
        else {
12328
0
            int res;
12329
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12330
0
                goto failed;
12331
0
            }
12332
0
            res = obj2ast_expr(state, tmp, &target, arena);
12333
0
            _Py_LeaveRecursiveCall();
12334
0
            if (res != 0) goto failed;
12335
0
            Py_CLEAR(tmp);
12336
0
        }
12337
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12338
0
            return -1;
12339
0
        }
12340
0
        if (tmp == NULL) {
12341
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
12342
0
            return -1;
12343
0
        }
12344
0
        else {
12345
0
            int res;
12346
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12347
0
                goto failed;
12348
0
            }
12349
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12350
0
            _Py_LeaveRecursiveCall();
12351
0
            if (res != 0) goto failed;
12352
0
            Py_CLEAR(tmp);
12353
0
        }
12354
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12355
0
            return -1;
12356
0
        }
12357
0
        if (tmp == NULL) {
12358
0
            tmp = PyList_New(0);
12359
0
            if (tmp == NULL) {
12360
0
                return -1;
12361
0
            }
12362
0
        }
12363
0
        {
12364
0
            int res;
12365
0
            Py_ssize_t len;
12366
0
            Py_ssize_t i;
12367
0
            if (!PyList_Check(tmp)) {
12368
0
                PyErr_Format(PyExc_TypeError, "For field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12369
0
                goto failed;
12370
0
            }
12371
0
            len = PyList_GET_SIZE(tmp);
12372
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12373
0
            if (body == NULL) goto failed;
12374
0
            for (i = 0; i < len; i++) {
12375
0
                stmt_ty val;
12376
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12377
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12378
0
                    goto failed;
12379
0
                }
12380
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12381
0
                _Py_LeaveRecursiveCall();
12382
0
                Py_DECREF(tmp2);
12383
0
                if (res != 0) goto failed;
12384
0
                if (len != PyList_GET_SIZE(tmp)) {
12385
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"body\" changed size during iteration");
12386
0
                    goto failed;
12387
0
                }
12388
0
                asdl_seq_SET(body, i, val);
12389
0
            }
12390
0
            Py_CLEAR(tmp);
12391
0
        }
12392
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12393
0
            return -1;
12394
0
        }
12395
0
        if (tmp == NULL) {
12396
0
            tmp = PyList_New(0);
12397
0
            if (tmp == NULL) {
12398
0
                return -1;
12399
0
            }
12400
0
        }
12401
0
        {
12402
0
            int res;
12403
0
            Py_ssize_t len;
12404
0
            Py_ssize_t i;
12405
0
            if (!PyList_Check(tmp)) {
12406
0
                PyErr_Format(PyExc_TypeError, "For field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12407
0
                goto failed;
12408
0
            }
12409
0
            len = PyList_GET_SIZE(tmp);
12410
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12411
0
            if (orelse == NULL) goto failed;
12412
0
            for (i = 0; i < len; i++) {
12413
0
                stmt_ty val;
12414
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12415
0
                if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12416
0
                    goto failed;
12417
0
                }
12418
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12419
0
                _Py_LeaveRecursiveCall();
12420
0
                Py_DECREF(tmp2);
12421
0
                if (res != 0) goto failed;
12422
0
                if (len != PyList_GET_SIZE(tmp)) {
12423
0
                    PyErr_SetString(PyExc_RuntimeError, "For field \"orelse\" changed size during iteration");
12424
0
                    goto failed;
12425
0
                }
12426
0
                asdl_seq_SET(orelse, i, val);
12427
0
            }
12428
0
            Py_CLEAR(tmp);
12429
0
        }
12430
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12431
0
            return -1;
12432
0
        }
12433
0
        if (tmp == NULL || tmp == Py_None) {
12434
0
            Py_CLEAR(tmp);
12435
0
            type_comment = NULL;
12436
0
        }
12437
0
        else {
12438
0
            int res;
12439
0
            if (_Py_EnterRecursiveCall(" while traversing 'For' node")) {
12440
0
                goto failed;
12441
0
            }
12442
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12443
0
            _Py_LeaveRecursiveCall();
12444
0
            if (res != 0) goto failed;
12445
0
            Py_CLEAR(tmp);
12446
0
        }
12447
0
        *out = _PyAST_For(target, iter, body, orelse, type_comment, lineno,
12448
0
                          col_offset, end_lineno, end_col_offset, arena);
12449
0
        if (*out == NULL) goto failed;
12450
0
        return 0;
12451
0
    }
12452
0
    tp = state->AsyncFor_type;
12453
0
    isinstance = PyObject_IsInstance(obj, tp);
12454
0
    if (isinstance == -1) {
12455
0
        return -1;
12456
0
    }
12457
0
    if (isinstance) {
12458
0
        expr_ty target;
12459
0
        expr_ty iter;
12460
0
        asdl_stmt_seq* body;
12461
0
        asdl_stmt_seq* orelse;
12462
0
        string type_comment;
12463
12464
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
12465
0
            return -1;
12466
0
        }
12467
0
        if (tmp == NULL) {
12468
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AsyncFor");
12469
0
            return -1;
12470
0
        }
12471
0
        else {
12472
0
            int res;
12473
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12474
0
                goto failed;
12475
0
            }
12476
0
            res = obj2ast_expr(state, tmp, &target, arena);
12477
0
            _Py_LeaveRecursiveCall();
12478
0
            if (res != 0) goto failed;
12479
0
            Py_CLEAR(tmp);
12480
0
        }
12481
0
        if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
12482
0
            return -1;
12483
0
        }
12484
0
        if (tmp == NULL) {
12485
0
            PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from AsyncFor");
12486
0
            return -1;
12487
0
        }
12488
0
        else {
12489
0
            int res;
12490
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12491
0
                goto failed;
12492
0
            }
12493
0
            res = obj2ast_expr(state, tmp, &iter, arena);
12494
0
            _Py_LeaveRecursiveCall();
12495
0
            if (res != 0) goto failed;
12496
0
            Py_CLEAR(tmp);
12497
0
        }
12498
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12499
0
            return -1;
12500
0
        }
12501
0
        if (tmp == NULL) {
12502
0
            tmp = PyList_New(0);
12503
0
            if (tmp == NULL) {
12504
0
                return -1;
12505
0
            }
12506
0
        }
12507
0
        {
12508
0
            int res;
12509
0
            Py_ssize_t len;
12510
0
            Py_ssize_t i;
12511
0
            if (!PyList_Check(tmp)) {
12512
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12513
0
                goto failed;
12514
0
            }
12515
0
            len = PyList_GET_SIZE(tmp);
12516
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12517
0
            if (body == NULL) goto failed;
12518
0
            for (i = 0; i < len; i++) {
12519
0
                stmt_ty val;
12520
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12521
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12522
0
                    goto failed;
12523
0
                }
12524
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12525
0
                _Py_LeaveRecursiveCall();
12526
0
                Py_DECREF(tmp2);
12527
0
                if (res != 0) goto failed;
12528
0
                if (len != PyList_GET_SIZE(tmp)) {
12529
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"body\" changed size during iteration");
12530
0
                    goto failed;
12531
0
                }
12532
0
                asdl_seq_SET(body, i, val);
12533
0
            }
12534
0
            Py_CLEAR(tmp);
12535
0
        }
12536
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12537
0
            return -1;
12538
0
        }
12539
0
        if (tmp == NULL) {
12540
0
            tmp = PyList_New(0);
12541
0
            if (tmp == NULL) {
12542
0
                return -1;
12543
0
            }
12544
0
        }
12545
0
        {
12546
0
            int res;
12547
0
            Py_ssize_t len;
12548
0
            Py_ssize_t i;
12549
0
            if (!PyList_Check(tmp)) {
12550
0
                PyErr_Format(PyExc_TypeError, "AsyncFor field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12551
0
                goto failed;
12552
0
            }
12553
0
            len = PyList_GET_SIZE(tmp);
12554
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12555
0
            if (orelse == NULL) goto failed;
12556
0
            for (i = 0; i < len; i++) {
12557
0
                stmt_ty val;
12558
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12559
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12560
0
                    goto failed;
12561
0
                }
12562
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12563
0
                _Py_LeaveRecursiveCall();
12564
0
                Py_DECREF(tmp2);
12565
0
                if (res != 0) goto failed;
12566
0
                if (len != PyList_GET_SIZE(tmp)) {
12567
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncFor field \"orelse\" changed size during iteration");
12568
0
                    goto failed;
12569
0
                }
12570
0
                asdl_seq_SET(orelse, i, val);
12571
0
            }
12572
0
            Py_CLEAR(tmp);
12573
0
        }
12574
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12575
0
            return -1;
12576
0
        }
12577
0
        if (tmp == NULL || tmp == Py_None) {
12578
0
            Py_CLEAR(tmp);
12579
0
            type_comment = NULL;
12580
0
        }
12581
0
        else {
12582
0
            int res;
12583
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncFor' node")) {
12584
0
                goto failed;
12585
0
            }
12586
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12587
0
            _Py_LeaveRecursiveCall();
12588
0
            if (res != 0) goto failed;
12589
0
            Py_CLEAR(tmp);
12590
0
        }
12591
0
        *out = _PyAST_AsyncFor(target, iter, body, orelse, type_comment,
12592
0
                               lineno, col_offset, end_lineno, end_col_offset,
12593
0
                               arena);
12594
0
        if (*out == NULL) goto failed;
12595
0
        return 0;
12596
0
    }
12597
0
    tp = state->While_type;
12598
0
    isinstance = PyObject_IsInstance(obj, tp);
12599
0
    if (isinstance == -1) {
12600
0
        return -1;
12601
0
    }
12602
0
    if (isinstance) {
12603
0
        expr_ty test;
12604
0
        asdl_stmt_seq* body;
12605
0
        asdl_stmt_seq* orelse;
12606
12607
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12608
0
            return -1;
12609
0
        }
12610
0
        if (tmp == NULL) {
12611
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
12612
0
            return -1;
12613
0
        }
12614
0
        else {
12615
0
            int res;
12616
0
            if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12617
0
                goto failed;
12618
0
            }
12619
0
            res = obj2ast_expr(state, tmp, &test, arena);
12620
0
            _Py_LeaveRecursiveCall();
12621
0
            if (res != 0) goto failed;
12622
0
            Py_CLEAR(tmp);
12623
0
        }
12624
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12625
0
            return -1;
12626
0
        }
12627
0
        if (tmp == NULL) {
12628
0
            tmp = PyList_New(0);
12629
0
            if (tmp == NULL) {
12630
0
                return -1;
12631
0
            }
12632
0
        }
12633
0
        {
12634
0
            int res;
12635
0
            Py_ssize_t len;
12636
0
            Py_ssize_t i;
12637
0
            if (!PyList_Check(tmp)) {
12638
0
                PyErr_Format(PyExc_TypeError, "While field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12639
0
                goto failed;
12640
0
            }
12641
0
            len = PyList_GET_SIZE(tmp);
12642
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12643
0
            if (body == NULL) goto failed;
12644
0
            for (i = 0; i < len; i++) {
12645
0
                stmt_ty val;
12646
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12647
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12648
0
                    goto failed;
12649
0
                }
12650
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12651
0
                _Py_LeaveRecursiveCall();
12652
0
                Py_DECREF(tmp2);
12653
0
                if (res != 0) goto failed;
12654
0
                if (len != PyList_GET_SIZE(tmp)) {
12655
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"body\" changed size during iteration");
12656
0
                    goto failed;
12657
0
                }
12658
0
                asdl_seq_SET(body, i, val);
12659
0
            }
12660
0
            Py_CLEAR(tmp);
12661
0
        }
12662
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12663
0
            return -1;
12664
0
        }
12665
0
        if (tmp == NULL) {
12666
0
            tmp = PyList_New(0);
12667
0
            if (tmp == NULL) {
12668
0
                return -1;
12669
0
            }
12670
0
        }
12671
0
        {
12672
0
            int res;
12673
0
            Py_ssize_t len;
12674
0
            Py_ssize_t i;
12675
0
            if (!PyList_Check(tmp)) {
12676
0
                PyErr_Format(PyExc_TypeError, "While field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12677
0
                goto failed;
12678
0
            }
12679
0
            len = PyList_GET_SIZE(tmp);
12680
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12681
0
            if (orelse == NULL) goto failed;
12682
0
            for (i = 0; i < len; i++) {
12683
0
                stmt_ty val;
12684
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12685
0
                if (_Py_EnterRecursiveCall(" while traversing 'While' node")) {
12686
0
                    goto failed;
12687
0
                }
12688
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12689
0
                _Py_LeaveRecursiveCall();
12690
0
                Py_DECREF(tmp2);
12691
0
                if (res != 0) goto failed;
12692
0
                if (len != PyList_GET_SIZE(tmp)) {
12693
0
                    PyErr_SetString(PyExc_RuntimeError, "While field \"orelse\" changed size during iteration");
12694
0
                    goto failed;
12695
0
                }
12696
0
                asdl_seq_SET(orelse, i, val);
12697
0
            }
12698
0
            Py_CLEAR(tmp);
12699
0
        }
12700
0
        *out = _PyAST_While(test, body, orelse, lineno, col_offset, end_lineno,
12701
0
                            end_col_offset, arena);
12702
0
        if (*out == NULL) goto failed;
12703
0
        return 0;
12704
0
    }
12705
0
    tp = state->If_type;
12706
0
    isinstance = PyObject_IsInstance(obj, tp);
12707
0
    if (isinstance == -1) {
12708
0
        return -1;
12709
0
    }
12710
0
    if (isinstance) {
12711
0
        expr_ty test;
12712
0
        asdl_stmt_seq* body;
12713
0
        asdl_stmt_seq* orelse;
12714
12715
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
12716
0
            return -1;
12717
0
        }
12718
0
        if (tmp == NULL) {
12719
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
12720
0
            return -1;
12721
0
        }
12722
0
        else {
12723
0
            int res;
12724
0
            if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12725
0
                goto failed;
12726
0
            }
12727
0
            res = obj2ast_expr(state, tmp, &test, arena);
12728
0
            _Py_LeaveRecursiveCall();
12729
0
            if (res != 0) goto failed;
12730
0
            Py_CLEAR(tmp);
12731
0
        }
12732
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12733
0
            return -1;
12734
0
        }
12735
0
        if (tmp == NULL) {
12736
0
            tmp = PyList_New(0);
12737
0
            if (tmp == NULL) {
12738
0
                return -1;
12739
0
            }
12740
0
        }
12741
0
        {
12742
0
            int res;
12743
0
            Py_ssize_t len;
12744
0
            Py_ssize_t i;
12745
0
            if (!PyList_Check(tmp)) {
12746
0
                PyErr_Format(PyExc_TypeError, "If field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12747
0
                goto failed;
12748
0
            }
12749
0
            len = PyList_GET_SIZE(tmp);
12750
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12751
0
            if (body == NULL) goto failed;
12752
0
            for (i = 0; i < len; i++) {
12753
0
                stmt_ty val;
12754
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12755
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12756
0
                    goto failed;
12757
0
                }
12758
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12759
0
                _Py_LeaveRecursiveCall();
12760
0
                Py_DECREF(tmp2);
12761
0
                if (res != 0) goto failed;
12762
0
                if (len != PyList_GET_SIZE(tmp)) {
12763
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"body\" changed size during iteration");
12764
0
                    goto failed;
12765
0
                }
12766
0
                asdl_seq_SET(body, i, val);
12767
0
            }
12768
0
            Py_CLEAR(tmp);
12769
0
        }
12770
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
12771
0
            return -1;
12772
0
        }
12773
0
        if (tmp == NULL) {
12774
0
            tmp = PyList_New(0);
12775
0
            if (tmp == NULL) {
12776
0
                return -1;
12777
0
            }
12778
0
        }
12779
0
        {
12780
0
            int res;
12781
0
            Py_ssize_t len;
12782
0
            Py_ssize_t i;
12783
0
            if (!PyList_Check(tmp)) {
12784
0
                PyErr_Format(PyExc_TypeError, "If field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12785
0
                goto failed;
12786
0
            }
12787
0
            len = PyList_GET_SIZE(tmp);
12788
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
12789
0
            if (orelse == NULL) goto failed;
12790
0
            for (i = 0; i < len; i++) {
12791
0
                stmt_ty val;
12792
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12793
0
                if (_Py_EnterRecursiveCall(" while traversing 'If' node")) {
12794
0
                    goto failed;
12795
0
                }
12796
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12797
0
                _Py_LeaveRecursiveCall();
12798
0
                Py_DECREF(tmp2);
12799
0
                if (res != 0) goto failed;
12800
0
                if (len != PyList_GET_SIZE(tmp)) {
12801
0
                    PyErr_SetString(PyExc_RuntimeError, "If field \"orelse\" changed size during iteration");
12802
0
                    goto failed;
12803
0
                }
12804
0
                asdl_seq_SET(orelse, i, val);
12805
0
            }
12806
0
            Py_CLEAR(tmp);
12807
0
        }
12808
0
        *out = _PyAST_If(test, body, orelse, lineno, col_offset, end_lineno,
12809
0
                         end_col_offset, arena);
12810
0
        if (*out == NULL) goto failed;
12811
0
        return 0;
12812
0
    }
12813
0
    tp = state->With_type;
12814
0
    isinstance = PyObject_IsInstance(obj, tp);
12815
0
    if (isinstance == -1) {
12816
0
        return -1;
12817
0
    }
12818
0
    if (isinstance) {
12819
0
        asdl_withitem_seq* items;
12820
0
        asdl_stmt_seq* body;
12821
0
        string type_comment;
12822
12823
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12824
0
            return -1;
12825
0
        }
12826
0
        if (tmp == NULL) {
12827
0
            tmp = PyList_New(0);
12828
0
            if (tmp == NULL) {
12829
0
                return -1;
12830
0
            }
12831
0
        }
12832
0
        {
12833
0
            int res;
12834
0
            Py_ssize_t len;
12835
0
            Py_ssize_t i;
12836
0
            if (!PyList_Check(tmp)) {
12837
0
                PyErr_Format(PyExc_TypeError, "With field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12838
0
                goto failed;
12839
0
            }
12840
0
            len = PyList_GET_SIZE(tmp);
12841
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12842
0
            if (items == NULL) goto failed;
12843
0
            for (i = 0; i < len; i++) {
12844
0
                withitem_ty val;
12845
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12846
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12847
0
                    goto failed;
12848
0
                }
12849
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12850
0
                _Py_LeaveRecursiveCall();
12851
0
                Py_DECREF(tmp2);
12852
0
                if (res != 0) goto failed;
12853
0
                if (len != PyList_GET_SIZE(tmp)) {
12854
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"items\" changed size during iteration");
12855
0
                    goto failed;
12856
0
                }
12857
0
                asdl_seq_SET(items, i, val);
12858
0
            }
12859
0
            Py_CLEAR(tmp);
12860
0
        }
12861
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12862
0
            return -1;
12863
0
        }
12864
0
        if (tmp == NULL) {
12865
0
            tmp = PyList_New(0);
12866
0
            if (tmp == NULL) {
12867
0
                return -1;
12868
0
            }
12869
0
        }
12870
0
        {
12871
0
            int res;
12872
0
            Py_ssize_t len;
12873
0
            Py_ssize_t i;
12874
0
            if (!PyList_Check(tmp)) {
12875
0
                PyErr_Format(PyExc_TypeError, "With field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12876
0
                goto failed;
12877
0
            }
12878
0
            len = PyList_GET_SIZE(tmp);
12879
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12880
0
            if (body == NULL) goto failed;
12881
0
            for (i = 0; i < len; i++) {
12882
0
                stmt_ty val;
12883
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12884
0
                if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12885
0
                    goto failed;
12886
0
                }
12887
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12888
0
                _Py_LeaveRecursiveCall();
12889
0
                Py_DECREF(tmp2);
12890
0
                if (res != 0) goto failed;
12891
0
                if (len != PyList_GET_SIZE(tmp)) {
12892
0
                    PyErr_SetString(PyExc_RuntimeError, "With field \"body\" changed size during iteration");
12893
0
                    goto failed;
12894
0
                }
12895
0
                asdl_seq_SET(body, i, val);
12896
0
            }
12897
0
            Py_CLEAR(tmp);
12898
0
        }
12899
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
12900
0
            return -1;
12901
0
        }
12902
0
        if (tmp == NULL || tmp == Py_None) {
12903
0
            Py_CLEAR(tmp);
12904
0
            type_comment = NULL;
12905
0
        }
12906
0
        else {
12907
0
            int res;
12908
0
            if (_Py_EnterRecursiveCall(" while traversing 'With' node")) {
12909
0
                goto failed;
12910
0
            }
12911
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
12912
0
            _Py_LeaveRecursiveCall();
12913
0
            if (res != 0) goto failed;
12914
0
            Py_CLEAR(tmp);
12915
0
        }
12916
0
        *out = _PyAST_With(items, body, type_comment, lineno, col_offset,
12917
0
                           end_lineno, end_col_offset, arena);
12918
0
        if (*out == NULL) goto failed;
12919
0
        return 0;
12920
0
    }
12921
0
    tp = state->AsyncWith_type;
12922
0
    isinstance = PyObject_IsInstance(obj, tp);
12923
0
    if (isinstance == -1) {
12924
0
        return -1;
12925
0
    }
12926
0
    if (isinstance) {
12927
0
        asdl_withitem_seq* items;
12928
0
        asdl_stmt_seq* body;
12929
0
        string type_comment;
12930
12931
0
        if (PyObject_GetOptionalAttr(obj, state->items, &tmp) < 0) {
12932
0
            return -1;
12933
0
        }
12934
0
        if (tmp == NULL) {
12935
0
            tmp = PyList_New(0);
12936
0
            if (tmp == NULL) {
12937
0
                return -1;
12938
0
            }
12939
0
        }
12940
0
        {
12941
0
            int res;
12942
0
            Py_ssize_t len;
12943
0
            Py_ssize_t i;
12944
0
            if (!PyList_Check(tmp)) {
12945
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"items\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12946
0
                goto failed;
12947
0
            }
12948
0
            len = PyList_GET_SIZE(tmp);
12949
0
            items = _Py_asdl_withitem_seq_new(len, arena);
12950
0
            if (items == NULL) goto failed;
12951
0
            for (i = 0; i < len; i++) {
12952
0
                withitem_ty val;
12953
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12954
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12955
0
                    goto failed;
12956
0
                }
12957
0
                res = obj2ast_withitem(state, tmp2, &val, arena);
12958
0
                _Py_LeaveRecursiveCall();
12959
0
                Py_DECREF(tmp2);
12960
0
                if (res != 0) goto failed;
12961
0
                if (len != PyList_GET_SIZE(tmp)) {
12962
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"items\" changed size during iteration");
12963
0
                    goto failed;
12964
0
                }
12965
0
                asdl_seq_SET(items, i, val);
12966
0
            }
12967
0
            Py_CLEAR(tmp);
12968
0
        }
12969
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
12970
0
            return -1;
12971
0
        }
12972
0
        if (tmp == NULL) {
12973
0
            tmp = PyList_New(0);
12974
0
            if (tmp == NULL) {
12975
0
                return -1;
12976
0
            }
12977
0
        }
12978
0
        {
12979
0
            int res;
12980
0
            Py_ssize_t len;
12981
0
            Py_ssize_t i;
12982
0
            if (!PyList_Check(tmp)) {
12983
0
                PyErr_Format(PyExc_TypeError, "AsyncWith field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
12984
0
                goto failed;
12985
0
            }
12986
0
            len = PyList_GET_SIZE(tmp);
12987
0
            body = _Py_asdl_stmt_seq_new(len, arena);
12988
0
            if (body == NULL) goto failed;
12989
0
            for (i = 0; i < len; i++) {
12990
0
                stmt_ty val;
12991
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
12992
0
                if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
12993
0
                    goto failed;
12994
0
                }
12995
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
12996
0
                _Py_LeaveRecursiveCall();
12997
0
                Py_DECREF(tmp2);
12998
0
                if (res != 0) goto failed;
12999
0
                if (len != PyList_GET_SIZE(tmp)) {
13000
0
                    PyErr_SetString(PyExc_RuntimeError, "AsyncWith field \"body\" changed size during iteration");
13001
0
                    goto failed;
13002
0
                }
13003
0
                asdl_seq_SET(body, i, val);
13004
0
            }
13005
0
            Py_CLEAR(tmp);
13006
0
        }
13007
0
        if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
13008
0
            return -1;
13009
0
        }
13010
0
        if (tmp == NULL || tmp == Py_None) {
13011
0
            Py_CLEAR(tmp);
13012
0
            type_comment = NULL;
13013
0
        }
13014
0
        else {
13015
0
            int res;
13016
0
            if (_Py_EnterRecursiveCall(" while traversing 'AsyncWith' node")) {
13017
0
                goto failed;
13018
0
            }
13019
0
            res = obj2ast_string(state, tmp, &type_comment, arena);
13020
0
            _Py_LeaveRecursiveCall();
13021
0
            if (res != 0) goto failed;
13022
0
            Py_CLEAR(tmp);
13023
0
        }
13024
0
        *out = _PyAST_AsyncWith(items, body, type_comment, lineno, col_offset,
13025
0
                                end_lineno, end_col_offset, arena);
13026
0
        if (*out == NULL) goto failed;
13027
0
        return 0;
13028
0
    }
13029
0
    tp = state->Match_type;
13030
0
    isinstance = PyObject_IsInstance(obj, tp);
13031
0
    if (isinstance == -1) {
13032
0
        return -1;
13033
0
    }
13034
0
    if (isinstance) {
13035
0
        expr_ty subject;
13036
0
        asdl_match_case_seq* cases;
13037
13038
0
        if (PyObject_GetOptionalAttr(obj, state->subject, &tmp) < 0) {
13039
0
            return -1;
13040
0
        }
13041
0
        if (tmp == NULL) {
13042
0
            PyErr_SetString(PyExc_TypeError, "required field \"subject\" missing from Match");
13043
0
            return -1;
13044
0
        }
13045
0
        else {
13046
0
            int res;
13047
0
            if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13048
0
                goto failed;
13049
0
            }
13050
0
            res = obj2ast_expr(state, tmp, &subject, arena);
13051
0
            _Py_LeaveRecursiveCall();
13052
0
            if (res != 0) goto failed;
13053
0
            Py_CLEAR(tmp);
13054
0
        }
13055
0
        if (PyObject_GetOptionalAttr(obj, state->cases, &tmp) < 0) {
13056
0
            return -1;
13057
0
        }
13058
0
        if (tmp == NULL) {
13059
0
            tmp = PyList_New(0);
13060
0
            if (tmp == NULL) {
13061
0
                return -1;
13062
0
            }
13063
0
        }
13064
0
        {
13065
0
            int res;
13066
0
            Py_ssize_t len;
13067
0
            Py_ssize_t i;
13068
0
            if (!PyList_Check(tmp)) {
13069
0
                PyErr_Format(PyExc_TypeError, "Match field \"cases\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13070
0
                goto failed;
13071
0
            }
13072
0
            len = PyList_GET_SIZE(tmp);
13073
0
            cases = _Py_asdl_match_case_seq_new(len, arena);
13074
0
            if (cases == NULL) goto failed;
13075
0
            for (i = 0; i < len; i++) {
13076
0
                match_case_ty val;
13077
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13078
0
                if (_Py_EnterRecursiveCall(" while traversing 'Match' node")) {
13079
0
                    goto failed;
13080
0
                }
13081
0
                res = obj2ast_match_case(state, tmp2, &val, arena);
13082
0
                _Py_LeaveRecursiveCall();
13083
0
                Py_DECREF(tmp2);
13084
0
                if (res != 0) goto failed;
13085
0
                if (len != PyList_GET_SIZE(tmp)) {
13086
0
                    PyErr_SetString(PyExc_RuntimeError, "Match field \"cases\" changed size during iteration");
13087
0
                    goto failed;
13088
0
                }
13089
0
                asdl_seq_SET(cases, i, val);
13090
0
            }
13091
0
            Py_CLEAR(tmp);
13092
0
        }
13093
0
        *out = _PyAST_Match(subject, cases, lineno, col_offset, end_lineno,
13094
0
                            end_col_offset, arena);
13095
0
        if (*out == NULL) goto failed;
13096
0
        return 0;
13097
0
    }
13098
0
    tp = state->Raise_type;
13099
0
    isinstance = PyObject_IsInstance(obj, tp);
13100
0
    if (isinstance == -1) {
13101
0
        return -1;
13102
0
    }
13103
0
    if (isinstance) {
13104
0
        expr_ty exc;
13105
0
        expr_ty cause;
13106
13107
0
        if (PyObject_GetOptionalAttr(obj, state->exc, &tmp) < 0) {
13108
0
            return -1;
13109
0
        }
13110
0
        if (tmp == NULL || tmp == Py_None) {
13111
0
            Py_CLEAR(tmp);
13112
0
            exc = NULL;
13113
0
        }
13114
0
        else {
13115
0
            int res;
13116
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13117
0
                goto failed;
13118
0
            }
13119
0
            res = obj2ast_expr(state, tmp, &exc, arena);
13120
0
            _Py_LeaveRecursiveCall();
13121
0
            if (res != 0) goto failed;
13122
0
            Py_CLEAR(tmp);
13123
0
        }
13124
0
        if (PyObject_GetOptionalAttr(obj, state->cause, &tmp) < 0) {
13125
0
            return -1;
13126
0
        }
13127
0
        if (tmp == NULL || tmp == Py_None) {
13128
0
            Py_CLEAR(tmp);
13129
0
            cause = NULL;
13130
0
        }
13131
0
        else {
13132
0
            int res;
13133
0
            if (_Py_EnterRecursiveCall(" while traversing 'Raise' node")) {
13134
0
                goto failed;
13135
0
            }
13136
0
            res = obj2ast_expr(state, tmp, &cause, arena);
13137
0
            _Py_LeaveRecursiveCall();
13138
0
            if (res != 0) goto failed;
13139
0
            Py_CLEAR(tmp);
13140
0
        }
13141
0
        *out = _PyAST_Raise(exc, cause, lineno, col_offset, end_lineno,
13142
0
                            end_col_offset, arena);
13143
0
        if (*out == NULL) goto failed;
13144
0
        return 0;
13145
0
    }
13146
0
    tp = state->Try_type;
13147
0
    isinstance = PyObject_IsInstance(obj, tp);
13148
0
    if (isinstance == -1) {
13149
0
        return -1;
13150
0
    }
13151
0
    if (isinstance) {
13152
0
        asdl_stmt_seq* body;
13153
0
        asdl_excepthandler_seq* handlers;
13154
0
        asdl_stmt_seq* orelse;
13155
0
        asdl_stmt_seq* finalbody;
13156
13157
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13158
0
            return -1;
13159
0
        }
13160
0
        if (tmp == NULL) {
13161
0
            tmp = PyList_New(0);
13162
0
            if (tmp == NULL) {
13163
0
                return -1;
13164
0
            }
13165
0
        }
13166
0
        {
13167
0
            int res;
13168
0
            Py_ssize_t len;
13169
0
            Py_ssize_t i;
13170
0
            if (!PyList_Check(tmp)) {
13171
0
                PyErr_Format(PyExc_TypeError, "Try field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13172
0
                goto failed;
13173
0
            }
13174
0
            len = PyList_GET_SIZE(tmp);
13175
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13176
0
            if (body == NULL) goto failed;
13177
0
            for (i = 0; i < len; i++) {
13178
0
                stmt_ty val;
13179
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13180
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13181
0
                    goto failed;
13182
0
                }
13183
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13184
0
                _Py_LeaveRecursiveCall();
13185
0
                Py_DECREF(tmp2);
13186
0
                if (res != 0) goto failed;
13187
0
                if (len != PyList_GET_SIZE(tmp)) {
13188
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"body\" changed size during iteration");
13189
0
                    goto failed;
13190
0
                }
13191
0
                asdl_seq_SET(body, i, val);
13192
0
            }
13193
0
            Py_CLEAR(tmp);
13194
0
        }
13195
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13196
0
            return -1;
13197
0
        }
13198
0
        if (tmp == NULL) {
13199
0
            tmp = PyList_New(0);
13200
0
            if (tmp == NULL) {
13201
0
                return -1;
13202
0
            }
13203
0
        }
13204
0
        {
13205
0
            int res;
13206
0
            Py_ssize_t len;
13207
0
            Py_ssize_t i;
13208
0
            if (!PyList_Check(tmp)) {
13209
0
                PyErr_Format(PyExc_TypeError, "Try field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13210
0
                goto failed;
13211
0
            }
13212
0
            len = PyList_GET_SIZE(tmp);
13213
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13214
0
            if (handlers == NULL) goto failed;
13215
0
            for (i = 0; i < len; i++) {
13216
0
                excepthandler_ty val;
13217
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13218
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13219
0
                    goto failed;
13220
0
                }
13221
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13222
0
                _Py_LeaveRecursiveCall();
13223
0
                Py_DECREF(tmp2);
13224
0
                if (res != 0) goto failed;
13225
0
                if (len != PyList_GET_SIZE(tmp)) {
13226
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"handlers\" changed size during iteration");
13227
0
                    goto failed;
13228
0
                }
13229
0
                asdl_seq_SET(handlers, i, val);
13230
0
            }
13231
0
            Py_CLEAR(tmp);
13232
0
        }
13233
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13234
0
            return -1;
13235
0
        }
13236
0
        if (tmp == NULL) {
13237
0
            tmp = PyList_New(0);
13238
0
            if (tmp == NULL) {
13239
0
                return -1;
13240
0
            }
13241
0
        }
13242
0
        {
13243
0
            int res;
13244
0
            Py_ssize_t len;
13245
0
            Py_ssize_t i;
13246
0
            if (!PyList_Check(tmp)) {
13247
0
                PyErr_Format(PyExc_TypeError, "Try field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13248
0
                goto failed;
13249
0
            }
13250
0
            len = PyList_GET_SIZE(tmp);
13251
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13252
0
            if (orelse == NULL) goto failed;
13253
0
            for (i = 0; i < len; i++) {
13254
0
                stmt_ty val;
13255
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13256
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13257
0
                    goto failed;
13258
0
                }
13259
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13260
0
                _Py_LeaveRecursiveCall();
13261
0
                Py_DECREF(tmp2);
13262
0
                if (res != 0) goto failed;
13263
0
                if (len != PyList_GET_SIZE(tmp)) {
13264
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"orelse\" changed size during iteration");
13265
0
                    goto failed;
13266
0
                }
13267
0
                asdl_seq_SET(orelse, i, val);
13268
0
            }
13269
0
            Py_CLEAR(tmp);
13270
0
        }
13271
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13272
0
            return -1;
13273
0
        }
13274
0
        if (tmp == NULL) {
13275
0
            tmp = PyList_New(0);
13276
0
            if (tmp == NULL) {
13277
0
                return -1;
13278
0
            }
13279
0
        }
13280
0
        {
13281
0
            int res;
13282
0
            Py_ssize_t len;
13283
0
            Py_ssize_t i;
13284
0
            if (!PyList_Check(tmp)) {
13285
0
                PyErr_Format(PyExc_TypeError, "Try field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13286
0
                goto failed;
13287
0
            }
13288
0
            len = PyList_GET_SIZE(tmp);
13289
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13290
0
            if (finalbody == NULL) goto failed;
13291
0
            for (i = 0; i < len; i++) {
13292
0
                stmt_ty val;
13293
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13294
0
                if (_Py_EnterRecursiveCall(" while traversing 'Try' node")) {
13295
0
                    goto failed;
13296
0
                }
13297
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13298
0
                _Py_LeaveRecursiveCall();
13299
0
                Py_DECREF(tmp2);
13300
0
                if (res != 0) goto failed;
13301
0
                if (len != PyList_GET_SIZE(tmp)) {
13302
0
                    PyErr_SetString(PyExc_RuntimeError, "Try field \"finalbody\" changed size during iteration");
13303
0
                    goto failed;
13304
0
                }
13305
0
                asdl_seq_SET(finalbody, i, val);
13306
0
            }
13307
0
            Py_CLEAR(tmp);
13308
0
        }
13309
0
        *out = _PyAST_Try(body, handlers, orelse, finalbody, lineno,
13310
0
                          col_offset, end_lineno, end_col_offset, arena);
13311
0
        if (*out == NULL) goto failed;
13312
0
        return 0;
13313
0
    }
13314
0
    tp = state->TryStar_type;
13315
0
    isinstance = PyObject_IsInstance(obj, tp);
13316
0
    if (isinstance == -1) {
13317
0
        return -1;
13318
0
    }
13319
0
    if (isinstance) {
13320
0
        asdl_stmt_seq* body;
13321
0
        asdl_excepthandler_seq* handlers;
13322
0
        asdl_stmt_seq* orelse;
13323
0
        asdl_stmt_seq* finalbody;
13324
13325
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
13326
0
            return -1;
13327
0
        }
13328
0
        if (tmp == NULL) {
13329
0
            tmp = PyList_New(0);
13330
0
            if (tmp == NULL) {
13331
0
                return -1;
13332
0
            }
13333
0
        }
13334
0
        {
13335
0
            int res;
13336
0
            Py_ssize_t len;
13337
0
            Py_ssize_t i;
13338
0
            if (!PyList_Check(tmp)) {
13339
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13340
0
                goto failed;
13341
0
            }
13342
0
            len = PyList_GET_SIZE(tmp);
13343
0
            body = _Py_asdl_stmt_seq_new(len, arena);
13344
0
            if (body == NULL) goto failed;
13345
0
            for (i = 0; i < len; i++) {
13346
0
                stmt_ty val;
13347
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13348
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13349
0
                    goto failed;
13350
0
                }
13351
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13352
0
                _Py_LeaveRecursiveCall();
13353
0
                Py_DECREF(tmp2);
13354
0
                if (res != 0) goto failed;
13355
0
                if (len != PyList_GET_SIZE(tmp)) {
13356
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"body\" changed size during iteration");
13357
0
                    goto failed;
13358
0
                }
13359
0
                asdl_seq_SET(body, i, val);
13360
0
            }
13361
0
            Py_CLEAR(tmp);
13362
0
        }
13363
0
        if (PyObject_GetOptionalAttr(obj, state->handlers, &tmp) < 0) {
13364
0
            return -1;
13365
0
        }
13366
0
        if (tmp == NULL) {
13367
0
            tmp = PyList_New(0);
13368
0
            if (tmp == NULL) {
13369
0
                return -1;
13370
0
            }
13371
0
        }
13372
0
        {
13373
0
            int res;
13374
0
            Py_ssize_t len;
13375
0
            Py_ssize_t i;
13376
0
            if (!PyList_Check(tmp)) {
13377
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"handlers\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13378
0
                goto failed;
13379
0
            }
13380
0
            len = PyList_GET_SIZE(tmp);
13381
0
            handlers = _Py_asdl_excepthandler_seq_new(len, arena);
13382
0
            if (handlers == NULL) goto failed;
13383
0
            for (i = 0; i < len; i++) {
13384
0
                excepthandler_ty val;
13385
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13386
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13387
0
                    goto failed;
13388
0
                }
13389
0
                res = obj2ast_excepthandler(state, tmp2, &val, arena);
13390
0
                _Py_LeaveRecursiveCall();
13391
0
                Py_DECREF(tmp2);
13392
0
                if (res != 0) goto failed;
13393
0
                if (len != PyList_GET_SIZE(tmp)) {
13394
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"handlers\" changed size during iteration");
13395
0
                    goto failed;
13396
0
                }
13397
0
                asdl_seq_SET(handlers, i, val);
13398
0
            }
13399
0
            Py_CLEAR(tmp);
13400
0
        }
13401
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
13402
0
            return -1;
13403
0
        }
13404
0
        if (tmp == NULL) {
13405
0
            tmp = PyList_New(0);
13406
0
            if (tmp == NULL) {
13407
0
                return -1;
13408
0
            }
13409
0
        }
13410
0
        {
13411
0
            int res;
13412
0
            Py_ssize_t len;
13413
0
            Py_ssize_t i;
13414
0
            if (!PyList_Check(tmp)) {
13415
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"orelse\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13416
0
                goto failed;
13417
0
            }
13418
0
            len = PyList_GET_SIZE(tmp);
13419
0
            orelse = _Py_asdl_stmt_seq_new(len, arena);
13420
0
            if (orelse == NULL) goto failed;
13421
0
            for (i = 0; i < len; i++) {
13422
0
                stmt_ty val;
13423
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13424
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13425
0
                    goto failed;
13426
0
                }
13427
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13428
0
                _Py_LeaveRecursiveCall();
13429
0
                Py_DECREF(tmp2);
13430
0
                if (res != 0) goto failed;
13431
0
                if (len != PyList_GET_SIZE(tmp)) {
13432
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"orelse\" changed size during iteration");
13433
0
                    goto failed;
13434
0
                }
13435
0
                asdl_seq_SET(orelse, i, val);
13436
0
            }
13437
0
            Py_CLEAR(tmp);
13438
0
        }
13439
0
        if (PyObject_GetOptionalAttr(obj, state->finalbody, &tmp) < 0) {
13440
0
            return -1;
13441
0
        }
13442
0
        if (tmp == NULL) {
13443
0
            tmp = PyList_New(0);
13444
0
            if (tmp == NULL) {
13445
0
                return -1;
13446
0
            }
13447
0
        }
13448
0
        {
13449
0
            int res;
13450
0
            Py_ssize_t len;
13451
0
            Py_ssize_t i;
13452
0
            if (!PyList_Check(tmp)) {
13453
0
                PyErr_Format(PyExc_TypeError, "TryStar field \"finalbody\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13454
0
                goto failed;
13455
0
            }
13456
0
            len = PyList_GET_SIZE(tmp);
13457
0
            finalbody = _Py_asdl_stmt_seq_new(len, arena);
13458
0
            if (finalbody == NULL) goto failed;
13459
0
            for (i = 0; i < len; i++) {
13460
0
                stmt_ty val;
13461
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13462
0
                if (_Py_EnterRecursiveCall(" while traversing 'TryStar' node")) {
13463
0
                    goto failed;
13464
0
                }
13465
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
13466
0
                _Py_LeaveRecursiveCall();
13467
0
                Py_DECREF(tmp2);
13468
0
                if (res != 0) goto failed;
13469
0
                if (len != PyList_GET_SIZE(tmp)) {
13470
0
                    PyErr_SetString(PyExc_RuntimeError, "TryStar field \"finalbody\" changed size during iteration");
13471
0
                    goto failed;
13472
0
                }
13473
0
                asdl_seq_SET(finalbody, i, val);
13474
0
            }
13475
0
            Py_CLEAR(tmp);
13476
0
        }
13477
0
        *out = _PyAST_TryStar(body, handlers, orelse, finalbody, lineno,
13478
0
                              col_offset, end_lineno, end_col_offset, arena);
13479
0
        if (*out == NULL) goto failed;
13480
0
        return 0;
13481
0
    }
13482
0
    tp = state->Assert_type;
13483
0
    isinstance = PyObject_IsInstance(obj, tp);
13484
0
    if (isinstance == -1) {
13485
0
        return -1;
13486
0
    }
13487
0
    if (isinstance) {
13488
0
        expr_ty test;
13489
0
        expr_ty msg;
13490
13491
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
13492
0
            return -1;
13493
0
        }
13494
0
        if (tmp == NULL) {
13495
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
13496
0
            return -1;
13497
0
        }
13498
0
        else {
13499
0
            int res;
13500
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13501
0
                goto failed;
13502
0
            }
13503
0
            res = obj2ast_expr(state, tmp, &test, arena);
13504
0
            _Py_LeaveRecursiveCall();
13505
0
            if (res != 0) goto failed;
13506
0
            Py_CLEAR(tmp);
13507
0
        }
13508
0
        if (PyObject_GetOptionalAttr(obj, state->msg, &tmp) < 0) {
13509
0
            return -1;
13510
0
        }
13511
0
        if (tmp == NULL || tmp == Py_None) {
13512
0
            Py_CLEAR(tmp);
13513
0
            msg = NULL;
13514
0
        }
13515
0
        else {
13516
0
            int res;
13517
0
            if (_Py_EnterRecursiveCall(" while traversing 'Assert' node")) {
13518
0
                goto failed;
13519
0
            }
13520
0
            res = obj2ast_expr(state, tmp, &msg, arena);
13521
0
            _Py_LeaveRecursiveCall();
13522
0
            if (res != 0) goto failed;
13523
0
            Py_CLEAR(tmp);
13524
0
        }
13525
0
        *out = _PyAST_Assert(test, msg, 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->Import_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
        asdl_alias_seq* names;
13537
0
        int is_lazy;
13538
13539
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13540
0
            return -1;
13541
0
        }
13542
0
        if (tmp == NULL) {
13543
0
            tmp = PyList_New(0);
13544
0
            if (tmp == NULL) {
13545
0
                return -1;
13546
0
            }
13547
0
        }
13548
0
        {
13549
0
            int res;
13550
0
            Py_ssize_t len;
13551
0
            Py_ssize_t i;
13552
0
            if (!PyList_Check(tmp)) {
13553
0
                PyErr_Format(PyExc_TypeError, "Import field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13554
0
                goto failed;
13555
0
            }
13556
0
            len = PyList_GET_SIZE(tmp);
13557
0
            names = _Py_asdl_alias_seq_new(len, arena);
13558
0
            if (names == NULL) goto failed;
13559
0
            for (i = 0; i < len; i++) {
13560
0
                alias_ty val;
13561
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13562
0
                if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13563
0
                    goto failed;
13564
0
                }
13565
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13566
0
                _Py_LeaveRecursiveCall();
13567
0
                Py_DECREF(tmp2);
13568
0
                if (res != 0) goto failed;
13569
0
                if (len != PyList_GET_SIZE(tmp)) {
13570
0
                    PyErr_SetString(PyExc_RuntimeError, "Import field \"names\" changed size during iteration");
13571
0
                    goto failed;
13572
0
                }
13573
0
                asdl_seq_SET(names, i, val);
13574
0
            }
13575
0
            Py_CLEAR(tmp);
13576
0
        }
13577
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13578
0
            return -1;
13579
0
        }
13580
0
        if (tmp == NULL || tmp == Py_None) {
13581
0
            Py_CLEAR(tmp);
13582
0
            is_lazy = 0;
13583
0
        }
13584
0
        else {
13585
0
            int res;
13586
0
            if (_Py_EnterRecursiveCall(" while traversing 'Import' node")) {
13587
0
                goto failed;
13588
0
            }
13589
0
            res = obj2ast_int(state, tmp, &is_lazy, arena);
13590
0
            _Py_LeaveRecursiveCall();
13591
0
            if (res != 0) goto failed;
13592
0
            Py_CLEAR(tmp);
13593
0
        }
13594
0
        *out = _PyAST_Import(names, is_lazy, lineno, col_offset, end_lineno,
13595
0
                             end_col_offset, arena);
13596
0
        if (*out == NULL) goto failed;
13597
0
        return 0;
13598
0
    }
13599
0
    tp = state->ImportFrom_type;
13600
0
    isinstance = PyObject_IsInstance(obj, tp);
13601
0
    if (isinstance == -1) {
13602
0
        return -1;
13603
0
    }
13604
0
    if (isinstance) {
13605
0
        identifier module;
13606
0
        asdl_alias_seq* names;
13607
0
        int level;
13608
0
        int is_lazy;
13609
13610
0
        if (PyObject_GetOptionalAttr(obj, state->module, &tmp) < 0) {
13611
0
            return -1;
13612
0
        }
13613
0
        if (tmp == NULL || tmp == Py_None) {
13614
0
            Py_CLEAR(tmp);
13615
0
            module = NULL;
13616
0
        }
13617
0
        else {
13618
0
            int res;
13619
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13620
0
                goto failed;
13621
0
            }
13622
0
            res = obj2ast_identifier(state, tmp, &module, arena);
13623
0
            _Py_LeaveRecursiveCall();
13624
0
            if (res != 0) goto failed;
13625
0
            Py_CLEAR(tmp);
13626
0
        }
13627
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13628
0
            return -1;
13629
0
        }
13630
0
        if (tmp == NULL) {
13631
0
            tmp = PyList_New(0);
13632
0
            if (tmp == NULL) {
13633
0
                return -1;
13634
0
            }
13635
0
        }
13636
0
        {
13637
0
            int res;
13638
0
            Py_ssize_t len;
13639
0
            Py_ssize_t i;
13640
0
            if (!PyList_Check(tmp)) {
13641
0
                PyErr_Format(PyExc_TypeError, "ImportFrom field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13642
0
                goto failed;
13643
0
            }
13644
0
            len = PyList_GET_SIZE(tmp);
13645
0
            names = _Py_asdl_alias_seq_new(len, arena);
13646
0
            if (names == NULL) goto failed;
13647
0
            for (i = 0; i < len; i++) {
13648
0
                alias_ty val;
13649
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13650
0
                if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13651
0
                    goto failed;
13652
0
                }
13653
0
                res = obj2ast_alias(state, tmp2, &val, arena);
13654
0
                _Py_LeaveRecursiveCall();
13655
0
                Py_DECREF(tmp2);
13656
0
                if (res != 0) goto failed;
13657
0
                if (len != PyList_GET_SIZE(tmp)) {
13658
0
                    PyErr_SetString(PyExc_RuntimeError, "ImportFrom field \"names\" changed size during iteration");
13659
0
                    goto failed;
13660
0
                }
13661
0
                asdl_seq_SET(names, i, val);
13662
0
            }
13663
0
            Py_CLEAR(tmp);
13664
0
        }
13665
0
        if (PyObject_GetOptionalAttr(obj, state->level, &tmp) < 0) {
13666
0
            return -1;
13667
0
        }
13668
0
        if (tmp == NULL || tmp == Py_None) {
13669
0
            Py_CLEAR(tmp);
13670
0
            level = 0;
13671
0
        }
13672
0
        else {
13673
0
            int res;
13674
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13675
0
                goto failed;
13676
0
            }
13677
0
            res = obj2ast_int(state, tmp, &level, arena);
13678
0
            _Py_LeaveRecursiveCall();
13679
0
            if (res != 0) goto failed;
13680
0
            Py_CLEAR(tmp);
13681
0
        }
13682
0
        if (PyObject_GetOptionalAttr(obj, state->is_lazy, &tmp) < 0) {
13683
0
            return -1;
13684
0
        }
13685
0
        if (tmp == NULL || tmp == Py_None) {
13686
0
            Py_CLEAR(tmp);
13687
0
            is_lazy = 0;
13688
0
        }
13689
0
        else {
13690
0
            int res;
13691
0
            if (_Py_EnterRecursiveCall(" while traversing 'ImportFrom' node")) {
13692
0
                goto failed;
13693
0
            }
13694
0
            res = obj2ast_int(state, tmp, &is_lazy, arena);
13695
0
            _Py_LeaveRecursiveCall();
13696
0
            if (res != 0) goto failed;
13697
0
            Py_CLEAR(tmp);
13698
0
        }
13699
0
        *out = _PyAST_ImportFrom(module, names, level, is_lazy, lineno,
13700
0
                                 col_offset, end_lineno, end_col_offset, arena);
13701
0
        if (*out == NULL) goto failed;
13702
0
        return 0;
13703
0
    }
13704
0
    tp = state->Global_type;
13705
0
    isinstance = PyObject_IsInstance(obj, tp);
13706
0
    if (isinstance == -1) {
13707
0
        return -1;
13708
0
    }
13709
0
    if (isinstance) {
13710
0
        asdl_identifier_seq* names;
13711
13712
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13713
0
            return -1;
13714
0
        }
13715
0
        if (tmp == NULL) {
13716
0
            tmp = PyList_New(0);
13717
0
            if (tmp == NULL) {
13718
0
                return -1;
13719
0
            }
13720
0
        }
13721
0
        {
13722
0
            int res;
13723
0
            Py_ssize_t len;
13724
0
            Py_ssize_t i;
13725
0
            if (!PyList_Check(tmp)) {
13726
0
                PyErr_Format(PyExc_TypeError, "Global field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13727
0
                goto failed;
13728
0
            }
13729
0
            len = PyList_GET_SIZE(tmp);
13730
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13731
0
            if (names == NULL) goto failed;
13732
0
            for (i = 0; i < len; i++) {
13733
0
                identifier val;
13734
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13735
0
                if (_Py_EnterRecursiveCall(" while traversing 'Global' node")) {
13736
0
                    goto failed;
13737
0
                }
13738
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13739
0
                _Py_LeaveRecursiveCall();
13740
0
                Py_DECREF(tmp2);
13741
0
                if (res != 0) goto failed;
13742
0
                if (len != PyList_GET_SIZE(tmp)) {
13743
0
                    PyErr_SetString(PyExc_RuntimeError, "Global field \"names\" changed size during iteration");
13744
0
                    goto failed;
13745
0
                }
13746
0
                asdl_seq_SET(names, i, val);
13747
0
            }
13748
0
            Py_CLEAR(tmp);
13749
0
        }
13750
0
        *out = _PyAST_Global(names, lineno, col_offset, end_lineno,
13751
0
                             end_col_offset, arena);
13752
0
        if (*out == NULL) goto failed;
13753
0
        return 0;
13754
0
    }
13755
0
    tp = state->Nonlocal_type;
13756
0
    isinstance = PyObject_IsInstance(obj, tp);
13757
0
    if (isinstance == -1) {
13758
0
        return -1;
13759
0
    }
13760
0
    if (isinstance) {
13761
0
        asdl_identifier_seq* names;
13762
13763
0
        if (PyObject_GetOptionalAttr(obj, state->names, &tmp) < 0) {
13764
0
            return -1;
13765
0
        }
13766
0
        if (tmp == NULL) {
13767
0
            tmp = PyList_New(0);
13768
0
            if (tmp == NULL) {
13769
0
                return -1;
13770
0
            }
13771
0
        }
13772
0
        {
13773
0
            int res;
13774
0
            Py_ssize_t len;
13775
0
            Py_ssize_t i;
13776
0
            if (!PyList_Check(tmp)) {
13777
0
                PyErr_Format(PyExc_TypeError, "Nonlocal field \"names\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
13778
0
                goto failed;
13779
0
            }
13780
0
            len = PyList_GET_SIZE(tmp);
13781
0
            names = _Py_asdl_identifier_seq_new(len, arena);
13782
0
            if (names == NULL) goto failed;
13783
0
            for (i = 0; i < len; i++) {
13784
0
                identifier val;
13785
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
13786
0
                if (_Py_EnterRecursiveCall(" while traversing 'Nonlocal' node")) {
13787
0
                    goto failed;
13788
0
                }
13789
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
13790
0
                _Py_LeaveRecursiveCall();
13791
0
                Py_DECREF(tmp2);
13792
0
                if (res != 0) goto failed;
13793
0
                if (len != PyList_GET_SIZE(tmp)) {
13794
0
                    PyErr_SetString(PyExc_RuntimeError, "Nonlocal field \"names\" changed size during iteration");
13795
0
                    goto failed;
13796
0
                }
13797
0
                asdl_seq_SET(names, i, val);
13798
0
            }
13799
0
            Py_CLEAR(tmp);
13800
0
        }
13801
0
        *out = _PyAST_Nonlocal(names, lineno, col_offset, end_lineno,
13802
0
                               end_col_offset, arena);
13803
0
        if (*out == NULL) goto failed;
13804
0
        return 0;
13805
0
    }
13806
0
    tp = state->Expr_type;
13807
0
    isinstance = PyObject_IsInstance(obj, tp);
13808
0
    if (isinstance == -1) {
13809
0
        return -1;
13810
0
    }
13811
0
    if (isinstance) {
13812
0
        expr_ty value;
13813
13814
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
13815
0
            return -1;
13816
0
        }
13817
0
        if (tmp == NULL) {
13818
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
13819
0
            return -1;
13820
0
        }
13821
0
        else {
13822
0
            int res;
13823
0
            if (_Py_EnterRecursiveCall(" while traversing 'Expr' node")) {
13824
0
                goto failed;
13825
0
            }
13826
0
            res = obj2ast_expr(state, tmp, &value, arena);
13827
0
            _Py_LeaveRecursiveCall();
13828
0
            if (res != 0) goto failed;
13829
0
            Py_CLEAR(tmp);
13830
0
        }
13831
0
        *out = _PyAST_Expr(value, lineno, col_offset, end_lineno,
13832
0
                           end_col_offset, arena);
13833
0
        if (*out == NULL) goto failed;
13834
0
        return 0;
13835
0
    }
13836
0
    tp = state->Pass_type;
13837
0
    isinstance = PyObject_IsInstance(obj, tp);
13838
0
    if (isinstance == -1) {
13839
0
        return -1;
13840
0
    }
13841
0
    if (isinstance) {
13842
13843
0
        *out = _PyAST_Pass(lineno, col_offset, end_lineno, end_col_offset,
13844
0
                           arena);
13845
0
        if (*out == NULL) goto failed;
13846
0
        return 0;
13847
0
    }
13848
0
    tp = state->Break_type;
13849
0
    isinstance = PyObject_IsInstance(obj, tp);
13850
0
    if (isinstance == -1) {
13851
0
        return -1;
13852
0
    }
13853
0
    if (isinstance) {
13854
13855
0
        *out = _PyAST_Break(lineno, col_offset, end_lineno, end_col_offset,
13856
0
                            arena);
13857
0
        if (*out == NULL) goto failed;
13858
0
        return 0;
13859
0
    }
13860
0
    tp = state->Continue_type;
13861
0
    isinstance = PyObject_IsInstance(obj, tp);
13862
0
    if (isinstance == -1) {
13863
0
        return -1;
13864
0
    }
13865
0
    if (isinstance) {
13866
13867
0
        *out = _PyAST_Continue(lineno, col_offset, end_lineno, end_col_offset,
13868
0
                               arena);
13869
0
        if (*out == NULL) goto failed;
13870
0
        return 0;
13871
0
    }
13872
13873
0
    PyErr_Format(PyExc_TypeError, "expected some sort of stmt, but got %R", obj);
13874
0
    failed:
13875
0
    Py_XDECREF(tmp);
13876
0
    return -1;
13877
0
}
13878
13879
int
13880
obj2ast_expr(struct ast_state *state, PyObject* obj, expr_ty* out, PyArena*
13881
             arena)
13882
0
{
13883
0
    int isinstance;
13884
13885
0
    PyObject *tmp = NULL;
13886
0
    PyObject *tp;
13887
0
    int lineno;
13888
0
    int col_offset;
13889
0
    int end_lineno;
13890
0
    int end_col_offset;
13891
13892
0
    if (obj == Py_None) {
13893
0
        *out = NULL;
13894
0
        return 0;
13895
0
    }
13896
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
13897
0
        return -1;
13898
0
    }
13899
0
    if (tmp == NULL) {
13900
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
13901
0
        return -1;
13902
0
    }
13903
0
    else {
13904
0
        int res;
13905
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13906
0
            goto failed;
13907
0
        }
13908
0
        res = obj2ast_int(state, tmp, &lineno, arena);
13909
0
        _Py_LeaveRecursiveCall();
13910
0
        if (res != 0) goto failed;
13911
0
        Py_CLEAR(tmp);
13912
0
    }
13913
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
13914
0
        return -1;
13915
0
    }
13916
0
    if (tmp == NULL) {
13917
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
13918
0
        return -1;
13919
0
    }
13920
0
    else {
13921
0
        int res;
13922
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13923
0
            goto failed;
13924
0
        }
13925
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
13926
0
        _Py_LeaveRecursiveCall();
13927
0
        if (res != 0) goto failed;
13928
0
        Py_CLEAR(tmp);
13929
0
    }
13930
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
13931
0
        return -1;
13932
0
    }
13933
0
    if (tmp == NULL || tmp == Py_None) {
13934
0
        Py_CLEAR(tmp);
13935
0
        end_lineno = lineno;
13936
0
    }
13937
0
    else {
13938
0
        int res;
13939
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13940
0
            goto failed;
13941
0
        }
13942
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
13943
0
        _Py_LeaveRecursiveCall();
13944
0
        if (res != 0) goto failed;
13945
0
        Py_CLEAR(tmp);
13946
0
    }
13947
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
13948
0
        return -1;
13949
0
    }
13950
0
    if (tmp == NULL || tmp == Py_None) {
13951
0
        Py_CLEAR(tmp);
13952
0
        end_col_offset = col_offset;
13953
0
    }
13954
0
    else {
13955
0
        int res;
13956
0
        if (_Py_EnterRecursiveCall(" while traversing 'expr' node")) {
13957
0
            goto failed;
13958
0
        }
13959
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
13960
0
        _Py_LeaveRecursiveCall();
13961
0
        if (res != 0) goto failed;
13962
0
        Py_CLEAR(tmp);
13963
0
    }
13964
0
    tp = state->BoolOp_type;
13965
0
    isinstance = PyObject_IsInstance(obj, tp);
13966
0
    if (isinstance == -1) {
13967
0
        return -1;
13968
0
    }
13969
0
    if (isinstance) {
13970
0
        boolop_ty op;
13971
0
        asdl_expr_seq* values;
13972
13973
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
13974
0
            return -1;
13975
0
        }
13976
0
        if (tmp == NULL) {
13977
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
13978
0
            return -1;
13979
0
        }
13980
0
        else {
13981
0
            int res;
13982
0
            if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
13983
0
                goto failed;
13984
0
            }
13985
0
            res = obj2ast_boolop(state, tmp, &op, arena);
13986
0
            _Py_LeaveRecursiveCall();
13987
0
            if (res != 0) goto failed;
13988
0
            Py_CLEAR(tmp);
13989
0
        }
13990
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
13991
0
            return -1;
13992
0
        }
13993
0
        if (tmp == NULL) {
13994
0
            tmp = PyList_New(0);
13995
0
            if (tmp == NULL) {
13996
0
                return -1;
13997
0
            }
13998
0
        }
13999
0
        {
14000
0
            int res;
14001
0
            Py_ssize_t len;
14002
0
            Py_ssize_t i;
14003
0
            if (!PyList_Check(tmp)) {
14004
0
                PyErr_Format(PyExc_TypeError, "BoolOp field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14005
0
                goto failed;
14006
0
            }
14007
0
            len = PyList_GET_SIZE(tmp);
14008
0
            values = _Py_asdl_expr_seq_new(len, arena);
14009
0
            if (values == NULL) goto failed;
14010
0
            for (i = 0; i < len; i++) {
14011
0
                expr_ty val;
14012
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14013
0
                if (_Py_EnterRecursiveCall(" while traversing 'BoolOp' node")) {
14014
0
                    goto failed;
14015
0
                }
14016
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14017
0
                _Py_LeaveRecursiveCall();
14018
0
                Py_DECREF(tmp2);
14019
0
                if (res != 0) goto failed;
14020
0
                if (len != PyList_GET_SIZE(tmp)) {
14021
0
                    PyErr_SetString(PyExc_RuntimeError, "BoolOp field \"values\" changed size during iteration");
14022
0
                    goto failed;
14023
0
                }
14024
0
                asdl_seq_SET(values, i, val);
14025
0
            }
14026
0
            Py_CLEAR(tmp);
14027
0
        }
14028
0
        *out = _PyAST_BoolOp(op, values, lineno, col_offset, end_lineno,
14029
0
                             end_col_offset, arena);
14030
0
        if (*out == NULL) goto failed;
14031
0
        return 0;
14032
0
    }
14033
0
    tp = state->NamedExpr_type;
14034
0
    isinstance = PyObject_IsInstance(obj, tp);
14035
0
    if (isinstance == -1) {
14036
0
        return -1;
14037
0
    }
14038
0
    if (isinstance) {
14039
0
        expr_ty target;
14040
0
        expr_ty value;
14041
14042
0
        if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
14043
0
            return -1;
14044
0
        }
14045
0
        if (tmp == NULL) {
14046
0
            PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from NamedExpr");
14047
0
            return -1;
14048
0
        }
14049
0
        else {
14050
0
            int res;
14051
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
14052
0
                goto failed;
14053
0
            }
14054
0
            res = obj2ast_expr(state, tmp, &target, arena);
14055
0
            _Py_LeaveRecursiveCall();
14056
0
            if (res != 0) goto failed;
14057
0
            Py_CLEAR(tmp);
14058
0
        }
14059
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14060
0
            return -1;
14061
0
        }
14062
0
        if (tmp == NULL) {
14063
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from NamedExpr");
14064
0
            return -1;
14065
0
        }
14066
0
        else {
14067
0
            int res;
14068
0
            if (_Py_EnterRecursiveCall(" while traversing 'NamedExpr' node")) {
14069
0
                goto failed;
14070
0
            }
14071
0
            res = obj2ast_expr(state, tmp, &value, arena);
14072
0
            _Py_LeaveRecursiveCall();
14073
0
            if (res != 0) goto failed;
14074
0
            Py_CLEAR(tmp);
14075
0
        }
14076
0
        *out = _PyAST_NamedExpr(target, value, lineno, col_offset, end_lineno,
14077
0
                                end_col_offset, arena);
14078
0
        if (*out == NULL) goto failed;
14079
0
        return 0;
14080
0
    }
14081
0
    tp = state->BinOp_type;
14082
0
    isinstance = PyObject_IsInstance(obj, tp);
14083
0
    if (isinstance == -1) {
14084
0
        return -1;
14085
0
    }
14086
0
    if (isinstance) {
14087
0
        expr_ty left;
14088
0
        operator_ty op;
14089
0
        expr_ty right;
14090
14091
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14092
0
            return -1;
14093
0
        }
14094
0
        if (tmp == NULL) {
14095
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
14096
0
            return -1;
14097
0
        }
14098
0
        else {
14099
0
            int res;
14100
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14101
0
                goto failed;
14102
0
            }
14103
0
            res = obj2ast_expr(state, tmp, &left, arena);
14104
0
            _Py_LeaveRecursiveCall();
14105
0
            if (res != 0) goto failed;
14106
0
            Py_CLEAR(tmp);
14107
0
        }
14108
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14109
0
            return -1;
14110
0
        }
14111
0
        if (tmp == NULL) {
14112
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
14113
0
            return -1;
14114
0
        }
14115
0
        else {
14116
0
            int res;
14117
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14118
0
                goto failed;
14119
0
            }
14120
0
            res = obj2ast_operator(state, tmp, &op, arena);
14121
0
            _Py_LeaveRecursiveCall();
14122
0
            if (res != 0) goto failed;
14123
0
            Py_CLEAR(tmp);
14124
0
        }
14125
0
        if (PyObject_GetOptionalAttr(obj, state->right, &tmp) < 0) {
14126
0
            return -1;
14127
0
        }
14128
0
        if (tmp == NULL) {
14129
0
            PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
14130
0
            return -1;
14131
0
        }
14132
0
        else {
14133
0
            int res;
14134
0
            if (_Py_EnterRecursiveCall(" while traversing 'BinOp' node")) {
14135
0
                goto failed;
14136
0
            }
14137
0
            res = obj2ast_expr(state, tmp, &right, arena);
14138
0
            _Py_LeaveRecursiveCall();
14139
0
            if (res != 0) goto failed;
14140
0
            Py_CLEAR(tmp);
14141
0
        }
14142
0
        *out = _PyAST_BinOp(left, op, right, lineno, col_offset, end_lineno,
14143
0
                            end_col_offset, arena);
14144
0
        if (*out == NULL) goto failed;
14145
0
        return 0;
14146
0
    }
14147
0
    tp = state->UnaryOp_type;
14148
0
    isinstance = PyObject_IsInstance(obj, tp);
14149
0
    if (isinstance == -1) {
14150
0
        return -1;
14151
0
    }
14152
0
    if (isinstance) {
14153
0
        unaryop_ty op;
14154
0
        expr_ty operand;
14155
14156
0
        if (PyObject_GetOptionalAttr(obj, state->op, &tmp) < 0) {
14157
0
            return -1;
14158
0
        }
14159
0
        if (tmp == NULL) {
14160
0
            PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
14161
0
            return -1;
14162
0
        }
14163
0
        else {
14164
0
            int res;
14165
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14166
0
                goto failed;
14167
0
            }
14168
0
            res = obj2ast_unaryop(state, tmp, &op, arena);
14169
0
            _Py_LeaveRecursiveCall();
14170
0
            if (res != 0) goto failed;
14171
0
            Py_CLEAR(tmp);
14172
0
        }
14173
0
        if (PyObject_GetOptionalAttr(obj, state->operand, &tmp) < 0) {
14174
0
            return -1;
14175
0
        }
14176
0
        if (tmp == NULL) {
14177
0
            PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
14178
0
            return -1;
14179
0
        }
14180
0
        else {
14181
0
            int res;
14182
0
            if (_Py_EnterRecursiveCall(" while traversing 'UnaryOp' node")) {
14183
0
                goto failed;
14184
0
            }
14185
0
            res = obj2ast_expr(state, tmp, &operand, arena);
14186
0
            _Py_LeaveRecursiveCall();
14187
0
            if (res != 0) goto failed;
14188
0
            Py_CLEAR(tmp);
14189
0
        }
14190
0
        *out = _PyAST_UnaryOp(op, operand, lineno, col_offset, end_lineno,
14191
0
                              end_col_offset, arena);
14192
0
        if (*out == NULL) goto failed;
14193
0
        return 0;
14194
0
    }
14195
0
    tp = state->Lambda_type;
14196
0
    isinstance = PyObject_IsInstance(obj, tp);
14197
0
    if (isinstance == -1) {
14198
0
        return -1;
14199
0
    }
14200
0
    if (isinstance) {
14201
0
        arguments_ty args;
14202
0
        expr_ty body;
14203
14204
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14205
0
            return -1;
14206
0
        }
14207
0
        if (tmp == NULL) {
14208
0
            PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
14209
0
            return -1;
14210
0
        }
14211
0
        else {
14212
0
            int res;
14213
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14214
0
                goto failed;
14215
0
            }
14216
0
            res = obj2ast_arguments(state, tmp, &args, arena);
14217
0
            _Py_LeaveRecursiveCall();
14218
0
            if (res != 0) goto failed;
14219
0
            Py_CLEAR(tmp);
14220
0
        }
14221
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14222
0
            return -1;
14223
0
        }
14224
0
        if (tmp == NULL) {
14225
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
14226
0
            return -1;
14227
0
        }
14228
0
        else {
14229
0
            int res;
14230
0
            if (_Py_EnterRecursiveCall(" while traversing 'Lambda' node")) {
14231
0
                goto failed;
14232
0
            }
14233
0
            res = obj2ast_expr(state, tmp, &body, arena);
14234
0
            _Py_LeaveRecursiveCall();
14235
0
            if (res != 0) goto failed;
14236
0
            Py_CLEAR(tmp);
14237
0
        }
14238
0
        *out = _PyAST_Lambda(args, body, lineno, col_offset, end_lineno,
14239
0
                             end_col_offset, arena);
14240
0
        if (*out == NULL) goto failed;
14241
0
        return 0;
14242
0
    }
14243
0
    tp = state->IfExp_type;
14244
0
    isinstance = PyObject_IsInstance(obj, tp);
14245
0
    if (isinstance == -1) {
14246
0
        return -1;
14247
0
    }
14248
0
    if (isinstance) {
14249
0
        expr_ty test;
14250
0
        expr_ty body;
14251
0
        expr_ty orelse;
14252
14253
0
        if (PyObject_GetOptionalAttr(obj, state->test, &tmp) < 0) {
14254
0
            return -1;
14255
0
        }
14256
0
        if (tmp == NULL) {
14257
0
            PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
14258
0
            return -1;
14259
0
        }
14260
0
        else {
14261
0
            int res;
14262
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14263
0
                goto failed;
14264
0
            }
14265
0
            res = obj2ast_expr(state, tmp, &test, arena);
14266
0
            _Py_LeaveRecursiveCall();
14267
0
            if (res != 0) goto failed;
14268
0
            Py_CLEAR(tmp);
14269
0
        }
14270
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
14271
0
            return -1;
14272
0
        }
14273
0
        if (tmp == NULL) {
14274
0
            PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
14275
0
            return -1;
14276
0
        }
14277
0
        else {
14278
0
            int res;
14279
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14280
0
                goto failed;
14281
0
            }
14282
0
            res = obj2ast_expr(state, tmp, &body, arena);
14283
0
            _Py_LeaveRecursiveCall();
14284
0
            if (res != 0) goto failed;
14285
0
            Py_CLEAR(tmp);
14286
0
        }
14287
0
        if (PyObject_GetOptionalAttr(obj, state->orelse, &tmp) < 0) {
14288
0
            return -1;
14289
0
        }
14290
0
        if (tmp == NULL) {
14291
0
            PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
14292
0
            return -1;
14293
0
        }
14294
0
        else {
14295
0
            int res;
14296
0
            if (_Py_EnterRecursiveCall(" while traversing 'IfExp' node")) {
14297
0
                goto failed;
14298
0
            }
14299
0
            res = obj2ast_expr(state, tmp, &orelse, arena);
14300
0
            _Py_LeaveRecursiveCall();
14301
0
            if (res != 0) goto failed;
14302
0
            Py_CLEAR(tmp);
14303
0
        }
14304
0
        *out = _PyAST_IfExp(test, body, orelse, lineno, col_offset, end_lineno,
14305
0
                            end_col_offset, arena);
14306
0
        if (*out == NULL) goto failed;
14307
0
        return 0;
14308
0
    }
14309
0
    tp = state->Dict_type;
14310
0
    isinstance = PyObject_IsInstance(obj, tp);
14311
0
    if (isinstance == -1) {
14312
0
        return -1;
14313
0
    }
14314
0
    if (isinstance) {
14315
0
        asdl_expr_seq* keys;
14316
0
        asdl_expr_seq* values;
14317
14318
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
14319
0
            return -1;
14320
0
        }
14321
0
        if (tmp == NULL) {
14322
0
            tmp = PyList_New(0);
14323
0
            if (tmp == NULL) {
14324
0
                return -1;
14325
0
            }
14326
0
        }
14327
0
        {
14328
0
            int res;
14329
0
            Py_ssize_t len;
14330
0
            Py_ssize_t i;
14331
0
            if (!PyList_Check(tmp)) {
14332
0
                PyErr_Format(PyExc_TypeError, "Dict field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14333
0
                goto failed;
14334
0
            }
14335
0
            len = PyList_GET_SIZE(tmp);
14336
0
            keys = _Py_asdl_expr_seq_new(len, arena);
14337
0
            if (keys == NULL) goto failed;
14338
0
            for (i = 0; i < len; i++) {
14339
0
                expr_ty val;
14340
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14341
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14342
0
                    goto failed;
14343
0
                }
14344
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14345
0
                _Py_LeaveRecursiveCall();
14346
0
                Py_DECREF(tmp2);
14347
0
                if (res != 0) goto failed;
14348
0
                if (len != PyList_GET_SIZE(tmp)) {
14349
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"keys\" changed size during iteration");
14350
0
                    goto failed;
14351
0
                }
14352
0
                asdl_seq_SET(keys, i, val);
14353
0
            }
14354
0
            Py_CLEAR(tmp);
14355
0
        }
14356
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
14357
0
            return -1;
14358
0
        }
14359
0
        if (tmp == NULL) {
14360
0
            tmp = PyList_New(0);
14361
0
            if (tmp == NULL) {
14362
0
                return -1;
14363
0
            }
14364
0
        }
14365
0
        {
14366
0
            int res;
14367
0
            Py_ssize_t len;
14368
0
            Py_ssize_t i;
14369
0
            if (!PyList_Check(tmp)) {
14370
0
                PyErr_Format(PyExc_TypeError, "Dict field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14371
0
                goto failed;
14372
0
            }
14373
0
            len = PyList_GET_SIZE(tmp);
14374
0
            values = _Py_asdl_expr_seq_new(len, arena);
14375
0
            if (values == NULL) goto failed;
14376
0
            for (i = 0; i < len; i++) {
14377
0
                expr_ty val;
14378
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14379
0
                if (_Py_EnterRecursiveCall(" while traversing 'Dict' node")) {
14380
0
                    goto failed;
14381
0
                }
14382
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14383
0
                _Py_LeaveRecursiveCall();
14384
0
                Py_DECREF(tmp2);
14385
0
                if (res != 0) goto failed;
14386
0
                if (len != PyList_GET_SIZE(tmp)) {
14387
0
                    PyErr_SetString(PyExc_RuntimeError, "Dict field \"values\" changed size during iteration");
14388
0
                    goto failed;
14389
0
                }
14390
0
                asdl_seq_SET(values, i, val);
14391
0
            }
14392
0
            Py_CLEAR(tmp);
14393
0
        }
14394
0
        *out = _PyAST_Dict(keys, values, lineno, col_offset, end_lineno,
14395
0
                           end_col_offset, arena);
14396
0
        if (*out == NULL) goto failed;
14397
0
        return 0;
14398
0
    }
14399
0
    tp = state->Set_type;
14400
0
    isinstance = PyObject_IsInstance(obj, tp);
14401
0
    if (isinstance == -1) {
14402
0
        return -1;
14403
0
    }
14404
0
    if (isinstance) {
14405
0
        asdl_expr_seq* elts;
14406
14407
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
14408
0
            return -1;
14409
0
        }
14410
0
        if (tmp == NULL) {
14411
0
            tmp = PyList_New(0);
14412
0
            if (tmp == NULL) {
14413
0
                return -1;
14414
0
            }
14415
0
        }
14416
0
        {
14417
0
            int res;
14418
0
            Py_ssize_t len;
14419
0
            Py_ssize_t i;
14420
0
            if (!PyList_Check(tmp)) {
14421
0
                PyErr_Format(PyExc_TypeError, "Set field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14422
0
                goto failed;
14423
0
            }
14424
0
            len = PyList_GET_SIZE(tmp);
14425
0
            elts = _Py_asdl_expr_seq_new(len, arena);
14426
0
            if (elts == NULL) goto failed;
14427
0
            for (i = 0; i < len; i++) {
14428
0
                expr_ty val;
14429
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14430
0
                if (_Py_EnterRecursiveCall(" while traversing 'Set' node")) {
14431
0
                    goto failed;
14432
0
                }
14433
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14434
0
                _Py_LeaveRecursiveCall();
14435
0
                Py_DECREF(tmp2);
14436
0
                if (res != 0) goto failed;
14437
0
                if (len != PyList_GET_SIZE(tmp)) {
14438
0
                    PyErr_SetString(PyExc_RuntimeError, "Set field \"elts\" changed size during iteration");
14439
0
                    goto failed;
14440
0
                }
14441
0
                asdl_seq_SET(elts, i, val);
14442
0
            }
14443
0
            Py_CLEAR(tmp);
14444
0
        }
14445
0
        *out = _PyAST_Set(elts, lineno, col_offset, end_lineno, end_col_offset,
14446
0
                          arena);
14447
0
        if (*out == NULL) goto failed;
14448
0
        return 0;
14449
0
    }
14450
0
    tp = state->ListComp_type;
14451
0
    isinstance = PyObject_IsInstance(obj, tp);
14452
0
    if (isinstance == -1) {
14453
0
        return -1;
14454
0
    }
14455
0
    if (isinstance) {
14456
0
        expr_ty elt;
14457
0
        asdl_comprehension_seq* generators;
14458
14459
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14460
0
            return -1;
14461
0
        }
14462
0
        if (tmp == NULL) {
14463
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
14464
0
            return -1;
14465
0
        }
14466
0
        else {
14467
0
            int res;
14468
0
            if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14469
0
                goto failed;
14470
0
            }
14471
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14472
0
            _Py_LeaveRecursiveCall();
14473
0
            if (res != 0) goto failed;
14474
0
            Py_CLEAR(tmp);
14475
0
        }
14476
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14477
0
            return -1;
14478
0
        }
14479
0
        if (tmp == NULL) {
14480
0
            tmp = PyList_New(0);
14481
0
            if (tmp == NULL) {
14482
0
                return -1;
14483
0
            }
14484
0
        }
14485
0
        {
14486
0
            int res;
14487
0
            Py_ssize_t len;
14488
0
            Py_ssize_t i;
14489
0
            if (!PyList_Check(tmp)) {
14490
0
                PyErr_Format(PyExc_TypeError, "ListComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14491
0
                goto failed;
14492
0
            }
14493
0
            len = PyList_GET_SIZE(tmp);
14494
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14495
0
            if (generators == NULL) goto failed;
14496
0
            for (i = 0; i < len; i++) {
14497
0
                comprehension_ty val;
14498
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14499
0
                if (_Py_EnterRecursiveCall(" while traversing 'ListComp' node")) {
14500
0
                    goto failed;
14501
0
                }
14502
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14503
0
                _Py_LeaveRecursiveCall();
14504
0
                Py_DECREF(tmp2);
14505
0
                if (res != 0) goto failed;
14506
0
                if (len != PyList_GET_SIZE(tmp)) {
14507
0
                    PyErr_SetString(PyExc_RuntimeError, "ListComp field \"generators\" changed size during iteration");
14508
0
                    goto failed;
14509
0
                }
14510
0
                asdl_seq_SET(generators, i, val);
14511
0
            }
14512
0
            Py_CLEAR(tmp);
14513
0
        }
14514
0
        *out = _PyAST_ListComp(elt, generators, lineno, col_offset, end_lineno,
14515
0
                               end_col_offset, arena);
14516
0
        if (*out == NULL) goto failed;
14517
0
        return 0;
14518
0
    }
14519
0
    tp = state->SetComp_type;
14520
0
    isinstance = PyObject_IsInstance(obj, tp);
14521
0
    if (isinstance == -1) {
14522
0
        return -1;
14523
0
    }
14524
0
    if (isinstance) {
14525
0
        expr_ty elt;
14526
0
        asdl_comprehension_seq* generators;
14527
14528
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14529
0
            return -1;
14530
0
        }
14531
0
        if (tmp == NULL) {
14532
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
14533
0
            return -1;
14534
0
        }
14535
0
        else {
14536
0
            int res;
14537
0
            if (_Py_EnterRecursiveCall(" while traversing 'SetComp' node")) {
14538
0
                goto failed;
14539
0
            }
14540
0
            res = obj2ast_expr(state, tmp, &elt, 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, "SetComp 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 'SetComp' 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, "SetComp 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_SetComp(elt, generators, lineno, col_offset, end_lineno,
14584
0
                              end_col_offset, arena);
14585
0
        if (*out == NULL) goto failed;
14586
0
        return 0;
14587
0
    }
14588
0
    tp = state->DictComp_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 key;
14595
0
        expr_ty value;
14596
0
        asdl_comprehension_seq* generators;
14597
14598
0
        if (PyObject_GetOptionalAttr(obj, state->key, &tmp) < 0) {
14599
0
            return -1;
14600
0
        }
14601
0
        if (tmp == NULL) {
14602
0
            PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
14603
0
            return -1;
14604
0
        }
14605
0
        else {
14606
0
            int res;
14607
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14608
0
                goto failed;
14609
0
            }
14610
0
            res = obj2ast_expr(state, tmp, &key, arena);
14611
0
            _Py_LeaveRecursiveCall();
14612
0
            if (res != 0) goto failed;
14613
0
            Py_CLEAR(tmp);
14614
0
        }
14615
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14616
0
            return -1;
14617
0
        }
14618
0
        if (tmp == NULL || tmp == Py_None) {
14619
0
            Py_CLEAR(tmp);
14620
0
            value = NULL;
14621
0
        }
14622
0
        else {
14623
0
            int res;
14624
0
            if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14625
0
                goto failed;
14626
0
            }
14627
0
            res = obj2ast_expr(state, tmp, &value, arena);
14628
0
            _Py_LeaveRecursiveCall();
14629
0
            if (res != 0) goto failed;
14630
0
            Py_CLEAR(tmp);
14631
0
        }
14632
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14633
0
            return -1;
14634
0
        }
14635
0
        if (tmp == NULL) {
14636
0
            tmp = PyList_New(0);
14637
0
            if (tmp == NULL) {
14638
0
                return -1;
14639
0
            }
14640
0
        }
14641
0
        {
14642
0
            int res;
14643
0
            Py_ssize_t len;
14644
0
            Py_ssize_t i;
14645
0
            if (!PyList_Check(tmp)) {
14646
0
                PyErr_Format(PyExc_TypeError, "DictComp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14647
0
                goto failed;
14648
0
            }
14649
0
            len = PyList_GET_SIZE(tmp);
14650
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14651
0
            if (generators == NULL) goto failed;
14652
0
            for (i = 0; i < len; i++) {
14653
0
                comprehension_ty val;
14654
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14655
0
                if (_Py_EnterRecursiveCall(" while traversing 'DictComp' node")) {
14656
0
                    goto failed;
14657
0
                }
14658
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14659
0
                _Py_LeaveRecursiveCall();
14660
0
                Py_DECREF(tmp2);
14661
0
                if (res != 0) goto failed;
14662
0
                if (len != PyList_GET_SIZE(tmp)) {
14663
0
                    PyErr_SetString(PyExc_RuntimeError, "DictComp field \"generators\" changed size during iteration");
14664
0
                    goto failed;
14665
0
                }
14666
0
                asdl_seq_SET(generators, i, val);
14667
0
            }
14668
0
            Py_CLEAR(tmp);
14669
0
        }
14670
0
        *out = _PyAST_DictComp(key, value, generators, lineno, col_offset,
14671
0
                               end_lineno, end_col_offset, arena);
14672
0
        if (*out == NULL) goto failed;
14673
0
        return 0;
14674
0
    }
14675
0
    tp = state->GeneratorExp_type;
14676
0
    isinstance = PyObject_IsInstance(obj, tp);
14677
0
    if (isinstance == -1) {
14678
0
        return -1;
14679
0
    }
14680
0
    if (isinstance) {
14681
0
        expr_ty elt;
14682
0
        asdl_comprehension_seq* generators;
14683
14684
0
        if (PyObject_GetOptionalAttr(obj, state->elt, &tmp) < 0) {
14685
0
            return -1;
14686
0
        }
14687
0
        if (tmp == NULL) {
14688
0
            PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
14689
0
            return -1;
14690
0
        }
14691
0
        else {
14692
0
            int res;
14693
0
            if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14694
0
                goto failed;
14695
0
            }
14696
0
            res = obj2ast_expr(state, tmp, &elt, arena);
14697
0
            _Py_LeaveRecursiveCall();
14698
0
            if (res != 0) goto failed;
14699
0
            Py_CLEAR(tmp);
14700
0
        }
14701
0
        if (PyObject_GetOptionalAttr(obj, state->generators, &tmp) < 0) {
14702
0
            return -1;
14703
0
        }
14704
0
        if (tmp == NULL) {
14705
0
            tmp = PyList_New(0);
14706
0
            if (tmp == NULL) {
14707
0
                return -1;
14708
0
            }
14709
0
        }
14710
0
        {
14711
0
            int res;
14712
0
            Py_ssize_t len;
14713
0
            Py_ssize_t i;
14714
0
            if (!PyList_Check(tmp)) {
14715
0
                PyErr_Format(PyExc_TypeError, "GeneratorExp field \"generators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14716
0
                goto failed;
14717
0
            }
14718
0
            len = PyList_GET_SIZE(tmp);
14719
0
            generators = _Py_asdl_comprehension_seq_new(len, arena);
14720
0
            if (generators == NULL) goto failed;
14721
0
            for (i = 0; i < len; i++) {
14722
0
                comprehension_ty val;
14723
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14724
0
                if (_Py_EnterRecursiveCall(" while traversing 'GeneratorExp' node")) {
14725
0
                    goto failed;
14726
0
                }
14727
0
                res = obj2ast_comprehension(state, tmp2, &val, arena);
14728
0
                _Py_LeaveRecursiveCall();
14729
0
                Py_DECREF(tmp2);
14730
0
                if (res != 0) goto failed;
14731
0
                if (len != PyList_GET_SIZE(tmp)) {
14732
0
                    PyErr_SetString(PyExc_RuntimeError, "GeneratorExp field \"generators\" changed size during iteration");
14733
0
                    goto failed;
14734
0
                }
14735
0
                asdl_seq_SET(generators, i, val);
14736
0
            }
14737
0
            Py_CLEAR(tmp);
14738
0
        }
14739
0
        *out = _PyAST_GeneratorExp(elt, generators, lineno, col_offset,
14740
0
                                   end_lineno, end_col_offset, arena);
14741
0
        if (*out == NULL) goto failed;
14742
0
        return 0;
14743
0
    }
14744
0
    tp = state->Await_type;
14745
0
    isinstance = PyObject_IsInstance(obj, tp);
14746
0
    if (isinstance == -1) {
14747
0
        return -1;
14748
0
    }
14749
0
    if (isinstance) {
14750
0
        expr_ty value;
14751
14752
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14753
0
            return -1;
14754
0
        }
14755
0
        if (tmp == NULL) {
14756
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Await");
14757
0
            return -1;
14758
0
        }
14759
0
        else {
14760
0
            int res;
14761
0
            if (_Py_EnterRecursiveCall(" while traversing 'Await' node")) {
14762
0
                goto failed;
14763
0
            }
14764
0
            res = obj2ast_expr(state, tmp, &value, arena);
14765
0
            _Py_LeaveRecursiveCall();
14766
0
            if (res != 0) goto failed;
14767
0
            Py_CLEAR(tmp);
14768
0
        }
14769
0
        *out = _PyAST_Await(value, lineno, col_offset, end_lineno,
14770
0
                            end_col_offset, arena);
14771
0
        if (*out == NULL) goto failed;
14772
0
        return 0;
14773
0
    }
14774
0
    tp = state->Yield_type;
14775
0
    isinstance = PyObject_IsInstance(obj, tp);
14776
0
    if (isinstance == -1) {
14777
0
        return -1;
14778
0
    }
14779
0
    if (isinstance) {
14780
0
        expr_ty value;
14781
14782
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14783
0
            return -1;
14784
0
        }
14785
0
        if (tmp == NULL || tmp == Py_None) {
14786
0
            Py_CLEAR(tmp);
14787
0
            value = NULL;
14788
0
        }
14789
0
        else {
14790
0
            int res;
14791
0
            if (_Py_EnterRecursiveCall(" while traversing 'Yield' node")) {
14792
0
                goto failed;
14793
0
            }
14794
0
            res = obj2ast_expr(state, tmp, &value, arena);
14795
0
            _Py_LeaveRecursiveCall();
14796
0
            if (res != 0) goto failed;
14797
0
            Py_CLEAR(tmp);
14798
0
        }
14799
0
        *out = _PyAST_Yield(value, lineno, col_offset, end_lineno,
14800
0
                            end_col_offset, arena);
14801
0
        if (*out == NULL) goto failed;
14802
0
        return 0;
14803
0
    }
14804
0
    tp = state->YieldFrom_type;
14805
0
    isinstance = PyObject_IsInstance(obj, tp);
14806
0
    if (isinstance == -1) {
14807
0
        return -1;
14808
0
    }
14809
0
    if (isinstance) {
14810
0
        expr_ty value;
14811
14812
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
14813
0
            return -1;
14814
0
        }
14815
0
        if (tmp == NULL) {
14816
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
14817
0
            return -1;
14818
0
        }
14819
0
        else {
14820
0
            int res;
14821
0
            if (_Py_EnterRecursiveCall(" while traversing 'YieldFrom' node")) {
14822
0
                goto failed;
14823
0
            }
14824
0
            res = obj2ast_expr(state, tmp, &value, arena);
14825
0
            _Py_LeaveRecursiveCall();
14826
0
            if (res != 0) goto failed;
14827
0
            Py_CLEAR(tmp);
14828
0
        }
14829
0
        *out = _PyAST_YieldFrom(value, lineno, col_offset, end_lineno,
14830
0
                                end_col_offset, arena);
14831
0
        if (*out == NULL) goto failed;
14832
0
        return 0;
14833
0
    }
14834
0
    tp = state->Compare_type;
14835
0
    isinstance = PyObject_IsInstance(obj, tp);
14836
0
    if (isinstance == -1) {
14837
0
        return -1;
14838
0
    }
14839
0
    if (isinstance) {
14840
0
        expr_ty left;
14841
0
        asdl_int_seq* ops;
14842
0
        asdl_expr_seq* comparators;
14843
14844
0
        if (PyObject_GetOptionalAttr(obj, state->left, &tmp) < 0) {
14845
0
            return -1;
14846
0
        }
14847
0
        if (tmp == NULL) {
14848
0
            PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
14849
0
            return -1;
14850
0
        }
14851
0
        else {
14852
0
            int res;
14853
0
            if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14854
0
                goto failed;
14855
0
            }
14856
0
            res = obj2ast_expr(state, tmp, &left, arena);
14857
0
            _Py_LeaveRecursiveCall();
14858
0
            if (res != 0) goto failed;
14859
0
            Py_CLEAR(tmp);
14860
0
        }
14861
0
        if (PyObject_GetOptionalAttr(obj, state->ops, &tmp) < 0) {
14862
0
            return -1;
14863
0
        }
14864
0
        if (tmp == NULL) {
14865
0
            tmp = PyList_New(0);
14866
0
            if (tmp == NULL) {
14867
0
                return -1;
14868
0
            }
14869
0
        }
14870
0
        {
14871
0
            int res;
14872
0
            Py_ssize_t len;
14873
0
            Py_ssize_t i;
14874
0
            if (!PyList_Check(tmp)) {
14875
0
                PyErr_Format(PyExc_TypeError, "Compare field \"ops\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14876
0
                goto failed;
14877
0
            }
14878
0
            len = PyList_GET_SIZE(tmp);
14879
0
            ops = _Py_asdl_int_seq_new(len, arena);
14880
0
            if (ops == NULL) goto failed;
14881
0
            for (i = 0; i < len; i++) {
14882
0
                cmpop_ty val;
14883
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14884
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14885
0
                    goto failed;
14886
0
                }
14887
0
                res = obj2ast_cmpop(state, tmp2, &val, arena);
14888
0
                _Py_LeaveRecursiveCall();
14889
0
                Py_DECREF(tmp2);
14890
0
                if (res != 0) goto failed;
14891
0
                if (len != PyList_GET_SIZE(tmp)) {
14892
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"ops\" changed size during iteration");
14893
0
                    goto failed;
14894
0
                }
14895
0
                asdl_seq_SET(ops, i, val);
14896
0
            }
14897
0
            Py_CLEAR(tmp);
14898
0
        }
14899
0
        if (PyObject_GetOptionalAttr(obj, state->comparators, &tmp) < 0) {
14900
0
            return -1;
14901
0
        }
14902
0
        if (tmp == NULL) {
14903
0
            tmp = PyList_New(0);
14904
0
            if (tmp == NULL) {
14905
0
                return -1;
14906
0
            }
14907
0
        }
14908
0
        {
14909
0
            int res;
14910
0
            Py_ssize_t len;
14911
0
            Py_ssize_t i;
14912
0
            if (!PyList_Check(tmp)) {
14913
0
                PyErr_Format(PyExc_TypeError, "Compare field \"comparators\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14914
0
                goto failed;
14915
0
            }
14916
0
            len = PyList_GET_SIZE(tmp);
14917
0
            comparators = _Py_asdl_expr_seq_new(len, arena);
14918
0
            if (comparators == NULL) goto failed;
14919
0
            for (i = 0; i < len; i++) {
14920
0
                expr_ty val;
14921
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14922
0
                if (_Py_EnterRecursiveCall(" while traversing 'Compare' node")) {
14923
0
                    goto failed;
14924
0
                }
14925
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14926
0
                _Py_LeaveRecursiveCall();
14927
0
                Py_DECREF(tmp2);
14928
0
                if (res != 0) goto failed;
14929
0
                if (len != PyList_GET_SIZE(tmp)) {
14930
0
                    PyErr_SetString(PyExc_RuntimeError, "Compare field \"comparators\" changed size during iteration");
14931
0
                    goto failed;
14932
0
                }
14933
0
                asdl_seq_SET(comparators, i, val);
14934
0
            }
14935
0
            Py_CLEAR(tmp);
14936
0
        }
14937
0
        *out = _PyAST_Compare(left, ops, comparators, lineno, col_offset,
14938
0
                              end_lineno, end_col_offset, arena);
14939
0
        if (*out == NULL) goto failed;
14940
0
        return 0;
14941
0
    }
14942
0
    tp = state->Call_type;
14943
0
    isinstance = PyObject_IsInstance(obj, tp);
14944
0
    if (isinstance == -1) {
14945
0
        return -1;
14946
0
    }
14947
0
    if (isinstance) {
14948
0
        expr_ty func;
14949
0
        asdl_expr_seq* args;
14950
0
        asdl_keyword_seq* keywords;
14951
14952
0
        if (PyObject_GetOptionalAttr(obj, state->func, &tmp) < 0) {
14953
0
            return -1;
14954
0
        }
14955
0
        if (tmp == NULL) {
14956
0
            PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
14957
0
            return -1;
14958
0
        }
14959
0
        else {
14960
0
            int res;
14961
0
            if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14962
0
                goto failed;
14963
0
            }
14964
0
            res = obj2ast_expr(state, tmp, &func, arena);
14965
0
            _Py_LeaveRecursiveCall();
14966
0
            if (res != 0) goto failed;
14967
0
            Py_CLEAR(tmp);
14968
0
        }
14969
0
        if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
14970
0
            return -1;
14971
0
        }
14972
0
        if (tmp == NULL) {
14973
0
            tmp = PyList_New(0);
14974
0
            if (tmp == NULL) {
14975
0
                return -1;
14976
0
            }
14977
0
        }
14978
0
        {
14979
0
            int res;
14980
0
            Py_ssize_t len;
14981
0
            Py_ssize_t i;
14982
0
            if (!PyList_Check(tmp)) {
14983
0
                PyErr_Format(PyExc_TypeError, "Call field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
14984
0
                goto failed;
14985
0
            }
14986
0
            len = PyList_GET_SIZE(tmp);
14987
0
            args = _Py_asdl_expr_seq_new(len, arena);
14988
0
            if (args == NULL) goto failed;
14989
0
            for (i = 0; i < len; i++) {
14990
0
                expr_ty val;
14991
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
14992
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
14993
0
                    goto failed;
14994
0
                }
14995
0
                res = obj2ast_expr(state, tmp2, &val, arena);
14996
0
                _Py_LeaveRecursiveCall();
14997
0
                Py_DECREF(tmp2);
14998
0
                if (res != 0) goto failed;
14999
0
                if (len != PyList_GET_SIZE(tmp)) {
15000
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"args\" changed size during iteration");
15001
0
                    goto failed;
15002
0
                }
15003
0
                asdl_seq_SET(args, i, val);
15004
0
            }
15005
0
            Py_CLEAR(tmp);
15006
0
        }
15007
0
        if (PyObject_GetOptionalAttr(obj, state->keywords, &tmp) < 0) {
15008
0
            return -1;
15009
0
        }
15010
0
        if (tmp == NULL) {
15011
0
            tmp = PyList_New(0);
15012
0
            if (tmp == NULL) {
15013
0
                return -1;
15014
0
            }
15015
0
        }
15016
0
        {
15017
0
            int res;
15018
0
            Py_ssize_t len;
15019
0
            Py_ssize_t i;
15020
0
            if (!PyList_Check(tmp)) {
15021
0
                PyErr_Format(PyExc_TypeError, "Call field \"keywords\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15022
0
                goto failed;
15023
0
            }
15024
0
            len = PyList_GET_SIZE(tmp);
15025
0
            keywords = _Py_asdl_keyword_seq_new(len, arena);
15026
0
            if (keywords == NULL) goto failed;
15027
0
            for (i = 0; i < len; i++) {
15028
0
                keyword_ty val;
15029
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15030
0
                if (_Py_EnterRecursiveCall(" while traversing 'Call' node")) {
15031
0
                    goto failed;
15032
0
                }
15033
0
                res = obj2ast_keyword(state, tmp2, &val, arena);
15034
0
                _Py_LeaveRecursiveCall();
15035
0
                Py_DECREF(tmp2);
15036
0
                if (res != 0) goto failed;
15037
0
                if (len != PyList_GET_SIZE(tmp)) {
15038
0
                    PyErr_SetString(PyExc_RuntimeError, "Call field \"keywords\" changed size during iteration");
15039
0
                    goto failed;
15040
0
                }
15041
0
                asdl_seq_SET(keywords, i, val);
15042
0
            }
15043
0
            Py_CLEAR(tmp);
15044
0
        }
15045
0
        *out = _PyAST_Call(func, args, keywords, lineno, col_offset,
15046
0
                           end_lineno, end_col_offset, arena);
15047
0
        if (*out == NULL) goto failed;
15048
0
        return 0;
15049
0
    }
15050
0
    tp = state->FormattedValue_type;
15051
0
    isinstance = PyObject_IsInstance(obj, tp);
15052
0
    if (isinstance == -1) {
15053
0
        return -1;
15054
0
    }
15055
0
    if (isinstance) {
15056
0
        expr_ty value;
15057
0
        int conversion;
15058
0
        expr_ty format_spec;
15059
15060
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15061
0
            return -1;
15062
0
        }
15063
0
        if (tmp == NULL) {
15064
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from FormattedValue");
15065
0
            return -1;
15066
0
        }
15067
0
        else {
15068
0
            int res;
15069
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15070
0
                goto failed;
15071
0
            }
15072
0
            res = obj2ast_expr(state, tmp, &value, arena);
15073
0
            _Py_LeaveRecursiveCall();
15074
0
            if (res != 0) goto failed;
15075
0
            Py_CLEAR(tmp);
15076
0
        }
15077
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15078
0
            return -1;
15079
0
        }
15080
0
        if (tmp == NULL) {
15081
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from FormattedValue");
15082
0
            return -1;
15083
0
        }
15084
0
        else {
15085
0
            int res;
15086
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15087
0
                goto failed;
15088
0
            }
15089
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15090
0
            _Py_LeaveRecursiveCall();
15091
0
            if (res != 0) goto failed;
15092
0
            Py_CLEAR(tmp);
15093
0
        }
15094
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15095
0
            return -1;
15096
0
        }
15097
0
        if (tmp == NULL || tmp == Py_None) {
15098
0
            Py_CLEAR(tmp);
15099
0
            format_spec = NULL;
15100
0
        }
15101
0
        else {
15102
0
            int res;
15103
0
            if (_Py_EnterRecursiveCall(" while traversing 'FormattedValue' node")) {
15104
0
                goto failed;
15105
0
            }
15106
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15107
0
            _Py_LeaveRecursiveCall();
15108
0
            if (res != 0) goto failed;
15109
0
            Py_CLEAR(tmp);
15110
0
        }
15111
0
        *out = _PyAST_FormattedValue(value, conversion, format_spec, lineno,
15112
0
                                     col_offset, end_lineno, end_col_offset,
15113
0
                                     arena);
15114
0
        if (*out == NULL) goto failed;
15115
0
        return 0;
15116
0
    }
15117
0
    tp = state->Interpolation_type;
15118
0
    isinstance = PyObject_IsInstance(obj, tp);
15119
0
    if (isinstance == -1) {
15120
0
        return -1;
15121
0
    }
15122
0
    if (isinstance) {
15123
0
        expr_ty value;
15124
0
        constant str;
15125
0
        int conversion;
15126
0
        expr_ty format_spec;
15127
15128
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15129
0
            return -1;
15130
0
        }
15131
0
        if (tmp == NULL) {
15132
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Interpolation");
15133
0
            return -1;
15134
0
        }
15135
0
        else {
15136
0
            int res;
15137
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15138
0
                goto failed;
15139
0
            }
15140
0
            res = obj2ast_expr(state, tmp, &value, arena);
15141
0
            _Py_LeaveRecursiveCall();
15142
0
            if (res != 0) goto failed;
15143
0
            Py_CLEAR(tmp);
15144
0
        }
15145
0
        if (PyObject_GetOptionalAttr(obj, state->str, &tmp) < 0) {
15146
0
            return -1;
15147
0
        }
15148
0
        if (tmp == NULL) {
15149
0
            PyErr_SetString(PyExc_TypeError, "required field \"str\" missing from Interpolation");
15150
0
            return -1;
15151
0
        }
15152
0
        else {
15153
0
            int res;
15154
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15155
0
                goto failed;
15156
0
            }
15157
0
            res = obj2ast_constant(state, tmp, &str, arena);
15158
0
            _Py_LeaveRecursiveCall();
15159
0
            if (res != 0) goto failed;
15160
0
            Py_CLEAR(tmp);
15161
0
        }
15162
0
        if (PyObject_GetOptionalAttr(obj, state->conversion, &tmp) < 0) {
15163
0
            return -1;
15164
0
        }
15165
0
        if (tmp == NULL) {
15166
0
            PyErr_SetString(PyExc_TypeError, "required field \"conversion\" missing from Interpolation");
15167
0
            return -1;
15168
0
        }
15169
0
        else {
15170
0
            int res;
15171
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15172
0
                goto failed;
15173
0
            }
15174
0
            res = obj2ast_int(state, tmp, &conversion, arena);
15175
0
            _Py_LeaveRecursiveCall();
15176
0
            if (res != 0) goto failed;
15177
0
            Py_CLEAR(tmp);
15178
0
        }
15179
0
        if (PyObject_GetOptionalAttr(obj, state->format_spec, &tmp) < 0) {
15180
0
            return -1;
15181
0
        }
15182
0
        if (tmp == NULL || tmp == Py_None) {
15183
0
            Py_CLEAR(tmp);
15184
0
            format_spec = NULL;
15185
0
        }
15186
0
        else {
15187
0
            int res;
15188
0
            if (_Py_EnterRecursiveCall(" while traversing 'Interpolation' node")) {
15189
0
                goto failed;
15190
0
            }
15191
0
            res = obj2ast_expr(state, tmp, &format_spec, arena);
15192
0
            _Py_LeaveRecursiveCall();
15193
0
            if (res != 0) goto failed;
15194
0
            Py_CLEAR(tmp);
15195
0
        }
15196
0
        *out = _PyAST_Interpolation(value, str, conversion, format_spec,
15197
0
                                    lineno, col_offset, end_lineno,
15198
0
                                    end_col_offset, arena);
15199
0
        if (*out == NULL) goto failed;
15200
0
        return 0;
15201
0
    }
15202
0
    tp = state->JoinedStr_type;
15203
0
    isinstance = PyObject_IsInstance(obj, tp);
15204
0
    if (isinstance == -1) {
15205
0
        return -1;
15206
0
    }
15207
0
    if (isinstance) {
15208
0
        asdl_expr_seq* values;
15209
15210
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15211
0
            return -1;
15212
0
        }
15213
0
        if (tmp == NULL) {
15214
0
            tmp = PyList_New(0);
15215
0
            if (tmp == NULL) {
15216
0
                return -1;
15217
0
            }
15218
0
        }
15219
0
        {
15220
0
            int res;
15221
0
            Py_ssize_t len;
15222
0
            Py_ssize_t i;
15223
0
            if (!PyList_Check(tmp)) {
15224
0
                PyErr_Format(PyExc_TypeError, "JoinedStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15225
0
                goto failed;
15226
0
            }
15227
0
            len = PyList_GET_SIZE(tmp);
15228
0
            values = _Py_asdl_expr_seq_new(len, arena);
15229
0
            if (values == NULL) goto failed;
15230
0
            for (i = 0; i < len; i++) {
15231
0
                expr_ty val;
15232
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15233
0
                if (_Py_EnterRecursiveCall(" while traversing 'JoinedStr' node")) {
15234
0
                    goto failed;
15235
0
                }
15236
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15237
0
                _Py_LeaveRecursiveCall();
15238
0
                Py_DECREF(tmp2);
15239
0
                if (res != 0) goto failed;
15240
0
                if (len != PyList_GET_SIZE(tmp)) {
15241
0
                    PyErr_SetString(PyExc_RuntimeError, "JoinedStr field \"values\" changed size during iteration");
15242
0
                    goto failed;
15243
0
                }
15244
0
                asdl_seq_SET(values, i, val);
15245
0
            }
15246
0
            Py_CLEAR(tmp);
15247
0
        }
15248
0
        *out = _PyAST_JoinedStr(values, lineno, col_offset, end_lineno,
15249
0
                                end_col_offset, arena);
15250
0
        if (*out == NULL) goto failed;
15251
0
        return 0;
15252
0
    }
15253
0
    tp = state->TemplateStr_type;
15254
0
    isinstance = PyObject_IsInstance(obj, tp);
15255
0
    if (isinstance == -1) {
15256
0
        return -1;
15257
0
    }
15258
0
    if (isinstance) {
15259
0
        asdl_expr_seq* values;
15260
15261
0
        if (PyObject_GetOptionalAttr(obj, state->values, &tmp) < 0) {
15262
0
            return -1;
15263
0
        }
15264
0
        if (tmp == NULL) {
15265
0
            tmp = PyList_New(0);
15266
0
            if (tmp == NULL) {
15267
0
                return -1;
15268
0
            }
15269
0
        }
15270
0
        {
15271
0
            int res;
15272
0
            Py_ssize_t len;
15273
0
            Py_ssize_t i;
15274
0
            if (!PyList_Check(tmp)) {
15275
0
                PyErr_Format(PyExc_TypeError, "TemplateStr field \"values\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15276
0
                goto failed;
15277
0
            }
15278
0
            len = PyList_GET_SIZE(tmp);
15279
0
            values = _Py_asdl_expr_seq_new(len, arena);
15280
0
            if (values == NULL) goto failed;
15281
0
            for (i = 0; i < len; i++) {
15282
0
                expr_ty val;
15283
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15284
0
                if (_Py_EnterRecursiveCall(" while traversing 'TemplateStr' node")) {
15285
0
                    goto failed;
15286
0
                }
15287
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15288
0
                _Py_LeaveRecursiveCall();
15289
0
                Py_DECREF(tmp2);
15290
0
                if (res != 0) goto failed;
15291
0
                if (len != PyList_GET_SIZE(tmp)) {
15292
0
                    PyErr_SetString(PyExc_RuntimeError, "TemplateStr field \"values\" changed size during iteration");
15293
0
                    goto failed;
15294
0
                }
15295
0
                asdl_seq_SET(values, i, val);
15296
0
            }
15297
0
            Py_CLEAR(tmp);
15298
0
        }
15299
0
        *out = _PyAST_TemplateStr(values, lineno, col_offset, end_lineno,
15300
0
                                  end_col_offset, arena);
15301
0
        if (*out == NULL) goto failed;
15302
0
        return 0;
15303
0
    }
15304
0
    tp = state->Constant_type;
15305
0
    isinstance = PyObject_IsInstance(obj, tp);
15306
0
    if (isinstance == -1) {
15307
0
        return -1;
15308
0
    }
15309
0
    if (isinstance) {
15310
0
        constant value;
15311
0
        string kind;
15312
15313
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15314
0
            return -1;
15315
0
        }
15316
0
        if (tmp == NULL) {
15317
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Constant");
15318
0
            return -1;
15319
0
        }
15320
0
        else {
15321
0
            int res;
15322
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15323
0
                goto failed;
15324
0
            }
15325
0
            res = obj2ast_constant(state, tmp, &value, arena);
15326
0
            _Py_LeaveRecursiveCall();
15327
0
            if (res != 0) goto failed;
15328
0
            Py_CLEAR(tmp);
15329
0
        }
15330
0
        if (PyObject_GetOptionalAttr(obj, state->kind, &tmp) < 0) {
15331
0
            return -1;
15332
0
        }
15333
0
        if (tmp == NULL || tmp == Py_None) {
15334
0
            Py_CLEAR(tmp);
15335
0
            kind = NULL;
15336
0
        }
15337
0
        else {
15338
0
            int res;
15339
0
            if (_Py_EnterRecursiveCall(" while traversing 'Constant' node")) {
15340
0
                goto failed;
15341
0
            }
15342
0
            res = obj2ast_string(state, tmp, &kind, arena);
15343
0
            _Py_LeaveRecursiveCall();
15344
0
            if (res != 0) goto failed;
15345
0
            Py_CLEAR(tmp);
15346
0
        }
15347
0
        *out = _PyAST_Constant(value, kind, lineno, col_offset, end_lineno,
15348
0
                               end_col_offset, arena);
15349
0
        if (*out == NULL) goto failed;
15350
0
        return 0;
15351
0
    }
15352
0
    tp = state->Attribute_type;
15353
0
    isinstance = PyObject_IsInstance(obj, tp);
15354
0
    if (isinstance == -1) {
15355
0
        return -1;
15356
0
    }
15357
0
    if (isinstance) {
15358
0
        expr_ty value;
15359
0
        identifier attr;
15360
0
        expr_context_ty ctx;
15361
15362
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15363
0
            return -1;
15364
0
        }
15365
0
        if (tmp == NULL) {
15366
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
15367
0
            return -1;
15368
0
        }
15369
0
        else {
15370
0
            int res;
15371
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15372
0
                goto failed;
15373
0
            }
15374
0
            res = obj2ast_expr(state, tmp, &value, arena);
15375
0
            _Py_LeaveRecursiveCall();
15376
0
            if (res != 0) goto failed;
15377
0
            Py_CLEAR(tmp);
15378
0
        }
15379
0
        if (PyObject_GetOptionalAttr(obj, state->attr, &tmp) < 0) {
15380
0
            return -1;
15381
0
        }
15382
0
        if (tmp == NULL) {
15383
0
            PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
15384
0
            return -1;
15385
0
        }
15386
0
        else {
15387
0
            int res;
15388
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15389
0
                goto failed;
15390
0
            }
15391
0
            res = obj2ast_identifier(state, tmp, &attr, arena);
15392
0
            _Py_LeaveRecursiveCall();
15393
0
            if (res != 0) goto failed;
15394
0
            Py_CLEAR(tmp);
15395
0
        }
15396
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15397
0
            return -1;
15398
0
        }
15399
0
        if (tmp == NULL) {
15400
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
15401
0
            return -1;
15402
0
        }
15403
0
        else {
15404
0
            int res;
15405
0
            if (_Py_EnterRecursiveCall(" while traversing 'Attribute' node")) {
15406
0
                goto failed;
15407
0
            }
15408
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15409
0
            _Py_LeaveRecursiveCall();
15410
0
            if (res != 0) goto failed;
15411
0
            Py_CLEAR(tmp);
15412
0
        }
15413
0
        *out = _PyAST_Attribute(value, attr, ctx, lineno, col_offset,
15414
0
                                end_lineno, end_col_offset, arena);
15415
0
        if (*out == NULL) goto failed;
15416
0
        return 0;
15417
0
    }
15418
0
    tp = state->Subscript_type;
15419
0
    isinstance = PyObject_IsInstance(obj, tp);
15420
0
    if (isinstance == -1) {
15421
0
        return -1;
15422
0
    }
15423
0
    if (isinstance) {
15424
0
        expr_ty value;
15425
0
        expr_ty slice;
15426
0
        expr_context_ty ctx;
15427
15428
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15429
0
            return -1;
15430
0
        }
15431
0
        if (tmp == NULL) {
15432
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
15433
0
            return -1;
15434
0
        }
15435
0
        else {
15436
0
            int res;
15437
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15438
0
                goto failed;
15439
0
            }
15440
0
            res = obj2ast_expr(state, tmp, &value, arena);
15441
0
            _Py_LeaveRecursiveCall();
15442
0
            if (res != 0) goto failed;
15443
0
            Py_CLEAR(tmp);
15444
0
        }
15445
0
        if (PyObject_GetOptionalAttr(obj, state->slice, &tmp) < 0) {
15446
0
            return -1;
15447
0
        }
15448
0
        if (tmp == NULL) {
15449
0
            PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
15450
0
            return -1;
15451
0
        }
15452
0
        else {
15453
0
            int res;
15454
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15455
0
                goto failed;
15456
0
            }
15457
0
            res = obj2ast_expr(state, tmp, &slice, arena);
15458
0
            _Py_LeaveRecursiveCall();
15459
0
            if (res != 0) goto failed;
15460
0
            Py_CLEAR(tmp);
15461
0
        }
15462
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15463
0
            return -1;
15464
0
        }
15465
0
        if (tmp == NULL) {
15466
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
15467
0
            return -1;
15468
0
        }
15469
0
        else {
15470
0
            int res;
15471
0
            if (_Py_EnterRecursiveCall(" while traversing 'Subscript' node")) {
15472
0
                goto failed;
15473
0
            }
15474
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15475
0
            _Py_LeaveRecursiveCall();
15476
0
            if (res != 0) goto failed;
15477
0
            Py_CLEAR(tmp);
15478
0
        }
15479
0
        *out = _PyAST_Subscript(value, slice, ctx, lineno, col_offset,
15480
0
                                end_lineno, end_col_offset, arena);
15481
0
        if (*out == NULL) goto failed;
15482
0
        return 0;
15483
0
    }
15484
0
    tp = state->Starred_type;
15485
0
    isinstance = PyObject_IsInstance(obj, tp);
15486
0
    if (isinstance == -1) {
15487
0
        return -1;
15488
0
    }
15489
0
    if (isinstance) {
15490
0
        expr_ty value;
15491
0
        expr_context_ty ctx;
15492
15493
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
15494
0
            return -1;
15495
0
        }
15496
0
        if (tmp == NULL) {
15497
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
15498
0
            return -1;
15499
0
        }
15500
0
        else {
15501
0
            int res;
15502
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15503
0
                goto failed;
15504
0
            }
15505
0
            res = obj2ast_expr(state, tmp, &value, arena);
15506
0
            _Py_LeaveRecursiveCall();
15507
0
            if (res != 0) goto failed;
15508
0
            Py_CLEAR(tmp);
15509
0
        }
15510
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15511
0
            return -1;
15512
0
        }
15513
0
        if (tmp == NULL) {
15514
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
15515
0
            return -1;
15516
0
        }
15517
0
        else {
15518
0
            int res;
15519
0
            if (_Py_EnterRecursiveCall(" while traversing 'Starred' node")) {
15520
0
                goto failed;
15521
0
            }
15522
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15523
0
            _Py_LeaveRecursiveCall();
15524
0
            if (res != 0) goto failed;
15525
0
            Py_CLEAR(tmp);
15526
0
        }
15527
0
        *out = _PyAST_Starred(value, ctx, lineno, col_offset, end_lineno,
15528
0
                              end_col_offset, arena);
15529
0
        if (*out == NULL) goto failed;
15530
0
        return 0;
15531
0
    }
15532
0
    tp = state->Name_type;
15533
0
    isinstance = PyObject_IsInstance(obj, tp);
15534
0
    if (isinstance == -1) {
15535
0
        return -1;
15536
0
    }
15537
0
    if (isinstance) {
15538
0
        identifier id;
15539
0
        expr_context_ty ctx;
15540
15541
0
        if (PyObject_GetOptionalAttr(obj, state->id, &tmp) < 0) {
15542
0
            return -1;
15543
0
        }
15544
0
        if (tmp == NULL) {
15545
0
            PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
15546
0
            return -1;
15547
0
        }
15548
0
        else {
15549
0
            int res;
15550
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15551
0
                goto failed;
15552
0
            }
15553
0
            res = obj2ast_identifier(state, tmp, &id, arena);
15554
0
            _Py_LeaveRecursiveCall();
15555
0
            if (res != 0) goto failed;
15556
0
            Py_CLEAR(tmp);
15557
0
        }
15558
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15559
0
            return -1;
15560
0
        }
15561
0
        if (tmp == NULL) {
15562
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
15563
0
            return -1;
15564
0
        }
15565
0
        else {
15566
0
            int res;
15567
0
            if (_Py_EnterRecursiveCall(" while traversing 'Name' node")) {
15568
0
                goto failed;
15569
0
            }
15570
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15571
0
            _Py_LeaveRecursiveCall();
15572
0
            if (res != 0) goto failed;
15573
0
            Py_CLEAR(tmp);
15574
0
        }
15575
0
        *out = _PyAST_Name(id, ctx, lineno, col_offset, end_lineno,
15576
0
                           end_col_offset, arena);
15577
0
        if (*out == NULL) goto failed;
15578
0
        return 0;
15579
0
    }
15580
0
    tp = state->List_type;
15581
0
    isinstance = PyObject_IsInstance(obj, tp);
15582
0
    if (isinstance == -1) {
15583
0
        return -1;
15584
0
    }
15585
0
    if (isinstance) {
15586
0
        asdl_expr_seq* elts;
15587
0
        expr_context_ty ctx;
15588
15589
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15590
0
            return -1;
15591
0
        }
15592
0
        if (tmp == NULL) {
15593
0
            tmp = PyList_New(0);
15594
0
            if (tmp == NULL) {
15595
0
                return -1;
15596
0
            }
15597
0
        }
15598
0
        {
15599
0
            int res;
15600
0
            Py_ssize_t len;
15601
0
            Py_ssize_t i;
15602
0
            if (!PyList_Check(tmp)) {
15603
0
                PyErr_Format(PyExc_TypeError, "List field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15604
0
                goto failed;
15605
0
            }
15606
0
            len = PyList_GET_SIZE(tmp);
15607
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15608
0
            if (elts == NULL) goto failed;
15609
0
            for (i = 0; i < len; i++) {
15610
0
                expr_ty val;
15611
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15612
0
                if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15613
0
                    goto failed;
15614
0
                }
15615
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15616
0
                _Py_LeaveRecursiveCall();
15617
0
                Py_DECREF(tmp2);
15618
0
                if (res != 0) goto failed;
15619
0
                if (len != PyList_GET_SIZE(tmp)) {
15620
0
                    PyErr_SetString(PyExc_RuntimeError, "List field \"elts\" changed size during iteration");
15621
0
                    goto failed;
15622
0
                }
15623
0
                asdl_seq_SET(elts, i, val);
15624
0
            }
15625
0
            Py_CLEAR(tmp);
15626
0
        }
15627
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15628
0
            return -1;
15629
0
        }
15630
0
        if (tmp == NULL) {
15631
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
15632
0
            return -1;
15633
0
        }
15634
0
        else {
15635
0
            int res;
15636
0
            if (_Py_EnterRecursiveCall(" while traversing 'List' node")) {
15637
0
                goto failed;
15638
0
            }
15639
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15640
0
            _Py_LeaveRecursiveCall();
15641
0
            if (res != 0) goto failed;
15642
0
            Py_CLEAR(tmp);
15643
0
        }
15644
0
        *out = _PyAST_List(elts, ctx, lineno, col_offset, end_lineno,
15645
0
                           end_col_offset, arena);
15646
0
        if (*out == NULL) goto failed;
15647
0
        return 0;
15648
0
    }
15649
0
    tp = state->Tuple_type;
15650
0
    isinstance = PyObject_IsInstance(obj, tp);
15651
0
    if (isinstance == -1) {
15652
0
        return -1;
15653
0
    }
15654
0
    if (isinstance) {
15655
0
        asdl_expr_seq* elts;
15656
0
        expr_context_ty ctx;
15657
15658
0
        if (PyObject_GetOptionalAttr(obj, state->elts, &tmp) < 0) {
15659
0
            return -1;
15660
0
        }
15661
0
        if (tmp == NULL) {
15662
0
            tmp = PyList_New(0);
15663
0
            if (tmp == NULL) {
15664
0
                return -1;
15665
0
            }
15666
0
        }
15667
0
        {
15668
0
            int res;
15669
0
            Py_ssize_t len;
15670
0
            Py_ssize_t i;
15671
0
            if (!PyList_Check(tmp)) {
15672
0
                PyErr_Format(PyExc_TypeError, "Tuple field \"elts\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
15673
0
                goto failed;
15674
0
            }
15675
0
            len = PyList_GET_SIZE(tmp);
15676
0
            elts = _Py_asdl_expr_seq_new(len, arena);
15677
0
            if (elts == NULL) goto failed;
15678
0
            for (i = 0; i < len; i++) {
15679
0
                expr_ty val;
15680
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
15681
0
                if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15682
0
                    goto failed;
15683
0
                }
15684
0
                res = obj2ast_expr(state, tmp2, &val, arena);
15685
0
                _Py_LeaveRecursiveCall();
15686
0
                Py_DECREF(tmp2);
15687
0
                if (res != 0) goto failed;
15688
0
                if (len != PyList_GET_SIZE(tmp)) {
15689
0
                    PyErr_SetString(PyExc_RuntimeError, "Tuple field \"elts\" changed size during iteration");
15690
0
                    goto failed;
15691
0
                }
15692
0
                asdl_seq_SET(elts, i, val);
15693
0
            }
15694
0
            Py_CLEAR(tmp);
15695
0
        }
15696
0
        if (PyObject_GetOptionalAttr(obj, state->ctx, &tmp) < 0) {
15697
0
            return -1;
15698
0
        }
15699
0
        if (tmp == NULL) {
15700
0
            PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
15701
0
            return -1;
15702
0
        }
15703
0
        else {
15704
0
            int res;
15705
0
            if (_Py_EnterRecursiveCall(" while traversing 'Tuple' node")) {
15706
0
                goto failed;
15707
0
            }
15708
0
            res = obj2ast_expr_context(state, tmp, &ctx, arena);
15709
0
            _Py_LeaveRecursiveCall();
15710
0
            if (res != 0) goto failed;
15711
0
            Py_CLEAR(tmp);
15712
0
        }
15713
0
        *out = _PyAST_Tuple(elts, ctx, lineno, col_offset, end_lineno,
15714
0
                            end_col_offset, arena);
15715
0
        if (*out == NULL) goto failed;
15716
0
        return 0;
15717
0
    }
15718
0
    tp = state->Slice_type;
15719
0
    isinstance = PyObject_IsInstance(obj, tp);
15720
0
    if (isinstance == -1) {
15721
0
        return -1;
15722
0
    }
15723
0
    if (isinstance) {
15724
0
        expr_ty lower;
15725
0
        expr_ty upper;
15726
0
        expr_ty step;
15727
15728
0
        if (PyObject_GetOptionalAttr(obj, state->lower, &tmp) < 0) {
15729
0
            return -1;
15730
0
        }
15731
0
        if (tmp == NULL || tmp == Py_None) {
15732
0
            Py_CLEAR(tmp);
15733
0
            lower = NULL;
15734
0
        }
15735
0
        else {
15736
0
            int res;
15737
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15738
0
                goto failed;
15739
0
            }
15740
0
            res = obj2ast_expr(state, tmp, &lower, arena);
15741
0
            _Py_LeaveRecursiveCall();
15742
0
            if (res != 0) goto failed;
15743
0
            Py_CLEAR(tmp);
15744
0
        }
15745
0
        if (PyObject_GetOptionalAttr(obj, state->upper, &tmp) < 0) {
15746
0
            return -1;
15747
0
        }
15748
0
        if (tmp == NULL || tmp == Py_None) {
15749
0
            Py_CLEAR(tmp);
15750
0
            upper = NULL;
15751
0
        }
15752
0
        else {
15753
0
            int res;
15754
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15755
0
                goto failed;
15756
0
            }
15757
0
            res = obj2ast_expr(state, tmp, &upper, arena);
15758
0
            _Py_LeaveRecursiveCall();
15759
0
            if (res != 0) goto failed;
15760
0
            Py_CLEAR(tmp);
15761
0
        }
15762
0
        if (PyObject_GetOptionalAttr(obj, state->step, &tmp) < 0) {
15763
0
            return -1;
15764
0
        }
15765
0
        if (tmp == NULL || tmp == Py_None) {
15766
0
            Py_CLEAR(tmp);
15767
0
            step = NULL;
15768
0
        }
15769
0
        else {
15770
0
            int res;
15771
0
            if (_Py_EnterRecursiveCall(" while traversing 'Slice' node")) {
15772
0
                goto failed;
15773
0
            }
15774
0
            res = obj2ast_expr(state, tmp, &step, arena);
15775
0
            _Py_LeaveRecursiveCall();
15776
0
            if (res != 0) goto failed;
15777
0
            Py_CLEAR(tmp);
15778
0
        }
15779
0
        *out = _PyAST_Slice(lower, upper, step, lineno, col_offset, end_lineno,
15780
0
                            end_col_offset, arena);
15781
0
        if (*out == NULL) goto failed;
15782
0
        return 0;
15783
0
    }
15784
15785
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr, but got %R", obj);
15786
0
    failed:
15787
0
    Py_XDECREF(tmp);
15788
0
    return -1;
15789
0
}
15790
15791
int
15792
obj2ast_expr_context(struct ast_state *state, PyObject* obj, expr_context_ty*
15793
                     out, PyArena* arena)
15794
0
{
15795
0
    int isinstance;
15796
15797
0
    isinstance = PyObject_IsInstance(obj, state->Load_type);
15798
0
    if (isinstance == -1) {
15799
0
        return -1;
15800
0
    }
15801
0
    if (isinstance) {
15802
0
        *out = Load;
15803
0
        return 0;
15804
0
    }
15805
0
    isinstance = PyObject_IsInstance(obj, state->Store_type);
15806
0
    if (isinstance == -1) {
15807
0
        return -1;
15808
0
    }
15809
0
    if (isinstance) {
15810
0
        *out = Store;
15811
0
        return 0;
15812
0
    }
15813
0
    isinstance = PyObject_IsInstance(obj, state->Del_type);
15814
0
    if (isinstance == -1) {
15815
0
        return -1;
15816
0
    }
15817
0
    if (isinstance) {
15818
0
        *out = Del;
15819
0
        return 0;
15820
0
    }
15821
15822
0
    PyErr_Format(PyExc_TypeError, "expected some sort of expr_context, but got %R", obj);
15823
0
    return -1;
15824
0
}
15825
15826
int
15827
obj2ast_boolop(struct ast_state *state, PyObject* obj, boolop_ty* out, PyArena*
15828
               arena)
15829
0
{
15830
0
    int isinstance;
15831
15832
0
    isinstance = PyObject_IsInstance(obj, state->And_type);
15833
0
    if (isinstance == -1) {
15834
0
        return -1;
15835
0
    }
15836
0
    if (isinstance) {
15837
0
        *out = And;
15838
0
        return 0;
15839
0
    }
15840
0
    isinstance = PyObject_IsInstance(obj, state->Or_type);
15841
0
    if (isinstance == -1) {
15842
0
        return -1;
15843
0
    }
15844
0
    if (isinstance) {
15845
0
        *out = Or;
15846
0
        return 0;
15847
0
    }
15848
15849
0
    PyErr_Format(PyExc_TypeError, "expected some sort of boolop, but got %R", obj);
15850
0
    return -1;
15851
0
}
15852
15853
int
15854
obj2ast_operator(struct ast_state *state, PyObject* obj, operator_ty* out,
15855
                 PyArena* arena)
15856
0
{
15857
0
    int isinstance;
15858
15859
0
    isinstance = PyObject_IsInstance(obj, state->Add_type);
15860
0
    if (isinstance == -1) {
15861
0
        return -1;
15862
0
    }
15863
0
    if (isinstance) {
15864
0
        *out = Add;
15865
0
        return 0;
15866
0
    }
15867
0
    isinstance = PyObject_IsInstance(obj, state->Sub_type);
15868
0
    if (isinstance == -1) {
15869
0
        return -1;
15870
0
    }
15871
0
    if (isinstance) {
15872
0
        *out = Sub;
15873
0
        return 0;
15874
0
    }
15875
0
    isinstance = PyObject_IsInstance(obj, state->Mult_type);
15876
0
    if (isinstance == -1) {
15877
0
        return -1;
15878
0
    }
15879
0
    if (isinstance) {
15880
0
        *out = Mult;
15881
0
        return 0;
15882
0
    }
15883
0
    isinstance = PyObject_IsInstance(obj, state->MatMult_type);
15884
0
    if (isinstance == -1) {
15885
0
        return -1;
15886
0
    }
15887
0
    if (isinstance) {
15888
0
        *out = MatMult;
15889
0
        return 0;
15890
0
    }
15891
0
    isinstance = PyObject_IsInstance(obj, state->Div_type);
15892
0
    if (isinstance == -1) {
15893
0
        return -1;
15894
0
    }
15895
0
    if (isinstance) {
15896
0
        *out = Div;
15897
0
        return 0;
15898
0
    }
15899
0
    isinstance = PyObject_IsInstance(obj, state->Mod_type);
15900
0
    if (isinstance == -1) {
15901
0
        return -1;
15902
0
    }
15903
0
    if (isinstance) {
15904
0
        *out = Mod;
15905
0
        return 0;
15906
0
    }
15907
0
    isinstance = PyObject_IsInstance(obj, state->Pow_type);
15908
0
    if (isinstance == -1) {
15909
0
        return -1;
15910
0
    }
15911
0
    if (isinstance) {
15912
0
        *out = Pow;
15913
0
        return 0;
15914
0
    }
15915
0
    isinstance = PyObject_IsInstance(obj, state->LShift_type);
15916
0
    if (isinstance == -1) {
15917
0
        return -1;
15918
0
    }
15919
0
    if (isinstance) {
15920
0
        *out = LShift;
15921
0
        return 0;
15922
0
    }
15923
0
    isinstance = PyObject_IsInstance(obj, state->RShift_type);
15924
0
    if (isinstance == -1) {
15925
0
        return -1;
15926
0
    }
15927
0
    if (isinstance) {
15928
0
        *out = RShift;
15929
0
        return 0;
15930
0
    }
15931
0
    isinstance = PyObject_IsInstance(obj, state->BitOr_type);
15932
0
    if (isinstance == -1) {
15933
0
        return -1;
15934
0
    }
15935
0
    if (isinstance) {
15936
0
        *out = BitOr;
15937
0
        return 0;
15938
0
    }
15939
0
    isinstance = PyObject_IsInstance(obj, state->BitXor_type);
15940
0
    if (isinstance == -1) {
15941
0
        return -1;
15942
0
    }
15943
0
    if (isinstance) {
15944
0
        *out = BitXor;
15945
0
        return 0;
15946
0
    }
15947
0
    isinstance = PyObject_IsInstance(obj, state->BitAnd_type);
15948
0
    if (isinstance == -1) {
15949
0
        return -1;
15950
0
    }
15951
0
    if (isinstance) {
15952
0
        *out = BitAnd;
15953
0
        return 0;
15954
0
    }
15955
0
    isinstance = PyObject_IsInstance(obj, state->FloorDiv_type);
15956
0
    if (isinstance == -1) {
15957
0
        return -1;
15958
0
    }
15959
0
    if (isinstance) {
15960
0
        *out = FloorDiv;
15961
0
        return 0;
15962
0
    }
15963
15964
0
    PyErr_Format(PyExc_TypeError, "expected some sort of operator, but got %R", obj);
15965
0
    return -1;
15966
0
}
15967
15968
int
15969
obj2ast_unaryop(struct ast_state *state, PyObject* obj, unaryop_ty* out,
15970
                PyArena* arena)
15971
0
{
15972
0
    int isinstance;
15973
15974
0
    isinstance = PyObject_IsInstance(obj, state->Invert_type);
15975
0
    if (isinstance == -1) {
15976
0
        return -1;
15977
0
    }
15978
0
    if (isinstance) {
15979
0
        *out = Invert;
15980
0
        return 0;
15981
0
    }
15982
0
    isinstance = PyObject_IsInstance(obj, state->Not_type);
15983
0
    if (isinstance == -1) {
15984
0
        return -1;
15985
0
    }
15986
0
    if (isinstance) {
15987
0
        *out = Not;
15988
0
        return 0;
15989
0
    }
15990
0
    isinstance = PyObject_IsInstance(obj, state->UAdd_type);
15991
0
    if (isinstance == -1) {
15992
0
        return -1;
15993
0
    }
15994
0
    if (isinstance) {
15995
0
        *out = UAdd;
15996
0
        return 0;
15997
0
    }
15998
0
    isinstance = PyObject_IsInstance(obj, state->USub_type);
15999
0
    if (isinstance == -1) {
16000
0
        return -1;
16001
0
    }
16002
0
    if (isinstance) {
16003
0
        *out = USub;
16004
0
        return 0;
16005
0
    }
16006
16007
0
    PyErr_Format(PyExc_TypeError, "expected some sort of unaryop, but got %R", obj);
16008
0
    return -1;
16009
0
}
16010
16011
int
16012
obj2ast_cmpop(struct ast_state *state, PyObject* obj, cmpop_ty* out, PyArena*
16013
              arena)
16014
0
{
16015
0
    int isinstance;
16016
16017
0
    isinstance = PyObject_IsInstance(obj, state->Eq_type);
16018
0
    if (isinstance == -1) {
16019
0
        return -1;
16020
0
    }
16021
0
    if (isinstance) {
16022
0
        *out = Eq;
16023
0
        return 0;
16024
0
    }
16025
0
    isinstance = PyObject_IsInstance(obj, state->NotEq_type);
16026
0
    if (isinstance == -1) {
16027
0
        return -1;
16028
0
    }
16029
0
    if (isinstance) {
16030
0
        *out = NotEq;
16031
0
        return 0;
16032
0
    }
16033
0
    isinstance = PyObject_IsInstance(obj, state->Lt_type);
16034
0
    if (isinstance == -1) {
16035
0
        return -1;
16036
0
    }
16037
0
    if (isinstance) {
16038
0
        *out = Lt;
16039
0
        return 0;
16040
0
    }
16041
0
    isinstance = PyObject_IsInstance(obj, state->LtE_type);
16042
0
    if (isinstance == -1) {
16043
0
        return -1;
16044
0
    }
16045
0
    if (isinstance) {
16046
0
        *out = LtE;
16047
0
        return 0;
16048
0
    }
16049
0
    isinstance = PyObject_IsInstance(obj, state->Gt_type);
16050
0
    if (isinstance == -1) {
16051
0
        return -1;
16052
0
    }
16053
0
    if (isinstance) {
16054
0
        *out = Gt;
16055
0
        return 0;
16056
0
    }
16057
0
    isinstance = PyObject_IsInstance(obj, state->GtE_type);
16058
0
    if (isinstance == -1) {
16059
0
        return -1;
16060
0
    }
16061
0
    if (isinstance) {
16062
0
        *out = GtE;
16063
0
        return 0;
16064
0
    }
16065
0
    isinstance = PyObject_IsInstance(obj, state->Is_type);
16066
0
    if (isinstance == -1) {
16067
0
        return -1;
16068
0
    }
16069
0
    if (isinstance) {
16070
0
        *out = Is;
16071
0
        return 0;
16072
0
    }
16073
0
    isinstance = PyObject_IsInstance(obj, state->IsNot_type);
16074
0
    if (isinstance == -1) {
16075
0
        return -1;
16076
0
    }
16077
0
    if (isinstance) {
16078
0
        *out = IsNot;
16079
0
        return 0;
16080
0
    }
16081
0
    isinstance = PyObject_IsInstance(obj, state->In_type);
16082
0
    if (isinstance == -1) {
16083
0
        return -1;
16084
0
    }
16085
0
    if (isinstance) {
16086
0
        *out = In;
16087
0
        return 0;
16088
0
    }
16089
0
    isinstance = PyObject_IsInstance(obj, state->NotIn_type);
16090
0
    if (isinstance == -1) {
16091
0
        return -1;
16092
0
    }
16093
0
    if (isinstance) {
16094
0
        *out = NotIn;
16095
0
        return 0;
16096
0
    }
16097
16098
0
    PyErr_Format(PyExc_TypeError, "expected some sort of cmpop, but got %R", obj);
16099
0
    return -1;
16100
0
}
16101
16102
int
16103
obj2ast_comprehension(struct ast_state *state, PyObject* obj, comprehension_ty*
16104
                      out, PyArena* arena)
16105
0
{
16106
0
    PyObject* tmp = NULL;
16107
0
    expr_ty target;
16108
0
    expr_ty iter;
16109
0
    asdl_expr_seq* ifs;
16110
0
    int is_async;
16111
16112
0
    if (PyObject_GetOptionalAttr(obj, state->target, &tmp) < 0) {
16113
0
        return -1;
16114
0
    }
16115
0
    if (tmp == NULL) {
16116
0
        PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
16117
0
        return -1;
16118
0
    }
16119
0
    else {
16120
0
        int res;
16121
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16122
0
            goto failed;
16123
0
        }
16124
0
        res = obj2ast_expr(state, tmp, &target, arena);
16125
0
        _Py_LeaveRecursiveCall();
16126
0
        if (res != 0) goto failed;
16127
0
        Py_CLEAR(tmp);
16128
0
    }
16129
0
    if (PyObject_GetOptionalAttr(obj, state->iter, &tmp) < 0) {
16130
0
        return -1;
16131
0
    }
16132
0
    if (tmp == NULL) {
16133
0
        PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
16134
0
        return -1;
16135
0
    }
16136
0
    else {
16137
0
        int res;
16138
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16139
0
            goto failed;
16140
0
        }
16141
0
        res = obj2ast_expr(state, tmp, &iter, arena);
16142
0
        _Py_LeaveRecursiveCall();
16143
0
        if (res != 0) goto failed;
16144
0
        Py_CLEAR(tmp);
16145
0
    }
16146
0
    if (PyObject_GetOptionalAttr(obj, state->ifs, &tmp) < 0) {
16147
0
        return -1;
16148
0
    }
16149
0
    if (tmp == NULL) {
16150
0
        tmp = PyList_New(0);
16151
0
        if (tmp == NULL) {
16152
0
            return -1;
16153
0
        }
16154
0
    }
16155
0
    {
16156
0
        int res;
16157
0
        Py_ssize_t len;
16158
0
        Py_ssize_t i;
16159
0
        if (!PyList_Check(tmp)) {
16160
0
            PyErr_Format(PyExc_TypeError, "comprehension field \"ifs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16161
0
            goto failed;
16162
0
        }
16163
0
        len = PyList_GET_SIZE(tmp);
16164
0
        ifs = _Py_asdl_expr_seq_new(len, arena);
16165
0
        if (ifs == NULL) goto failed;
16166
0
        for (i = 0; i < len; i++) {
16167
0
            expr_ty val;
16168
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16169
0
            if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16170
0
                goto failed;
16171
0
            }
16172
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16173
0
            _Py_LeaveRecursiveCall();
16174
0
            Py_DECREF(tmp2);
16175
0
            if (res != 0) goto failed;
16176
0
            if (len != PyList_GET_SIZE(tmp)) {
16177
0
                PyErr_SetString(PyExc_RuntimeError, "comprehension field \"ifs\" changed size during iteration");
16178
0
                goto failed;
16179
0
            }
16180
0
            asdl_seq_SET(ifs, i, val);
16181
0
        }
16182
0
        Py_CLEAR(tmp);
16183
0
    }
16184
0
    if (PyObject_GetOptionalAttr(obj, state->is_async, &tmp) < 0) {
16185
0
        return -1;
16186
0
    }
16187
0
    if (tmp == NULL) {
16188
0
        PyErr_SetString(PyExc_TypeError, "required field \"is_async\" missing from comprehension");
16189
0
        return -1;
16190
0
    }
16191
0
    else {
16192
0
        int res;
16193
0
        if (_Py_EnterRecursiveCall(" while traversing 'comprehension' node")) {
16194
0
            goto failed;
16195
0
        }
16196
0
        res = obj2ast_int(state, tmp, &is_async, arena);
16197
0
        _Py_LeaveRecursiveCall();
16198
0
        if (res != 0) goto failed;
16199
0
        Py_CLEAR(tmp);
16200
0
    }
16201
0
    *out = _PyAST_comprehension(target, iter, ifs, is_async, arena);
16202
0
    if (*out == NULL) goto failed;
16203
0
    return 0;
16204
0
failed:
16205
0
    Py_XDECREF(tmp);
16206
0
    return -1;
16207
0
}
16208
16209
int
16210
obj2ast_excepthandler(struct ast_state *state, PyObject* obj, excepthandler_ty*
16211
                      out, PyArena* arena)
16212
0
{
16213
0
    int isinstance;
16214
16215
0
    PyObject *tmp = NULL;
16216
0
    PyObject *tp;
16217
0
    int lineno;
16218
0
    int col_offset;
16219
0
    int end_lineno;
16220
0
    int end_col_offset;
16221
16222
0
    if (obj == Py_None) {
16223
0
        *out = NULL;
16224
0
        return 0;
16225
0
    }
16226
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16227
0
        return -1;
16228
0
    }
16229
0
    if (tmp == NULL) {
16230
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
16231
0
        return -1;
16232
0
    }
16233
0
    else {
16234
0
        int res;
16235
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16236
0
            goto failed;
16237
0
        }
16238
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16239
0
        _Py_LeaveRecursiveCall();
16240
0
        if (res != 0) goto failed;
16241
0
        Py_CLEAR(tmp);
16242
0
    }
16243
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16244
0
        return -1;
16245
0
    }
16246
0
    if (tmp == NULL) {
16247
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
16248
0
        return -1;
16249
0
    }
16250
0
    else {
16251
0
        int res;
16252
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16253
0
            goto failed;
16254
0
        }
16255
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16256
0
        _Py_LeaveRecursiveCall();
16257
0
        if (res != 0) goto failed;
16258
0
        Py_CLEAR(tmp);
16259
0
    }
16260
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16261
0
        return -1;
16262
0
    }
16263
0
    if (tmp == NULL || tmp == Py_None) {
16264
0
        Py_CLEAR(tmp);
16265
0
        end_lineno = lineno;
16266
0
    }
16267
0
    else {
16268
0
        int res;
16269
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16270
0
            goto failed;
16271
0
        }
16272
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16273
0
        _Py_LeaveRecursiveCall();
16274
0
        if (res != 0) goto failed;
16275
0
        Py_CLEAR(tmp);
16276
0
    }
16277
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16278
0
        return -1;
16279
0
    }
16280
0
    if (tmp == NULL || tmp == Py_None) {
16281
0
        Py_CLEAR(tmp);
16282
0
        end_col_offset = col_offset;
16283
0
    }
16284
0
    else {
16285
0
        int res;
16286
0
        if (_Py_EnterRecursiveCall(" while traversing 'excepthandler' node")) {
16287
0
            goto failed;
16288
0
        }
16289
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16290
0
        _Py_LeaveRecursiveCall();
16291
0
        if (res != 0) goto failed;
16292
0
        Py_CLEAR(tmp);
16293
0
    }
16294
0
    tp = state->ExceptHandler_type;
16295
0
    isinstance = PyObject_IsInstance(obj, tp);
16296
0
    if (isinstance == -1) {
16297
0
        return -1;
16298
0
    }
16299
0
    if (isinstance) {
16300
0
        expr_ty type;
16301
0
        identifier name;
16302
0
        asdl_stmt_seq* body;
16303
16304
0
        if (PyObject_GetOptionalAttr(obj, state->type, &tmp) < 0) {
16305
0
            return -1;
16306
0
        }
16307
0
        if (tmp == NULL || tmp == Py_None) {
16308
0
            Py_CLEAR(tmp);
16309
0
            type = NULL;
16310
0
        }
16311
0
        else {
16312
0
            int res;
16313
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16314
0
                goto failed;
16315
0
            }
16316
0
            res = obj2ast_expr(state, tmp, &type, arena);
16317
0
            _Py_LeaveRecursiveCall();
16318
0
            if (res != 0) goto failed;
16319
0
            Py_CLEAR(tmp);
16320
0
        }
16321
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16322
0
            return -1;
16323
0
        }
16324
0
        if (tmp == NULL || tmp == Py_None) {
16325
0
            Py_CLEAR(tmp);
16326
0
            name = NULL;
16327
0
        }
16328
0
        else {
16329
0
            int res;
16330
0
            if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16331
0
                goto failed;
16332
0
            }
16333
0
            res = obj2ast_identifier(state, tmp, &name, arena);
16334
0
            _Py_LeaveRecursiveCall();
16335
0
            if (res != 0) goto failed;
16336
0
            Py_CLEAR(tmp);
16337
0
        }
16338
0
        if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
16339
0
            return -1;
16340
0
        }
16341
0
        if (tmp == NULL) {
16342
0
            tmp = PyList_New(0);
16343
0
            if (tmp == NULL) {
16344
0
                return -1;
16345
0
            }
16346
0
        }
16347
0
        {
16348
0
            int res;
16349
0
            Py_ssize_t len;
16350
0
            Py_ssize_t i;
16351
0
            if (!PyList_Check(tmp)) {
16352
0
                PyErr_Format(PyExc_TypeError, "ExceptHandler field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16353
0
                goto failed;
16354
0
            }
16355
0
            len = PyList_GET_SIZE(tmp);
16356
0
            body = _Py_asdl_stmt_seq_new(len, arena);
16357
0
            if (body == NULL) goto failed;
16358
0
            for (i = 0; i < len; i++) {
16359
0
                stmt_ty val;
16360
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16361
0
                if (_Py_EnterRecursiveCall(" while traversing 'ExceptHandler' node")) {
16362
0
                    goto failed;
16363
0
                }
16364
0
                res = obj2ast_stmt(state, tmp2, &val, arena);
16365
0
                _Py_LeaveRecursiveCall();
16366
0
                Py_DECREF(tmp2);
16367
0
                if (res != 0) goto failed;
16368
0
                if (len != PyList_GET_SIZE(tmp)) {
16369
0
                    PyErr_SetString(PyExc_RuntimeError, "ExceptHandler field \"body\" changed size during iteration");
16370
0
                    goto failed;
16371
0
                }
16372
0
                asdl_seq_SET(body, i, val);
16373
0
            }
16374
0
            Py_CLEAR(tmp);
16375
0
        }
16376
0
        *out = _PyAST_ExceptHandler(type, name, body, lineno, col_offset,
16377
0
                                    end_lineno, end_col_offset, arena);
16378
0
        if (*out == NULL) goto failed;
16379
0
        return 0;
16380
0
    }
16381
16382
0
    PyErr_Format(PyExc_TypeError, "expected some sort of excepthandler, but got %R", obj);
16383
0
    failed:
16384
0
    Py_XDECREF(tmp);
16385
0
    return -1;
16386
0
}
16387
16388
int
16389
obj2ast_arguments(struct ast_state *state, PyObject* obj, arguments_ty* out,
16390
                  PyArena* arena)
16391
0
{
16392
0
    PyObject* tmp = NULL;
16393
0
    asdl_arg_seq* posonlyargs;
16394
0
    asdl_arg_seq* args;
16395
0
    arg_ty vararg;
16396
0
    asdl_arg_seq* kwonlyargs;
16397
0
    asdl_expr_seq* kw_defaults;
16398
0
    arg_ty kwarg;
16399
0
    asdl_expr_seq* defaults;
16400
16401
0
    if (PyObject_GetOptionalAttr(obj, state->posonlyargs, &tmp) < 0) {
16402
0
        return -1;
16403
0
    }
16404
0
    if (tmp == NULL) {
16405
0
        tmp = PyList_New(0);
16406
0
        if (tmp == NULL) {
16407
0
            return -1;
16408
0
        }
16409
0
    }
16410
0
    {
16411
0
        int res;
16412
0
        Py_ssize_t len;
16413
0
        Py_ssize_t i;
16414
0
        if (!PyList_Check(tmp)) {
16415
0
            PyErr_Format(PyExc_TypeError, "arguments field \"posonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16416
0
            goto failed;
16417
0
        }
16418
0
        len = PyList_GET_SIZE(tmp);
16419
0
        posonlyargs = _Py_asdl_arg_seq_new(len, arena);
16420
0
        if (posonlyargs == NULL) goto failed;
16421
0
        for (i = 0; i < len; i++) {
16422
0
            arg_ty val;
16423
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16424
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16425
0
                goto failed;
16426
0
            }
16427
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16428
0
            _Py_LeaveRecursiveCall();
16429
0
            Py_DECREF(tmp2);
16430
0
            if (res != 0) goto failed;
16431
0
            if (len != PyList_GET_SIZE(tmp)) {
16432
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"posonlyargs\" changed size during iteration");
16433
0
                goto failed;
16434
0
            }
16435
0
            asdl_seq_SET(posonlyargs, i, val);
16436
0
        }
16437
0
        Py_CLEAR(tmp);
16438
0
    }
16439
0
    if (PyObject_GetOptionalAttr(obj, state->args, &tmp) < 0) {
16440
0
        return -1;
16441
0
    }
16442
0
    if (tmp == NULL) {
16443
0
        tmp = PyList_New(0);
16444
0
        if (tmp == NULL) {
16445
0
            return -1;
16446
0
        }
16447
0
    }
16448
0
    {
16449
0
        int res;
16450
0
        Py_ssize_t len;
16451
0
        Py_ssize_t i;
16452
0
        if (!PyList_Check(tmp)) {
16453
0
            PyErr_Format(PyExc_TypeError, "arguments field \"args\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16454
0
            goto failed;
16455
0
        }
16456
0
        len = PyList_GET_SIZE(tmp);
16457
0
        args = _Py_asdl_arg_seq_new(len, arena);
16458
0
        if (args == NULL) goto failed;
16459
0
        for (i = 0; i < len; i++) {
16460
0
            arg_ty val;
16461
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16462
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16463
0
                goto failed;
16464
0
            }
16465
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16466
0
            _Py_LeaveRecursiveCall();
16467
0
            Py_DECREF(tmp2);
16468
0
            if (res != 0) goto failed;
16469
0
            if (len != PyList_GET_SIZE(tmp)) {
16470
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"args\" changed size during iteration");
16471
0
                goto failed;
16472
0
            }
16473
0
            asdl_seq_SET(args, i, val);
16474
0
        }
16475
0
        Py_CLEAR(tmp);
16476
0
    }
16477
0
    if (PyObject_GetOptionalAttr(obj, state->vararg, &tmp) < 0) {
16478
0
        return -1;
16479
0
    }
16480
0
    if (tmp == NULL || tmp == Py_None) {
16481
0
        Py_CLEAR(tmp);
16482
0
        vararg = NULL;
16483
0
    }
16484
0
    else {
16485
0
        int res;
16486
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16487
0
            goto failed;
16488
0
        }
16489
0
        res = obj2ast_arg(state, tmp, &vararg, arena);
16490
0
        _Py_LeaveRecursiveCall();
16491
0
        if (res != 0) goto failed;
16492
0
        Py_CLEAR(tmp);
16493
0
    }
16494
0
    if (PyObject_GetOptionalAttr(obj, state->kwonlyargs, &tmp) < 0) {
16495
0
        return -1;
16496
0
    }
16497
0
    if (tmp == NULL) {
16498
0
        tmp = PyList_New(0);
16499
0
        if (tmp == NULL) {
16500
0
            return -1;
16501
0
        }
16502
0
    }
16503
0
    {
16504
0
        int res;
16505
0
        Py_ssize_t len;
16506
0
        Py_ssize_t i;
16507
0
        if (!PyList_Check(tmp)) {
16508
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kwonlyargs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16509
0
            goto failed;
16510
0
        }
16511
0
        len = PyList_GET_SIZE(tmp);
16512
0
        kwonlyargs = _Py_asdl_arg_seq_new(len, arena);
16513
0
        if (kwonlyargs == NULL) goto failed;
16514
0
        for (i = 0; i < len; i++) {
16515
0
            arg_ty val;
16516
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16517
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16518
0
                goto failed;
16519
0
            }
16520
0
            res = obj2ast_arg(state, tmp2, &val, arena);
16521
0
            _Py_LeaveRecursiveCall();
16522
0
            Py_DECREF(tmp2);
16523
0
            if (res != 0) goto failed;
16524
0
            if (len != PyList_GET_SIZE(tmp)) {
16525
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kwonlyargs\" changed size during iteration");
16526
0
                goto failed;
16527
0
            }
16528
0
            asdl_seq_SET(kwonlyargs, i, val);
16529
0
        }
16530
0
        Py_CLEAR(tmp);
16531
0
    }
16532
0
    if (PyObject_GetOptionalAttr(obj, state->kw_defaults, &tmp) < 0) {
16533
0
        return -1;
16534
0
    }
16535
0
    if (tmp == NULL) {
16536
0
        tmp = PyList_New(0);
16537
0
        if (tmp == NULL) {
16538
0
            return -1;
16539
0
        }
16540
0
    }
16541
0
    {
16542
0
        int res;
16543
0
        Py_ssize_t len;
16544
0
        Py_ssize_t i;
16545
0
        if (!PyList_Check(tmp)) {
16546
0
            PyErr_Format(PyExc_TypeError, "arguments field \"kw_defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16547
0
            goto failed;
16548
0
        }
16549
0
        len = PyList_GET_SIZE(tmp);
16550
0
        kw_defaults = _Py_asdl_expr_seq_new(len, arena);
16551
0
        if (kw_defaults == NULL) goto failed;
16552
0
        for (i = 0; i < len; i++) {
16553
0
            expr_ty val;
16554
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16555
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16556
0
                goto failed;
16557
0
            }
16558
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16559
0
            _Py_LeaveRecursiveCall();
16560
0
            Py_DECREF(tmp2);
16561
0
            if (res != 0) goto failed;
16562
0
            if (len != PyList_GET_SIZE(tmp)) {
16563
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"kw_defaults\" changed size during iteration");
16564
0
                goto failed;
16565
0
            }
16566
0
            asdl_seq_SET(kw_defaults, i, val);
16567
0
        }
16568
0
        Py_CLEAR(tmp);
16569
0
    }
16570
0
    if (PyObject_GetOptionalAttr(obj, state->kwarg, &tmp) < 0) {
16571
0
        return -1;
16572
0
    }
16573
0
    if (tmp == NULL || tmp == Py_None) {
16574
0
        Py_CLEAR(tmp);
16575
0
        kwarg = NULL;
16576
0
    }
16577
0
    else {
16578
0
        int res;
16579
0
        if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16580
0
            goto failed;
16581
0
        }
16582
0
        res = obj2ast_arg(state, tmp, &kwarg, arena);
16583
0
        _Py_LeaveRecursiveCall();
16584
0
        if (res != 0) goto failed;
16585
0
        Py_CLEAR(tmp);
16586
0
    }
16587
0
    if (PyObject_GetOptionalAttr(obj, state->defaults, &tmp) < 0) {
16588
0
        return -1;
16589
0
    }
16590
0
    if (tmp == NULL) {
16591
0
        tmp = PyList_New(0);
16592
0
        if (tmp == NULL) {
16593
0
            return -1;
16594
0
        }
16595
0
    }
16596
0
    {
16597
0
        int res;
16598
0
        Py_ssize_t len;
16599
0
        Py_ssize_t i;
16600
0
        if (!PyList_Check(tmp)) {
16601
0
            PyErr_Format(PyExc_TypeError, "arguments field \"defaults\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
16602
0
            goto failed;
16603
0
        }
16604
0
        len = PyList_GET_SIZE(tmp);
16605
0
        defaults = _Py_asdl_expr_seq_new(len, arena);
16606
0
        if (defaults == NULL) goto failed;
16607
0
        for (i = 0; i < len; i++) {
16608
0
            expr_ty val;
16609
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
16610
0
            if (_Py_EnterRecursiveCall(" while traversing 'arguments' node")) {
16611
0
                goto failed;
16612
0
            }
16613
0
            res = obj2ast_expr(state, tmp2, &val, arena);
16614
0
            _Py_LeaveRecursiveCall();
16615
0
            Py_DECREF(tmp2);
16616
0
            if (res != 0) goto failed;
16617
0
            if (len != PyList_GET_SIZE(tmp)) {
16618
0
                PyErr_SetString(PyExc_RuntimeError, "arguments field \"defaults\" changed size during iteration");
16619
0
                goto failed;
16620
0
            }
16621
0
            asdl_seq_SET(defaults, i, val);
16622
0
        }
16623
0
        Py_CLEAR(tmp);
16624
0
    }
16625
0
    *out = _PyAST_arguments(posonlyargs, args, vararg, kwonlyargs, kw_defaults,
16626
0
                            kwarg, defaults, arena);
16627
0
    if (*out == NULL) goto failed;
16628
0
    return 0;
16629
0
failed:
16630
0
    Py_XDECREF(tmp);
16631
0
    return -1;
16632
0
}
16633
16634
int
16635
obj2ast_arg(struct ast_state *state, PyObject* obj, arg_ty* out, PyArena* arena)
16636
0
{
16637
0
    PyObject* tmp = NULL;
16638
0
    identifier arg;
16639
0
    expr_ty annotation;
16640
0
    string type_comment;
16641
0
    int lineno;
16642
0
    int col_offset;
16643
0
    int end_lineno;
16644
0
    int end_col_offset;
16645
16646
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16647
0
        return -1;
16648
0
    }
16649
0
    if (tmp == NULL) {
16650
0
        PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
16651
0
        return -1;
16652
0
    }
16653
0
    else {
16654
0
        int res;
16655
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16656
0
            goto failed;
16657
0
        }
16658
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16659
0
        _Py_LeaveRecursiveCall();
16660
0
        if (res != 0) goto failed;
16661
0
        Py_CLEAR(tmp);
16662
0
    }
16663
0
    if (PyObject_GetOptionalAttr(obj, state->annotation, &tmp) < 0) {
16664
0
        return -1;
16665
0
    }
16666
0
    if (tmp == NULL || tmp == Py_None) {
16667
0
        Py_CLEAR(tmp);
16668
0
        annotation = NULL;
16669
0
    }
16670
0
    else {
16671
0
        int res;
16672
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16673
0
            goto failed;
16674
0
        }
16675
0
        res = obj2ast_expr(state, tmp, &annotation, arena);
16676
0
        _Py_LeaveRecursiveCall();
16677
0
        if (res != 0) goto failed;
16678
0
        Py_CLEAR(tmp);
16679
0
    }
16680
0
    if (PyObject_GetOptionalAttr(obj, state->type_comment, &tmp) < 0) {
16681
0
        return -1;
16682
0
    }
16683
0
    if (tmp == NULL || tmp == Py_None) {
16684
0
        Py_CLEAR(tmp);
16685
0
        type_comment = NULL;
16686
0
    }
16687
0
    else {
16688
0
        int res;
16689
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16690
0
            goto failed;
16691
0
        }
16692
0
        res = obj2ast_string(state, tmp, &type_comment, arena);
16693
0
        _Py_LeaveRecursiveCall();
16694
0
        if (res != 0) goto failed;
16695
0
        Py_CLEAR(tmp);
16696
0
    }
16697
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16698
0
        return -1;
16699
0
    }
16700
0
    if (tmp == NULL) {
16701
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from arg");
16702
0
        return -1;
16703
0
    }
16704
0
    else {
16705
0
        int res;
16706
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16707
0
            goto failed;
16708
0
        }
16709
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16710
0
        _Py_LeaveRecursiveCall();
16711
0
        if (res != 0) goto failed;
16712
0
        Py_CLEAR(tmp);
16713
0
    }
16714
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16715
0
        return -1;
16716
0
    }
16717
0
    if (tmp == NULL) {
16718
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from arg");
16719
0
        return -1;
16720
0
    }
16721
0
    else {
16722
0
        int res;
16723
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16724
0
            goto failed;
16725
0
        }
16726
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16727
0
        _Py_LeaveRecursiveCall();
16728
0
        if (res != 0) goto failed;
16729
0
        Py_CLEAR(tmp);
16730
0
    }
16731
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16732
0
        return -1;
16733
0
    }
16734
0
    if (tmp == NULL || tmp == Py_None) {
16735
0
        Py_CLEAR(tmp);
16736
0
        end_lineno = lineno;
16737
0
    }
16738
0
    else {
16739
0
        int res;
16740
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16741
0
            goto failed;
16742
0
        }
16743
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16744
0
        _Py_LeaveRecursiveCall();
16745
0
        if (res != 0) goto failed;
16746
0
        Py_CLEAR(tmp);
16747
0
    }
16748
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16749
0
        return -1;
16750
0
    }
16751
0
    if (tmp == NULL || tmp == Py_None) {
16752
0
        Py_CLEAR(tmp);
16753
0
        end_col_offset = col_offset;
16754
0
    }
16755
0
    else {
16756
0
        int res;
16757
0
        if (_Py_EnterRecursiveCall(" while traversing 'arg' node")) {
16758
0
            goto failed;
16759
0
        }
16760
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16761
0
        _Py_LeaveRecursiveCall();
16762
0
        if (res != 0) goto failed;
16763
0
        Py_CLEAR(tmp);
16764
0
    }
16765
0
    *out = _PyAST_arg(arg, annotation, type_comment, lineno, col_offset,
16766
0
                      end_lineno, end_col_offset, arena);
16767
0
    if (*out == NULL) goto failed;
16768
0
    return 0;
16769
0
failed:
16770
0
    Py_XDECREF(tmp);
16771
0
    return -1;
16772
0
}
16773
16774
int
16775
obj2ast_keyword(struct ast_state *state, PyObject* obj, keyword_ty* out,
16776
                PyArena* arena)
16777
0
{
16778
0
    PyObject* tmp = NULL;
16779
0
    identifier arg;
16780
0
    expr_ty value;
16781
0
    int lineno;
16782
0
    int col_offset;
16783
0
    int end_lineno;
16784
0
    int end_col_offset;
16785
16786
0
    if (PyObject_GetOptionalAttr(obj, state->arg, &tmp) < 0) {
16787
0
        return -1;
16788
0
    }
16789
0
    if (tmp == NULL || tmp == Py_None) {
16790
0
        Py_CLEAR(tmp);
16791
0
        arg = NULL;
16792
0
    }
16793
0
    else {
16794
0
        int res;
16795
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16796
0
            goto failed;
16797
0
        }
16798
0
        res = obj2ast_identifier(state, tmp, &arg, arena);
16799
0
        _Py_LeaveRecursiveCall();
16800
0
        if (res != 0) goto failed;
16801
0
        Py_CLEAR(tmp);
16802
0
    }
16803
0
    if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
16804
0
        return -1;
16805
0
    }
16806
0
    if (tmp == NULL) {
16807
0
        PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
16808
0
        return -1;
16809
0
    }
16810
0
    else {
16811
0
        int res;
16812
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16813
0
            goto failed;
16814
0
        }
16815
0
        res = obj2ast_expr(state, tmp, &value, arena);
16816
0
        _Py_LeaveRecursiveCall();
16817
0
        if (res != 0) goto failed;
16818
0
        Py_CLEAR(tmp);
16819
0
    }
16820
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16821
0
        return -1;
16822
0
    }
16823
0
    if (tmp == NULL) {
16824
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from keyword");
16825
0
        return -1;
16826
0
    }
16827
0
    else {
16828
0
        int res;
16829
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16830
0
            goto failed;
16831
0
        }
16832
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16833
0
        _Py_LeaveRecursiveCall();
16834
0
        if (res != 0) goto failed;
16835
0
        Py_CLEAR(tmp);
16836
0
    }
16837
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16838
0
        return -1;
16839
0
    }
16840
0
    if (tmp == NULL) {
16841
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from keyword");
16842
0
        return -1;
16843
0
    }
16844
0
    else {
16845
0
        int res;
16846
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16847
0
            goto failed;
16848
0
        }
16849
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16850
0
        _Py_LeaveRecursiveCall();
16851
0
        if (res != 0) goto failed;
16852
0
        Py_CLEAR(tmp);
16853
0
    }
16854
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16855
0
        return -1;
16856
0
    }
16857
0
    if (tmp == NULL || tmp == Py_None) {
16858
0
        Py_CLEAR(tmp);
16859
0
        end_lineno = lineno;
16860
0
    }
16861
0
    else {
16862
0
        int res;
16863
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16864
0
            goto failed;
16865
0
        }
16866
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16867
0
        _Py_LeaveRecursiveCall();
16868
0
        if (res != 0) goto failed;
16869
0
        Py_CLEAR(tmp);
16870
0
    }
16871
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16872
0
        return -1;
16873
0
    }
16874
0
    if (tmp == NULL || tmp == Py_None) {
16875
0
        Py_CLEAR(tmp);
16876
0
        end_col_offset = col_offset;
16877
0
    }
16878
0
    else {
16879
0
        int res;
16880
0
        if (_Py_EnterRecursiveCall(" while traversing 'keyword' node")) {
16881
0
            goto failed;
16882
0
        }
16883
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
16884
0
        _Py_LeaveRecursiveCall();
16885
0
        if (res != 0) goto failed;
16886
0
        Py_CLEAR(tmp);
16887
0
    }
16888
0
    *out = _PyAST_keyword(arg, value, lineno, col_offset, end_lineno,
16889
0
                          end_col_offset, arena);
16890
0
    if (*out == NULL) goto failed;
16891
0
    return 0;
16892
0
failed:
16893
0
    Py_XDECREF(tmp);
16894
0
    return -1;
16895
0
}
16896
16897
int
16898
obj2ast_alias(struct ast_state *state, PyObject* obj, alias_ty* out, PyArena*
16899
              arena)
16900
0
{
16901
0
    PyObject* tmp = NULL;
16902
0
    identifier name;
16903
0
    identifier asname;
16904
0
    int lineno;
16905
0
    int col_offset;
16906
0
    int end_lineno;
16907
0
    int end_col_offset;
16908
16909
0
    if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
16910
0
        return -1;
16911
0
    }
16912
0
    if (tmp == NULL) {
16913
0
        PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
16914
0
        return -1;
16915
0
    }
16916
0
    else {
16917
0
        int res;
16918
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16919
0
            goto failed;
16920
0
        }
16921
0
        res = obj2ast_identifier(state, tmp, &name, arena);
16922
0
        _Py_LeaveRecursiveCall();
16923
0
        if (res != 0) goto failed;
16924
0
        Py_CLEAR(tmp);
16925
0
    }
16926
0
    if (PyObject_GetOptionalAttr(obj, state->asname, &tmp) < 0) {
16927
0
        return -1;
16928
0
    }
16929
0
    if (tmp == NULL || tmp == Py_None) {
16930
0
        Py_CLEAR(tmp);
16931
0
        asname = NULL;
16932
0
    }
16933
0
    else {
16934
0
        int res;
16935
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16936
0
            goto failed;
16937
0
        }
16938
0
        res = obj2ast_identifier(state, tmp, &asname, arena);
16939
0
        _Py_LeaveRecursiveCall();
16940
0
        if (res != 0) goto failed;
16941
0
        Py_CLEAR(tmp);
16942
0
    }
16943
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
16944
0
        return -1;
16945
0
    }
16946
0
    if (tmp == NULL) {
16947
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from alias");
16948
0
        return -1;
16949
0
    }
16950
0
    else {
16951
0
        int res;
16952
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16953
0
            goto failed;
16954
0
        }
16955
0
        res = obj2ast_int(state, tmp, &lineno, arena);
16956
0
        _Py_LeaveRecursiveCall();
16957
0
        if (res != 0) goto failed;
16958
0
        Py_CLEAR(tmp);
16959
0
    }
16960
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
16961
0
        return -1;
16962
0
    }
16963
0
    if (tmp == NULL) {
16964
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from alias");
16965
0
        return -1;
16966
0
    }
16967
0
    else {
16968
0
        int res;
16969
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16970
0
            goto failed;
16971
0
        }
16972
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
16973
0
        _Py_LeaveRecursiveCall();
16974
0
        if (res != 0) goto failed;
16975
0
        Py_CLEAR(tmp);
16976
0
    }
16977
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
16978
0
        return -1;
16979
0
    }
16980
0
    if (tmp == NULL || tmp == Py_None) {
16981
0
        Py_CLEAR(tmp);
16982
0
        end_lineno = lineno;
16983
0
    }
16984
0
    else {
16985
0
        int res;
16986
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
16987
0
            goto failed;
16988
0
        }
16989
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
16990
0
        _Py_LeaveRecursiveCall();
16991
0
        if (res != 0) goto failed;
16992
0
        Py_CLEAR(tmp);
16993
0
    }
16994
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
16995
0
        return -1;
16996
0
    }
16997
0
    if (tmp == NULL || tmp == Py_None) {
16998
0
        Py_CLEAR(tmp);
16999
0
        end_col_offset = col_offset;
17000
0
    }
17001
0
    else {
17002
0
        int res;
17003
0
        if (_Py_EnterRecursiveCall(" while traversing 'alias' node")) {
17004
0
            goto failed;
17005
0
        }
17006
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17007
0
        _Py_LeaveRecursiveCall();
17008
0
        if (res != 0) goto failed;
17009
0
        Py_CLEAR(tmp);
17010
0
    }
17011
0
    *out = _PyAST_alias(name, asname, lineno, col_offset, end_lineno,
17012
0
                        end_col_offset, arena);
17013
0
    if (*out == NULL) goto failed;
17014
0
    return 0;
17015
0
failed:
17016
0
    Py_XDECREF(tmp);
17017
0
    return -1;
17018
0
}
17019
17020
int
17021
obj2ast_withitem(struct ast_state *state, PyObject* obj, withitem_ty* out,
17022
                 PyArena* arena)
17023
0
{
17024
0
    PyObject* tmp = NULL;
17025
0
    expr_ty context_expr;
17026
0
    expr_ty optional_vars;
17027
17028
0
    if (PyObject_GetOptionalAttr(obj, state->context_expr, &tmp) < 0) {
17029
0
        return -1;
17030
0
    }
17031
0
    if (tmp == NULL) {
17032
0
        PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
17033
0
        return -1;
17034
0
    }
17035
0
    else {
17036
0
        int res;
17037
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
17038
0
            goto failed;
17039
0
        }
17040
0
        res = obj2ast_expr(state, tmp, &context_expr, arena);
17041
0
        _Py_LeaveRecursiveCall();
17042
0
        if (res != 0) goto failed;
17043
0
        Py_CLEAR(tmp);
17044
0
    }
17045
0
    if (PyObject_GetOptionalAttr(obj, state->optional_vars, &tmp) < 0) {
17046
0
        return -1;
17047
0
    }
17048
0
    if (tmp == NULL || tmp == Py_None) {
17049
0
        Py_CLEAR(tmp);
17050
0
        optional_vars = NULL;
17051
0
    }
17052
0
    else {
17053
0
        int res;
17054
0
        if (_Py_EnterRecursiveCall(" while traversing 'withitem' node")) {
17055
0
            goto failed;
17056
0
        }
17057
0
        res = obj2ast_expr(state, tmp, &optional_vars, arena);
17058
0
        _Py_LeaveRecursiveCall();
17059
0
        if (res != 0) goto failed;
17060
0
        Py_CLEAR(tmp);
17061
0
    }
17062
0
    *out = _PyAST_withitem(context_expr, optional_vars, arena);
17063
0
    if (*out == NULL) goto failed;
17064
0
    return 0;
17065
0
failed:
17066
0
    Py_XDECREF(tmp);
17067
0
    return -1;
17068
0
}
17069
17070
int
17071
obj2ast_match_case(struct ast_state *state, PyObject* obj, match_case_ty* out,
17072
                   PyArena* arena)
17073
0
{
17074
0
    PyObject* tmp = NULL;
17075
0
    pattern_ty pattern;
17076
0
    expr_ty guard;
17077
0
    asdl_stmt_seq* body;
17078
17079
0
    if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17080
0
        return -1;
17081
0
    }
17082
0
    if (tmp == NULL) {
17083
0
        PyErr_SetString(PyExc_TypeError, "required field \"pattern\" missing from match_case");
17084
0
        return -1;
17085
0
    }
17086
0
    else {
17087
0
        int res;
17088
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17089
0
            goto failed;
17090
0
        }
17091
0
        res = obj2ast_pattern(state, tmp, &pattern, arena);
17092
0
        _Py_LeaveRecursiveCall();
17093
0
        if (res != 0) goto failed;
17094
0
        Py_CLEAR(tmp);
17095
0
    }
17096
0
    if (PyObject_GetOptionalAttr(obj, state->guard, &tmp) < 0) {
17097
0
        return -1;
17098
0
    }
17099
0
    if (tmp == NULL || tmp == Py_None) {
17100
0
        Py_CLEAR(tmp);
17101
0
        guard = NULL;
17102
0
    }
17103
0
    else {
17104
0
        int res;
17105
0
        if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17106
0
            goto failed;
17107
0
        }
17108
0
        res = obj2ast_expr(state, tmp, &guard, arena);
17109
0
        _Py_LeaveRecursiveCall();
17110
0
        if (res != 0) goto failed;
17111
0
        Py_CLEAR(tmp);
17112
0
    }
17113
0
    if (PyObject_GetOptionalAttr(obj, state->body, &tmp) < 0) {
17114
0
        return -1;
17115
0
    }
17116
0
    if (tmp == NULL) {
17117
0
        tmp = PyList_New(0);
17118
0
        if (tmp == NULL) {
17119
0
            return -1;
17120
0
        }
17121
0
    }
17122
0
    {
17123
0
        int res;
17124
0
        Py_ssize_t len;
17125
0
        Py_ssize_t i;
17126
0
        if (!PyList_Check(tmp)) {
17127
0
            PyErr_Format(PyExc_TypeError, "match_case field \"body\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17128
0
            goto failed;
17129
0
        }
17130
0
        len = PyList_GET_SIZE(tmp);
17131
0
        body = _Py_asdl_stmt_seq_new(len, arena);
17132
0
        if (body == NULL) goto failed;
17133
0
        for (i = 0; i < len; i++) {
17134
0
            stmt_ty val;
17135
0
            PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17136
0
            if (_Py_EnterRecursiveCall(" while traversing 'match_case' node")) {
17137
0
                goto failed;
17138
0
            }
17139
0
            res = obj2ast_stmt(state, tmp2, &val, arena);
17140
0
            _Py_LeaveRecursiveCall();
17141
0
            Py_DECREF(tmp2);
17142
0
            if (res != 0) goto failed;
17143
0
            if (len != PyList_GET_SIZE(tmp)) {
17144
0
                PyErr_SetString(PyExc_RuntimeError, "match_case field \"body\" changed size during iteration");
17145
0
                goto failed;
17146
0
            }
17147
0
            asdl_seq_SET(body, i, val);
17148
0
        }
17149
0
        Py_CLEAR(tmp);
17150
0
    }
17151
0
    *out = _PyAST_match_case(pattern, guard, body, arena);
17152
0
    if (*out == NULL) goto failed;
17153
0
    return 0;
17154
0
failed:
17155
0
    Py_XDECREF(tmp);
17156
0
    return -1;
17157
0
}
17158
17159
int
17160
obj2ast_pattern(struct ast_state *state, PyObject* obj, pattern_ty* out,
17161
                PyArena* arena)
17162
0
{
17163
0
    int isinstance;
17164
17165
0
    PyObject *tmp = NULL;
17166
0
    PyObject *tp;
17167
0
    int lineno;
17168
0
    int col_offset;
17169
0
    int end_lineno;
17170
0
    int end_col_offset;
17171
17172
0
    if (obj == Py_None) {
17173
0
        *out = NULL;
17174
0
        return 0;
17175
0
    }
17176
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17177
0
        return -1;
17178
0
    }
17179
0
    if (tmp == NULL) {
17180
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from pattern");
17181
0
        return -1;
17182
0
    }
17183
0
    else {
17184
0
        int res;
17185
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17186
0
            goto failed;
17187
0
        }
17188
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17189
0
        _Py_LeaveRecursiveCall();
17190
0
        if (res != 0) goto failed;
17191
0
        Py_CLEAR(tmp);
17192
0
    }
17193
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17194
0
        return -1;
17195
0
    }
17196
0
    if (tmp == NULL) {
17197
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from pattern");
17198
0
        return -1;
17199
0
    }
17200
0
    else {
17201
0
        int res;
17202
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17203
0
            goto failed;
17204
0
        }
17205
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17206
0
        _Py_LeaveRecursiveCall();
17207
0
        if (res != 0) goto failed;
17208
0
        Py_CLEAR(tmp);
17209
0
    }
17210
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17211
0
        return -1;
17212
0
    }
17213
0
    if (tmp == NULL) {
17214
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from pattern");
17215
0
        return -1;
17216
0
    }
17217
0
    else {
17218
0
        int res;
17219
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17220
0
            goto failed;
17221
0
        }
17222
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17223
0
        _Py_LeaveRecursiveCall();
17224
0
        if (res != 0) goto failed;
17225
0
        Py_CLEAR(tmp);
17226
0
    }
17227
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17228
0
        return -1;
17229
0
    }
17230
0
    if (tmp == NULL) {
17231
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from pattern");
17232
0
        return -1;
17233
0
    }
17234
0
    else {
17235
0
        int res;
17236
0
        if (_Py_EnterRecursiveCall(" while traversing 'pattern' node")) {
17237
0
            goto failed;
17238
0
        }
17239
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17240
0
        _Py_LeaveRecursiveCall();
17241
0
        if (res != 0) goto failed;
17242
0
        Py_CLEAR(tmp);
17243
0
    }
17244
0
    tp = state->MatchValue_type;
17245
0
    isinstance = PyObject_IsInstance(obj, tp);
17246
0
    if (isinstance == -1) {
17247
0
        return -1;
17248
0
    }
17249
0
    if (isinstance) {
17250
0
        expr_ty value;
17251
17252
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17253
0
            return -1;
17254
0
        }
17255
0
        if (tmp == NULL) {
17256
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchValue");
17257
0
            return -1;
17258
0
        }
17259
0
        else {
17260
0
            int res;
17261
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchValue' node")) {
17262
0
                goto failed;
17263
0
            }
17264
0
            res = obj2ast_expr(state, tmp, &value, arena);
17265
0
            _Py_LeaveRecursiveCall();
17266
0
            if (res != 0) goto failed;
17267
0
            Py_CLEAR(tmp);
17268
0
        }
17269
0
        *out = _PyAST_MatchValue(value, lineno, col_offset, end_lineno,
17270
0
                                 end_col_offset, arena);
17271
0
        if (*out == NULL) goto failed;
17272
0
        return 0;
17273
0
    }
17274
0
    tp = state->MatchSingleton_type;
17275
0
    isinstance = PyObject_IsInstance(obj, tp);
17276
0
    if (isinstance == -1) {
17277
0
        return -1;
17278
0
    }
17279
0
    if (isinstance) {
17280
0
        constant value;
17281
17282
0
        if (PyObject_GetOptionalAttr(obj, state->value, &tmp) < 0) {
17283
0
            return -1;
17284
0
        }
17285
0
        if (tmp == NULL) {
17286
0
            PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from MatchSingleton");
17287
0
            return -1;
17288
0
        }
17289
0
        else {
17290
0
            int res;
17291
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchSingleton' node")) {
17292
0
                goto failed;
17293
0
            }
17294
0
            res = obj2ast_constant(state, tmp, &value, arena);
17295
0
            _Py_LeaveRecursiveCall();
17296
0
            if (res != 0) goto failed;
17297
0
            Py_CLEAR(tmp);
17298
0
        }
17299
0
        *out = _PyAST_MatchSingleton(value, lineno, col_offset, end_lineno,
17300
0
                                     end_col_offset, arena);
17301
0
        if (*out == NULL) goto failed;
17302
0
        return 0;
17303
0
    }
17304
0
    tp = state->MatchSequence_type;
17305
0
    isinstance = PyObject_IsInstance(obj, tp);
17306
0
    if (isinstance == -1) {
17307
0
        return -1;
17308
0
    }
17309
0
    if (isinstance) {
17310
0
        asdl_pattern_seq* patterns;
17311
17312
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17313
0
            return -1;
17314
0
        }
17315
0
        if (tmp == NULL) {
17316
0
            tmp = PyList_New(0);
17317
0
            if (tmp == NULL) {
17318
0
                return -1;
17319
0
            }
17320
0
        }
17321
0
        {
17322
0
            int res;
17323
0
            Py_ssize_t len;
17324
0
            Py_ssize_t i;
17325
0
            if (!PyList_Check(tmp)) {
17326
0
                PyErr_Format(PyExc_TypeError, "MatchSequence field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17327
0
                goto failed;
17328
0
            }
17329
0
            len = PyList_GET_SIZE(tmp);
17330
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17331
0
            if (patterns == NULL) goto failed;
17332
0
            for (i = 0; i < len; i++) {
17333
0
                pattern_ty val;
17334
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17335
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchSequence' node")) {
17336
0
                    goto failed;
17337
0
                }
17338
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17339
0
                _Py_LeaveRecursiveCall();
17340
0
                Py_DECREF(tmp2);
17341
0
                if (res != 0) goto failed;
17342
0
                if (len != PyList_GET_SIZE(tmp)) {
17343
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchSequence field \"patterns\" changed size during iteration");
17344
0
                    goto failed;
17345
0
                }
17346
0
                asdl_seq_SET(patterns, i, val);
17347
0
            }
17348
0
            Py_CLEAR(tmp);
17349
0
        }
17350
0
        *out = _PyAST_MatchSequence(patterns, lineno, col_offset, end_lineno,
17351
0
                                    end_col_offset, arena);
17352
0
        if (*out == NULL) goto failed;
17353
0
        return 0;
17354
0
    }
17355
0
    tp = state->MatchMapping_type;
17356
0
    isinstance = PyObject_IsInstance(obj, tp);
17357
0
    if (isinstance == -1) {
17358
0
        return -1;
17359
0
    }
17360
0
    if (isinstance) {
17361
0
        asdl_expr_seq* keys;
17362
0
        asdl_pattern_seq* patterns;
17363
0
        identifier rest;
17364
17365
0
        if (PyObject_GetOptionalAttr(obj, state->keys, &tmp) < 0) {
17366
0
            return -1;
17367
0
        }
17368
0
        if (tmp == NULL) {
17369
0
            tmp = PyList_New(0);
17370
0
            if (tmp == NULL) {
17371
0
                return -1;
17372
0
            }
17373
0
        }
17374
0
        {
17375
0
            int res;
17376
0
            Py_ssize_t len;
17377
0
            Py_ssize_t i;
17378
0
            if (!PyList_Check(tmp)) {
17379
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"keys\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17380
0
                goto failed;
17381
0
            }
17382
0
            len = PyList_GET_SIZE(tmp);
17383
0
            keys = _Py_asdl_expr_seq_new(len, arena);
17384
0
            if (keys == NULL) goto failed;
17385
0
            for (i = 0; i < len; i++) {
17386
0
                expr_ty val;
17387
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17388
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17389
0
                    goto failed;
17390
0
                }
17391
0
                res = obj2ast_expr(state, tmp2, &val, arena);
17392
0
                _Py_LeaveRecursiveCall();
17393
0
                Py_DECREF(tmp2);
17394
0
                if (res != 0) goto failed;
17395
0
                if (len != PyList_GET_SIZE(tmp)) {
17396
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"keys\" changed size during iteration");
17397
0
                    goto failed;
17398
0
                }
17399
0
                asdl_seq_SET(keys, i, val);
17400
0
            }
17401
0
            Py_CLEAR(tmp);
17402
0
        }
17403
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17404
0
            return -1;
17405
0
        }
17406
0
        if (tmp == NULL) {
17407
0
            tmp = PyList_New(0);
17408
0
            if (tmp == NULL) {
17409
0
                return -1;
17410
0
            }
17411
0
        }
17412
0
        {
17413
0
            int res;
17414
0
            Py_ssize_t len;
17415
0
            Py_ssize_t i;
17416
0
            if (!PyList_Check(tmp)) {
17417
0
                PyErr_Format(PyExc_TypeError, "MatchMapping field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17418
0
                goto failed;
17419
0
            }
17420
0
            len = PyList_GET_SIZE(tmp);
17421
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17422
0
            if (patterns == NULL) goto failed;
17423
0
            for (i = 0; i < len; i++) {
17424
0
                pattern_ty val;
17425
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17426
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17427
0
                    goto failed;
17428
0
                }
17429
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17430
0
                _Py_LeaveRecursiveCall();
17431
0
                Py_DECREF(tmp2);
17432
0
                if (res != 0) goto failed;
17433
0
                if (len != PyList_GET_SIZE(tmp)) {
17434
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchMapping field \"patterns\" changed size during iteration");
17435
0
                    goto failed;
17436
0
                }
17437
0
                asdl_seq_SET(patterns, i, val);
17438
0
            }
17439
0
            Py_CLEAR(tmp);
17440
0
        }
17441
0
        if (PyObject_GetOptionalAttr(obj, state->rest, &tmp) < 0) {
17442
0
            return -1;
17443
0
        }
17444
0
        if (tmp == NULL || tmp == Py_None) {
17445
0
            Py_CLEAR(tmp);
17446
0
            rest = NULL;
17447
0
        }
17448
0
        else {
17449
0
            int res;
17450
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchMapping' node")) {
17451
0
                goto failed;
17452
0
            }
17453
0
            res = obj2ast_identifier(state, tmp, &rest, arena);
17454
0
            _Py_LeaveRecursiveCall();
17455
0
            if (res != 0) goto failed;
17456
0
            Py_CLEAR(tmp);
17457
0
        }
17458
0
        *out = _PyAST_MatchMapping(keys, patterns, rest, lineno, col_offset,
17459
0
                                   end_lineno, end_col_offset, arena);
17460
0
        if (*out == NULL) goto failed;
17461
0
        return 0;
17462
0
    }
17463
0
    tp = state->MatchClass_type;
17464
0
    isinstance = PyObject_IsInstance(obj, tp);
17465
0
    if (isinstance == -1) {
17466
0
        return -1;
17467
0
    }
17468
0
    if (isinstance) {
17469
0
        expr_ty cls;
17470
0
        asdl_pattern_seq* patterns;
17471
0
        asdl_identifier_seq* kwd_attrs;
17472
0
        asdl_pattern_seq* kwd_patterns;
17473
17474
0
        if (PyObject_GetOptionalAttr(obj, state->cls, &tmp) < 0) {
17475
0
            return -1;
17476
0
        }
17477
0
        if (tmp == NULL) {
17478
0
            PyErr_SetString(PyExc_TypeError, "required field \"cls\" missing from MatchClass");
17479
0
            return -1;
17480
0
        }
17481
0
        else {
17482
0
            int res;
17483
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17484
0
                goto failed;
17485
0
            }
17486
0
            res = obj2ast_expr(state, tmp, &cls, arena);
17487
0
            _Py_LeaveRecursiveCall();
17488
0
            if (res != 0) goto failed;
17489
0
            Py_CLEAR(tmp);
17490
0
        }
17491
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17492
0
            return -1;
17493
0
        }
17494
0
        if (tmp == NULL) {
17495
0
            tmp = PyList_New(0);
17496
0
            if (tmp == NULL) {
17497
0
                return -1;
17498
0
            }
17499
0
        }
17500
0
        {
17501
0
            int res;
17502
0
            Py_ssize_t len;
17503
0
            Py_ssize_t i;
17504
0
            if (!PyList_Check(tmp)) {
17505
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17506
0
                goto failed;
17507
0
            }
17508
0
            len = PyList_GET_SIZE(tmp);
17509
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17510
0
            if (patterns == NULL) goto failed;
17511
0
            for (i = 0; i < len; i++) {
17512
0
                pattern_ty val;
17513
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17514
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17515
0
                    goto failed;
17516
0
                }
17517
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17518
0
                _Py_LeaveRecursiveCall();
17519
0
                Py_DECREF(tmp2);
17520
0
                if (res != 0) goto failed;
17521
0
                if (len != PyList_GET_SIZE(tmp)) {
17522
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"patterns\" changed size during iteration");
17523
0
                    goto failed;
17524
0
                }
17525
0
                asdl_seq_SET(patterns, i, val);
17526
0
            }
17527
0
            Py_CLEAR(tmp);
17528
0
        }
17529
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_attrs, &tmp) < 0) {
17530
0
            return -1;
17531
0
        }
17532
0
        if (tmp == NULL) {
17533
0
            tmp = PyList_New(0);
17534
0
            if (tmp == NULL) {
17535
0
                return -1;
17536
0
            }
17537
0
        }
17538
0
        {
17539
0
            int res;
17540
0
            Py_ssize_t len;
17541
0
            Py_ssize_t i;
17542
0
            if (!PyList_Check(tmp)) {
17543
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_attrs\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17544
0
                goto failed;
17545
0
            }
17546
0
            len = PyList_GET_SIZE(tmp);
17547
0
            kwd_attrs = _Py_asdl_identifier_seq_new(len, arena);
17548
0
            if (kwd_attrs == NULL) goto failed;
17549
0
            for (i = 0; i < len; i++) {
17550
0
                identifier val;
17551
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17552
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17553
0
                    goto failed;
17554
0
                }
17555
0
                res = obj2ast_identifier(state, tmp2, &val, arena);
17556
0
                _Py_LeaveRecursiveCall();
17557
0
                Py_DECREF(tmp2);
17558
0
                if (res != 0) goto failed;
17559
0
                if (len != PyList_GET_SIZE(tmp)) {
17560
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_attrs\" changed size during iteration");
17561
0
                    goto failed;
17562
0
                }
17563
0
                asdl_seq_SET(kwd_attrs, i, val);
17564
0
            }
17565
0
            Py_CLEAR(tmp);
17566
0
        }
17567
0
        if (PyObject_GetOptionalAttr(obj, state->kwd_patterns, &tmp) < 0) {
17568
0
            return -1;
17569
0
        }
17570
0
        if (tmp == NULL) {
17571
0
            tmp = PyList_New(0);
17572
0
            if (tmp == NULL) {
17573
0
                return -1;
17574
0
            }
17575
0
        }
17576
0
        {
17577
0
            int res;
17578
0
            Py_ssize_t len;
17579
0
            Py_ssize_t i;
17580
0
            if (!PyList_Check(tmp)) {
17581
0
                PyErr_Format(PyExc_TypeError, "MatchClass field \"kwd_patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17582
0
                goto failed;
17583
0
            }
17584
0
            len = PyList_GET_SIZE(tmp);
17585
0
            kwd_patterns = _Py_asdl_pattern_seq_new(len, arena);
17586
0
            if (kwd_patterns == NULL) goto failed;
17587
0
            for (i = 0; i < len; i++) {
17588
0
                pattern_ty val;
17589
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17590
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchClass' node")) {
17591
0
                    goto failed;
17592
0
                }
17593
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17594
0
                _Py_LeaveRecursiveCall();
17595
0
                Py_DECREF(tmp2);
17596
0
                if (res != 0) goto failed;
17597
0
                if (len != PyList_GET_SIZE(tmp)) {
17598
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchClass field \"kwd_patterns\" changed size during iteration");
17599
0
                    goto failed;
17600
0
                }
17601
0
                asdl_seq_SET(kwd_patterns, i, val);
17602
0
            }
17603
0
            Py_CLEAR(tmp);
17604
0
        }
17605
0
        *out = _PyAST_MatchClass(cls, patterns, kwd_attrs, kwd_patterns,
17606
0
                                 lineno, col_offset, end_lineno,
17607
0
                                 end_col_offset, arena);
17608
0
        if (*out == NULL) goto failed;
17609
0
        return 0;
17610
0
    }
17611
0
    tp = state->MatchStar_type;
17612
0
    isinstance = PyObject_IsInstance(obj, tp);
17613
0
    if (isinstance == -1) {
17614
0
        return -1;
17615
0
    }
17616
0
    if (isinstance) {
17617
0
        identifier name;
17618
17619
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17620
0
            return -1;
17621
0
        }
17622
0
        if (tmp == NULL || tmp == Py_None) {
17623
0
            Py_CLEAR(tmp);
17624
0
            name = NULL;
17625
0
        }
17626
0
        else {
17627
0
            int res;
17628
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchStar' node")) {
17629
0
                goto failed;
17630
0
            }
17631
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17632
0
            _Py_LeaveRecursiveCall();
17633
0
            if (res != 0) goto failed;
17634
0
            Py_CLEAR(tmp);
17635
0
        }
17636
0
        *out = _PyAST_MatchStar(name, lineno, col_offset, end_lineno,
17637
0
                                end_col_offset, arena);
17638
0
        if (*out == NULL) goto failed;
17639
0
        return 0;
17640
0
    }
17641
0
    tp = state->MatchAs_type;
17642
0
    isinstance = PyObject_IsInstance(obj, tp);
17643
0
    if (isinstance == -1) {
17644
0
        return -1;
17645
0
    }
17646
0
    if (isinstance) {
17647
0
        pattern_ty pattern;
17648
0
        identifier name;
17649
17650
0
        if (PyObject_GetOptionalAttr(obj, state->pattern, &tmp) < 0) {
17651
0
            return -1;
17652
0
        }
17653
0
        if (tmp == NULL || tmp == Py_None) {
17654
0
            Py_CLEAR(tmp);
17655
0
            pattern = NULL;
17656
0
        }
17657
0
        else {
17658
0
            int res;
17659
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17660
0
                goto failed;
17661
0
            }
17662
0
            res = obj2ast_pattern(state, tmp, &pattern, arena);
17663
0
            _Py_LeaveRecursiveCall();
17664
0
            if (res != 0) goto failed;
17665
0
            Py_CLEAR(tmp);
17666
0
        }
17667
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17668
0
            return -1;
17669
0
        }
17670
0
        if (tmp == NULL || tmp == Py_None) {
17671
0
            Py_CLEAR(tmp);
17672
0
            name = NULL;
17673
0
        }
17674
0
        else {
17675
0
            int res;
17676
0
            if (_Py_EnterRecursiveCall(" while traversing 'MatchAs' node")) {
17677
0
                goto failed;
17678
0
            }
17679
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17680
0
            _Py_LeaveRecursiveCall();
17681
0
            if (res != 0) goto failed;
17682
0
            Py_CLEAR(tmp);
17683
0
        }
17684
0
        *out = _PyAST_MatchAs(pattern, name, lineno, col_offset, end_lineno,
17685
0
                              end_col_offset, arena);
17686
0
        if (*out == NULL) goto failed;
17687
0
        return 0;
17688
0
    }
17689
0
    tp = state->MatchOr_type;
17690
0
    isinstance = PyObject_IsInstance(obj, tp);
17691
0
    if (isinstance == -1) {
17692
0
        return -1;
17693
0
    }
17694
0
    if (isinstance) {
17695
0
        asdl_pattern_seq* patterns;
17696
17697
0
        if (PyObject_GetOptionalAttr(obj, state->patterns, &tmp) < 0) {
17698
0
            return -1;
17699
0
        }
17700
0
        if (tmp == NULL) {
17701
0
            tmp = PyList_New(0);
17702
0
            if (tmp == NULL) {
17703
0
                return -1;
17704
0
            }
17705
0
        }
17706
0
        {
17707
0
            int res;
17708
0
            Py_ssize_t len;
17709
0
            Py_ssize_t i;
17710
0
            if (!PyList_Check(tmp)) {
17711
0
                PyErr_Format(PyExc_TypeError, "MatchOr field \"patterns\" must be a list, not a %.200s", _PyType_Name(Py_TYPE(tmp)));
17712
0
                goto failed;
17713
0
            }
17714
0
            len = PyList_GET_SIZE(tmp);
17715
0
            patterns = _Py_asdl_pattern_seq_new(len, arena);
17716
0
            if (patterns == NULL) goto failed;
17717
0
            for (i = 0; i < len; i++) {
17718
0
                pattern_ty val;
17719
0
                PyObject *tmp2 = Py_NewRef(PyList_GET_ITEM(tmp, i));
17720
0
                if (_Py_EnterRecursiveCall(" while traversing 'MatchOr' node")) {
17721
0
                    goto failed;
17722
0
                }
17723
0
                res = obj2ast_pattern(state, tmp2, &val, arena);
17724
0
                _Py_LeaveRecursiveCall();
17725
0
                Py_DECREF(tmp2);
17726
0
                if (res != 0) goto failed;
17727
0
                if (len != PyList_GET_SIZE(tmp)) {
17728
0
                    PyErr_SetString(PyExc_RuntimeError, "MatchOr field \"patterns\" changed size during iteration");
17729
0
                    goto failed;
17730
0
                }
17731
0
                asdl_seq_SET(patterns, i, val);
17732
0
            }
17733
0
            Py_CLEAR(tmp);
17734
0
        }
17735
0
        *out = _PyAST_MatchOr(patterns, lineno, col_offset, end_lineno,
17736
0
                              end_col_offset, arena);
17737
0
        if (*out == NULL) goto failed;
17738
0
        return 0;
17739
0
    }
17740
17741
0
    PyErr_Format(PyExc_TypeError, "expected some sort of pattern, but got %R", obj);
17742
0
    failed:
17743
0
    Py_XDECREF(tmp);
17744
0
    return -1;
17745
0
}
17746
17747
int
17748
obj2ast_type_ignore(struct ast_state *state, PyObject* obj, type_ignore_ty*
17749
                    out, PyArena* arena)
17750
0
{
17751
0
    int isinstance;
17752
17753
0
    PyObject *tmp = NULL;
17754
0
    PyObject *tp;
17755
17756
0
    if (obj == Py_None) {
17757
0
        *out = NULL;
17758
0
        return 0;
17759
0
    }
17760
0
    tp = state->TypeIgnore_type;
17761
0
    isinstance = PyObject_IsInstance(obj, tp);
17762
0
    if (isinstance == -1) {
17763
0
        return -1;
17764
0
    }
17765
0
    if (isinstance) {
17766
0
        int lineno;
17767
0
        string tag;
17768
17769
0
        if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17770
0
            return -1;
17771
0
        }
17772
0
        if (tmp == NULL) {
17773
0
            PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from TypeIgnore");
17774
0
            return -1;
17775
0
        }
17776
0
        else {
17777
0
            int res;
17778
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17779
0
                goto failed;
17780
0
            }
17781
0
            res = obj2ast_int(state, tmp, &lineno, arena);
17782
0
            _Py_LeaveRecursiveCall();
17783
0
            if (res != 0) goto failed;
17784
0
            Py_CLEAR(tmp);
17785
0
        }
17786
0
        if (PyObject_GetOptionalAttr(obj, state->tag, &tmp) < 0) {
17787
0
            return -1;
17788
0
        }
17789
0
        if (tmp == NULL) {
17790
0
            PyErr_SetString(PyExc_TypeError, "required field \"tag\" missing from TypeIgnore");
17791
0
            return -1;
17792
0
        }
17793
0
        else {
17794
0
            int res;
17795
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeIgnore' node")) {
17796
0
                goto failed;
17797
0
            }
17798
0
            res = obj2ast_string(state, tmp, &tag, arena);
17799
0
            _Py_LeaveRecursiveCall();
17800
0
            if (res != 0) goto failed;
17801
0
            Py_CLEAR(tmp);
17802
0
        }
17803
0
        *out = _PyAST_TypeIgnore(lineno, tag, arena);
17804
0
        if (*out == NULL) goto failed;
17805
0
        return 0;
17806
0
    }
17807
17808
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_ignore, but got %R", obj);
17809
0
    failed:
17810
0
    Py_XDECREF(tmp);
17811
0
    return -1;
17812
0
}
17813
17814
int
17815
obj2ast_type_param(struct ast_state *state, PyObject* obj, type_param_ty* out,
17816
                   PyArena* arena)
17817
0
{
17818
0
    int isinstance;
17819
17820
0
    PyObject *tmp = NULL;
17821
0
    PyObject *tp;
17822
0
    int lineno;
17823
0
    int col_offset;
17824
0
    int end_lineno;
17825
0
    int end_col_offset;
17826
17827
0
    if (obj == Py_None) {
17828
0
        *out = NULL;
17829
0
        return 0;
17830
0
    }
17831
0
    if (PyObject_GetOptionalAttr(obj, state->lineno, &tmp) < 0) {
17832
0
        return -1;
17833
0
    }
17834
0
    if (tmp == NULL) {
17835
0
        PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from type_param");
17836
0
        return -1;
17837
0
    }
17838
0
    else {
17839
0
        int res;
17840
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17841
0
            goto failed;
17842
0
        }
17843
0
        res = obj2ast_int(state, tmp, &lineno, arena);
17844
0
        _Py_LeaveRecursiveCall();
17845
0
        if (res != 0) goto failed;
17846
0
        Py_CLEAR(tmp);
17847
0
    }
17848
0
    if (PyObject_GetOptionalAttr(obj, state->col_offset, &tmp) < 0) {
17849
0
        return -1;
17850
0
    }
17851
0
    if (tmp == NULL) {
17852
0
        PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from type_param");
17853
0
        return -1;
17854
0
    }
17855
0
    else {
17856
0
        int res;
17857
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17858
0
            goto failed;
17859
0
        }
17860
0
        res = obj2ast_int(state, tmp, &col_offset, arena);
17861
0
        _Py_LeaveRecursiveCall();
17862
0
        if (res != 0) goto failed;
17863
0
        Py_CLEAR(tmp);
17864
0
    }
17865
0
    if (PyObject_GetOptionalAttr(obj, state->end_lineno, &tmp) < 0) {
17866
0
        return -1;
17867
0
    }
17868
0
    if (tmp == NULL) {
17869
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_lineno\" missing from type_param");
17870
0
        return -1;
17871
0
    }
17872
0
    else {
17873
0
        int res;
17874
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17875
0
            goto failed;
17876
0
        }
17877
0
        res = obj2ast_int(state, tmp, &end_lineno, arena);
17878
0
        _Py_LeaveRecursiveCall();
17879
0
        if (res != 0) goto failed;
17880
0
        Py_CLEAR(tmp);
17881
0
    }
17882
0
    if (PyObject_GetOptionalAttr(obj, state->end_col_offset, &tmp) < 0) {
17883
0
        return -1;
17884
0
    }
17885
0
    if (tmp == NULL) {
17886
0
        PyErr_SetString(PyExc_TypeError, "required field \"end_col_offset\" missing from type_param");
17887
0
        return -1;
17888
0
    }
17889
0
    else {
17890
0
        int res;
17891
0
        if (_Py_EnterRecursiveCall(" while traversing 'type_param' node")) {
17892
0
            goto failed;
17893
0
        }
17894
0
        res = obj2ast_int(state, tmp, &end_col_offset, arena);
17895
0
        _Py_LeaveRecursiveCall();
17896
0
        if (res != 0) goto failed;
17897
0
        Py_CLEAR(tmp);
17898
0
    }
17899
0
    tp = state->TypeVar_type;
17900
0
    isinstance = PyObject_IsInstance(obj, tp);
17901
0
    if (isinstance == -1) {
17902
0
        return -1;
17903
0
    }
17904
0
    if (isinstance) {
17905
0
        identifier name;
17906
0
        expr_ty bound;
17907
0
        expr_ty default_value;
17908
17909
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17910
0
            return -1;
17911
0
        }
17912
0
        if (tmp == NULL) {
17913
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVar");
17914
0
            return -1;
17915
0
        }
17916
0
        else {
17917
0
            int res;
17918
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17919
0
                goto failed;
17920
0
            }
17921
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17922
0
            _Py_LeaveRecursiveCall();
17923
0
            if (res != 0) goto failed;
17924
0
            Py_CLEAR(tmp);
17925
0
        }
17926
0
        if (PyObject_GetOptionalAttr(obj, state->bound, &tmp) < 0) {
17927
0
            return -1;
17928
0
        }
17929
0
        if (tmp == NULL || tmp == Py_None) {
17930
0
            Py_CLEAR(tmp);
17931
0
            bound = NULL;
17932
0
        }
17933
0
        else {
17934
0
            int res;
17935
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17936
0
                goto failed;
17937
0
            }
17938
0
            res = obj2ast_expr(state, tmp, &bound, arena);
17939
0
            _Py_LeaveRecursiveCall();
17940
0
            if (res != 0) goto failed;
17941
0
            Py_CLEAR(tmp);
17942
0
        }
17943
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17944
0
            return -1;
17945
0
        }
17946
0
        if (tmp == NULL || tmp == Py_None) {
17947
0
            Py_CLEAR(tmp);
17948
0
            default_value = NULL;
17949
0
        }
17950
0
        else {
17951
0
            int res;
17952
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVar' node")) {
17953
0
                goto failed;
17954
0
            }
17955
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
17956
0
            _Py_LeaveRecursiveCall();
17957
0
            if (res != 0) goto failed;
17958
0
            Py_CLEAR(tmp);
17959
0
        }
17960
0
        *out = _PyAST_TypeVar(name, bound, default_value, lineno, col_offset,
17961
0
                              end_lineno, end_col_offset, arena);
17962
0
        if (*out == NULL) goto failed;
17963
0
        return 0;
17964
0
    }
17965
0
    tp = state->ParamSpec_type;
17966
0
    isinstance = PyObject_IsInstance(obj, tp);
17967
0
    if (isinstance == -1) {
17968
0
        return -1;
17969
0
    }
17970
0
    if (isinstance) {
17971
0
        identifier name;
17972
0
        expr_ty default_value;
17973
17974
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
17975
0
            return -1;
17976
0
        }
17977
0
        if (tmp == NULL) {
17978
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ParamSpec");
17979
0
            return -1;
17980
0
        }
17981
0
        else {
17982
0
            int res;
17983
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
17984
0
                goto failed;
17985
0
            }
17986
0
            res = obj2ast_identifier(state, tmp, &name, arena);
17987
0
            _Py_LeaveRecursiveCall();
17988
0
            if (res != 0) goto failed;
17989
0
            Py_CLEAR(tmp);
17990
0
        }
17991
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
17992
0
            return -1;
17993
0
        }
17994
0
        if (tmp == NULL || tmp == Py_None) {
17995
0
            Py_CLEAR(tmp);
17996
0
            default_value = NULL;
17997
0
        }
17998
0
        else {
17999
0
            int res;
18000
0
            if (_Py_EnterRecursiveCall(" while traversing 'ParamSpec' node")) {
18001
0
                goto failed;
18002
0
            }
18003
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
18004
0
            _Py_LeaveRecursiveCall();
18005
0
            if (res != 0) goto failed;
18006
0
            Py_CLEAR(tmp);
18007
0
        }
18008
0
        *out = _PyAST_ParamSpec(name, default_value, lineno, col_offset,
18009
0
                                end_lineno, end_col_offset, arena);
18010
0
        if (*out == NULL) goto failed;
18011
0
        return 0;
18012
0
    }
18013
0
    tp = state->TypeVarTuple_type;
18014
0
    isinstance = PyObject_IsInstance(obj, tp);
18015
0
    if (isinstance == -1) {
18016
0
        return -1;
18017
0
    }
18018
0
    if (isinstance) {
18019
0
        identifier name;
18020
0
        expr_ty default_value;
18021
18022
0
        if (PyObject_GetOptionalAttr(obj, state->name, &tmp) < 0) {
18023
0
            return -1;
18024
0
        }
18025
0
        if (tmp == NULL) {
18026
0
            PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from TypeVarTuple");
18027
0
            return -1;
18028
0
        }
18029
0
        else {
18030
0
            int res;
18031
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
18032
0
                goto failed;
18033
0
            }
18034
0
            res = obj2ast_identifier(state, tmp, &name, arena);
18035
0
            _Py_LeaveRecursiveCall();
18036
0
            if (res != 0) goto failed;
18037
0
            Py_CLEAR(tmp);
18038
0
        }
18039
0
        if (PyObject_GetOptionalAttr(obj, state->default_value, &tmp) < 0) {
18040
0
            return -1;
18041
0
        }
18042
0
        if (tmp == NULL || tmp == Py_None) {
18043
0
            Py_CLEAR(tmp);
18044
0
            default_value = NULL;
18045
0
        }
18046
0
        else {
18047
0
            int res;
18048
0
            if (_Py_EnterRecursiveCall(" while traversing 'TypeVarTuple' node")) {
18049
0
                goto failed;
18050
0
            }
18051
0
            res = obj2ast_expr(state, tmp, &default_value, arena);
18052
0
            _Py_LeaveRecursiveCall();
18053
0
            if (res != 0) goto failed;
18054
0
            Py_CLEAR(tmp);
18055
0
        }
18056
0
        *out = _PyAST_TypeVarTuple(name, default_value, lineno, col_offset,
18057
0
                                   end_lineno, end_col_offset, arena);
18058
0
        if (*out == NULL) goto failed;
18059
0
        return 0;
18060
0
    }
18061
18062
0
    PyErr_Format(PyExc_TypeError, "expected some sort of type_param, but got %R", obj);
18063
0
    failed:
18064
0
    Py_XDECREF(tmp);
18065
0
    return -1;
18066
0
}
18067
18068
18069
static int
18070
astmodule_exec(PyObject *m)
18071
6
{
18072
6
    struct ast_state *state = get_ast_state();
18073
6
    if (state == NULL) {
18074
0
        return -1;
18075
0
    }
18076
6
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
18077
0
        return -1;
18078
0
    }
18079
6
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
18080
0
        return -1;
18081
0
    }
18082
6
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
18083
0
        return -1;
18084
0
    }
18085
6
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
18086
0
        return -1;
18087
0
    }
18088
6
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18089
0
        return -1;
18090
0
    }
18091
6
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18092
0
        return -1;
18093
0
    }
18094
6
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18095
0
        return -1;
18096
0
    }
18097
6
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18098
0
        return -1;
18099
0
    }
18100
6
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18101
0
        return -1;
18102
0
    }
18103
6
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18104
0
        {
18105
0
        return -1;
18106
0
    }
18107
6
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18108
0
        return -1;
18109
0
    }
18110
6
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18111
0
        return -1;
18112
0
    }
18113
6
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18114
6
        state->AsyncFunctionDef_type) < 0) {
18115
0
        return -1;
18116
0
    }
18117
6
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18118
0
        return -1;
18119
0
    }
18120
6
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18121
0
        return -1;
18122
0
    }
18123
6
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18124
0
        return -1;
18125
0
    }
18126
6
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18127
0
        return -1;
18128
0
    }
18129
6
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18130
0
        return -1;
18131
0
    }
18132
6
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18133
0
        return -1;
18134
0
    }
18135
6
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18136
0
        return -1;
18137
0
    }
18138
6
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18139
0
        return -1;
18140
0
    }
18141
6
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18142
0
        return -1;
18143
0
    }
18144
6
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18145
0
        return -1;
18146
0
    }
18147
6
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18148
0
        return -1;
18149
0
    }
18150
6
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18151
0
        return -1;
18152
0
    }
18153
6
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18154
0
        return -1;
18155
0
    }
18156
6
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18157
0
        return -1;
18158
0
    }
18159
6
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18160
0
        return -1;
18161
0
    }
18162
6
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18163
0
        return -1;
18164
0
    }
18165
6
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18166
0
        return -1;
18167
0
    }
18168
6
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18169
0
        return -1;
18170
0
    }
18171
6
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18172
0
        return -1;
18173
0
    }
18174
6
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18175
0
        return -1;
18176
0
    }
18177
6
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18178
0
        return -1;
18179
0
    }
18180
6
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18181
0
        return -1;
18182
0
    }
18183
6
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18184
0
        return -1;
18185
0
    }
18186
6
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18187
0
        return -1;
18188
0
    }
18189
6
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18190
0
        return -1;
18191
0
    }
18192
6
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18193
0
        return -1;
18194
0
    }
18195
6
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18196
0
        return -1;
18197
0
    }
18198
6
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18199
0
        return -1;
18200
0
    }
18201
6
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18202
0
        return -1;
18203
0
    }
18204
6
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18205
0
        return -1;
18206
0
    }
18207
6
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18208
0
        return -1;
18209
0
    }
18210
6
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18211
0
        return -1;
18212
0
    }
18213
6
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18214
0
        return -1;
18215
0
    }
18216
6
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18217
0
        return -1;
18218
0
    }
18219
6
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18220
0
        return -1;
18221
0
    }
18222
6
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18223
0
        return -1;
18224
0
    }
18225
6
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18226
0
        return -1;
18227
0
    }
18228
6
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18229
0
        return -1;
18230
0
    }
18231
6
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18232
0
        {
18233
0
        return -1;
18234
0
    }
18235
6
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18236
0
        return -1;
18237
0
    }
18238
6
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18239
0
        return -1;
18240
0
    }
18241
6
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18242
0
        return -1;
18243
0
    }
18244
6
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18245
0
        return -1;
18246
0
    }
18247
6
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18248
0
        return -1;
18249
0
    }
18250
6
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18251
6
        < 0) {
18252
0
        return -1;
18253
0
    }
18254
6
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18255
6
        0) {
18256
0
        return -1;
18257
0
    }
18258
6
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18259
0
        return -1;
18260
0
    }
18261
6
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18262
0
        return -1;
18263
0
    }
18264
6
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18265
0
        return -1;
18266
0
    }
18267
6
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18268
0
        return -1;
18269
0
    }
18270
6
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18271
0
        return -1;
18272
0
    }
18273
6
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18274
0
        return -1;
18275
0
    }
18276
6
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18277
0
        return -1;
18278
0
    }
18279
6
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18280
0
        return -1;
18281
0
    }
18282
6
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18283
0
        return -1;
18284
0
    }
18285
6
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18286
0
        return -1;
18287
0
    }
18288
6
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18289
0
        {
18290
0
        return -1;
18291
0
    }
18292
6
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18293
0
        return -1;
18294
0
    }
18295
6
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18296
0
        return -1;
18297
0
    }
18298
6
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18299
0
        return -1;
18300
0
    }
18301
6
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18302
0
        return -1;
18303
0
    }
18304
6
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18305
0
        return -1;
18306
0
    }
18307
6
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18308
0
        return -1;
18309
0
    }
18310
6
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18311
0
        return -1;
18312
0
    }
18313
6
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18314
0
        return -1;
18315
0
    }
18316
6
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18317
0
        return -1;
18318
0
    }
18319
6
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18320
0
        return -1;
18321
0
    }
18322
6
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18323
0
        return -1;
18324
0
    }
18325
6
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18326
0
        return -1;
18327
0
    }
18328
6
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18329
0
        return -1;
18330
0
    }
18331
6
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18332
0
        return -1;
18333
0
    }
18334
6
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18335
0
        return -1;
18336
0
    }
18337
6
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18338
0
        return -1;
18339
0
    }
18340
6
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18341
0
        return -1;
18342
0
    }
18343
6
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18344
0
        return -1;
18345
0
    }
18346
6
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18347
0
        return -1;
18348
0
    }
18349
6
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18350
0
        return -1;
18351
0
    }
18352
6
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18353
0
        return -1;
18354
0
    }
18355
6
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18356
0
        return -1;
18357
0
    }
18358
6
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18359
0
        return -1;
18360
0
    }
18361
6
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18362
0
        return -1;
18363
0
    }
18364
6
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18365
0
        return -1;
18366
0
    }
18367
6
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18368
0
        return -1;
18369
0
    }
18370
6
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18371
0
        return -1;
18372
0
    }
18373
6
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18374
0
        return -1;
18375
0
    }
18376
6
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18377
0
        return -1;
18378
0
    }
18379
6
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18380
0
        return -1;
18381
0
    }
18382
6
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18383
0
        return -1;
18384
0
    }
18385
6
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18386
0
        return -1;
18387
0
    }
18388
6
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18389
0
        return -1;
18390
0
    }
18391
6
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18392
0
        return -1;
18393
0
    }
18394
6
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18395
0
        return -1;
18396
0
    }
18397
6
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18398
0
        return -1;
18399
0
    }
18400
6
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18401
6
        0) {
18402
0
        return -1;
18403
0
    }
18404
6
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18405
6
        0) {
18406
0
        return -1;
18407
0
    }
18408
6
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18409
6
        0) {
18410
0
        return -1;
18411
0
    }
18412
6
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18413
0
        return -1;
18414
0
    }
18415
6
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18416
0
        return -1;
18417
0
    }
18418
6
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18419
0
        return -1;
18420
0
    }
18421
6
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18422
0
        return -1;
18423
0
    }
18424
6
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18425
0
        return -1;
18426
0
    }
18427
6
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18428
0
        return -1;
18429
0
    }
18430
6
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18431
0
        return -1;
18432
0
    }
18433
6
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18434
0
        return -1;
18435
0
    }
18436
6
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18437
6
        < 0) {
18438
0
        return -1;
18439
0
    }
18440
6
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18441
6
        0) {
18442
0
        return -1;
18443
0
    }
18444
6
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18445
0
        {
18446
0
        return -1;
18447
0
    }
18448
6
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18449
0
        return -1;
18450
0
    }
18451
6
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18452
0
        return -1;
18453
0
    }
18454
6
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18455
0
        return -1;
18456
0
    }
18457
6
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18458
0
        return -1;
18459
0
    }
18460
6
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18461
0
        return -1;
18462
0
    }
18463
6
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18464
0
        return -1;
18465
0
    }
18466
6
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18467
0
        return -1;
18468
0
    }
18469
6
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18470
0
        return -1;
18471
0
    }
18472
6
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18473
0
        return -1;
18474
0
    }
18475
6
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18476
0
        {
18477
0
        return -1;
18478
0
    }
18479
6
    return 0;
18480
6
}
18481
18482
static PyModuleDef_Slot astmodule_slots[] = {
18483
    {Py_mod_exec, astmodule_exec},
18484
    {Py_mod_multiple_interpreters, Py_MOD_PER_INTERPRETER_GIL_SUPPORTED},
18485
    {Py_mod_gil, Py_MOD_GIL_NOT_USED},
18486
    {0, NULL}
18487
};
18488
18489
static struct PyModuleDef _astmodule = {
18490
    PyModuleDef_HEAD_INIT,
18491
    .m_name = "_ast",
18492
    // The _ast module uses a per-interpreter state (PyInterpreterState.ast)
18493
    .m_size = 0,
18494
    .m_slots = astmodule_slots,
18495
};
18496
18497
PyMODINIT_FUNC
18498
PyInit__ast(void)
18499
6
{
18500
6
    return PyModuleDef_Init(&_astmodule);
18501
6
}
18502
18503
18504
PyObject* PyAST_mod2obj(mod_ty t)
18505
4.99k
{
18506
4.99k
    struct ast_state *state = get_ast_state();
18507
4.99k
    if (state == NULL) {
18508
0
        return NULL;
18509
0
    }
18510
4.99k
    PyObject *result = ast2obj_mod(state, t);
18511
18512
4.99k
    return result;
18513
4.99k
}
18514
18515
/* mode is 0 for "exec", 1 for "eval" and 2 for "single" input */
18516
int PyAst_CheckMode(PyObject *ast, int mode)
18517
0
{
18518
0
    const char * const req_name[] = {"Module", "Expression", "Interactive"};
18519
18520
0
    struct ast_state *state = get_ast_state();
18521
0
    if (state == NULL) {
18522
0
        return -1;
18523
0
    }
18524
18525
0
    PyObject *req_type[3];
18526
0
    req_type[0] = state->Module_type;
18527
0
    req_type[1] = state->Expression_type;
18528
0
    req_type[2] = state->Interactive_type;
18529
18530
0
    assert(0 <= mode && mode <= 2);
18531
0
    int isinstance = PyObject_IsInstance(ast, req_type[mode]);
18532
0
    if (isinstance == -1) {
18533
0
        return -1;
18534
0
    }
18535
0
    if (!isinstance) {
18536
0
        PyErr_Format(PyExc_TypeError, "expected %s node, got %.400s",
18537
0
                     req_name[mode], _PyType_Name(Py_TYPE(ast)));
18538
0
        return -1;
18539
0
    }
18540
0
    return 0;
18541
0
}
18542
18543
mod_ty PyAST_obj2mod(PyObject* ast, PyArena* arena, int mode)
18544
0
{
18545
0
    if (PySys_Audit("compile", "OO", ast, Py_None) < 0) {
18546
0
        return NULL;
18547
0
    }
18548
18549
0
    struct ast_state *state = get_ast_state();
18550
0
    if (state == NULL) {
18551
0
        return NULL;
18552
0
    }
18553
18554
0
    if (PyAst_CheckMode(ast, mode) < 0) {
18555
0
        return NULL;
18556
0
    }
18557
18558
0
    mod_ty res = NULL;
18559
0
    if (obj2ast_mod(state, ast, &res, arena) != 0)
18560
0
        return NULL;
18561
0
    else
18562
0
        return res;
18563
0
}
18564
18565
int PyAST_Check(PyObject* obj)
18566
17.3k
{
18567
17.3k
    struct ast_state *state = get_ast_state();
18568
17.3k
    if (state == NULL) {
18569
0
        return -1;
18570
0
    }
18571
17.3k
    return PyObject_IsInstance(obj, state->AST_type);
18572
17.3k
}
18573
18574