Coverage Report

Created: 2026-03-23 06:45

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
98.0k
{
23
98.0k
    PyInterpreterState *interp = _PyInterpreterState_GET();
24
98.0k
    struct ast_state *state = &interp->ast;
25
98.0k
    assert(!state->finalized);
26
98.0k
    if (_PyOnceFlag_CallOnce(&state->once, (_Py_once_fn_t *)&init_types, state) < 0) {
27
0
        return NULL;
28
0
    }
29
98.0k
    return state;
30
98.0k
}
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
15
{
290
15
    if ((state->__dict__ = PyUnicode_InternFromString("__dict__")) == NULL) return -1;
291
15
    if ((state->__doc__ = PyUnicode_InternFromString("__doc__")) == NULL) return -1;
292
15
    if ((state->__match_args__ = PyUnicode_InternFromString("__match_args__")) == NULL) return -1;
293
15
    if ((state->__module__ = PyUnicode_InternFromString("__module__")) == NULL) return -1;
294
15
    if ((state->_attributes = PyUnicode_InternFromString("_attributes")) == NULL) return -1;
295
15
    if ((state->_fields = PyUnicode_InternFromString("_fields")) == NULL) return -1;
296
15
    if ((state->annotation = PyUnicode_InternFromString("annotation")) == NULL) return -1;
297
15
    if ((state->arg = PyUnicode_InternFromString("arg")) == NULL) return -1;
298
15
    if ((state->args = PyUnicode_InternFromString("args")) == NULL) return -1;
299
15
    if ((state->argtypes = PyUnicode_InternFromString("argtypes")) == NULL) return -1;
300
15
    if ((state->asname = PyUnicode_InternFromString("asname")) == NULL) return -1;
301
15
    if ((state->ast = PyUnicode_InternFromString("ast")) == NULL) return -1;
302
15
    if ((state->attr = PyUnicode_InternFromString("attr")) == NULL) return -1;
303
15
    if ((state->bases = PyUnicode_InternFromString("bases")) == NULL) return -1;
304
15
    if ((state->body = PyUnicode_InternFromString("body")) == NULL) return -1;
305
15
    if ((state->bound = PyUnicode_InternFromString("bound")) == NULL) return -1;
306
15
    if ((state->cases = PyUnicode_InternFromString("cases")) == NULL) return -1;
307
15
    if ((state->cause = PyUnicode_InternFromString("cause")) == NULL) return -1;
308
15
    if ((state->cls = PyUnicode_InternFromString("cls")) == NULL) return -1;
309
15
    if ((state->col_offset = PyUnicode_InternFromString("col_offset")) == NULL) return -1;
310
15
    if ((state->comparators = PyUnicode_InternFromString("comparators")) == NULL) return -1;
311
15
    if ((state->context_expr = PyUnicode_InternFromString("context_expr")) == NULL) return -1;
312
15
    if ((state->conversion = PyUnicode_InternFromString("conversion")) == NULL) return -1;
313
15
    if ((state->ctx = PyUnicode_InternFromString("ctx")) == NULL) return -1;
314
15
    if ((state->decorator_list = PyUnicode_InternFromString("decorator_list")) == NULL) return -1;
315
15
    if ((state->default_value = PyUnicode_InternFromString("default_value")) == NULL) return -1;
316
15
    if ((state->defaults = PyUnicode_InternFromString("defaults")) == NULL) return -1;
317
15
    if ((state->elt = PyUnicode_InternFromString("elt")) == NULL) return -1;
318
15
    if ((state->elts = PyUnicode_InternFromString("elts")) == NULL) return -1;
319
15
    if ((state->end_col_offset = PyUnicode_InternFromString("end_col_offset")) == NULL) return -1;
320
15
    if ((state->end_lineno = PyUnicode_InternFromString("end_lineno")) == NULL) return -1;
321
15
    if ((state->exc = PyUnicode_InternFromString("exc")) == NULL) return -1;
322
15
    if ((state->finalbody = PyUnicode_InternFromString("finalbody")) == NULL) return -1;
323
15
    if ((state->format_spec = PyUnicode_InternFromString("format_spec")) == NULL) return -1;
324
15
    if ((state->func = PyUnicode_InternFromString("func")) == NULL) return -1;
325
15
    if ((state->generators = PyUnicode_InternFromString("generators")) == NULL) return -1;
326
15
    if ((state->guard = PyUnicode_InternFromString("guard")) == NULL) return -1;
327
15
    if ((state->handlers = PyUnicode_InternFromString("handlers")) == NULL) return -1;
328
15
    if ((state->id = PyUnicode_InternFromString("id")) == NULL) return -1;
329
15
    if ((state->ifs = PyUnicode_InternFromString("ifs")) == NULL) return -1;
330
15
    if ((state->is_async = PyUnicode_InternFromString("is_async")) == NULL) return -1;
331
15
    if ((state->is_lazy = PyUnicode_InternFromString("is_lazy")) == NULL) return -1;
332
15
    if ((state->items = PyUnicode_InternFromString("items")) == NULL) return -1;
333
15
    if ((state->iter = PyUnicode_InternFromString("iter")) == NULL) return -1;
334
15
    if ((state->key = PyUnicode_InternFromString("key")) == NULL) return -1;
335
15
    if ((state->keys = PyUnicode_InternFromString("keys")) == NULL) return -1;
336
15
    if ((state->keywords = PyUnicode_InternFromString("keywords")) == NULL) return -1;
337
15
    if ((state->kind = PyUnicode_InternFromString("kind")) == NULL) return -1;
338
15
    if ((state->kw_defaults = PyUnicode_InternFromString("kw_defaults")) == NULL) return -1;
339
15
    if ((state->kwarg = PyUnicode_InternFromString("kwarg")) == NULL) return -1;
340
15
    if ((state->kwd_attrs = PyUnicode_InternFromString("kwd_attrs")) == NULL) return -1;
341
15
    if ((state->kwd_patterns = PyUnicode_InternFromString("kwd_patterns")) == NULL) return -1;
342
15
    if ((state->kwonlyargs = PyUnicode_InternFromString("kwonlyargs")) == NULL) return -1;
343
15
    if ((state->left = PyUnicode_InternFromString("left")) == NULL) return -1;
344
15
    if ((state->level = PyUnicode_InternFromString("level")) == NULL) return -1;
345
15
    if ((state->lineno = PyUnicode_InternFromString("lineno")) == NULL) return -1;
346
15
    if ((state->lower = PyUnicode_InternFromString("lower")) == NULL) return -1;
347
15
    if ((state->module = PyUnicode_InternFromString("module")) == NULL) return -1;
348
15
    if ((state->msg = PyUnicode_InternFromString("msg")) == NULL) return -1;
349
15
    if ((state->name = PyUnicode_InternFromString("name")) == NULL) return -1;
350
15
    if ((state->names = PyUnicode_InternFromString("names")) == NULL) return -1;
351
15
    if ((state->op = PyUnicode_InternFromString("op")) == NULL) return -1;
352
15
    if ((state->operand = PyUnicode_InternFromString("operand")) == NULL) return -1;
353
15
    if ((state->ops = PyUnicode_InternFromString("ops")) == NULL) return -1;
354
15
    if ((state->optional_vars = PyUnicode_InternFromString("optional_vars")) == NULL) return -1;
355
15
    if ((state->orelse = PyUnicode_InternFromString("orelse")) == NULL) return -1;
356
15
    if ((state->pattern = PyUnicode_InternFromString("pattern")) == NULL) return -1;
357
15
    if ((state->patterns = PyUnicode_InternFromString("patterns")) == NULL) return -1;
358
15
    if ((state->posonlyargs = PyUnicode_InternFromString("posonlyargs")) == NULL) return -1;
359
15
    if ((state->rest = PyUnicode_InternFromString("rest")) == NULL) return -1;
360
15
    if ((state->returns = PyUnicode_InternFromString("returns")) == NULL) return -1;
361
15
    if ((state->right = PyUnicode_InternFromString("right")) == NULL) return -1;
362
15
    if ((state->simple = PyUnicode_InternFromString("simple")) == NULL) return -1;
363
15
    if ((state->slice = PyUnicode_InternFromString("slice")) == NULL) return -1;
364
15
    if ((state->step = PyUnicode_InternFromString("step")) == NULL) return -1;
365
15
    if ((state->str = PyUnicode_InternFromString("str")) == NULL) return -1;
366
15
    if ((state->subject = PyUnicode_InternFromString("subject")) == NULL) return -1;
367
15
    if ((state->tag = PyUnicode_InternFromString("tag")) == NULL) return -1;
368
15
    if ((state->target = PyUnicode_InternFromString("target")) == NULL) return -1;
369
15
    if ((state->targets = PyUnicode_InternFromString("targets")) == NULL) return -1;
370
15
    if ((state->test = PyUnicode_InternFromString("test")) == NULL) return -1;
371
15
    if ((state->type = PyUnicode_InternFromString("type")) == NULL) return -1;
372
15
    if ((state->type_comment = PyUnicode_InternFromString("type_comment")) == NULL) return -1;
373
15
    if ((state->type_ignores = PyUnicode_InternFromString("type_ignores")) == NULL) return -1;
374
15
    if ((state->type_params = PyUnicode_InternFromString("type_params")) == NULL) return -1;
375
15
    if ((state->upper = PyUnicode_InternFromString("upper")) == NULL) return -1;
376
15
    if ((state->value = PyUnicode_InternFromString("value")) == NULL) return -1;
377
15
    if ((state->values = PyUnicode_InternFromString("values")) == NULL) return -1;
378
15
    if ((state->vararg = PyUnicode_InternFromString("vararg")) == NULL) return -1;
379
15
    return 0;
380
15
};
381
382
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(mod, mod_ty)
383
0
GENERATE_ASDL_SEQ_CONSTRUCTOR(stmt, stmt_ty)
384
698k
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
929k
GENERATE_ASDL_SEQ_CONSTRUCTOR(arg, arg_ty)
389
9.14k
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.15k
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
15
{
823
15
    bool cond;
824
15
    PyObject *Module_annotations = PyDict_New();
825
15
    if (!Module_annotations) return 0;
826
15
    {
827
15
        PyObject *type = state->stmt_type;
828
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
829
15
        cond = type != NULL;
830
15
        if (!cond) {
831
0
            Py_DECREF(Module_annotations);
832
0
            return 0;
833
0
        }
834
15
        cond = PyDict_SetItemString(Module_annotations, "body", type) == 0;
835
15
        Py_DECREF(type);
836
15
        if (!cond) {
837
0
            Py_DECREF(Module_annotations);
838
0
            return 0;
839
0
        }
840
15
    }
841
15
    {
842
15
        PyObject *type = state->type_ignore_type;
843
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
844
15
        cond = type != NULL;
845
15
        if (!cond) {
846
0
            Py_DECREF(Module_annotations);
847
0
            return 0;
848
0
        }
849
15
        cond = PyDict_SetItemString(Module_annotations, "type_ignores", type)
850
15
                                    == 0;
851
15
        Py_DECREF(type);
852
15
        if (!cond) {
853
0
            Py_DECREF(Module_annotations);
854
0
            return 0;
855
0
        }
856
15
    }
857
15
    cond = PyObject_SetAttrString(state->Module_type, "_field_types",
858
15
                                  Module_annotations) == 0;
859
15
    if (!cond) {
860
0
        Py_DECREF(Module_annotations);
861
0
        return 0;
862
0
    }
863
15
    cond = PyObject_SetAttrString(state->Module_type, "__annotations__",
864
15
                                  Module_annotations) == 0;
865
15
    if (!cond) {
866
0
        Py_DECREF(Module_annotations);
867
0
        return 0;
868
0
    }
869
15
    Py_DECREF(Module_annotations);
870
15
    PyObject *Interactive_annotations = PyDict_New();
871
15
    if (!Interactive_annotations) return 0;
872
15
    {
873
15
        PyObject *type = state->stmt_type;
874
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
875
15
        cond = type != NULL;
876
15
        if (!cond) {
877
0
            Py_DECREF(Interactive_annotations);
878
0
            return 0;
879
0
        }
880
15
        cond = PyDict_SetItemString(Interactive_annotations, "body", type) == 0;
881
15
        Py_DECREF(type);
882
15
        if (!cond) {
883
0
            Py_DECREF(Interactive_annotations);
884
0
            return 0;
885
0
        }
886
15
    }
887
15
    cond = PyObject_SetAttrString(state->Interactive_type, "_field_types",
888
15
                                  Interactive_annotations) == 0;
889
15
    if (!cond) {
890
0
        Py_DECREF(Interactive_annotations);
891
0
        return 0;
892
0
    }
893
15
    cond = PyObject_SetAttrString(state->Interactive_type, "__annotations__",
894
15
                                  Interactive_annotations) == 0;
895
15
    if (!cond) {
896
0
        Py_DECREF(Interactive_annotations);
897
0
        return 0;
898
0
    }
899
15
    Py_DECREF(Interactive_annotations);
900
15
    PyObject *Expression_annotations = PyDict_New();
901
15
    if (!Expression_annotations) return 0;
902
15
    {
903
15
        PyObject *type = state->expr_type;
904
15
        Py_INCREF(type);
905
15
        cond = PyDict_SetItemString(Expression_annotations, "body", type) == 0;
906
15
        Py_DECREF(type);
907
15
        if (!cond) {
908
0
            Py_DECREF(Expression_annotations);
909
0
            return 0;
910
0
        }
911
15
    }
912
15
    cond = PyObject_SetAttrString(state->Expression_type, "_field_types",
913
15
                                  Expression_annotations) == 0;
914
15
    if (!cond) {
915
0
        Py_DECREF(Expression_annotations);
916
0
        return 0;
917
0
    }
918
15
    cond = PyObject_SetAttrString(state->Expression_type, "__annotations__",
919
15
                                  Expression_annotations) == 0;
920
15
    if (!cond) {
921
0
        Py_DECREF(Expression_annotations);
922
0
        return 0;
923
0
    }
924
15
    Py_DECREF(Expression_annotations);
925
15
    PyObject *FunctionType_annotations = PyDict_New();
926
15
    if (!FunctionType_annotations) return 0;
927
15
    {
928
15
        PyObject *type = state->expr_type;
929
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
930
15
        cond = type != NULL;
931
15
        if (!cond) {
932
0
            Py_DECREF(FunctionType_annotations);
933
0
            return 0;
934
0
        }
935
15
        cond = PyDict_SetItemString(FunctionType_annotations, "argtypes", type)
936
15
                                    == 0;
937
15
        Py_DECREF(type);
938
15
        if (!cond) {
939
0
            Py_DECREF(FunctionType_annotations);
940
0
            return 0;
941
0
        }
942
15
    }
943
15
    {
944
15
        PyObject *type = state->expr_type;
945
15
        Py_INCREF(type);
946
15
        cond = PyDict_SetItemString(FunctionType_annotations, "returns", type)
947
15
                                    == 0;
948
15
        Py_DECREF(type);
949
15
        if (!cond) {
950
0
            Py_DECREF(FunctionType_annotations);
951
0
            return 0;
952
0
        }
953
15
    }
954
15
    cond = PyObject_SetAttrString(state->FunctionType_type, "_field_types",
955
15
                                  FunctionType_annotations) == 0;
956
15
    if (!cond) {
957
0
        Py_DECREF(FunctionType_annotations);
958
0
        return 0;
959
0
    }
960
15
    cond = PyObject_SetAttrString(state->FunctionType_type, "__annotations__",
961
15
                                  FunctionType_annotations) == 0;
962
15
    if (!cond) {
963
0
        Py_DECREF(FunctionType_annotations);
964
0
        return 0;
965
0
    }
966
15
    Py_DECREF(FunctionType_annotations);
967
15
    PyObject *FunctionDef_annotations = PyDict_New();
968
15
    if (!FunctionDef_annotations) return 0;
969
15
    {
970
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
971
15
        Py_INCREF(type);
972
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "name", type) == 0;
973
15
        Py_DECREF(type);
974
15
        if (!cond) {
975
0
            Py_DECREF(FunctionDef_annotations);
976
0
            return 0;
977
0
        }
978
15
    }
979
15
    {
980
15
        PyObject *type = state->arguments_type;
981
15
        Py_INCREF(type);
982
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "args", type) == 0;
983
15
        Py_DECREF(type);
984
15
        if (!cond) {
985
0
            Py_DECREF(FunctionDef_annotations);
986
0
            return 0;
987
0
        }
988
15
    }
989
15
    {
990
15
        PyObject *type = state->stmt_type;
991
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
992
15
        cond = type != NULL;
993
15
        if (!cond) {
994
0
            Py_DECREF(FunctionDef_annotations);
995
0
            return 0;
996
0
        }
997
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "body", type) == 0;
998
15
        Py_DECREF(type);
999
15
        if (!cond) {
1000
0
            Py_DECREF(FunctionDef_annotations);
1001
0
            return 0;
1002
0
        }
1003
15
    }
1004
15
    {
1005
15
        PyObject *type = state->expr_type;
1006
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1007
15
        cond = type != NULL;
1008
15
        if (!cond) {
1009
0
            Py_DECREF(FunctionDef_annotations);
1010
0
            return 0;
1011
0
        }
1012
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "decorator_list",
1013
15
                                    type) == 0;
1014
15
        Py_DECREF(type);
1015
15
        if (!cond) {
1016
0
            Py_DECREF(FunctionDef_annotations);
1017
0
            return 0;
1018
0
        }
1019
15
    }
1020
15
    {
1021
15
        PyObject *type = state->expr_type;
1022
15
        type = _Py_union_type_or(type, Py_None);
1023
15
        cond = type != NULL;
1024
15
        if (!cond) {
1025
0
            Py_DECREF(FunctionDef_annotations);
1026
0
            return 0;
1027
0
        }
1028
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "returns", type)
1029
15
                                    == 0;
1030
15
        Py_DECREF(type);
1031
15
        if (!cond) {
1032
0
            Py_DECREF(FunctionDef_annotations);
1033
0
            return 0;
1034
0
        }
1035
15
    }
1036
15
    {
1037
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1038
15
        type = _Py_union_type_or(type, Py_None);
1039
15
        cond = type != NULL;
1040
15
        if (!cond) {
1041
0
            Py_DECREF(FunctionDef_annotations);
1042
0
            return 0;
1043
0
        }
1044
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_comment",
1045
15
                                    type) == 0;
1046
15
        Py_DECREF(type);
1047
15
        if (!cond) {
1048
0
            Py_DECREF(FunctionDef_annotations);
1049
0
            return 0;
1050
0
        }
1051
15
    }
1052
15
    {
1053
15
        PyObject *type = state->type_param_type;
1054
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1055
15
        cond = type != NULL;
1056
15
        if (!cond) {
1057
0
            Py_DECREF(FunctionDef_annotations);
1058
0
            return 0;
1059
0
        }
1060
15
        cond = PyDict_SetItemString(FunctionDef_annotations, "type_params",
1061
15
                                    type) == 0;
1062
15
        Py_DECREF(type);
1063
15
        if (!cond) {
1064
0
            Py_DECREF(FunctionDef_annotations);
1065
0
            return 0;
1066
0
        }
1067
15
    }
1068
15
    cond = PyObject_SetAttrString(state->FunctionDef_type, "_field_types",
1069
15
                                  FunctionDef_annotations) == 0;
1070
15
    if (!cond) {
1071
0
        Py_DECREF(FunctionDef_annotations);
1072
0
        return 0;
1073
0
    }
1074
15
    cond = PyObject_SetAttrString(state->FunctionDef_type, "__annotations__",
1075
15
                                  FunctionDef_annotations) == 0;
1076
15
    if (!cond) {
1077
0
        Py_DECREF(FunctionDef_annotations);
1078
0
        return 0;
1079
0
    }
1080
15
    Py_DECREF(FunctionDef_annotations);
1081
15
    PyObject *AsyncFunctionDef_annotations = PyDict_New();
1082
15
    if (!AsyncFunctionDef_annotations) return 0;
1083
15
    {
1084
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1085
15
        Py_INCREF(type);
1086
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "name", type)
1087
15
                                    == 0;
1088
15
        Py_DECREF(type);
1089
15
        if (!cond) {
1090
0
            Py_DECREF(AsyncFunctionDef_annotations);
1091
0
            return 0;
1092
0
        }
1093
15
    }
1094
15
    {
1095
15
        PyObject *type = state->arguments_type;
1096
15
        Py_INCREF(type);
1097
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "args", type)
1098
15
                                    == 0;
1099
15
        Py_DECREF(type);
1100
15
        if (!cond) {
1101
0
            Py_DECREF(AsyncFunctionDef_annotations);
1102
0
            return 0;
1103
0
        }
1104
15
    }
1105
15
    {
1106
15
        PyObject *type = state->stmt_type;
1107
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1108
15
        cond = type != NULL;
1109
15
        if (!cond) {
1110
0
            Py_DECREF(AsyncFunctionDef_annotations);
1111
0
            return 0;
1112
0
        }
1113
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "body", type)
1114
15
                                    == 0;
1115
15
        Py_DECREF(type);
1116
15
        if (!cond) {
1117
0
            Py_DECREF(AsyncFunctionDef_annotations);
1118
0
            return 0;
1119
0
        }
1120
15
    }
1121
15
    {
1122
15
        PyObject *type = state->expr_type;
1123
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1124
15
        cond = type != NULL;
1125
15
        if (!cond) {
1126
0
            Py_DECREF(AsyncFunctionDef_annotations);
1127
0
            return 0;
1128
0
        }
1129
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1130
15
                                    "decorator_list", type) == 0;
1131
15
        Py_DECREF(type);
1132
15
        if (!cond) {
1133
0
            Py_DECREF(AsyncFunctionDef_annotations);
1134
0
            return 0;
1135
0
        }
1136
15
    }
1137
15
    {
1138
15
        PyObject *type = state->expr_type;
1139
15
        type = _Py_union_type_or(type, Py_None);
1140
15
        cond = type != NULL;
1141
15
        if (!cond) {
1142
0
            Py_DECREF(AsyncFunctionDef_annotations);
1143
0
            return 0;
1144
0
        }
1145
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations, "returns",
1146
15
                                    type) == 0;
1147
15
        Py_DECREF(type);
1148
15
        if (!cond) {
1149
0
            Py_DECREF(AsyncFunctionDef_annotations);
1150
0
            return 0;
1151
0
        }
1152
15
    }
1153
15
    {
1154
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1155
15
        type = _Py_union_type_or(type, Py_None);
1156
15
        cond = type != NULL;
1157
15
        if (!cond) {
1158
0
            Py_DECREF(AsyncFunctionDef_annotations);
1159
0
            return 0;
1160
0
        }
1161
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1162
15
                                    "type_comment", type) == 0;
1163
15
        Py_DECREF(type);
1164
15
        if (!cond) {
1165
0
            Py_DECREF(AsyncFunctionDef_annotations);
1166
0
            return 0;
1167
0
        }
1168
15
    }
1169
15
    {
1170
15
        PyObject *type = state->type_param_type;
1171
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1172
15
        cond = type != NULL;
1173
15
        if (!cond) {
1174
0
            Py_DECREF(AsyncFunctionDef_annotations);
1175
0
            return 0;
1176
0
        }
1177
15
        cond = PyDict_SetItemString(AsyncFunctionDef_annotations,
1178
15
                                    "type_params", type) == 0;
1179
15
        Py_DECREF(type);
1180
15
        if (!cond) {
1181
0
            Py_DECREF(AsyncFunctionDef_annotations);
1182
0
            return 0;
1183
0
        }
1184
15
    }
1185
15
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type, "_field_types",
1186
15
                                  AsyncFunctionDef_annotations) == 0;
1187
15
    if (!cond) {
1188
0
        Py_DECREF(AsyncFunctionDef_annotations);
1189
0
        return 0;
1190
0
    }
1191
15
    cond = PyObject_SetAttrString(state->AsyncFunctionDef_type,
1192
15
                                  "__annotations__",
1193
15
                                  AsyncFunctionDef_annotations) == 0;
1194
15
    if (!cond) {
1195
0
        Py_DECREF(AsyncFunctionDef_annotations);
1196
0
        return 0;
1197
0
    }
1198
15
    Py_DECREF(AsyncFunctionDef_annotations);
1199
15
    PyObject *ClassDef_annotations = PyDict_New();
1200
15
    if (!ClassDef_annotations) return 0;
1201
15
    {
1202
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1203
15
        Py_INCREF(type);
1204
15
        cond = PyDict_SetItemString(ClassDef_annotations, "name", type) == 0;
1205
15
        Py_DECREF(type);
1206
15
        if (!cond) {
1207
0
            Py_DECREF(ClassDef_annotations);
1208
0
            return 0;
1209
0
        }
1210
15
    }
1211
15
    {
1212
15
        PyObject *type = state->expr_type;
1213
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1214
15
        cond = type != NULL;
1215
15
        if (!cond) {
1216
0
            Py_DECREF(ClassDef_annotations);
1217
0
            return 0;
1218
0
        }
1219
15
        cond = PyDict_SetItemString(ClassDef_annotations, "bases", type) == 0;
1220
15
        Py_DECREF(type);
1221
15
        if (!cond) {
1222
0
            Py_DECREF(ClassDef_annotations);
1223
0
            return 0;
1224
0
        }
1225
15
    }
1226
15
    {
1227
15
        PyObject *type = state->keyword_type;
1228
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1229
15
        cond = type != NULL;
1230
15
        if (!cond) {
1231
0
            Py_DECREF(ClassDef_annotations);
1232
0
            return 0;
1233
0
        }
1234
15
        cond = PyDict_SetItemString(ClassDef_annotations, "keywords", type) ==
1235
15
                                    0;
1236
15
        Py_DECREF(type);
1237
15
        if (!cond) {
1238
0
            Py_DECREF(ClassDef_annotations);
1239
0
            return 0;
1240
0
        }
1241
15
    }
1242
15
    {
1243
15
        PyObject *type = state->stmt_type;
1244
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1245
15
        cond = type != NULL;
1246
15
        if (!cond) {
1247
0
            Py_DECREF(ClassDef_annotations);
1248
0
            return 0;
1249
0
        }
1250
15
        cond = PyDict_SetItemString(ClassDef_annotations, "body", type) == 0;
1251
15
        Py_DECREF(type);
1252
15
        if (!cond) {
1253
0
            Py_DECREF(ClassDef_annotations);
1254
0
            return 0;
1255
0
        }
1256
15
    }
1257
15
    {
1258
15
        PyObject *type = state->expr_type;
1259
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1260
15
        cond = type != NULL;
1261
15
        if (!cond) {
1262
0
            Py_DECREF(ClassDef_annotations);
1263
0
            return 0;
1264
0
        }
1265
15
        cond = PyDict_SetItemString(ClassDef_annotations, "decorator_list",
1266
15
                                    type) == 0;
1267
15
        Py_DECREF(type);
1268
15
        if (!cond) {
1269
0
            Py_DECREF(ClassDef_annotations);
1270
0
            return 0;
1271
0
        }
1272
15
    }
1273
15
    {
1274
15
        PyObject *type = state->type_param_type;
1275
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1276
15
        cond = type != NULL;
1277
15
        if (!cond) {
1278
0
            Py_DECREF(ClassDef_annotations);
1279
0
            return 0;
1280
0
        }
1281
15
        cond = PyDict_SetItemString(ClassDef_annotations, "type_params", type)
1282
15
                                    == 0;
1283
15
        Py_DECREF(type);
1284
15
        if (!cond) {
1285
0
            Py_DECREF(ClassDef_annotations);
1286
0
            return 0;
1287
0
        }
1288
15
    }
1289
15
    cond = PyObject_SetAttrString(state->ClassDef_type, "_field_types",
1290
15
                                  ClassDef_annotations) == 0;
1291
15
    if (!cond) {
1292
0
        Py_DECREF(ClassDef_annotations);
1293
0
        return 0;
1294
0
    }
1295
15
    cond = PyObject_SetAttrString(state->ClassDef_type, "__annotations__",
1296
15
                                  ClassDef_annotations) == 0;
1297
15
    if (!cond) {
1298
0
        Py_DECREF(ClassDef_annotations);
1299
0
        return 0;
1300
0
    }
1301
15
    Py_DECREF(ClassDef_annotations);
1302
15
    PyObject *Return_annotations = PyDict_New();
1303
15
    if (!Return_annotations) return 0;
1304
15
    {
1305
15
        PyObject *type = state->expr_type;
1306
15
        type = _Py_union_type_or(type, Py_None);
1307
15
        cond = type != NULL;
1308
15
        if (!cond) {
1309
0
            Py_DECREF(Return_annotations);
1310
0
            return 0;
1311
0
        }
1312
15
        cond = PyDict_SetItemString(Return_annotations, "value", type) == 0;
1313
15
        Py_DECREF(type);
1314
15
        if (!cond) {
1315
0
            Py_DECREF(Return_annotations);
1316
0
            return 0;
1317
0
        }
1318
15
    }
1319
15
    cond = PyObject_SetAttrString(state->Return_type, "_field_types",
1320
15
                                  Return_annotations) == 0;
1321
15
    if (!cond) {
1322
0
        Py_DECREF(Return_annotations);
1323
0
        return 0;
1324
0
    }
1325
15
    cond = PyObject_SetAttrString(state->Return_type, "__annotations__",
1326
15
                                  Return_annotations) == 0;
1327
15
    if (!cond) {
1328
0
        Py_DECREF(Return_annotations);
1329
0
        return 0;
1330
0
    }
1331
15
    Py_DECREF(Return_annotations);
1332
15
    PyObject *Delete_annotations = PyDict_New();
1333
15
    if (!Delete_annotations) return 0;
1334
15
    {
1335
15
        PyObject *type = state->expr_type;
1336
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1337
15
        cond = type != NULL;
1338
15
        if (!cond) {
1339
0
            Py_DECREF(Delete_annotations);
1340
0
            return 0;
1341
0
        }
1342
15
        cond = PyDict_SetItemString(Delete_annotations, "targets", type) == 0;
1343
15
        Py_DECREF(type);
1344
15
        if (!cond) {
1345
0
            Py_DECREF(Delete_annotations);
1346
0
            return 0;
1347
0
        }
1348
15
    }
1349
15
    cond = PyObject_SetAttrString(state->Delete_type, "_field_types",
1350
15
                                  Delete_annotations) == 0;
1351
15
    if (!cond) {
1352
0
        Py_DECREF(Delete_annotations);
1353
0
        return 0;
1354
0
    }
1355
15
    cond = PyObject_SetAttrString(state->Delete_type, "__annotations__",
1356
15
                                  Delete_annotations) == 0;
1357
15
    if (!cond) {
1358
0
        Py_DECREF(Delete_annotations);
1359
0
        return 0;
1360
0
    }
1361
15
    Py_DECREF(Delete_annotations);
1362
15
    PyObject *Assign_annotations = PyDict_New();
1363
15
    if (!Assign_annotations) return 0;
1364
15
    {
1365
15
        PyObject *type = state->expr_type;
1366
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1367
15
        cond = type != NULL;
1368
15
        if (!cond) {
1369
0
            Py_DECREF(Assign_annotations);
1370
0
            return 0;
1371
0
        }
1372
15
        cond = PyDict_SetItemString(Assign_annotations, "targets", type) == 0;
1373
15
        Py_DECREF(type);
1374
15
        if (!cond) {
1375
0
            Py_DECREF(Assign_annotations);
1376
0
            return 0;
1377
0
        }
1378
15
    }
1379
15
    {
1380
15
        PyObject *type = state->expr_type;
1381
15
        Py_INCREF(type);
1382
15
        cond = PyDict_SetItemString(Assign_annotations, "value", type) == 0;
1383
15
        Py_DECREF(type);
1384
15
        if (!cond) {
1385
0
            Py_DECREF(Assign_annotations);
1386
0
            return 0;
1387
0
        }
1388
15
    }
1389
15
    {
1390
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1391
15
        type = _Py_union_type_or(type, Py_None);
1392
15
        cond = type != NULL;
1393
15
        if (!cond) {
1394
0
            Py_DECREF(Assign_annotations);
1395
0
            return 0;
1396
0
        }
1397
15
        cond = PyDict_SetItemString(Assign_annotations, "type_comment", type)
1398
15
                                    == 0;
1399
15
        Py_DECREF(type);
1400
15
        if (!cond) {
1401
0
            Py_DECREF(Assign_annotations);
1402
0
            return 0;
1403
0
        }
1404
15
    }
1405
15
    cond = PyObject_SetAttrString(state->Assign_type, "_field_types",
1406
15
                                  Assign_annotations) == 0;
1407
15
    if (!cond) {
1408
0
        Py_DECREF(Assign_annotations);
1409
0
        return 0;
1410
0
    }
1411
15
    cond = PyObject_SetAttrString(state->Assign_type, "__annotations__",
1412
15
                                  Assign_annotations) == 0;
1413
15
    if (!cond) {
1414
0
        Py_DECREF(Assign_annotations);
1415
0
        return 0;
1416
0
    }
1417
15
    Py_DECREF(Assign_annotations);
1418
15
    PyObject *TypeAlias_annotations = PyDict_New();
1419
15
    if (!TypeAlias_annotations) return 0;
1420
15
    {
1421
15
        PyObject *type = state->expr_type;
1422
15
        Py_INCREF(type);
1423
15
        cond = PyDict_SetItemString(TypeAlias_annotations, "name", type) == 0;
1424
15
        Py_DECREF(type);
1425
15
        if (!cond) {
1426
0
            Py_DECREF(TypeAlias_annotations);
1427
0
            return 0;
1428
0
        }
1429
15
    }
1430
15
    {
1431
15
        PyObject *type = state->type_param_type;
1432
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1433
15
        cond = type != NULL;
1434
15
        if (!cond) {
1435
0
            Py_DECREF(TypeAlias_annotations);
1436
0
            return 0;
1437
0
        }
1438
15
        cond = PyDict_SetItemString(TypeAlias_annotations, "type_params", type)
1439
15
                                    == 0;
1440
15
        Py_DECREF(type);
1441
15
        if (!cond) {
1442
0
            Py_DECREF(TypeAlias_annotations);
1443
0
            return 0;
1444
0
        }
1445
15
    }
1446
15
    {
1447
15
        PyObject *type = state->expr_type;
1448
15
        Py_INCREF(type);
1449
15
        cond = PyDict_SetItemString(TypeAlias_annotations, "value", type) == 0;
1450
15
        Py_DECREF(type);
1451
15
        if (!cond) {
1452
0
            Py_DECREF(TypeAlias_annotations);
1453
0
            return 0;
1454
0
        }
1455
15
    }
1456
15
    cond = PyObject_SetAttrString(state->TypeAlias_type, "_field_types",
1457
15
                                  TypeAlias_annotations) == 0;
1458
15
    if (!cond) {
1459
0
        Py_DECREF(TypeAlias_annotations);
1460
0
        return 0;
1461
0
    }
1462
15
    cond = PyObject_SetAttrString(state->TypeAlias_type, "__annotations__",
1463
15
                                  TypeAlias_annotations) == 0;
1464
15
    if (!cond) {
1465
0
        Py_DECREF(TypeAlias_annotations);
1466
0
        return 0;
1467
0
    }
1468
15
    Py_DECREF(TypeAlias_annotations);
1469
15
    PyObject *AugAssign_annotations = PyDict_New();
1470
15
    if (!AugAssign_annotations) return 0;
1471
15
    {
1472
15
        PyObject *type = state->expr_type;
1473
15
        Py_INCREF(type);
1474
15
        cond = PyDict_SetItemString(AugAssign_annotations, "target", type) == 0;
1475
15
        Py_DECREF(type);
1476
15
        if (!cond) {
1477
0
            Py_DECREF(AugAssign_annotations);
1478
0
            return 0;
1479
0
        }
1480
15
    }
1481
15
    {
1482
15
        PyObject *type = state->operator_type;
1483
15
        Py_INCREF(type);
1484
15
        cond = PyDict_SetItemString(AugAssign_annotations, "op", type) == 0;
1485
15
        Py_DECREF(type);
1486
15
        if (!cond) {
1487
0
            Py_DECREF(AugAssign_annotations);
1488
0
            return 0;
1489
0
        }
1490
15
    }
1491
15
    {
1492
15
        PyObject *type = state->expr_type;
1493
15
        Py_INCREF(type);
1494
15
        cond = PyDict_SetItemString(AugAssign_annotations, "value", type) == 0;
1495
15
        Py_DECREF(type);
1496
15
        if (!cond) {
1497
0
            Py_DECREF(AugAssign_annotations);
1498
0
            return 0;
1499
0
        }
1500
15
    }
1501
15
    cond = PyObject_SetAttrString(state->AugAssign_type, "_field_types",
1502
15
                                  AugAssign_annotations) == 0;
1503
15
    if (!cond) {
1504
0
        Py_DECREF(AugAssign_annotations);
1505
0
        return 0;
1506
0
    }
1507
15
    cond = PyObject_SetAttrString(state->AugAssign_type, "__annotations__",
1508
15
                                  AugAssign_annotations) == 0;
1509
15
    if (!cond) {
1510
0
        Py_DECREF(AugAssign_annotations);
1511
0
        return 0;
1512
0
    }
1513
15
    Py_DECREF(AugAssign_annotations);
1514
15
    PyObject *AnnAssign_annotations = PyDict_New();
1515
15
    if (!AnnAssign_annotations) return 0;
1516
15
    {
1517
15
        PyObject *type = state->expr_type;
1518
15
        Py_INCREF(type);
1519
15
        cond = PyDict_SetItemString(AnnAssign_annotations, "target", type) == 0;
1520
15
        Py_DECREF(type);
1521
15
        if (!cond) {
1522
0
            Py_DECREF(AnnAssign_annotations);
1523
0
            return 0;
1524
0
        }
1525
15
    }
1526
15
    {
1527
15
        PyObject *type = state->expr_type;
1528
15
        Py_INCREF(type);
1529
15
        cond = PyDict_SetItemString(AnnAssign_annotations, "annotation", type)
1530
15
                                    == 0;
1531
15
        Py_DECREF(type);
1532
15
        if (!cond) {
1533
0
            Py_DECREF(AnnAssign_annotations);
1534
0
            return 0;
1535
0
        }
1536
15
    }
1537
15
    {
1538
15
        PyObject *type = state->expr_type;
1539
15
        type = _Py_union_type_or(type, Py_None);
1540
15
        cond = type != NULL;
1541
15
        if (!cond) {
1542
0
            Py_DECREF(AnnAssign_annotations);
1543
0
            return 0;
1544
0
        }
1545
15
        cond = PyDict_SetItemString(AnnAssign_annotations, "value", type) == 0;
1546
15
        Py_DECREF(type);
1547
15
        if (!cond) {
1548
0
            Py_DECREF(AnnAssign_annotations);
1549
0
            return 0;
1550
0
        }
1551
15
    }
1552
15
    {
1553
15
        PyObject *type = (PyObject *)&PyLong_Type;
1554
15
        Py_INCREF(type);
1555
15
        cond = PyDict_SetItemString(AnnAssign_annotations, "simple", type) == 0;
1556
15
        Py_DECREF(type);
1557
15
        if (!cond) {
1558
0
            Py_DECREF(AnnAssign_annotations);
1559
0
            return 0;
1560
0
        }
1561
15
    }
1562
15
    cond = PyObject_SetAttrString(state->AnnAssign_type, "_field_types",
1563
15
                                  AnnAssign_annotations) == 0;
1564
15
    if (!cond) {
1565
0
        Py_DECREF(AnnAssign_annotations);
1566
0
        return 0;
1567
0
    }
1568
15
    cond = PyObject_SetAttrString(state->AnnAssign_type, "__annotations__",
1569
15
                                  AnnAssign_annotations) == 0;
1570
15
    if (!cond) {
1571
0
        Py_DECREF(AnnAssign_annotations);
1572
0
        return 0;
1573
0
    }
1574
15
    Py_DECREF(AnnAssign_annotations);
1575
15
    PyObject *For_annotations = PyDict_New();
1576
15
    if (!For_annotations) return 0;
1577
15
    {
1578
15
        PyObject *type = state->expr_type;
1579
15
        Py_INCREF(type);
1580
15
        cond = PyDict_SetItemString(For_annotations, "target", type) == 0;
1581
15
        Py_DECREF(type);
1582
15
        if (!cond) {
1583
0
            Py_DECREF(For_annotations);
1584
0
            return 0;
1585
0
        }
1586
15
    }
1587
15
    {
1588
15
        PyObject *type = state->expr_type;
1589
15
        Py_INCREF(type);
1590
15
        cond = PyDict_SetItemString(For_annotations, "iter", type) == 0;
1591
15
        Py_DECREF(type);
1592
15
        if (!cond) {
1593
0
            Py_DECREF(For_annotations);
1594
0
            return 0;
1595
0
        }
1596
15
    }
1597
15
    {
1598
15
        PyObject *type = state->stmt_type;
1599
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1600
15
        cond = type != NULL;
1601
15
        if (!cond) {
1602
0
            Py_DECREF(For_annotations);
1603
0
            return 0;
1604
0
        }
1605
15
        cond = PyDict_SetItemString(For_annotations, "body", type) == 0;
1606
15
        Py_DECREF(type);
1607
15
        if (!cond) {
1608
0
            Py_DECREF(For_annotations);
1609
0
            return 0;
1610
0
        }
1611
15
    }
1612
15
    {
1613
15
        PyObject *type = state->stmt_type;
1614
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1615
15
        cond = type != NULL;
1616
15
        if (!cond) {
1617
0
            Py_DECREF(For_annotations);
1618
0
            return 0;
1619
0
        }
1620
15
        cond = PyDict_SetItemString(For_annotations, "orelse", type) == 0;
1621
15
        Py_DECREF(type);
1622
15
        if (!cond) {
1623
0
            Py_DECREF(For_annotations);
1624
0
            return 0;
1625
0
        }
1626
15
    }
1627
15
    {
1628
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1629
15
        type = _Py_union_type_or(type, Py_None);
1630
15
        cond = type != NULL;
1631
15
        if (!cond) {
1632
0
            Py_DECREF(For_annotations);
1633
0
            return 0;
1634
0
        }
1635
15
        cond = PyDict_SetItemString(For_annotations, "type_comment", type) == 0;
1636
15
        Py_DECREF(type);
1637
15
        if (!cond) {
1638
0
            Py_DECREF(For_annotations);
1639
0
            return 0;
1640
0
        }
1641
15
    }
1642
15
    cond = PyObject_SetAttrString(state->For_type, "_field_types",
1643
15
                                  For_annotations) == 0;
1644
15
    if (!cond) {
1645
0
        Py_DECREF(For_annotations);
1646
0
        return 0;
1647
0
    }
1648
15
    cond = PyObject_SetAttrString(state->For_type, "__annotations__",
1649
15
                                  For_annotations) == 0;
1650
15
    if (!cond) {
1651
0
        Py_DECREF(For_annotations);
1652
0
        return 0;
1653
0
    }
1654
15
    Py_DECREF(For_annotations);
1655
15
    PyObject *AsyncFor_annotations = PyDict_New();
1656
15
    if (!AsyncFor_annotations) return 0;
1657
15
    {
1658
15
        PyObject *type = state->expr_type;
1659
15
        Py_INCREF(type);
1660
15
        cond = PyDict_SetItemString(AsyncFor_annotations, "target", type) == 0;
1661
15
        Py_DECREF(type);
1662
15
        if (!cond) {
1663
0
            Py_DECREF(AsyncFor_annotations);
1664
0
            return 0;
1665
0
        }
1666
15
    }
1667
15
    {
1668
15
        PyObject *type = state->expr_type;
1669
15
        Py_INCREF(type);
1670
15
        cond = PyDict_SetItemString(AsyncFor_annotations, "iter", type) == 0;
1671
15
        Py_DECREF(type);
1672
15
        if (!cond) {
1673
0
            Py_DECREF(AsyncFor_annotations);
1674
0
            return 0;
1675
0
        }
1676
15
    }
1677
15
    {
1678
15
        PyObject *type = state->stmt_type;
1679
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1680
15
        cond = type != NULL;
1681
15
        if (!cond) {
1682
0
            Py_DECREF(AsyncFor_annotations);
1683
0
            return 0;
1684
0
        }
1685
15
        cond = PyDict_SetItemString(AsyncFor_annotations, "body", type) == 0;
1686
15
        Py_DECREF(type);
1687
15
        if (!cond) {
1688
0
            Py_DECREF(AsyncFor_annotations);
1689
0
            return 0;
1690
0
        }
1691
15
    }
1692
15
    {
1693
15
        PyObject *type = state->stmt_type;
1694
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1695
15
        cond = type != NULL;
1696
15
        if (!cond) {
1697
0
            Py_DECREF(AsyncFor_annotations);
1698
0
            return 0;
1699
0
        }
1700
15
        cond = PyDict_SetItemString(AsyncFor_annotations, "orelse", type) == 0;
1701
15
        Py_DECREF(type);
1702
15
        if (!cond) {
1703
0
            Py_DECREF(AsyncFor_annotations);
1704
0
            return 0;
1705
0
        }
1706
15
    }
1707
15
    {
1708
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1709
15
        type = _Py_union_type_or(type, Py_None);
1710
15
        cond = type != NULL;
1711
15
        if (!cond) {
1712
0
            Py_DECREF(AsyncFor_annotations);
1713
0
            return 0;
1714
0
        }
1715
15
        cond = PyDict_SetItemString(AsyncFor_annotations, "type_comment", type)
1716
15
                                    == 0;
1717
15
        Py_DECREF(type);
1718
15
        if (!cond) {
1719
0
            Py_DECREF(AsyncFor_annotations);
1720
0
            return 0;
1721
0
        }
1722
15
    }
1723
15
    cond = PyObject_SetAttrString(state->AsyncFor_type, "_field_types",
1724
15
                                  AsyncFor_annotations) == 0;
1725
15
    if (!cond) {
1726
0
        Py_DECREF(AsyncFor_annotations);
1727
0
        return 0;
1728
0
    }
1729
15
    cond = PyObject_SetAttrString(state->AsyncFor_type, "__annotations__",
1730
15
                                  AsyncFor_annotations) == 0;
1731
15
    if (!cond) {
1732
0
        Py_DECREF(AsyncFor_annotations);
1733
0
        return 0;
1734
0
    }
1735
15
    Py_DECREF(AsyncFor_annotations);
1736
15
    PyObject *While_annotations = PyDict_New();
1737
15
    if (!While_annotations) return 0;
1738
15
    {
1739
15
        PyObject *type = state->expr_type;
1740
15
        Py_INCREF(type);
1741
15
        cond = PyDict_SetItemString(While_annotations, "test", type) == 0;
1742
15
        Py_DECREF(type);
1743
15
        if (!cond) {
1744
0
            Py_DECREF(While_annotations);
1745
0
            return 0;
1746
0
        }
1747
15
    }
1748
15
    {
1749
15
        PyObject *type = state->stmt_type;
1750
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1751
15
        cond = type != NULL;
1752
15
        if (!cond) {
1753
0
            Py_DECREF(While_annotations);
1754
0
            return 0;
1755
0
        }
1756
15
        cond = PyDict_SetItemString(While_annotations, "body", type) == 0;
1757
15
        Py_DECREF(type);
1758
15
        if (!cond) {
1759
0
            Py_DECREF(While_annotations);
1760
0
            return 0;
1761
0
        }
1762
15
    }
1763
15
    {
1764
15
        PyObject *type = state->stmt_type;
1765
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1766
15
        cond = type != NULL;
1767
15
        if (!cond) {
1768
0
            Py_DECREF(While_annotations);
1769
0
            return 0;
1770
0
        }
1771
15
        cond = PyDict_SetItemString(While_annotations, "orelse", type) == 0;
1772
15
        Py_DECREF(type);
1773
15
        if (!cond) {
1774
0
            Py_DECREF(While_annotations);
1775
0
            return 0;
1776
0
        }
1777
15
    }
1778
15
    cond = PyObject_SetAttrString(state->While_type, "_field_types",
1779
15
                                  While_annotations) == 0;
1780
15
    if (!cond) {
1781
0
        Py_DECREF(While_annotations);
1782
0
        return 0;
1783
0
    }
1784
15
    cond = PyObject_SetAttrString(state->While_type, "__annotations__",
1785
15
                                  While_annotations) == 0;
1786
15
    if (!cond) {
1787
0
        Py_DECREF(While_annotations);
1788
0
        return 0;
1789
0
    }
1790
15
    Py_DECREF(While_annotations);
1791
15
    PyObject *If_annotations = PyDict_New();
1792
15
    if (!If_annotations) return 0;
1793
15
    {
1794
15
        PyObject *type = state->expr_type;
1795
15
        Py_INCREF(type);
1796
15
        cond = PyDict_SetItemString(If_annotations, "test", type) == 0;
1797
15
        Py_DECREF(type);
1798
15
        if (!cond) {
1799
0
            Py_DECREF(If_annotations);
1800
0
            return 0;
1801
0
        }
1802
15
    }
1803
15
    {
1804
15
        PyObject *type = state->stmt_type;
1805
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1806
15
        cond = type != NULL;
1807
15
        if (!cond) {
1808
0
            Py_DECREF(If_annotations);
1809
0
            return 0;
1810
0
        }
1811
15
        cond = PyDict_SetItemString(If_annotations, "body", type) == 0;
1812
15
        Py_DECREF(type);
1813
15
        if (!cond) {
1814
0
            Py_DECREF(If_annotations);
1815
0
            return 0;
1816
0
        }
1817
15
    }
1818
15
    {
1819
15
        PyObject *type = state->stmt_type;
1820
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1821
15
        cond = type != NULL;
1822
15
        if (!cond) {
1823
0
            Py_DECREF(If_annotations);
1824
0
            return 0;
1825
0
        }
1826
15
        cond = PyDict_SetItemString(If_annotations, "orelse", type) == 0;
1827
15
        Py_DECREF(type);
1828
15
        if (!cond) {
1829
0
            Py_DECREF(If_annotations);
1830
0
            return 0;
1831
0
        }
1832
15
    }
1833
15
    cond = PyObject_SetAttrString(state->If_type, "_field_types",
1834
15
                                  If_annotations) == 0;
1835
15
    if (!cond) {
1836
0
        Py_DECREF(If_annotations);
1837
0
        return 0;
1838
0
    }
1839
15
    cond = PyObject_SetAttrString(state->If_type, "__annotations__",
1840
15
                                  If_annotations) == 0;
1841
15
    if (!cond) {
1842
0
        Py_DECREF(If_annotations);
1843
0
        return 0;
1844
0
    }
1845
15
    Py_DECREF(If_annotations);
1846
15
    PyObject *With_annotations = PyDict_New();
1847
15
    if (!With_annotations) return 0;
1848
15
    {
1849
15
        PyObject *type = state->withitem_type;
1850
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1851
15
        cond = type != NULL;
1852
15
        if (!cond) {
1853
0
            Py_DECREF(With_annotations);
1854
0
            return 0;
1855
0
        }
1856
15
        cond = PyDict_SetItemString(With_annotations, "items", type) == 0;
1857
15
        Py_DECREF(type);
1858
15
        if (!cond) {
1859
0
            Py_DECREF(With_annotations);
1860
0
            return 0;
1861
0
        }
1862
15
    }
1863
15
    {
1864
15
        PyObject *type = state->stmt_type;
1865
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1866
15
        cond = type != NULL;
1867
15
        if (!cond) {
1868
0
            Py_DECREF(With_annotations);
1869
0
            return 0;
1870
0
        }
1871
15
        cond = PyDict_SetItemString(With_annotations, "body", type) == 0;
1872
15
        Py_DECREF(type);
1873
15
        if (!cond) {
1874
0
            Py_DECREF(With_annotations);
1875
0
            return 0;
1876
0
        }
1877
15
    }
1878
15
    {
1879
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1880
15
        type = _Py_union_type_or(type, Py_None);
1881
15
        cond = type != NULL;
1882
15
        if (!cond) {
1883
0
            Py_DECREF(With_annotations);
1884
0
            return 0;
1885
0
        }
1886
15
        cond = PyDict_SetItemString(With_annotations, "type_comment", type) ==
1887
15
                                    0;
1888
15
        Py_DECREF(type);
1889
15
        if (!cond) {
1890
0
            Py_DECREF(With_annotations);
1891
0
            return 0;
1892
0
        }
1893
15
    }
1894
15
    cond = PyObject_SetAttrString(state->With_type, "_field_types",
1895
15
                                  With_annotations) == 0;
1896
15
    if (!cond) {
1897
0
        Py_DECREF(With_annotations);
1898
0
        return 0;
1899
0
    }
1900
15
    cond = PyObject_SetAttrString(state->With_type, "__annotations__",
1901
15
                                  With_annotations) == 0;
1902
15
    if (!cond) {
1903
0
        Py_DECREF(With_annotations);
1904
0
        return 0;
1905
0
    }
1906
15
    Py_DECREF(With_annotations);
1907
15
    PyObject *AsyncWith_annotations = PyDict_New();
1908
15
    if (!AsyncWith_annotations) return 0;
1909
15
    {
1910
15
        PyObject *type = state->withitem_type;
1911
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1912
15
        cond = type != NULL;
1913
15
        if (!cond) {
1914
0
            Py_DECREF(AsyncWith_annotations);
1915
0
            return 0;
1916
0
        }
1917
15
        cond = PyDict_SetItemString(AsyncWith_annotations, "items", type) == 0;
1918
15
        Py_DECREF(type);
1919
15
        if (!cond) {
1920
0
            Py_DECREF(AsyncWith_annotations);
1921
0
            return 0;
1922
0
        }
1923
15
    }
1924
15
    {
1925
15
        PyObject *type = state->stmt_type;
1926
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1927
15
        cond = type != NULL;
1928
15
        if (!cond) {
1929
0
            Py_DECREF(AsyncWith_annotations);
1930
0
            return 0;
1931
0
        }
1932
15
        cond = PyDict_SetItemString(AsyncWith_annotations, "body", type) == 0;
1933
15
        Py_DECREF(type);
1934
15
        if (!cond) {
1935
0
            Py_DECREF(AsyncWith_annotations);
1936
0
            return 0;
1937
0
        }
1938
15
    }
1939
15
    {
1940
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
1941
15
        type = _Py_union_type_or(type, Py_None);
1942
15
        cond = type != NULL;
1943
15
        if (!cond) {
1944
0
            Py_DECREF(AsyncWith_annotations);
1945
0
            return 0;
1946
0
        }
1947
15
        cond = PyDict_SetItemString(AsyncWith_annotations, "type_comment",
1948
15
                                    type) == 0;
1949
15
        Py_DECREF(type);
1950
15
        if (!cond) {
1951
0
            Py_DECREF(AsyncWith_annotations);
1952
0
            return 0;
1953
0
        }
1954
15
    }
1955
15
    cond = PyObject_SetAttrString(state->AsyncWith_type, "_field_types",
1956
15
                                  AsyncWith_annotations) == 0;
1957
15
    if (!cond) {
1958
0
        Py_DECREF(AsyncWith_annotations);
1959
0
        return 0;
1960
0
    }
1961
15
    cond = PyObject_SetAttrString(state->AsyncWith_type, "__annotations__",
1962
15
                                  AsyncWith_annotations) == 0;
1963
15
    if (!cond) {
1964
0
        Py_DECREF(AsyncWith_annotations);
1965
0
        return 0;
1966
0
    }
1967
15
    Py_DECREF(AsyncWith_annotations);
1968
15
    PyObject *Match_annotations = PyDict_New();
1969
15
    if (!Match_annotations) return 0;
1970
15
    {
1971
15
        PyObject *type = state->expr_type;
1972
15
        Py_INCREF(type);
1973
15
        cond = PyDict_SetItemString(Match_annotations, "subject", type) == 0;
1974
15
        Py_DECREF(type);
1975
15
        if (!cond) {
1976
0
            Py_DECREF(Match_annotations);
1977
0
            return 0;
1978
0
        }
1979
15
    }
1980
15
    {
1981
15
        PyObject *type = state->match_case_type;
1982
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
1983
15
        cond = type != NULL;
1984
15
        if (!cond) {
1985
0
            Py_DECREF(Match_annotations);
1986
0
            return 0;
1987
0
        }
1988
15
        cond = PyDict_SetItemString(Match_annotations, "cases", type) == 0;
1989
15
        Py_DECREF(type);
1990
15
        if (!cond) {
1991
0
            Py_DECREF(Match_annotations);
1992
0
            return 0;
1993
0
        }
1994
15
    }
1995
15
    cond = PyObject_SetAttrString(state->Match_type, "_field_types",
1996
15
                                  Match_annotations) == 0;
1997
15
    if (!cond) {
1998
0
        Py_DECREF(Match_annotations);
1999
0
        return 0;
2000
0
    }
2001
15
    cond = PyObject_SetAttrString(state->Match_type, "__annotations__",
2002
15
                                  Match_annotations) == 0;
2003
15
    if (!cond) {
2004
0
        Py_DECREF(Match_annotations);
2005
0
        return 0;
2006
0
    }
2007
15
    Py_DECREF(Match_annotations);
2008
15
    PyObject *Raise_annotations = PyDict_New();
2009
15
    if (!Raise_annotations) return 0;
2010
15
    {
2011
15
        PyObject *type = state->expr_type;
2012
15
        type = _Py_union_type_or(type, Py_None);
2013
15
        cond = type != NULL;
2014
15
        if (!cond) {
2015
0
            Py_DECREF(Raise_annotations);
2016
0
            return 0;
2017
0
        }
2018
15
        cond = PyDict_SetItemString(Raise_annotations, "exc", type) == 0;
2019
15
        Py_DECREF(type);
2020
15
        if (!cond) {
2021
0
            Py_DECREF(Raise_annotations);
2022
0
            return 0;
2023
0
        }
2024
15
    }
2025
15
    {
2026
15
        PyObject *type = state->expr_type;
2027
15
        type = _Py_union_type_or(type, Py_None);
2028
15
        cond = type != NULL;
2029
15
        if (!cond) {
2030
0
            Py_DECREF(Raise_annotations);
2031
0
            return 0;
2032
0
        }
2033
15
        cond = PyDict_SetItemString(Raise_annotations, "cause", type) == 0;
2034
15
        Py_DECREF(type);
2035
15
        if (!cond) {
2036
0
            Py_DECREF(Raise_annotations);
2037
0
            return 0;
2038
0
        }
2039
15
    }
2040
15
    cond = PyObject_SetAttrString(state->Raise_type, "_field_types",
2041
15
                                  Raise_annotations) == 0;
2042
15
    if (!cond) {
2043
0
        Py_DECREF(Raise_annotations);
2044
0
        return 0;
2045
0
    }
2046
15
    cond = PyObject_SetAttrString(state->Raise_type, "__annotations__",
2047
15
                                  Raise_annotations) == 0;
2048
15
    if (!cond) {
2049
0
        Py_DECREF(Raise_annotations);
2050
0
        return 0;
2051
0
    }
2052
15
    Py_DECREF(Raise_annotations);
2053
15
    PyObject *Try_annotations = PyDict_New();
2054
15
    if (!Try_annotations) return 0;
2055
15
    {
2056
15
        PyObject *type = state->stmt_type;
2057
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2058
15
        cond = type != NULL;
2059
15
        if (!cond) {
2060
0
            Py_DECREF(Try_annotations);
2061
0
            return 0;
2062
0
        }
2063
15
        cond = PyDict_SetItemString(Try_annotations, "body", type) == 0;
2064
15
        Py_DECREF(type);
2065
15
        if (!cond) {
2066
0
            Py_DECREF(Try_annotations);
2067
0
            return 0;
2068
0
        }
2069
15
    }
2070
15
    {
2071
15
        PyObject *type = state->excepthandler_type;
2072
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2073
15
        cond = type != NULL;
2074
15
        if (!cond) {
2075
0
            Py_DECREF(Try_annotations);
2076
0
            return 0;
2077
0
        }
2078
15
        cond = PyDict_SetItemString(Try_annotations, "handlers", type) == 0;
2079
15
        Py_DECREF(type);
2080
15
        if (!cond) {
2081
0
            Py_DECREF(Try_annotations);
2082
0
            return 0;
2083
0
        }
2084
15
    }
2085
15
    {
2086
15
        PyObject *type = state->stmt_type;
2087
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2088
15
        cond = type != NULL;
2089
15
        if (!cond) {
2090
0
            Py_DECREF(Try_annotations);
2091
0
            return 0;
2092
0
        }
2093
15
        cond = PyDict_SetItemString(Try_annotations, "orelse", type) == 0;
2094
15
        Py_DECREF(type);
2095
15
        if (!cond) {
2096
0
            Py_DECREF(Try_annotations);
2097
0
            return 0;
2098
0
        }
2099
15
    }
2100
15
    {
2101
15
        PyObject *type = state->stmt_type;
2102
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2103
15
        cond = type != NULL;
2104
15
        if (!cond) {
2105
0
            Py_DECREF(Try_annotations);
2106
0
            return 0;
2107
0
        }
2108
15
        cond = PyDict_SetItemString(Try_annotations, "finalbody", type) == 0;
2109
15
        Py_DECREF(type);
2110
15
        if (!cond) {
2111
0
            Py_DECREF(Try_annotations);
2112
0
            return 0;
2113
0
        }
2114
15
    }
2115
15
    cond = PyObject_SetAttrString(state->Try_type, "_field_types",
2116
15
                                  Try_annotations) == 0;
2117
15
    if (!cond) {
2118
0
        Py_DECREF(Try_annotations);
2119
0
        return 0;
2120
0
    }
2121
15
    cond = PyObject_SetAttrString(state->Try_type, "__annotations__",
2122
15
                                  Try_annotations) == 0;
2123
15
    if (!cond) {
2124
0
        Py_DECREF(Try_annotations);
2125
0
        return 0;
2126
0
    }
2127
15
    Py_DECREF(Try_annotations);
2128
15
    PyObject *TryStar_annotations = PyDict_New();
2129
15
    if (!TryStar_annotations) return 0;
2130
15
    {
2131
15
        PyObject *type = state->stmt_type;
2132
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2133
15
        cond = type != NULL;
2134
15
        if (!cond) {
2135
0
            Py_DECREF(TryStar_annotations);
2136
0
            return 0;
2137
0
        }
2138
15
        cond = PyDict_SetItemString(TryStar_annotations, "body", type) == 0;
2139
15
        Py_DECREF(type);
2140
15
        if (!cond) {
2141
0
            Py_DECREF(TryStar_annotations);
2142
0
            return 0;
2143
0
        }
2144
15
    }
2145
15
    {
2146
15
        PyObject *type = state->excepthandler_type;
2147
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2148
15
        cond = type != NULL;
2149
15
        if (!cond) {
2150
0
            Py_DECREF(TryStar_annotations);
2151
0
            return 0;
2152
0
        }
2153
15
        cond = PyDict_SetItemString(TryStar_annotations, "handlers", type) == 0;
2154
15
        Py_DECREF(type);
2155
15
        if (!cond) {
2156
0
            Py_DECREF(TryStar_annotations);
2157
0
            return 0;
2158
0
        }
2159
15
    }
2160
15
    {
2161
15
        PyObject *type = state->stmt_type;
2162
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2163
15
        cond = type != NULL;
2164
15
        if (!cond) {
2165
0
            Py_DECREF(TryStar_annotations);
2166
0
            return 0;
2167
0
        }
2168
15
        cond = PyDict_SetItemString(TryStar_annotations, "orelse", type) == 0;
2169
15
        Py_DECREF(type);
2170
15
        if (!cond) {
2171
0
            Py_DECREF(TryStar_annotations);
2172
0
            return 0;
2173
0
        }
2174
15
    }
2175
15
    {
2176
15
        PyObject *type = state->stmt_type;
2177
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2178
15
        cond = type != NULL;
2179
15
        if (!cond) {
2180
0
            Py_DECREF(TryStar_annotations);
2181
0
            return 0;
2182
0
        }
2183
15
        cond = PyDict_SetItemString(TryStar_annotations, "finalbody", type) ==
2184
15
                                    0;
2185
15
        Py_DECREF(type);
2186
15
        if (!cond) {
2187
0
            Py_DECREF(TryStar_annotations);
2188
0
            return 0;
2189
0
        }
2190
15
    }
2191
15
    cond = PyObject_SetAttrString(state->TryStar_type, "_field_types",
2192
15
                                  TryStar_annotations) == 0;
2193
15
    if (!cond) {
2194
0
        Py_DECREF(TryStar_annotations);
2195
0
        return 0;
2196
0
    }
2197
15
    cond = PyObject_SetAttrString(state->TryStar_type, "__annotations__",
2198
15
                                  TryStar_annotations) == 0;
2199
15
    if (!cond) {
2200
0
        Py_DECREF(TryStar_annotations);
2201
0
        return 0;
2202
0
    }
2203
15
    Py_DECREF(TryStar_annotations);
2204
15
    PyObject *Assert_annotations = PyDict_New();
2205
15
    if (!Assert_annotations) return 0;
2206
15
    {
2207
15
        PyObject *type = state->expr_type;
2208
15
        Py_INCREF(type);
2209
15
        cond = PyDict_SetItemString(Assert_annotations, "test", type) == 0;
2210
15
        Py_DECREF(type);
2211
15
        if (!cond) {
2212
0
            Py_DECREF(Assert_annotations);
2213
0
            return 0;
2214
0
        }
2215
15
    }
2216
15
    {
2217
15
        PyObject *type = state->expr_type;
2218
15
        type = _Py_union_type_or(type, Py_None);
2219
15
        cond = type != NULL;
2220
15
        if (!cond) {
2221
0
            Py_DECREF(Assert_annotations);
2222
0
            return 0;
2223
0
        }
2224
15
        cond = PyDict_SetItemString(Assert_annotations, "msg", type) == 0;
2225
15
        Py_DECREF(type);
2226
15
        if (!cond) {
2227
0
            Py_DECREF(Assert_annotations);
2228
0
            return 0;
2229
0
        }
2230
15
    }
2231
15
    cond = PyObject_SetAttrString(state->Assert_type, "_field_types",
2232
15
                                  Assert_annotations) == 0;
2233
15
    if (!cond) {
2234
0
        Py_DECREF(Assert_annotations);
2235
0
        return 0;
2236
0
    }
2237
15
    cond = PyObject_SetAttrString(state->Assert_type, "__annotations__",
2238
15
                                  Assert_annotations) == 0;
2239
15
    if (!cond) {
2240
0
        Py_DECREF(Assert_annotations);
2241
0
        return 0;
2242
0
    }
2243
15
    Py_DECREF(Assert_annotations);
2244
15
    PyObject *Import_annotations = PyDict_New();
2245
15
    if (!Import_annotations) return 0;
2246
15
    {
2247
15
        PyObject *type = state->alias_type;
2248
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2249
15
        cond = type != NULL;
2250
15
        if (!cond) {
2251
0
            Py_DECREF(Import_annotations);
2252
0
            return 0;
2253
0
        }
2254
15
        cond = PyDict_SetItemString(Import_annotations, "names", type) == 0;
2255
15
        Py_DECREF(type);
2256
15
        if (!cond) {
2257
0
            Py_DECREF(Import_annotations);
2258
0
            return 0;
2259
0
        }
2260
15
    }
2261
15
    {
2262
15
        PyObject *type = (PyObject *)&PyLong_Type;
2263
15
        type = _Py_union_type_or(type, Py_None);
2264
15
        cond = type != NULL;
2265
15
        if (!cond) {
2266
0
            Py_DECREF(Import_annotations);
2267
0
            return 0;
2268
0
        }
2269
15
        cond = PyDict_SetItemString(Import_annotations, "is_lazy", type) == 0;
2270
15
        Py_DECREF(type);
2271
15
        if (!cond) {
2272
0
            Py_DECREF(Import_annotations);
2273
0
            return 0;
2274
0
        }
2275
15
    }
2276
15
    cond = PyObject_SetAttrString(state->Import_type, "_field_types",
2277
15
                                  Import_annotations) == 0;
2278
15
    if (!cond) {
2279
0
        Py_DECREF(Import_annotations);
2280
0
        return 0;
2281
0
    }
2282
15
    cond = PyObject_SetAttrString(state->Import_type, "__annotations__",
2283
15
                                  Import_annotations) == 0;
2284
15
    if (!cond) {
2285
0
        Py_DECREF(Import_annotations);
2286
0
        return 0;
2287
0
    }
2288
15
    Py_DECREF(Import_annotations);
2289
15
    PyObject *ImportFrom_annotations = PyDict_New();
2290
15
    if (!ImportFrom_annotations) return 0;
2291
15
    {
2292
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
2293
15
        type = _Py_union_type_or(type, Py_None);
2294
15
        cond = type != NULL;
2295
15
        if (!cond) {
2296
0
            Py_DECREF(ImportFrom_annotations);
2297
0
            return 0;
2298
0
        }
2299
15
        cond = PyDict_SetItemString(ImportFrom_annotations, "module", type) ==
2300
15
                                    0;
2301
15
        Py_DECREF(type);
2302
15
        if (!cond) {
2303
0
            Py_DECREF(ImportFrom_annotations);
2304
0
            return 0;
2305
0
        }
2306
15
    }
2307
15
    {
2308
15
        PyObject *type = state->alias_type;
2309
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2310
15
        cond = type != NULL;
2311
15
        if (!cond) {
2312
0
            Py_DECREF(ImportFrom_annotations);
2313
0
            return 0;
2314
0
        }
2315
15
        cond = PyDict_SetItemString(ImportFrom_annotations, "names", type) == 0;
2316
15
        Py_DECREF(type);
2317
15
        if (!cond) {
2318
0
            Py_DECREF(ImportFrom_annotations);
2319
0
            return 0;
2320
0
        }
2321
15
    }
2322
15
    {
2323
15
        PyObject *type = (PyObject *)&PyLong_Type;
2324
15
        type = _Py_union_type_or(type, Py_None);
2325
15
        cond = type != NULL;
2326
15
        if (!cond) {
2327
0
            Py_DECREF(ImportFrom_annotations);
2328
0
            return 0;
2329
0
        }
2330
15
        cond = PyDict_SetItemString(ImportFrom_annotations, "level", type) == 0;
2331
15
        Py_DECREF(type);
2332
15
        if (!cond) {
2333
0
            Py_DECREF(ImportFrom_annotations);
2334
0
            return 0;
2335
0
        }
2336
15
    }
2337
15
    {
2338
15
        PyObject *type = (PyObject *)&PyLong_Type;
2339
15
        type = _Py_union_type_or(type, Py_None);
2340
15
        cond = type != NULL;
2341
15
        if (!cond) {
2342
0
            Py_DECREF(ImportFrom_annotations);
2343
0
            return 0;
2344
0
        }
2345
15
        cond = PyDict_SetItemString(ImportFrom_annotations, "is_lazy", type) ==
2346
15
                                    0;
2347
15
        Py_DECREF(type);
2348
15
        if (!cond) {
2349
0
            Py_DECREF(ImportFrom_annotations);
2350
0
            return 0;
2351
0
        }
2352
15
    }
2353
15
    cond = PyObject_SetAttrString(state->ImportFrom_type, "_field_types",
2354
15
                                  ImportFrom_annotations) == 0;
2355
15
    if (!cond) {
2356
0
        Py_DECREF(ImportFrom_annotations);
2357
0
        return 0;
2358
0
    }
2359
15
    cond = PyObject_SetAttrString(state->ImportFrom_type, "__annotations__",
2360
15
                                  ImportFrom_annotations) == 0;
2361
15
    if (!cond) {
2362
0
        Py_DECREF(ImportFrom_annotations);
2363
0
        return 0;
2364
0
    }
2365
15
    Py_DECREF(ImportFrom_annotations);
2366
15
    PyObject *Global_annotations = PyDict_New();
2367
15
    if (!Global_annotations) return 0;
2368
15
    {
2369
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
2370
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2371
15
        cond = type != NULL;
2372
15
        if (!cond) {
2373
0
            Py_DECREF(Global_annotations);
2374
0
            return 0;
2375
0
        }
2376
15
        cond = PyDict_SetItemString(Global_annotations, "names", type) == 0;
2377
15
        Py_DECREF(type);
2378
15
        if (!cond) {
2379
0
            Py_DECREF(Global_annotations);
2380
0
            return 0;
2381
0
        }
2382
15
    }
2383
15
    cond = PyObject_SetAttrString(state->Global_type, "_field_types",
2384
15
                                  Global_annotations) == 0;
2385
15
    if (!cond) {
2386
0
        Py_DECREF(Global_annotations);
2387
0
        return 0;
2388
0
    }
2389
15
    cond = PyObject_SetAttrString(state->Global_type, "__annotations__",
2390
15
                                  Global_annotations) == 0;
2391
15
    if (!cond) {
2392
0
        Py_DECREF(Global_annotations);
2393
0
        return 0;
2394
0
    }
2395
15
    Py_DECREF(Global_annotations);
2396
15
    PyObject *Nonlocal_annotations = PyDict_New();
2397
15
    if (!Nonlocal_annotations) return 0;
2398
15
    {
2399
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
2400
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2401
15
        cond = type != NULL;
2402
15
        if (!cond) {
2403
0
            Py_DECREF(Nonlocal_annotations);
2404
0
            return 0;
2405
0
        }
2406
15
        cond = PyDict_SetItemString(Nonlocal_annotations, "names", type) == 0;
2407
15
        Py_DECREF(type);
2408
15
        if (!cond) {
2409
0
            Py_DECREF(Nonlocal_annotations);
2410
0
            return 0;
2411
0
        }
2412
15
    }
2413
15
    cond = PyObject_SetAttrString(state->Nonlocal_type, "_field_types",
2414
15
                                  Nonlocal_annotations) == 0;
2415
15
    if (!cond) {
2416
0
        Py_DECREF(Nonlocal_annotations);
2417
0
        return 0;
2418
0
    }
2419
15
    cond = PyObject_SetAttrString(state->Nonlocal_type, "__annotations__",
2420
15
                                  Nonlocal_annotations) == 0;
2421
15
    if (!cond) {
2422
0
        Py_DECREF(Nonlocal_annotations);
2423
0
        return 0;
2424
0
    }
2425
15
    Py_DECREF(Nonlocal_annotations);
2426
15
    PyObject *Expr_annotations = PyDict_New();
2427
15
    if (!Expr_annotations) return 0;
2428
15
    {
2429
15
        PyObject *type = state->expr_type;
2430
15
        Py_INCREF(type);
2431
15
        cond = PyDict_SetItemString(Expr_annotations, "value", type) == 0;
2432
15
        Py_DECREF(type);
2433
15
        if (!cond) {
2434
0
            Py_DECREF(Expr_annotations);
2435
0
            return 0;
2436
0
        }
2437
15
    }
2438
15
    cond = PyObject_SetAttrString(state->Expr_type, "_field_types",
2439
15
                                  Expr_annotations) == 0;
2440
15
    if (!cond) {
2441
0
        Py_DECREF(Expr_annotations);
2442
0
        return 0;
2443
0
    }
2444
15
    cond = PyObject_SetAttrString(state->Expr_type, "__annotations__",
2445
15
                                  Expr_annotations) == 0;
2446
15
    if (!cond) {
2447
0
        Py_DECREF(Expr_annotations);
2448
0
        return 0;
2449
0
    }
2450
15
    Py_DECREF(Expr_annotations);
2451
15
    PyObject *Pass_annotations = PyDict_New();
2452
15
    if (!Pass_annotations) return 0;
2453
15
    cond = PyObject_SetAttrString(state->Pass_type, "_field_types",
2454
15
                                  Pass_annotations) == 0;
2455
15
    if (!cond) {
2456
0
        Py_DECREF(Pass_annotations);
2457
0
        return 0;
2458
0
    }
2459
15
    cond = PyObject_SetAttrString(state->Pass_type, "__annotations__",
2460
15
                                  Pass_annotations) == 0;
2461
15
    if (!cond) {
2462
0
        Py_DECREF(Pass_annotations);
2463
0
        return 0;
2464
0
    }
2465
15
    Py_DECREF(Pass_annotations);
2466
15
    PyObject *Break_annotations = PyDict_New();
2467
15
    if (!Break_annotations) return 0;
2468
15
    cond = PyObject_SetAttrString(state->Break_type, "_field_types",
2469
15
                                  Break_annotations) == 0;
2470
15
    if (!cond) {
2471
0
        Py_DECREF(Break_annotations);
2472
0
        return 0;
2473
0
    }
2474
15
    cond = PyObject_SetAttrString(state->Break_type, "__annotations__",
2475
15
                                  Break_annotations) == 0;
2476
15
    if (!cond) {
2477
0
        Py_DECREF(Break_annotations);
2478
0
        return 0;
2479
0
    }
2480
15
    Py_DECREF(Break_annotations);
2481
15
    PyObject *Continue_annotations = PyDict_New();
2482
15
    if (!Continue_annotations) return 0;
2483
15
    cond = PyObject_SetAttrString(state->Continue_type, "_field_types",
2484
15
                                  Continue_annotations) == 0;
2485
15
    if (!cond) {
2486
0
        Py_DECREF(Continue_annotations);
2487
0
        return 0;
2488
0
    }
2489
15
    cond = PyObject_SetAttrString(state->Continue_type, "__annotations__",
2490
15
                                  Continue_annotations) == 0;
2491
15
    if (!cond) {
2492
0
        Py_DECREF(Continue_annotations);
2493
0
        return 0;
2494
0
    }
2495
15
    Py_DECREF(Continue_annotations);
2496
15
    PyObject *BoolOp_annotations = PyDict_New();
2497
15
    if (!BoolOp_annotations) return 0;
2498
15
    {
2499
15
        PyObject *type = state->boolop_type;
2500
15
        Py_INCREF(type);
2501
15
        cond = PyDict_SetItemString(BoolOp_annotations, "op", type) == 0;
2502
15
        Py_DECREF(type);
2503
15
        if (!cond) {
2504
0
            Py_DECREF(BoolOp_annotations);
2505
0
            return 0;
2506
0
        }
2507
15
    }
2508
15
    {
2509
15
        PyObject *type = state->expr_type;
2510
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2511
15
        cond = type != NULL;
2512
15
        if (!cond) {
2513
0
            Py_DECREF(BoolOp_annotations);
2514
0
            return 0;
2515
0
        }
2516
15
        cond = PyDict_SetItemString(BoolOp_annotations, "values", type) == 0;
2517
15
        Py_DECREF(type);
2518
15
        if (!cond) {
2519
0
            Py_DECREF(BoolOp_annotations);
2520
0
            return 0;
2521
0
        }
2522
15
    }
2523
15
    cond = PyObject_SetAttrString(state->BoolOp_type, "_field_types",
2524
15
                                  BoolOp_annotations) == 0;
2525
15
    if (!cond) {
2526
0
        Py_DECREF(BoolOp_annotations);
2527
0
        return 0;
2528
0
    }
2529
15
    cond = PyObject_SetAttrString(state->BoolOp_type, "__annotations__",
2530
15
                                  BoolOp_annotations) == 0;
2531
15
    if (!cond) {
2532
0
        Py_DECREF(BoolOp_annotations);
2533
0
        return 0;
2534
0
    }
2535
15
    Py_DECREF(BoolOp_annotations);
2536
15
    PyObject *NamedExpr_annotations = PyDict_New();
2537
15
    if (!NamedExpr_annotations) return 0;
2538
15
    {
2539
15
        PyObject *type = state->expr_type;
2540
15
        Py_INCREF(type);
2541
15
        cond = PyDict_SetItemString(NamedExpr_annotations, "target", type) == 0;
2542
15
        Py_DECREF(type);
2543
15
        if (!cond) {
2544
0
            Py_DECREF(NamedExpr_annotations);
2545
0
            return 0;
2546
0
        }
2547
15
    }
2548
15
    {
2549
15
        PyObject *type = state->expr_type;
2550
15
        Py_INCREF(type);
2551
15
        cond = PyDict_SetItemString(NamedExpr_annotations, "value", type) == 0;
2552
15
        Py_DECREF(type);
2553
15
        if (!cond) {
2554
0
            Py_DECREF(NamedExpr_annotations);
2555
0
            return 0;
2556
0
        }
2557
15
    }
2558
15
    cond = PyObject_SetAttrString(state->NamedExpr_type, "_field_types",
2559
15
                                  NamedExpr_annotations) == 0;
2560
15
    if (!cond) {
2561
0
        Py_DECREF(NamedExpr_annotations);
2562
0
        return 0;
2563
0
    }
2564
15
    cond = PyObject_SetAttrString(state->NamedExpr_type, "__annotations__",
2565
15
                                  NamedExpr_annotations) == 0;
2566
15
    if (!cond) {
2567
0
        Py_DECREF(NamedExpr_annotations);
2568
0
        return 0;
2569
0
    }
2570
15
    Py_DECREF(NamedExpr_annotations);
2571
15
    PyObject *BinOp_annotations = PyDict_New();
2572
15
    if (!BinOp_annotations) return 0;
2573
15
    {
2574
15
        PyObject *type = state->expr_type;
2575
15
        Py_INCREF(type);
2576
15
        cond = PyDict_SetItemString(BinOp_annotations, "left", type) == 0;
2577
15
        Py_DECREF(type);
2578
15
        if (!cond) {
2579
0
            Py_DECREF(BinOp_annotations);
2580
0
            return 0;
2581
0
        }
2582
15
    }
2583
15
    {
2584
15
        PyObject *type = state->operator_type;
2585
15
        Py_INCREF(type);
2586
15
        cond = PyDict_SetItemString(BinOp_annotations, "op", type) == 0;
2587
15
        Py_DECREF(type);
2588
15
        if (!cond) {
2589
0
            Py_DECREF(BinOp_annotations);
2590
0
            return 0;
2591
0
        }
2592
15
    }
2593
15
    {
2594
15
        PyObject *type = state->expr_type;
2595
15
        Py_INCREF(type);
2596
15
        cond = PyDict_SetItemString(BinOp_annotations, "right", type) == 0;
2597
15
        Py_DECREF(type);
2598
15
        if (!cond) {
2599
0
            Py_DECREF(BinOp_annotations);
2600
0
            return 0;
2601
0
        }
2602
15
    }
2603
15
    cond = PyObject_SetAttrString(state->BinOp_type, "_field_types",
2604
15
                                  BinOp_annotations) == 0;
2605
15
    if (!cond) {
2606
0
        Py_DECREF(BinOp_annotations);
2607
0
        return 0;
2608
0
    }
2609
15
    cond = PyObject_SetAttrString(state->BinOp_type, "__annotations__",
2610
15
                                  BinOp_annotations) == 0;
2611
15
    if (!cond) {
2612
0
        Py_DECREF(BinOp_annotations);
2613
0
        return 0;
2614
0
    }
2615
15
    Py_DECREF(BinOp_annotations);
2616
15
    PyObject *UnaryOp_annotations = PyDict_New();
2617
15
    if (!UnaryOp_annotations) return 0;
2618
15
    {
2619
15
        PyObject *type = state->unaryop_type;
2620
15
        Py_INCREF(type);
2621
15
        cond = PyDict_SetItemString(UnaryOp_annotations, "op", type) == 0;
2622
15
        Py_DECREF(type);
2623
15
        if (!cond) {
2624
0
            Py_DECREF(UnaryOp_annotations);
2625
0
            return 0;
2626
0
        }
2627
15
    }
2628
15
    {
2629
15
        PyObject *type = state->expr_type;
2630
15
        Py_INCREF(type);
2631
15
        cond = PyDict_SetItemString(UnaryOp_annotations, "operand", type) == 0;
2632
15
        Py_DECREF(type);
2633
15
        if (!cond) {
2634
0
            Py_DECREF(UnaryOp_annotations);
2635
0
            return 0;
2636
0
        }
2637
15
    }
2638
15
    cond = PyObject_SetAttrString(state->UnaryOp_type, "_field_types",
2639
15
                                  UnaryOp_annotations) == 0;
2640
15
    if (!cond) {
2641
0
        Py_DECREF(UnaryOp_annotations);
2642
0
        return 0;
2643
0
    }
2644
15
    cond = PyObject_SetAttrString(state->UnaryOp_type, "__annotations__",
2645
15
                                  UnaryOp_annotations) == 0;
2646
15
    if (!cond) {
2647
0
        Py_DECREF(UnaryOp_annotations);
2648
0
        return 0;
2649
0
    }
2650
15
    Py_DECREF(UnaryOp_annotations);
2651
15
    PyObject *Lambda_annotations = PyDict_New();
2652
15
    if (!Lambda_annotations) return 0;
2653
15
    {
2654
15
        PyObject *type = state->arguments_type;
2655
15
        Py_INCREF(type);
2656
15
        cond = PyDict_SetItemString(Lambda_annotations, "args", type) == 0;
2657
15
        Py_DECREF(type);
2658
15
        if (!cond) {
2659
0
            Py_DECREF(Lambda_annotations);
2660
0
            return 0;
2661
0
        }
2662
15
    }
2663
15
    {
2664
15
        PyObject *type = state->expr_type;
2665
15
        Py_INCREF(type);
2666
15
        cond = PyDict_SetItemString(Lambda_annotations, "body", type) == 0;
2667
15
        Py_DECREF(type);
2668
15
        if (!cond) {
2669
0
            Py_DECREF(Lambda_annotations);
2670
0
            return 0;
2671
0
        }
2672
15
    }
2673
15
    cond = PyObject_SetAttrString(state->Lambda_type, "_field_types",
2674
15
                                  Lambda_annotations) == 0;
2675
15
    if (!cond) {
2676
0
        Py_DECREF(Lambda_annotations);
2677
0
        return 0;
2678
0
    }
2679
15
    cond = PyObject_SetAttrString(state->Lambda_type, "__annotations__",
2680
15
                                  Lambda_annotations) == 0;
2681
15
    if (!cond) {
2682
0
        Py_DECREF(Lambda_annotations);
2683
0
        return 0;
2684
0
    }
2685
15
    Py_DECREF(Lambda_annotations);
2686
15
    PyObject *IfExp_annotations = PyDict_New();
2687
15
    if (!IfExp_annotations) return 0;
2688
15
    {
2689
15
        PyObject *type = state->expr_type;
2690
15
        Py_INCREF(type);
2691
15
        cond = PyDict_SetItemString(IfExp_annotations, "test", type) == 0;
2692
15
        Py_DECREF(type);
2693
15
        if (!cond) {
2694
0
            Py_DECREF(IfExp_annotations);
2695
0
            return 0;
2696
0
        }
2697
15
    }
2698
15
    {
2699
15
        PyObject *type = state->expr_type;
2700
15
        Py_INCREF(type);
2701
15
        cond = PyDict_SetItemString(IfExp_annotations, "body", type) == 0;
2702
15
        Py_DECREF(type);
2703
15
        if (!cond) {
2704
0
            Py_DECREF(IfExp_annotations);
2705
0
            return 0;
2706
0
        }
2707
15
    }
2708
15
    {
2709
15
        PyObject *type = state->expr_type;
2710
15
        Py_INCREF(type);
2711
15
        cond = PyDict_SetItemString(IfExp_annotations, "orelse", type) == 0;
2712
15
        Py_DECREF(type);
2713
15
        if (!cond) {
2714
0
            Py_DECREF(IfExp_annotations);
2715
0
            return 0;
2716
0
        }
2717
15
    }
2718
15
    cond = PyObject_SetAttrString(state->IfExp_type, "_field_types",
2719
15
                                  IfExp_annotations) == 0;
2720
15
    if (!cond) {
2721
0
        Py_DECREF(IfExp_annotations);
2722
0
        return 0;
2723
0
    }
2724
15
    cond = PyObject_SetAttrString(state->IfExp_type, "__annotations__",
2725
15
                                  IfExp_annotations) == 0;
2726
15
    if (!cond) {
2727
0
        Py_DECREF(IfExp_annotations);
2728
0
        return 0;
2729
0
    }
2730
15
    Py_DECREF(IfExp_annotations);
2731
15
    PyObject *Dict_annotations = PyDict_New();
2732
15
    if (!Dict_annotations) return 0;
2733
15
    {
2734
15
        PyObject *type = state->expr_type;
2735
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2736
15
        cond = type != NULL;
2737
15
        if (!cond) {
2738
0
            Py_DECREF(Dict_annotations);
2739
0
            return 0;
2740
0
        }
2741
15
        cond = PyDict_SetItemString(Dict_annotations, "keys", type) == 0;
2742
15
        Py_DECREF(type);
2743
15
        if (!cond) {
2744
0
            Py_DECREF(Dict_annotations);
2745
0
            return 0;
2746
0
        }
2747
15
    }
2748
15
    {
2749
15
        PyObject *type = state->expr_type;
2750
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2751
15
        cond = type != NULL;
2752
15
        if (!cond) {
2753
0
            Py_DECREF(Dict_annotations);
2754
0
            return 0;
2755
0
        }
2756
15
        cond = PyDict_SetItemString(Dict_annotations, "values", type) == 0;
2757
15
        Py_DECREF(type);
2758
15
        if (!cond) {
2759
0
            Py_DECREF(Dict_annotations);
2760
0
            return 0;
2761
0
        }
2762
15
    }
2763
15
    cond = PyObject_SetAttrString(state->Dict_type, "_field_types",
2764
15
                                  Dict_annotations) == 0;
2765
15
    if (!cond) {
2766
0
        Py_DECREF(Dict_annotations);
2767
0
        return 0;
2768
0
    }
2769
15
    cond = PyObject_SetAttrString(state->Dict_type, "__annotations__",
2770
15
                                  Dict_annotations) == 0;
2771
15
    if (!cond) {
2772
0
        Py_DECREF(Dict_annotations);
2773
0
        return 0;
2774
0
    }
2775
15
    Py_DECREF(Dict_annotations);
2776
15
    PyObject *Set_annotations = PyDict_New();
2777
15
    if (!Set_annotations) return 0;
2778
15
    {
2779
15
        PyObject *type = state->expr_type;
2780
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2781
15
        cond = type != NULL;
2782
15
        if (!cond) {
2783
0
            Py_DECREF(Set_annotations);
2784
0
            return 0;
2785
0
        }
2786
15
        cond = PyDict_SetItemString(Set_annotations, "elts", type) == 0;
2787
15
        Py_DECREF(type);
2788
15
        if (!cond) {
2789
0
            Py_DECREF(Set_annotations);
2790
0
            return 0;
2791
0
        }
2792
15
    }
2793
15
    cond = PyObject_SetAttrString(state->Set_type, "_field_types",
2794
15
                                  Set_annotations) == 0;
2795
15
    if (!cond) {
2796
0
        Py_DECREF(Set_annotations);
2797
0
        return 0;
2798
0
    }
2799
15
    cond = PyObject_SetAttrString(state->Set_type, "__annotations__",
2800
15
                                  Set_annotations) == 0;
2801
15
    if (!cond) {
2802
0
        Py_DECREF(Set_annotations);
2803
0
        return 0;
2804
0
    }
2805
15
    Py_DECREF(Set_annotations);
2806
15
    PyObject *ListComp_annotations = PyDict_New();
2807
15
    if (!ListComp_annotations) return 0;
2808
15
    {
2809
15
        PyObject *type = state->expr_type;
2810
15
        Py_INCREF(type);
2811
15
        cond = PyDict_SetItemString(ListComp_annotations, "elt", type) == 0;
2812
15
        Py_DECREF(type);
2813
15
        if (!cond) {
2814
0
            Py_DECREF(ListComp_annotations);
2815
0
            return 0;
2816
0
        }
2817
15
    }
2818
15
    {
2819
15
        PyObject *type = state->comprehension_type;
2820
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2821
15
        cond = type != NULL;
2822
15
        if (!cond) {
2823
0
            Py_DECREF(ListComp_annotations);
2824
0
            return 0;
2825
0
        }
2826
15
        cond = PyDict_SetItemString(ListComp_annotations, "generators", type)
2827
15
                                    == 0;
2828
15
        Py_DECREF(type);
2829
15
        if (!cond) {
2830
0
            Py_DECREF(ListComp_annotations);
2831
0
            return 0;
2832
0
        }
2833
15
    }
2834
15
    cond = PyObject_SetAttrString(state->ListComp_type, "_field_types",
2835
15
                                  ListComp_annotations) == 0;
2836
15
    if (!cond) {
2837
0
        Py_DECREF(ListComp_annotations);
2838
0
        return 0;
2839
0
    }
2840
15
    cond = PyObject_SetAttrString(state->ListComp_type, "__annotations__",
2841
15
                                  ListComp_annotations) == 0;
2842
15
    if (!cond) {
2843
0
        Py_DECREF(ListComp_annotations);
2844
0
        return 0;
2845
0
    }
2846
15
    Py_DECREF(ListComp_annotations);
2847
15
    PyObject *SetComp_annotations = PyDict_New();
2848
15
    if (!SetComp_annotations) return 0;
2849
15
    {
2850
15
        PyObject *type = state->expr_type;
2851
15
        Py_INCREF(type);
2852
15
        cond = PyDict_SetItemString(SetComp_annotations, "elt", type) == 0;
2853
15
        Py_DECREF(type);
2854
15
        if (!cond) {
2855
0
            Py_DECREF(SetComp_annotations);
2856
0
            return 0;
2857
0
        }
2858
15
    }
2859
15
    {
2860
15
        PyObject *type = state->comprehension_type;
2861
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2862
15
        cond = type != NULL;
2863
15
        if (!cond) {
2864
0
            Py_DECREF(SetComp_annotations);
2865
0
            return 0;
2866
0
        }
2867
15
        cond = PyDict_SetItemString(SetComp_annotations, "generators", type) ==
2868
15
                                    0;
2869
15
        Py_DECREF(type);
2870
15
        if (!cond) {
2871
0
            Py_DECREF(SetComp_annotations);
2872
0
            return 0;
2873
0
        }
2874
15
    }
2875
15
    cond = PyObject_SetAttrString(state->SetComp_type, "_field_types",
2876
15
                                  SetComp_annotations) == 0;
2877
15
    if (!cond) {
2878
0
        Py_DECREF(SetComp_annotations);
2879
0
        return 0;
2880
0
    }
2881
15
    cond = PyObject_SetAttrString(state->SetComp_type, "__annotations__",
2882
15
                                  SetComp_annotations) == 0;
2883
15
    if (!cond) {
2884
0
        Py_DECREF(SetComp_annotations);
2885
0
        return 0;
2886
0
    }
2887
15
    Py_DECREF(SetComp_annotations);
2888
15
    PyObject *DictComp_annotations = PyDict_New();
2889
15
    if (!DictComp_annotations) return 0;
2890
15
    {
2891
15
        PyObject *type = state->expr_type;
2892
15
        Py_INCREF(type);
2893
15
        cond = PyDict_SetItemString(DictComp_annotations, "key", type) == 0;
2894
15
        Py_DECREF(type);
2895
15
        if (!cond) {
2896
0
            Py_DECREF(DictComp_annotations);
2897
0
            return 0;
2898
0
        }
2899
15
    }
2900
15
    {
2901
15
        PyObject *type = state->expr_type;
2902
15
        type = _Py_union_type_or(type, Py_None);
2903
15
        cond = type != NULL;
2904
15
        if (!cond) {
2905
0
            Py_DECREF(DictComp_annotations);
2906
0
            return 0;
2907
0
        }
2908
15
        cond = PyDict_SetItemString(DictComp_annotations, "value", type) == 0;
2909
15
        Py_DECREF(type);
2910
15
        if (!cond) {
2911
0
            Py_DECREF(DictComp_annotations);
2912
0
            return 0;
2913
0
        }
2914
15
    }
2915
15
    {
2916
15
        PyObject *type = state->comprehension_type;
2917
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2918
15
        cond = type != NULL;
2919
15
        if (!cond) {
2920
0
            Py_DECREF(DictComp_annotations);
2921
0
            return 0;
2922
0
        }
2923
15
        cond = PyDict_SetItemString(DictComp_annotations, "generators", type)
2924
15
                                    == 0;
2925
15
        Py_DECREF(type);
2926
15
        if (!cond) {
2927
0
            Py_DECREF(DictComp_annotations);
2928
0
            return 0;
2929
0
        }
2930
15
    }
2931
15
    cond = PyObject_SetAttrString(state->DictComp_type, "_field_types",
2932
15
                                  DictComp_annotations) == 0;
2933
15
    if (!cond) {
2934
0
        Py_DECREF(DictComp_annotations);
2935
0
        return 0;
2936
0
    }
2937
15
    cond = PyObject_SetAttrString(state->DictComp_type, "__annotations__",
2938
15
                                  DictComp_annotations) == 0;
2939
15
    if (!cond) {
2940
0
        Py_DECREF(DictComp_annotations);
2941
0
        return 0;
2942
0
    }
2943
15
    Py_DECREF(DictComp_annotations);
2944
15
    PyObject *GeneratorExp_annotations = PyDict_New();
2945
15
    if (!GeneratorExp_annotations) return 0;
2946
15
    {
2947
15
        PyObject *type = state->expr_type;
2948
15
        Py_INCREF(type);
2949
15
        cond = PyDict_SetItemString(GeneratorExp_annotations, "elt", type) == 0;
2950
15
        Py_DECREF(type);
2951
15
        if (!cond) {
2952
0
            Py_DECREF(GeneratorExp_annotations);
2953
0
            return 0;
2954
0
        }
2955
15
    }
2956
15
    {
2957
15
        PyObject *type = state->comprehension_type;
2958
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
2959
15
        cond = type != NULL;
2960
15
        if (!cond) {
2961
0
            Py_DECREF(GeneratorExp_annotations);
2962
0
            return 0;
2963
0
        }
2964
15
        cond = PyDict_SetItemString(GeneratorExp_annotations, "generators",
2965
15
                                    type) == 0;
2966
15
        Py_DECREF(type);
2967
15
        if (!cond) {
2968
0
            Py_DECREF(GeneratorExp_annotations);
2969
0
            return 0;
2970
0
        }
2971
15
    }
2972
15
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "_field_types",
2973
15
                                  GeneratorExp_annotations) == 0;
2974
15
    if (!cond) {
2975
0
        Py_DECREF(GeneratorExp_annotations);
2976
0
        return 0;
2977
0
    }
2978
15
    cond = PyObject_SetAttrString(state->GeneratorExp_type, "__annotations__",
2979
15
                                  GeneratorExp_annotations) == 0;
2980
15
    if (!cond) {
2981
0
        Py_DECREF(GeneratorExp_annotations);
2982
0
        return 0;
2983
0
    }
2984
15
    Py_DECREF(GeneratorExp_annotations);
2985
15
    PyObject *Await_annotations = PyDict_New();
2986
15
    if (!Await_annotations) return 0;
2987
15
    {
2988
15
        PyObject *type = state->expr_type;
2989
15
        Py_INCREF(type);
2990
15
        cond = PyDict_SetItemString(Await_annotations, "value", type) == 0;
2991
15
        Py_DECREF(type);
2992
15
        if (!cond) {
2993
0
            Py_DECREF(Await_annotations);
2994
0
            return 0;
2995
0
        }
2996
15
    }
2997
15
    cond = PyObject_SetAttrString(state->Await_type, "_field_types",
2998
15
                                  Await_annotations) == 0;
2999
15
    if (!cond) {
3000
0
        Py_DECREF(Await_annotations);
3001
0
        return 0;
3002
0
    }
3003
15
    cond = PyObject_SetAttrString(state->Await_type, "__annotations__",
3004
15
                                  Await_annotations) == 0;
3005
15
    if (!cond) {
3006
0
        Py_DECREF(Await_annotations);
3007
0
        return 0;
3008
0
    }
3009
15
    Py_DECREF(Await_annotations);
3010
15
    PyObject *Yield_annotations = PyDict_New();
3011
15
    if (!Yield_annotations) return 0;
3012
15
    {
3013
15
        PyObject *type = state->expr_type;
3014
15
        type = _Py_union_type_or(type, Py_None);
3015
15
        cond = type != NULL;
3016
15
        if (!cond) {
3017
0
            Py_DECREF(Yield_annotations);
3018
0
            return 0;
3019
0
        }
3020
15
        cond = PyDict_SetItemString(Yield_annotations, "value", type) == 0;
3021
15
        Py_DECREF(type);
3022
15
        if (!cond) {
3023
0
            Py_DECREF(Yield_annotations);
3024
0
            return 0;
3025
0
        }
3026
15
    }
3027
15
    cond = PyObject_SetAttrString(state->Yield_type, "_field_types",
3028
15
                                  Yield_annotations) == 0;
3029
15
    if (!cond) {
3030
0
        Py_DECREF(Yield_annotations);
3031
0
        return 0;
3032
0
    }
3033
15
    cond = PyObject_SetAttrString(state->Yield_type, "__annotations__",
3034
15
                                  Yield_annotations) == 0;
3035
15
    if (!cond) {
3036
0
        Py_DECREF(Yield_annotations);
3037
0
        return 0;
3038
0
    }
3039
15
    Py_DECREF(Yield_annotations);
3040
15
    PyObject *YieldFrom_annotations = PyDict_New();
3041
15
    if (!YieldFrom_annotations) return 0;
3042
15
    {
3043
15
        PyObject *type = state->expr_type;
3044
15
        Py_INCREF(type);
3045
15
        cond = PyDict_SetItemString(YieldFrom_annotations, "value", type) == 0;
3046
15
        Py_DECREF(type);
3047
15
        if (!cond) {
3048
0
            Py_DECREF(YieldFrom_annotations);
3049
0
            return 0;
3050
0
        }
3051
15
    }
3052
15
    cond = PyObject_SetAttrString(state->YieldFrom_type, "_field_types",
3053
15
                                  YieldFrom_annotations) == 0;
3054
15
    if (!cond) {
3055
0
        Py_DECREF(YieldFrom_annotations);
3056
0
        return 0;
3057
0
    }
3058
15
    cond = PyObject_SetAttrString(state->YieldFrom_type, "__annotations__",
3059
15
                                  YieldFrom_annotations) == 0;
3060
15
    if (!cond) {
3061
0
        Py_DECREF(YieldFrom_annotations);
3062
0
        return 0;
3063
0
    }
3064
15
    Py_DECREF(YieldFrom_annotations);
3065
15
    PyObject *Compare_annotations = PyDict_New();
3066
15
    if (!Compare_annotations) return 0;
3067
15
    {
3068
15
        PyObject *type = state->expr_type;
3069
15
        Py_INCREF(type);
3070
15
        cond = PyDict_SetItemString(Compare_annotations, "left", type) == 0;
3071
15
        Py_DECREF(type);
3072
15
        if (!cond) {
3073
0
            Py_DECREF(Compare_annotations);
3074
0
            return 0;
3075
0
        }
3076
15
    }
3077
15
    {
3078
15
        PyObject *type = state->cmpop_type;
3079
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3080
15
        cond = type != NULL;
3081
15
        if (!cond) {
3082
0
            Py_DECREF(Compare_annotations);
3083
0
            return 0;
3084
0
        }
3085
15
        cond = PyDict_SetItemString(Compare_annotations, "ops", type) == 0;
3086
15
        Py_DECREF(type);
3087
15
        if (!cond) {
3088
0
            Py_DECREF(Compare_annotations);
3089
0
            return 0;
3090
0
        }
3091
15
    }
3092
15
    {
3093
15
        PyObject *type = state->expr_type;
3094
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3095
15
        cond = type != NULL;
3096
15
        if (!cond) {
3097
0
            Py_DECREF(Compare_annotations);
3098
0
            return 0;
3099
0
        }
3100
15
        cond = PyDict_SetItemString(Compare_annotations, "comparators", type)
3101
15
                                    == 0;
3102
15
        Py_DECREF(type);
3103
15
        if (!cond) {
3104
0
            Py_DECREF(Compare_annotations);
3105
0
            return 0;
3106
0
        }
3107
15
    }
3108
15
    cond = PyObject_SetAttrString(state->Compare_type, "_field_types",
3109
15
                                  Compare_annotations) == 0;
3110
15
    if (!cond) {
3111
0
        Py_DECREF(Compare_annotations);
3112
0
        return 0;
3113
0
    }
3114
15
    cond = PyObject_SetAttrString(state->Compare_type, "__annotations__",
3115
15
                                  Compare_annotations) == 0;
3116
15
    if (!cond) {
3117
0
        Py_DECREF(Compare_annotations);
3118
0
        return 0;
3119
0
    }
3120
15
    Py_DECREF(Compare_annotations);
3121
15
    PyObject *Call_annotations = PyDict_New();
3122
15
    if (!Call_annotations) return 0;
3123
15
    {
3124
15
        PyObject *type = state->expr_type;
3125
15
        Py_INCREF(type);
3126
15
        cond = PyDict_SetItemString(Call_annotations, "func", type) == 0;
3127
15
        Py_DECREF(type);
3128
15
        if (!cond) {
3129
0
            Py_DECREF(Call_annotations);
3130
0
            return 0;
3131
0
        }
3132
15
    }
3133
15
    {
3134
15
        PyObject *type = state->expr_type;
3135
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3136
15
        cond = type != NULL;
3137
15
        if (!cond) {
3138
0
            Py_DECREF(Call_annotations);
3139
0
            return 0;
3140
0
        }
3141
15
        cond = PyDict_SetItemString(Call_annotations, "args", type) == 0;
3142
15
        Py_DECREF(type);
3143
15
        if (!cond) {
3144
0
            Py_DECREF(Call_annotations);
3145
0
            return 0;
3146
0
        }
3147
15
    }
3148
15
    {
3149
15
        PyObject *type = state->keyword_type;
3150
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3151
15
        cond = type != NULL;
3152
15
        if (!cond) {
3153
0
            Py_DECREF(Call_annotations);
3154
0
            return 0;
3155
0
        }
3156
15
        cond = PyDict_SetItemString(Call_annotations, "keywords", type) == 0;
3157
15
        Py_DECREF(type);
3158
15
        if (!cond) {
3159
0
            Py_DECREF(Call_annotations);
3160
0
            return 0;
3161
0
        }
3162
15
    }
3163
15
    cond = PyObject_SetAttrString(state->Call_type, "_field_types",
3164
15
                                  Call_annotations) == 0;
3165
15
    if (!cond) {
3166
0
        Py_DECREF(Call_annotations);
3167
0
        return 0;
3168
0
    }
3169
15
    cond = PyObject_SetAttrString(state->Call_type, "__annotations__",
3170
15
                                  Call_annotations) == 0;
3171
15
    if (!cond) {
3172
0
        Py_DECREF(Call_annotations);
3173
0
        return 0;
3174
0
    }
3175
15
    Py_DECREF(Call_annotations);
3176
15
    PyObject *FormattedValue_annotations = PyDict_New();
3177
15
    if (!FormattedValue_annotations) return 0;
3178
15
    {
3179
15
        PyObject *type = state->expr_type;
3180
15
        Py_INCREF(type);
3181
15
        cond = PyDict_SetItemString(FormattedValue_annotations, "value", type)
3182
15
                                    == 0;
3183
15
        Py_DECREF(type);
3184
15
        if (!cond) {
3185
0
            Py_DECREF(FormattedValue_annotations);
3186
0
            return 0;
3187
0
        }
3188
15
    }
3189
15
    {
3190
15
        PyObject *type = (PyObject *)&PyLong_Type;
3191
15
        Py_INCREF(type);
3192
15
        cond = PyDict_SetItemString(FormattedValue_annotations, "conversion",
3193
15
                                    type) == 0;
3194
15
        Py_DECREF(type);
3195
15
        if (!cond) {
3196
0
            Py_DECREF(FormattedValue_annotations);
3197
0
            return 0;
3198
0
        }
3199
15
    }
3200
15
    {
3201
15
        PyObject *type = state->expr_type;
3202
15
        type = _Py_union_type_or(type, Py_None);
3203
15
        cond = type != NULL;
3204
15
        if (!cond) {
3205
0
            Py_DECREF(FormattedValue_annotations);
3206
0
            return 0;
3207
0
        }
3208
15
        cond = PyDict_SetItemString(FormattedValue_annotations, "format_spec",
3209
15
                                    type) == 0;
3210
15
        Py_DECREF(type);
3211
15
        if (!cond) {
3212
0
            Py_DECREF(FormattedValue_annotations);
3213
0
            return 0;
3214
0
        }
3215
15
    }
3216
15
    cond = PyObject_SetAttrString(state->FormattedValue_type, "_field_types",
3217
15
                                  FormattedValue_annotations) == 0;
3218
15
    if (!cond) {
3219
0
        Py_DECREF(FormattedValue_annotations);
3220
0
        return 0;
3221
0
    }
3222
15
    cond = PyObject_SetAttrString(state->FormattedValue_type,
3223
15
                                  "__annotations__",
3224
15
                                  FormattedValue_annotations) == 0;
3225
15
    if (!cond) {
3226
0
        Py_DECREF(FormattedValue_annotations);
3227
0
        return 0;
3228
0
    }
3229
15
    Py_DECREF(FormattedValue_annotations);
3230
15
    PyObject *Interpolation_annotations = PyDict_New();
3231
15
    if (!Interpolation_annotations) return 0;
3232
15
    {
3233
15
        PyObject *type = state->expr_type;
3234
15
        Py_INCREF(type);
3235
15
        cond = PyDict_SetItemString(Interpolation_annotations, "value", type)
3236
15
                                    == 0;
3237
15
        Py_DECREF(type);
3238
15
        if (!cond) {
3239
0
            Py_DECREF(Interpolation_annotations);
3240
0
            return 0;
3241
0
        }
3242
15
    }
3243
15
    {
3244
15
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3245
15
        Py_INCREF(type);
3246
15
        cond = PyDict_SetItemString(Interpolation_annotations, "str", type) ==
3247
15
                                    0;
3248
15
        Py_DECREF(type);
3249
15
        if (!cond) {
3250
0
            Py_DECREF(Interpolation_annotations);
3251
0
            return 0;
3252
0
        }
3253
15
    }
3254
15
    {
3255
15
        PyObject *type = (PyObject *)&PyLong_Type;
3256
15
        Py_INCREF(type);
3257
15
        cond = PyDict_SetItemString(Interpolation_annotations, "conversion",
3258
15
                                    type) == 0;
3259
15
        Py_DECREF(type);
3260
15
        if (!cond) {
3261
0
            Py_DECREF(Interpolation_annotations);
3262
0
            return 0;
3263
0
        }
3264
15
    }
3265
15
    {
3266
15
        PyObject *type = state->expr_type;
3267
15
        type = _Py_union_type_or(type, Py_None);
3268
15
        cond = type != NULL;
3269
15
        if (!cond) {
3270
0
            Py_DECREF(Interpolation_annotations);
3271
0
            return 0;
3272
0
        }
3273
15
        cond = PyDict_SetItemString(Interpolation_annotations, "format_spec",
3274
15
                                    type) == 0;
3275
15
        Py_DECREF(type);
3276
15
        if (!cond) {
3277
0
            Py_DECREF(Interpolation_annotations);
3278
0
            return 0;
3279
0
        }
3280
15
    }
3281
15
    cond = PyObject_SetAttrString(state->Interpolation_type, "_field_types",
3282
15
                                  Interpolation_annotations) == 0;
3283
15
    if (!cond) {
3284
0
        Py_DECREF(Interpolation_annotations);
3285
0
        return 0;
3286
0
    }
3287
15
    cond = PyObject_SetAttrString(state->Interpolation_type, "__annotations__",
3288
15
                                  Interpolation_annotations) == 0;
3289
15
    if (!cond) {
3290
0
        Py_DECREF(Interpolation_annotations);
3291
0
        return 0;
3292
0
    }
3293
15
    Py_DECREF(Interpolation_annotations);
3294
15
    PyObject *JoinedStr_annotations = PyDict_New();
3295
15
    if (!JoinedStr_annotations) return 0;
3296
15
    {
3297
15
        PyObject *type = state->expr_type;
3298
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3299
15
        cond = type != NULL;
3300
15
        if (!cond) {
3301
0
            Py_DECREF(JoinedStr_annotations);
3302
0
            return 0;
3303
0
        }
3304
15
        cond = PyDict_SetItemString(JoinedStr_annotations, "values", type) == 0;
3305
15
        Py_DECREF(type);
3306
15
        if (!cond) {
3307
0
            Py_DECREF(JoinedStr_annotations);
3308
0
            return 0;
3309
0
        }
3310
15
    }
3311
15
    cond = PyObject_SetAttrString(state->JoinedStr_type, "_field_types",
3312
15
                                  JoinedStr_annotations) == 0;
3313
15
    if (!cond) {
3314
0
        Py_DECREF(JoinedStr_annotations);
3315
0
        return 0;
3316
0
    }
3317
15
    cond = PyObject_SetAttrString(state->JoinedStr_type, "__annotations__",
3318
15
                                  JoinedStr_annotations) == 0;
3319
15
    if (!cond) {
3320
0
        Py_DECREF(JoinedStr_annotations);
3321
0
        return 0;
3322
0
    }
3323
15
    Py_DECREF(JoinedStr_annotations);
3324
15
    PyObject *TemplateStr_annotations = PyDict_New();
3325
15
    if (!TemplateStr_annotations) return 0;
3326
15
    {
3327
15
        PyObject *type = state->expr_type;
3328
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3329
15
        cond = type != NULL;
3330
15
        if (!cond) {
3331
0
            Py_DECREF(TemplateStr_annotations);
3332
0
            return 0;
3333
0
        }
3334
15
        cond = PyDict_SetItemString(TemplateStr_annotations, "values", type) ==
3335
15
                                    0;
3336
15
        Py_DECREF(type);
3337
15
        if (!cond) {
3338
0
            Py_DECREF(TemplateStr_annotations);
3339
0
            return 0;
3340
0
        }
3341
15
    }
3342
15
    cond = PyObject_SetAttrString(state->TemplateStr_type, "_field_types",
3343
15
                                  TemplateStr_annotations) == 0;
3344
15
    if (!cond) {
3345
0
        Py_DECREF(TemplateStr_annotations);
3346
0
        return 0;
3347
0
    }
3348
15
    cond = PyObject_SetAttrString(state->TemplateStr_type, "__annotations__",
3349
15
                                  TemplateStr_annotations) == 0;
3350
15
    if (!cond) {
3351
0
        Py_DECREF(TemplateStr_annotations);
3352
0
        return 0;
3353
0
    }
3354
15
    Py_DECREF(TemplateStr_annotations);
3355
15
    PyObject *Constant_annotations = PyDict_New();
3356
15
    if (!Constant_annotations) return 0;
3357
15
    {
3358
15
        PyObject *type = (PyObject *)&PyBaseObject_Type;
3359
15
        Py_INCREF(type);
3360
15
        cond = PyDict_SetItemString(Constant_annotations, "value", type) == 0;
3361
15
        Py_DECREF(type);
3362
15
        if (!cond) {
3363
0
            Py_DECREF(Constant_annotations);
3364
0
            return 0;
3365
0
        }
3366
15
    }
3367
15
    {
3368
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
3369
15
        type = _Py_union_type_or(type, Py_None);
3370
15
        cond = type != NULL;
3371
15
        if (!cond) {
3372
0
            Py_DECREF(Constant_annotations);
3373
0
            return 0;
3374
0
        }
3375
15
        cond = PyDict_SetItemString(Constant_annotations, "kind", type) == 0;
3376
15
        Py_DECREF(type);
3377
15
        if (!cond) {
3378
0
            Py_DECREF(Constant_annotations);
3379
0
            return 0;
3380
0
        }
3381
15
    }
3382
15
    cond = PyObject_SetAttrString(state->Constant_type, "_field_types",
3383
15
                                  Constant_annotations) == 0;
3384
15
    if (!cond) {
3385
0
        Py_DECREF(Constant_annotations);
3386
0
        return 0;
3387
0
    }
3388
15
    cond = PyObject_SetAttrString(state->Constant_type, "__annotations__",
3389
15
                                  Constant_annotations) == 0;
3390
15
    if (!cond) {
3391
0
        Py_DECREF(Constant_annotations);
3392
0
        return 0;
3393
0
    }
3394
15
    Py_DECREF(Constant_annotations);
3395
15
    PyObject *Attribute_annotations = PyDict_New();
3396
15
    if (!Attribute_annotations) return 0;
3397
15
    {
3398
15
        PyObject *type = state->expr_type;
3399
15
        Py_INCREF(type);
3400
15
        cond = PyDict_SetItemString(Attribute_annotations, "value", type) == 0;
3401
15
        Py_DECREF(type);
3402
15
        if (!cond) {
3403
0
            Py_DECREF(Attribute_annotations);
3404
0
            return 0;
3405
0
        }
3406
15
    }
3407
15
    {
3408
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
3409
15
        Py_INCREF(type);
3410
15
        cond = PyDict_SetItemString(Attribute_annotations, "attr", type) == 0;
3411
15
        Py_DECREF(type);
3412
15
        if (!cond) {
3413
0
            Py_DECREF(Attribute_annotations);
3414
0
            return 0;
3415
0
        }
3416
15
    }
3417
15
    {
3418
15
        PyObject *type = state->expr_context_type;
3419
15
        Py_INCREF(type);
3420
15
        cond = PyDict_SetItemString(Attribute_annotations, "ctx", type) == 0;
3421
15
        Py_DECREF(type);
3422
15
        if (!cond) {
3423
0
            Py_DECREF(Attribute_annotations);
3424
0
            return 0;
3425
0
        }
3426
15
    }
3427
15
    cond = PyObject_SetAttrString(state->Attribute_type, "_field_types",
3428
15
                                  Attribute_annotations) == 0;
3429
15
    if (!cond) {
3430
0
        Py_DECREF(Attribute_annotations);
3431
0
        return 0;
3432
0
    }
3433
15
    cond = PyObject_SetAttrString(state->Attribute_type, "__annotations__",
3434
15
                                  Attribute_annotations) == 0;
3435
15
    if (!cond) {
3436
0
        Py_DECREF(Attribute_annotations);
3437
0
        return 0;
3438
0
    }
3439
15
    Py_DECREF(Attribute_annotations);
3440
15
    PyObject *Subscript_annotations = PyDict_New();
3441
15
    if (!Subscript_annotations) return 0;
3442
15
    {
3443
15
        PyObject *type = state->expr_type;
3444
15
        Py_INCREF(type);
3445
15
        cond = PyDict_SetItemString(Subscript_annotations, "value", type) == 0;
3446
15
        Py_DECREF(type);
3447
15
        if (!cond) {
3448
0
            Py_DECREF(Subscript_annotations);
3449
0
            return 0;
3450
0
        }
3451
15
    }
3452
15
    {
3453
15
        PyObject *type = state->expr_type;
3454
15
        Py_INCREF(type);
3455
15
        cond = PyDict_SetItemString(Subscript_annotations, "slice", type) == 0;
3456
15
        Py_DECREF(type);
3457
15
        if (!cond) {
3458
0
            Py_DECREF(Subscript_annotations);
3459
0
            return 0;
3460
0
        }
3461
15
    }
3462
15
    {
3463
15
        PyObject *type = state->expr_context_type;
3464
15
        Py_INCREF(type);
3465
15
        cond = PyDict_SetItemString(Subscript_annotations, "ctx", type) == 0;
3466
15
        Py_DECREF(type);
3467
15
        if (!cond) {
3468
0
            Py_DECREF(Subscript_annotations);
3469
0
            return 0;
3470
0
        }
3471
15
    }
3472
15
    cond = PyObject_SetAttrString(state->Subscript_type, "_field_types",
3473
15
                                  Subscript_annotations) == 0;
3474
15
    if (!cond) {
3475
0
        Py_DECREF(Subscript_annotations);
3476
0
        return 0;
3477
0
    }
3478
15
    cond = PyObject_SetAttrString(state->Subscript_type, "__annotations__",
3479
15
                                  Subscript_annotations) == 0;
3480
15
    if (!cond) {
3481
0
        Py_DECREF(Subscript_annotations);
3482
0
        return 0;
3483
0
    }
3484
15
    Py_DECREF(Subscript_annotations);
3485
15
    PyObject *Starred_annotations = PyDict_New();
3486
15
    if (!Starred_annotations) return 0;
3487
15
    {
3488
15
        PyObject *type = state->expr_type;
3489
15
        Py_INCREF(type);
3490
15
        cond = PyDict_SetItemString(Starred_annotations, "value", type) == 0;
3491
15
        Py_DECREF(type);
3492
15
        if (!cond) {
3493
0
            Py_DECREF(Starred_annotations);
3494
0
            return 0;
3495
0
        }
3496
15
    }
3497
15
    {
3498
15
        PyObject *type = state->expr_context_type;
3499
15
        Py_INCREF(type);
3500
15
        cond = PyDict_SetItemString(Starred_annotations, "ctx", type) == 0;
3501
15
        Py_DECREF(type);
3502
15
        if (!cond) {
3503
0
            Py_DECREF(Starred_annotations);
3504
0
            return 0;
3505
0
        }
3506
15
    }
3507
15
    cond = PyObject_SetAttrString(state->Starred_type, "_field_types",
3508
15
                                  Starred_annotations) == 0;
3509
15
    if (!cond) {
3510
0
        Py_DECREF(Starred_annotations);
3511
0
        return 0;
3512
0
    }
3513
15
    cond = PyObject_SetAttrString(state->Starred_type, "__annotations__",
3514
15
                                  Starred_annotations) == 0;
3515
15
    if (!cond) {
3516
0
        Py_DECREF(Starred_annotations);
3517
0
        return 0;
3518
0
    }
3519
15
    Py_DECREF(Starred_annotations);
3520
15
    PyObject *Name_annotations = PyDict_New();
3521
15
    if (!Name_annotations) return 0;
3522
15
    {
3523
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
3524
15
        Py_INCREF(type);
3525
15
        cond = PyDict_SetItemString(Name_annotations, "id", type) == 0;
3526
15
        Py_DECREF(type);
3527
15
        if (!cond) {
3528
0
            Py_DECREF(Name_annotations);
3529
0
            return 0;
3530
0
        }
3531
15
    }
3532
15
    {
3533
15
        PyObject *type = state->expr_context_type;
3534
15
        Py_INCREF(type);
3535
15
        cond = PyDict_SetItemString(Name_annotations, "ctx", type) == 0;
3536
15
        Py_DECREF(type);
3537
15
        if (!cond) {
3538
0
            Py_DECREF(Name_annotations);
3539
0
            return 0;
3540
0
        }
3541
15
    }
3542
15
    cond = PyObject_SetAttrString(state->Name_type, "_field_types",
3543
15
                                  Name_annotations) == 0;
3544
15
    if (!cond) {
3545
0
        Py_DECREF(Name_annotations);
3546
0
        return 0;
3547
0
    }
3548
15
    cond = PyObject_SetAttrString(state->Name_type, "__annotations__",
3549
15
                                  Name_annotations) == 0;
3550
15
    if (!cond) {
3551
0
        Py_DECREF(Name_annotations);
3552
0
        return 0;
3553
0
    }
3554
15
    Py_DECREF(Name_annotations);
3555
15
    PyObject *List_annotations = PyDict_New();
3556
15
    if (!List_annotations) return 0;
3557
15
    {
3558
15
        PyObject *type = state->expr_type;
3559
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3560
15
        cond = type != NULL;
3561
15
        if (!cond) {
3562
0
            Py_DECREF(List_annotations);
3563
0
            return 0;
3564
0
        }
3565
15
        cond = PyDict_SetItemString(List_annotations, "elts", type) == 0;
3566
15
        Py_DECREF(type);
3567
15
        if (!cond) {
3568
0
            Py_DECREF(List_annotations);
3569
0
            return 0;
3570
0
        }
3571
15
    }
3572
15
    {
3573
15
        PyObject *type = state->expr_context_type;
3574
15
        Py_INCREF(type);
3575
15
        cond = PyDict_SetItemString(List_annotations, "ctx", type) == 0;
3576
15
        Py_DECREF(type);
3577
15
        if (!cond) {
3578
0
            Py_DECREF(List_annotations);
3579
0
            return 0;
3580
0
        }
3581
15
    }
3582
15
    cond = PyObject_SetAttrString(state->List_type, "_field_types",
3583
15
                                  List_annotations) == 0;
3584
15
    if (!cond) {
3585
0
        Py_DECREF(List_annotations);
3586
0
        return 0;
3587
0
    }
3588
15
    cond = PyObject_SetAttrString(state->List_type, "__annotations__",
3589
15
                                  List_annotations) == 0;
3590
15
    if (!cond) {
3591
0
        Py_DECREF(List_annotations);
3592
0
        return 0;
3593
0
    }
3594
15
    Py_DECREF(List_annotations);
3595
15
    PyObject *Tuple_annotations = PyDict_New();
3596
15
    if (!Tuple_annotations) return 0;
3597
15
    {
3598
15
        PyObject *type = state->expr_type;
3599
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
3600
15
        cond = type != NULL;
3601
15
        if (!cond) {
3602
0
            Py_DECREF(Tuple_annotations);
3603
0
            return 0;
3604
0
        }
3605
15
        cond = PyDict_SetItemString(Tuple_annotations, "elts", type) == 0;
3606
15
        Py_DECREF(type);
3607
15
        if (!cond) {
3608
0
            Py_DECREF(Tuple_annotations);
3609
0
            return 0;
3610
0
        }
3611
15
    }
3612
15
    {
3613
15
        PyObject *type = state->expr_context_type;
3614
15
        Py_INCREF(type);
3615
15
        cond = PyDict_SetItemString(Tuple_annotations, "ctx", type) == 0;
3616
15
        Py_DECREF(type);
3617
15
        if (!cond) {
3618
0
            Py_DECREF(Tuple_annotations);
3619
0
            return 0;
3620
0
        }
3621
15
    }
3622
15
    cond = PyObject_SetAttrString(state->Tuple_type, "_field_types",
3623
15
                                  Tuple_annotations) == 0;
3624
15
    if (!cond) {
3625
0
        Py_DECREF(Tuple_annotations);
3626
0
        return 0;
3627
0
    }
3628
15
    cond = PyObject_SetAttrString(state->Tuple_type, "__annotations__",
3629
15
                                  Tuple_annotations) == 0;
3630
15
    if (!cond) {
3631
0
        Py_DECREF(Tuple_annotations);
3632
0
        return 0;
3633
0
    }
3634
15
    Py_DECREF(Tuple_annotations);
3635
15
    PyObject *Slice_annotations = PyDict_New();
3636
15
    if (!Slice_annotations) return 0;
3637
15
    {
3638
15
        PyObject *type = state->expr_type;
3639
15
        type = _Py_union_type_or(type, Py_None);
3640
15
        cond = type != NULL;
3641
15
        if (!cond) {
3642
0
            Py_DECREF(Slice_annotations);
3643
0
            return 0;
3644
0
        }
3645
15
        cond = PyDict_SetItemString(Slice_annotations, "lower", type) == 0;
3646
15
        Py_DECREF(type);
3647
15
        if (!cond) {
3648
0
            Py_DECREF(Slice_annotations);
3649
0
            return 0;
3650
0
        }
3651
15
    }
3652
15
    {
3653
15
        PyObject *type = state->expr_type;
3654
15
        type = _Py_union_type_or(type, Py_None);
3655
15
        cond = type != NULL;
3656
15
        if (!cond) {
3657
0
            Py_DECREF(Slice_annotations);
3658
0
            return 0;
3659
0
        }
3660
15
        cond = PyDict_SetItemString(Slice_annotations, "upper", type) == 0;
3661
15
        Py_DECREF(type);
3662
15
        if (!cond) {
3663
0
            Py_DECREF(Slice_annotations);
3664
0
            return 0;
3665
0
        }
3666
15
    }
3667
15
    {
3668
15
        PyObject *type = state->expr_type;
3669
15
        type = _Py_union_type_or(type, Py_None);
3670
15
        cond = type != NULL;
3671
15
        if (!cond) {
3672
0
            Py_DECREF(Slice_annotations);
3673
0
            return 0;
3674
0
        }
3675
15
        cond = PyDict_SetItemString(Slice_annotations, "step", type) == 0;
3676
15
        Py_DECREF(type);
3677
15
        if (!cond) {
3678
0
            Py_DECREF(Slice_annotations);
3679
0
            return 0;
3680
0
        }
3681
15
    }
3682
15
    cond = PyObject_SetAttrString(state->Slice_type, "_field_types",
3683
15
                                  Slice_annotations) == 0;
3684
15
    if (!cond) {
3685
0
        Py_DECREF(Slice_annotations);
3686
0
        return 0;
3687
0
    }
3688
15
    cond = PyObject_SetAttrString(state->Slice_type, "__annotations__",
3689
15
                                  Slice_annotations) == 0;
3690
15
    if (!cond) {
3691
0
        Py_DECREF(Slice_annotations);
3692
0
        return 0;
3693
0
    }
3694
15
    Py_DECREF(Slice_annotations);
3695
15
    PyObject *Load_annotations = PyDict_New();
3696
15
    if (!Load_annotations) return 0;
3697
15
    cond = PyObject_SetAttrString(state->Load_type, "_field_types",
3698
15
                                  Load_annotations) == 0;
3699
15
    if (!cond) {
3700
0
        Py_DECREF(Load_annotations);
3701
0
        return 0;
3702
0
    }
3703
15
    cond = PyObject_SetAttrString(state->Load_type, "__annotations__",
3704
15
                                  Load_annotations) == 0;
3705
15
    if (!cond) {
3706
0
        Py_DECREF(Load_annotations);
3707
0
        return 0;
3708
0
    }
3709
15
    Py_DECREF(Load_annotations);
3710
15
    PyObject *Store_annotations = PyDict_New();
3711
15
    if (!Store_annotations) return 0;
3712
15
    cond = PyObject_SetAttrString(state->Store_type, "_field_types",
3713
15
                                  Store_annotations) == 0;
3714
15
    if (!cond) {
3715
0
        Py_DECREF(Store_annotations);
3716
0
        return 0;
3717
0
    }
3718
15
    cond = PyObject_SetAttrString(state->Store_type, "__annotations__",
3719
15
                                  Store_annotations) == 0;
3720
15
    if (!cond) {
3721
0
        Py_DECREF(Store_annotations);
3722
0
        return 0;
3723
0
    }
3724
15
    Py_DECREF(Store_annotations);
3725
15
    PyObject *Del_annotations = PyDict_New();
3726
15
    if (!Del_annotations) return 0;
3727
15
    cond = PyObject_SetAttrString(state->Del_type, "_field_types",
3728
15
                                  Del_annotations) == 0;
3729
15
    if (!cond) {
3730
0
        Py_DECREF(Del_annotations);
3731
0
        return 0;
3732
0
    }
3733
15
    cond = PyObject_SetAttrString(state->Del_type, "__annotations__",
3734
15
                                  Del_annotations) == 0;
3735
15
    if (!cond) {
3736
0
        Py_DECREF(Del_annotations);
3737
0
        return 0;
3738
0
    }
3739
15
    Py_DECREF(Del_annotations);
3740
15
    PyObject *And_annotations = PyDict_New();
3741
15
    if (!And_annotations) return 0;
3742
15
    cond = PyObject_SetAttrString(state->And_type, "_field_types",
3743
15
                                  And_annotations) == 0;
3744
15
    if (!cond) {
3745
0
        Py_DECREF(And_annotations);
3746
0
        return 0;
3747
0
    }
3748
15
    cond = PyObject_SetAttrString(state->And_type, "__annotations__",
3749
15
                                  And_annotations) == 0;
3750
15
    if (!cond) {
3751
0
        Py_DECREF(And_annotations);
3752
0
        return 0;
3753
0
    }
3754
15
    Py_DECREF(And_annotations);
3755
15
    PyObject *Or_annotations = PyDict_New();
3756
15
    if (!Or_annotations) return 0;
3757
15
    cond = PyObject_SetAttrString(state->Or_type, "_field_types",
3758
15
                                  Or_annotations) == 0;
3759
15
    if (!cond) {
3760
0
        Py_DECREF(Or_annotations);
3761
0
        return 0;
3762
0
    }
3763
15
    cond = PyObject_SetAttrString(state->Or_type, "__annotations__",
3764
15
                                  Or_annotations) == 0;
3765
15
    if (!cond) {
3766
0
        Py_DECREF(Or_annotations);
3767
0
        return 0;
3768
0
    }
3769
15
    Py_DECREF(Or_annotations);
3770
15
    PyObject *Add_annotations = PyDict_New();
3771
15
    if (!Add_annotations) return 0;
3772
15
    cond = PyObject_SetAttrString(state->Add_type, "_field_types",
3773
15
                                  Add_annotations) == 0;
3774
15
    if (!cond) {
3775
0
        Py_DECREF(Add_annotations);
3776
0
        return 0;
3777
0
    }
3778
15
    cond = PyObject_SetAttrString(state->Add_type, "__annotations__",
3779
15
                                  Add_annotations) == 0;
3780
15
    if (!cond) {
3781
0
        Py_DECREF(Add_annotations);
3782
0
        return 0;
3783
0
    }
3784
15
    Py_DECREF(Add_annotations);
3785
15
    PyObject *Sub_annotations = PyDict_New();
3786
15
    if (!Sub_annotations) return 0;
3787
15
    cond = PyObject_SetAttrString(state->Sub_type, "_field_types",
3788
15
                                  Sub_annotations) == 0;
3789
15
    if (!cond) {
3790
0
        Py_DECREF(Sub_annotations);
3791
0
        return 0;
3792
0
    }
3793
15
    cond = PyObject_SetAttrString(state->Sub_type, "__annotations__",
3794
15
                                  Sub_annotations) == 0;
3795
15
    if (!cond) {
3796
0
        Py_DECREF(Sub_annotations);
3797
0
        return 0;
3798
0
    }
3799
15
    Py_DECREF(Sub_annotations);
3800
15
    PyObject *Mult_annotations = PyDict_New();
3801
15
    if (!Mult_annotations) return 0;
3802
15
    cond = PyObject_SetAttrString(state->Mult_type, "_field_types",
3803
15
                                  Mult_annotations) == 0;
3804
15
    if (!cond) {
3805
0
        Py_DECREF(Mult_annotations);
3806
0
        return 0;
3807
0
    }
3808
15
    cond = PyObject_SetAttrString(state->Mult_type, "__annotations__",
3809
15
                                  Mult_annotations) == 0;
3810
15
    if (!cond) {
3811
0
        Py_DECREF(Mult_annotations);
3812
0
        return 0;
3813
0
    }
3814
15
    Py_DECREF(Mult_annotations);
3815
15
    PyObject *MatMult_annotations = PyDict_New();
3816
15
    if (!MatMult_annotations) return 0;
3817
15
    cond = PyObject_SetAttrString(state->MatMult_type, "_field_types",
3818
15
                                  MatMult_annotations) == 0;
3819
15
    if (!cond) {
3820
0
        Py_DECREF(MatMult_annotations);
3821
0
        return 0;
3822
0
    }
3823
15
    cond = PyObject_SetAttrString(state->MatMult_type, "__annotations__",
3824
15
                                  MatMult_annotations) == 0;
3825
15
    if (!cond) {
3826
0
        Py_DECREF(MatMult_annotations);
3827
0
        return 0;
3828
0
    }
3829
15
    Py_DECREF(MatMult_annotations);
3830
15
    PyObject *Div_annotations = PyDict_New();
3831
15
    if (!Div_annotations) return 0;
3832
15
    cond = PyObject_SetAttrString(state->Div_type, "_field_types",
3833
15
                                  Div_annotations) == 0;
3834
15
    if (!cond) {
3835
0
        Py_DECREF(Div_annotations);
3836
0
        return 0;
3837
0
    }
3838
15
    cond = PyObject_SetAttrString(state->Div_type, "__annotations__",
3839
15
                                  Div_annotations) == 0;
3840
15
    if (!cond) {
3841
0
        Py_DECREF(Div_annotations);
3842
0
        return 0;
3843
0
    }
3844
15
    Py_DECREF(Div_annotations);
3845
15
    PyObject *Mod_annotations = PyDict_New();
3846
15
    if (!Mod_annotations) return 0;
3847
15
    cond = PyObject_SetAttrString(state->Mod_type, "_field_types",
3848
15
                                  Mod_annotations) == 0;
3849
15
    if (!cond) {
3850
0
        Py_DECREF(Mod_annotations);
3851
0
        return 0;
3852
0
    }
3853
15
    cond = PyObject_SetAttrString(state->Mod_type, "__annotations__",
3854
15
                                  Mod_annotations) == 0;
3855
15
    if (!cond) {
3856
0
        Py_DECREF(Mod_annotations);
3857
0
        return 0;
3858
0
    }
3859
15
    Py_DECREF(Mod_annotations);
3860
15
    PyObject *Pow_annotations = PyDict_New();
3861
15
    if (!Pow_annotations) return 0;
3862
15
    cond = PyObject_SetAttrString(state->Pow_type, "_field_types",
3863
15
                                  Pow_annotations) == 0;
3864
15
    if (!cond) {
3865
0
        Py_DECREF(Pow_annotations);
3866
0
        return 0;
3867
0
    }
3868
15
    cond = PyObject_SetAttrString(state->Pow_type, "__annotations__",
3869
15
                                  Pow_annotations) == 0;
3870
15
    if (!cond) {
3871
0
        Py_DECREF(Pow_annotations);
3872
0
        return 0;
3873
0
    }
3874
15
    Py_DECREF(Pow_annotations);
3875
15
    PyObject *LShift_annotations = PyDict_New();
3876
15
    if (!LShift_annotations) return 0;
3877
15
    cond = PyObject_SetAttrString(state->LShift_type, "_field_types",
3878
15
                                  LShift_annotations) == 0;
3879
15
    if (!cond) {
3880
0
        Py_DECREF(LShift_annotations);
3881
0
        return 0;
3882
0
    }
3883
15
    cond = PyObject_SetAttrString(state->LShift_type, "__annotations__",
3884
15
                                  LShift_annotations) == 0;
3885
15
    if (!cond) {
3886
0
        Py_DECREF(LShift_annotations);
3887
0
        return 0;
3888
0
    }
3889
15
    Py_DECREF(LShift_annotations);
3890
15
    PyObject *RShift_annotations = PyDict_New();
3891
15
    if (!RShift_annotations) return 0;
3892
15
    cond = PyObject_SetAttrString(state->RShift_type, "_field_types",
3893
15
                                  RShift_annotations) == 0;
3894
15
    if (!cond) {
3895
0
        Py_DECREF(RShift_annotations);
3896
0
        return 0;
3897
0
    }
3898
15
    cond = PyObject_SetAttrString(state->RShift_type, "__annotations__",
3899
15
                                  RShift_annotations) == 0;
3900
15
    if (!cond) {
3901
0
        Py_DECREF(RShift_annotations);
3902
0
        return 0;
3903
0
    }
3904
15
    Py_DECREF(RShift_annotations);
3905
15
    PyObject *BitOr_annotations = PyDict_New();
3906
15
    if (!BitOr_annotations) return 0;
3907
15
    cond = PyObject_SetAttrString(state->BitOr_type, "_field_types",
3908
15
                                  BitOr_annotations) == 0;
3909
15
    if (!cond) {
3910
0
        Py_DECREF(BitOr_annotations);
3911
0
        return 0;
3912
0
    }
3913
15
    cond = PyObject_SetAttrString(state->BitOr_type, "__annotations__",
3914
15
                                  BitOr_annotations) == 0;
3915
15
    if (!cond) {
3916
0
        Py_DECREF(BitOr_annotations);
3917
0
        return 0;
3918
0
    }
3919
15
    Py_DECREF(BitOr_annotations);
3920
15
    PyObject *BitXor_annotations = PyDict_New();
3921
15
    if (!BitXor_annotations) return 0;
3922
15
    cond = PyObject_SetAttrString(state->BitXor_type, "_field_types",
3923
15
                                  BitXor_annotations) == 0;
3924
15
    if (!cond) {
3925
0
        Py_DECREF(BitXor_annotations);
3926
0
        return 0;
3927
0
    }
3928
15
    cond = PyObject_SetAttrString(state->BitXor_type, "__annotations__",
3929
15
                                  BitXor_annotations) == 0;
3930
15
    if (!cond) {
3931
0
        Py_DECREF(BitXor_annotations);
3932
0
        return 0;
3933
0
    }
3934
15
    Py_DECREF(BitXor_annotations);
3935
15
    PyObject *BitAnd_annotations = PyDict_New();
3936
15
    if (!BitAnd_annotations) return 0;
3937
15
    cond = PyObject_SetAttrString(state->BitAnd_type, "_field_types",
3938
15
                                  BitAnd_annotations) == 0;
3939
15
    if (!cond) {
3940
0
        Py_DECREF(BitAnd_annotations);
3941
0
        return 0;
3942
0
    }
3943
15
    cond = PyObject_SetAttrString(state->BitAnd_type, "__annotations__",
3944
15
                                  BitAnd_annotations) == 0;
3945
15
    if (!cond) {
3946
0
        Py_DECREF(BitAnd_annotations);
3947
0
        return 0;
3948
0
    }
3949
15
    Py_DECREF(BitAnd_annotations);
3950
15
    PyObject *FloorDiv_annotations = PyDict_New();
3951
15
    if (!FloorDiv_annotations) return 0;
3952
15
    cond = PyObject_SetAttrString(state->FloorDiv_type, "_field_types",
3953
15
                                  FloorDiv_annotations) == 0;
3954
15
    if (!cond) {
3955
0
        Py_DECREF(FloorDiv_annotations);
3956
0
        return 0;
3957
0
    }
3958
15
    cond = PyObject_SetAttrString(state->FloorDiv_type, "__annotations__",
3959
15
                                  FloorDiv_annotations) == 0;
3960
15
    if (!cond) {
3961
0
        Py_DECREF(FloorDiv_annotations);
3962
0
        return 0;
3963
0
    }
3964
15
    Py_DECREF(FloorDiv_annotations);
3965
15
    PyObject *Invert_annotations = PyDict_New();
3966
15
    if (!Invert_annotations) return 0;
3967
15
    cond = PyObject_SetAttrString(state->Invert_type, "_field_types",
3968
15
                                  Invert_annotations) == 0;
3969
15
    if (!cond) {
3970
0
        Py_DECREF(Invert_annotations);
3971
0
        return 0;
3972
0
    }
3973
15
    cond = PyObject_SetAttrString(state->Invert_type, "__annotations__",
3974
15
                                  Invert_annotations) == 0;
3975
15
    if (!cond) {
3976
0
        Py_DECREF(Invert_annotations);
3977
0
        return 0;
3978
0
    }
3979
15
    Py_DECREF(Invert_annotations);
3980
15
    PyObject *Not_annotations = PyDict_New();
3981
15
    if (!Not_annotations) return 0;
3982
15
    cond = PyObject_SetAttrString(state->Not_type, "_field_types",
3983
15
                                  Not_annotations) == 0;
3984
15
    if (!cond) {
3985
0
        Py_DECREF(Not_annotations);
3986
0
        return 0;
3987
0
    }
3988
15
    cond = PyObject_SetAttrString(state->Not_type, "__annotations__",
3989
15
                                  Not_annotations) == 0;
3990
15
    if (!cond) {
3991
0
        Py_DECREF(Not_annotations);
3992
0
        return 0;
3993
0
    }
3994
15
    Py_DECREF(Not_annotations);
3995
15
    PyObject *UAdd_annotations = PyDict_New();
3996
15
    if (!UAdd_annotations) return 0;
3997
15
    cond = PyObject_SetAttrString(state->UAdd_type, "_field_types",
3998
15
                                  UAdd_annotations) == 0;
3999
15
    if (!cond) {
4000
0
        Py_DECREF(UAdd_annotations);
4001
0
        return 0;
4002
0
    }
4003
15
    cond = PyObject_SetAttrString(state->UAdd_type, "__annotations__",
4004
15
                                  UAdd_annotations) == 0;
4005
15
    if (!cond) {
4006
0
        Py_DECREF(UAdd_annotations);
4007
0
        return 0;
4008
0
    }
4009
15
    Py_DECREF(UAdd_annotations);
4010
15
    PyObject *USub_annotations = PyDict_New();
4011
15
    if (!USub_annotations) return 0;
4012
15
    cond = PyObject_SetAttrString(state->USub_type, "_field_types",
4013
15
                                  USub_annotations) == 0;
4014
15
    if (!cond) {
4015
0
        Py_DECREF(USub_annotations);
4016
0
        return 0;
4017
0
    }
4018
15
    cond = PyObject_SetAttrString(state->USub_type, "__annotations__",
4019
15
                                  USub_annotations) == 0;
4020
15
    if (!cond) {
4021
0
        Py_DECREF(USub_annotations);
4022
0
        return 0;
4023
0
    }
4024
15
    Py_DECREF(USub_annotations);
4025
15
    PyObject *Eq_annotations = PyDict_New();
4026
15
    if (!Eq_annotations) return 0;
4027
15
    cond = PyObject_SetAttrString(state->Eq_type, "_field_types",
4028
15
                                  Eq_annotations) == 0;
4029
15
    if (!cond) {
4030
0
        Py_DECREF(Eq_annotations);
4031
0
        return 0;
4032
0
    }
4033
15
    cond = PyObject_SetAttrString(state->Eq_type, "__annotations__",
4034
15
                                  Eq_annotations) == 0;
4035
15
    if (!cond) {
4036
0
        Py_DECREF(Eq_annotations);
4037
0
        return 0;
4038
0
    }
4039
15
    Py_DECREF(Eq_annotations);
4040
15
    PyObject *NotEq_annotations = PyDict_New();
4041
15
    if (!NotEq_annotations) return 0;
4042
15
    cond = PyObject_SetAttrString(state->NotEq_type, "_field_types",
4043
15
                                  NotEq_annotations) == 0;
4044
15
    if (!cond) {
4045
0
        Py_DECREF(NotEq_annotations);
4046
0
        return 0;
4047
0
    }
4048
15
    cond = PyObject_SetAttrString(state->NotEq_type, "__annotations__",
4049
15
                                  NotEq_annotations) == 0;
4050
15
    if (!cond) {
4051
0
        Py_DECREF(NotEq_annotations);
4052
0
        return 0;
4053
0
    }
4054
15
    Py_DECREF(NotEq_annotations);
4055
15
    PyObject *Lt_annotations = PyDict_New();
4056
15
    if (!Lt_annotations) return 0;
4057
15
    cond = PyObject_SetAttrString(state->Lt_type, "_field_types",
4058
15
                                  Lt_annotations) == 0;
4059
15
    if (!cond) {
4060
0
        Py_DECREF(Lt_annotations);
4061
0
        return 0;
4062
0
    }
4063
15
    cond = PyObject_SetAttrString(state->Lt_type, "__annotations__",
4064
15
                                  Lt_annotations) == 0;
4065
15
    if (!cond) {
4066
0
        Py_DECREF(Lt_annotations);
4067
0
        return 0;
4068
0
    }
4069
15
    Py_DECREF(Lt_annotations);
4070
15
    PyObject *LtE_annotations = PyDict_New();
4071
15
    if (!LtE_annotations) return 0;
4072
15
    cond = PyObject_SetAttrString(state->LtE_type, "_field_types",
4073
15
                                  LtE_annotations) == 0;
4074
15
    if (!cond) {
4075
0
        Py_DECREF(LtE_annotations);
4076
0
        return 0;
4077
0
    }
4078
15
    cond = PyObject_SetAttrString(state->LtE_type, "__annotations__",
4079
15
                                  LtE_annotations) == 0;
4080
15
    if (!cond) {
4081
0
        Py_DECREF(LtE_annotations);
4082
0
        return 0;
4083
0
    }
4084
15
    Py_DECREF(LtE_annotations);
4085
15
    PyObject *Gt_annotations = PyDict_New();
4086
15
    if (!Gt_annotations) return 0;
4087
15
    cond = PyObject_SetAttrString(state->Gt_type, "_field_types",
4088
15
                                  Gt_annotations) == 0;
4089
15
    if (!cond) {
4090
0
        Py_DECREF(Gt_annotations);
4091
0
        return 0;
4092
0
    }
4093
15
    cond = PyObject_SetAttrString(state->Gt_type, "__annotations__",
4094
15
                                  Gt_annotations) == 0;
4095
15
    if (!cond) {
4096
0
        Py_DECREF(Gt_annotations);
4097
0
        return 0;
4098
0
    }
4099
15
    Py_DECREF(Gt_annotations);
4100
15
    PyObject *GtE_annotations = PyDict_New();
4101
15
    if (!GtE_annotations) return 0;
4102
15
    cond = PyObject_SetAttrString(state->GtE_type, "_field_types",
4103
15
                                  GtE_annotations) == 0;
4104
15
    if (!cond) {
4105
0
        Py_DECREF(GtE_annotations);
4106
0
        return 0;
4107
0
    }
4108
15
    cond = PyObject_SetAttrString(state->GtE_type, "__annotations__",
4109
15
                                  GtE_annotations) == 0;
4110
15
    if (!cond) {
4111
0
        Py_DECREF(GtE_annotations);
4112
0
        return 0;
4113
0
    }
4114
15
    Py_DECREF(GtE_annotations);
4115
15
    PyObject *Is_annotations = PyDict_New();
4116
15
    if (!Is_annotations) return 0;
4117
15
    cond = PyObject_SetAttrString(state->Is_type, "_field_types",
4118
15
                                  Is_annotations) == 0;
4119
15
    if (!cond) {
4120
0
        Py_DECREF(Is_annotations);
4121
0
        return 0;
4122
0
    }
4123
15
    cond = PyObject_SetAttrString(state->Is_type, "__annotations__",
4124
15
                                  Is_annotations) == 0;
4125
15
    if (!cond) {
4126
0
        Py_DECREF(Is_annotations);
4127
0
        return 0;
4128
0
    }
4129
15
    Py_DECREF(Is_annotations);
4130
15
    PyObject *IsNot_annotations = PyDict_New();
4131
15
    if (!IsNot_annotations) return 0;
4132
15
    cond = PyObject_SetAttrString(state->IsNot_type, "_field_types",
4133
15
                                  IsNot_annotations) == 0;
4134
15
    if (!cond) {
4135
0
        Py_DECREF(IsNot_annotations);
4136
0
        return 0;
4137
0
    }
4138
15
    cond = PyObject_SetAttrString(state->IsNot_type, "__annotations__",
4139
15
                                  IsNot_annotations) == 0;
4140
15
    if (!cond) {
4141
0
        Py_DECREF(IsNot_annotations);
4142
0
        return 0;
4143
0
    }
4144
15
    Py_DECREF(IsNot_annotations);
4145
15
    PyObject *In_annotations = PyDict_New();
4146
15
    if (!In_annotations) return 0;
4147
15
    cond = PyObject_SetAttrString(state->In_type, "_field_types",
4148
15
                                  In_annotations) == 0;
4149
15
    if (!cond) {
4150
0
        Py_DECREF(In_annotations);
4151
0
        return 0;
4152
0
    }
4153
15
    cond = PyObject_SetAttrString(state->In_type, "__annotations__",
4154
15
                                  In_annotations) == 0;
4155
15
    if (!cond) {
4156
0
        Py_DECREF(In_annotations);
4157
0
        return 0;
4158
0
    }
4159
15
    Py_DECREF(In_annotations);
4160
15
    PyObject *NotIn_annotations = PyDict_New();
4161
15
    if (!NotIn_annotations) return 0;
4162
15
    cond = PyObject_SetAttrString(state->NotIn_type, "_field_types",
4163
15
                                  NotIn_annotations) == 0;
4164
15
    if (!cond) {
4165
0
        Py_DECREF(NotIn_annotations);
4166
0
        return 0;
4167
0
    }
4168
15
    cond = PyObject_SetAttrString(state->NotIn_type, "__annotations__",
4169
15
                                  NotIn_annotations) == 0;
4170
15
    if (!cond) {
4171
0
        Py_DECREF(NotIn_annotations);
4172
0
        return 0;
4173
0
    }
4174
15
    Py_DECREF(NotIn_annotations);
4175
15
    PyObject *comprehension_annotations = PyDict_New();
4176
15
    if (!comprehension_annotations) return 0;
4177
15
    {
4178
15
        PyObject *type = state->expr_type;
4179
15
        Py_INCREF(type);
4180
15
        cond = PyDict_SetItemString(comprehension_annotations, "target", type)
4181
15
                                    == 0;
4182
15
        Py_DECREF(type);
4183
15
        if (!cond) {
4184
0
            Py_DECREF(comprehension_annotations);
4185
0
            return 0;
4186
0
        }
4187
15
    }
4188
15
    {
4189
15
        PyObject *type = state->expr_type;
4190
15
        Py_INCREF(type);
4191
15
        cond = PyDict_SetItemString(comprehension_annotations, "iter", type) ==
4192
15
                                    0;
4193
15
        Py_DECREF(type);
4194
15
        if (!cond) {
4195
0
            Py_DECREF(comprehension_annotations);
4196
0
            return 0;
4197
0
        }
4198
15
    }
4199
15
    {
4200
15
        PyObject *type = state->expr_type;
4201
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4202
15
        cond = type != NULL;
4203
15
        if (!cond) {
4204
0
            Py_DECREF(comprehension_annotations);
4205
0
            return 0;
4206
0
        }
4207
15
        cond = PyDict_SetItemString(comprehension_annotations, "ifs", type) ==
4208
15
                                    0;
4209
15
        Py_DECREF(type);
4210
15
        if (!cond) {
4211
0
            Py_DECREF(comprehension_annotations);
4212
0
            return 0;
4213
0
        }
4214
15
    }
4215
15
    {
4216
15
        PyObject *type = (PyObject *)&PyLong_Type;
4217
15
        Py_INCREF(type);
4218
15
        cond = PyDict_SetItemString(comprehension_annotations, "is_async",
4219
15
                                    type) == 0;
4220
15
        Py_DECREF(type);
4221
15
        if (!cond) {
4222
0
            Py_DECREF(comprehension_annotations);
4223
0
            return 0;
4224
0
        }
4225
15
    }
4226
15
    cond = PyObject_SetAttrString(state->comprehension_type, "_field_types",
4227
15
                                  comprehension_annotations) == 0;
4228
15
    if (!cond) {
4229
0
        Py_DECREF(comprehension_annotations);
4230
0
        return 0;
4231
0
    }
4232
15
    cond = PyObject_SetAttrString(state->comprehension_type, "__annotations__",
4233
15
                                  comprehension_annotations) == 0;
4234
15
    if (!cond) {
4235
0
        Py_DECREF(comprehension_annotations);
4236
0
        return 0;
4237
0
    }
4238
15
    Py_DECREF(comprehension_annotations);
4239
15
    PyObject *ExceptHandler_annotations = PyDict_New();
4240
15
    if (!ExceptHandler_annotations) return 0;
4241
15
    {
4242
15
        PyObject *type = state->expr_type;
4243
15
        type = _Py_union_type_or(type, Py_None);
4244
15
        cond = type != NULL;
4245
15
        if (!cond) {
4246
0
            Py_DECREF(ExceptHandler_annotations);
4247
0
            return 0;
4248
0
        }
4249
15
        cond = PyDict_SetItemString(ExceptHandler_annotations, "type", type) ==
4250
15
                                    0;
4251
15
        Py_DECREF(type);
4252
15
        if (!cond) {
4253
0
            Py_DECREF(ExceptHandler_annotations);
4254
0
            return 0;
4255
0
        }
4256
15
    }
4257
15
    {
4258
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4259
15
        type = _Py_union_type_or(type, Py_None);
4260
15
        cond = type != NULL;
4261
15
        if (!cond) {
4262
0
            Py_DECREF(ExceptHandler_annotations);
4263
0
            return 0;
4264
0
        }
4265
15
        cond = PyDict_SetItemString(ExceptHandler_annotations, "name", type) ==
4266
15
                                    0;
4267
15
        Py_DECREF(type);
4268
15
        if (!cond) {
4269
0
            Py_DECREF(ExceptHandler_annotations);
4270
0
            return 0;
4271
0
        }
4272
15
    }
4273
15
    {
4274
15
        PyObject *type = state->stmt_type;
4275
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4276
15
        cond = type != NULL;
4277
15
        if (!cond) {
4278
0
            Py_DECREF(ExceptHandler_annotations);
4279
0
            return 0;
4280
0
        }
4281
15
        cond = PyDict_SetItemString(ExceptHandler_annotations, "body", type) ==
4282
15
                                    0;
4283
15
        Py_DECREF(type);
4284
15
        if (!cond) {
4285
0
            Py_DECREF(ExceptHandler_annotations);
4286
0
            return 0;
4287
0
        }
4288
15
    }
4289
15
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "_field_types",
4290
15
                                  ExceptHandler_annotations) == 0;
4291
15
    if (!cond) {
4292
0
        Py_DECREF(ExceptHandler_annotations);
4293
0
        return 0;
4294
0
    }
4295
15
    cond = PyObject_SetAttrString(state->ExceptHandler_type, "__annotations__",
4296
15
                                  ExceptHandler_annotations) == 0;
4297
15
    if (!cond) {
4298
0
        Py_DECREF(ExceptHandler_annotations);
4299
0
        return 0;
4300
0
    }
4301
15
    Py_DECREF(ExceptHandler_annotations);
4302
15
    PyObject *arguments_annotations = PyDict_New();
4303
15
    if (!arguments_annotations) return 0;
4304
15
    {
4305
15
        PyObject *type = state->arg_type;
4306
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4307
15
        cond = type != NULL;
4308
15
        if (!cond) {
4309
0
            Py_DECREF(arguments_annotations);
4310
0
            return 0;
4311
0
        }
4312
15
        cond = PyDict_SetItemString(arguments_annotations, "posonlyargs", type)
4313
15
                                    == 0;
4314
15
        Py_DECREF(type);
4315
15
        if (!cond) {
4316
0
            Py_DECREF(arguments_annotations);
4317
0
            return 0;
4318
0
        }
4319
15
    }
4320
15
    {
4321
15
        PyObject *type = state->arg_type;
4322
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4323
15
        cond = type != NULL;
4324
15
        if (!cond) {
4325
0
            Py_DECREF(arguments_annotations);
4326
0
            return 0;
4327
0
        }
4328
15
        cond = PyDict_SetItemString(arguments_annotations, "args", type) == 0;
4329
15
        Py_DECREF(type);
4330
15
        if (!cond) {
4331
0
            Py_DECREF(arguments_annotations);
4332
0
            return 0;
4333
0
        }
4334
15
    }
4335
15
    {
4336
15
        PyObject *type = state->arg_type;
4337
15
        type = _Py_union_type_or(type, Py_None);
4338
15
        cond = type != NULL;
4339
15
        if (!cond) {
4340
0
            Py_DECREF(arguments_annotations);
4341
0
            return 0;
4342
0
        }
4343
15
        cond = PyDict_SetItemString(arguments_annotations, "vararg", type) == 0;
4344
15
        Py_DECREF(type);
4345
15
        if (!cond) {
4346
0
            Py_DECREF(arguments_annotations);
4347
0
            return 0;
4348
0
        }
4349
15
    }
4350
15
    {
4351
15
        PyObject *type = state->arg_type;
4352
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4353
15
        cond = type != NULL;
4354
15
        if (!cond) {
4355
0
            Py_DECREF(arguments_annotations);
4356
0
            return 0;
4357
0
        }
4358
15
        cond = PyDict_SetItemString(arguments_annotations, "kwonlyargs", type)
4359
15
                                    == 0;
4360
15
        Py_DECREF(type);
4361
15
        if (!cond) {
4362
0
            Py_DECREF(arguments_annotations);
4363
0
            return 0;
4364
0
        }
4365
15
    }
4366
15
    {
4367
15
        PyObject *type = state->expr_type;
4368
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4369
15
        cond = type != NULL;
4370
15
        if (!cond) {
4371
0
            Py_DECREF(arguments_annotations);
4372
0
            return 0;
4373
0
        }
4374
15
        cond = PyDict_SetItemString(arguments_annotations, "kw_defaults", type)
4375
15
                                    == 0;
4376
15
        Py_DECREF(type);
4377
15
        if (!cond) {
4378
0
            Py_DECREF(arguments_annotations);
4379
0
            return 0;
4380
0
        }
4381
15
    }
4382
15
    {
4383
15
        PyObject *type = state->arg_type;
4384
15
        type = _Py_union_type_or(type, Py_None);
4385
15
        cond = type != NULL;
4386
15
        if (!cond) {
4387
0
            Py_DECREF(arguments_annotations);
4388
0
            return 0;
4389
0
        }
4390
15
        cond = PyDict_SetItemString(arguments_annotations, "kwarg", type) == 0;
4391
15
        Py_DECREF(type);
4392
15
        if (!cond) {
4393
0
            Py_DECREF(arguments_annotations);
4394
0
            return 0;
4395
0
        }
4396
15
    }
4397
15
    {
4398
15
        PyObject *type = state->expr_type;
4399
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4400
15
        cond = type != NULL;
4401
15
        if (!cond) {
4402
0
            Py_DECREF(arguments_annotations);
4403
0
            return 0;
4404
0
        }
4405
15
        cond = PyDict_SetItemString(arguments_annotations, "defaults", type) ==
4406
15
                                    0;
4407
15
        Py_DECREF(type);
4408
15
        if (!cond) {
4409
0
            Py_DECREF(arguments_annotations);
4410
0
            return 0;
4411
0
        }
4412
15
    }
4413
15
    cond = PyObject_SetAttrString(state->arguments_type, "_field_types",
4414
15
                                  arguments_annotations) == 0;
4415
15
    if (!cond) {
4416
0
        Py_DECREF(arguments_annotations);
4417
0
        return 0;
4418
0
    }
4419
15
    cond = PyObject_SetAttrString(state->arguments_type, "__annotations__",
4420
15
                                  arguments_annotations) == 0;
4421
15
    if (!cond) {
4422
0
        Py_DECREF(arguments_annotations);
4423
0
        return 0;
4424
0
    }
4425
15
    Py_DECREF(arguments_annotations);
4426
15
    PyObject *arg_annotations = PyDict_New();
4427
15
    if (!arg_annotations) return 0;
4428
15
    {
4429
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4430
15
        Py_INCREF(type);
4431
15
        cond = PyDict_SetItemString(arg_annotations, "arg", type) == 0;
4432
15
        Py_DECREF(type);
4433
15
        if (!cond) {
4434
0
            Py_DECREF(arg_annotations);
4435
0
            return 0;
4436
0
        }
4437
15
    }
4438
15
    {
4439
15
        PyObject *type = state->expr_type;
4440
15
        type = _Py_union_type_or(type, Py_None);
4441
15
        cond = type != NULL;
4442
15
        if (!cond) {
4443
0
            Py_DECREF(arg_annotations);
4444
0
            return 0;
4445
0
        }
4446
15
        cond = PyDict_SetItemString(arg_annotations, "annotation", type) == 0;
4447
15
        Py_DECREF(type);
4448
15
        if (!cond) {
4449
0
            Py_DECREF(arg_annotations);
4450
0
            return 0;
4451
0
        }
4452
15
    }
4453
15
    {
4454
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4455
15
        type = _Py_union_type_or(type, Py_None);
4456
15
        cond = type != NULL;
4457
15
        if (!cond) {
4458
0
            Py_DECREF(arg_annotations);
4459
0
            return 0;
4460
0
        }
4461
15
        cond = PyDict_SetItemString(arg_annotations, "type_comment", type) == 0;
4462
15
        Py_DECREF(type);
4463
15
        if (!cond) {
4464
0
            Py_DECREF(arg_annotations);
4465
0
            return 0;
4466
0
        }
4467
15
    }
4468
15
    cond = PyObject_SetAttrString(state->arg_type, "_field_types",
4469
15
                                  arg_annotations) == 0;
4470
15
    if (!cond) {
4471
0
        Py_DECREF(arg_annotations);
4472
0
        return 0;
4473
0
    }
4474
15
    cond = PyObject_SetAttrString(state->arg_type, "__annotations__",
4475
15
                                  arg_annotations) == 0;
4476
15
    if (!cond) {
4477
0
        Py_DECREF(arg_annotations);
4478
0
        return 0;
4479
0
    }
4480
15
    Py_DECREF(arg_annotations);
4481
15
    PyObject *keyword_annotations = PyDict_New();
4482
15
    if (!keyword_annotations) return 0;
4483
15
    {
4484
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4485
15
        type = _Py_union_type_or(type, Py_None);
4486
15
        cond = type != NULL;
4487
15
        if (!cond) {
4488
0
            Py_DECREF(keyword_annotations);
4489
0
            return 0;
4490
0
        }
4491
15
        cond = PyDict_SetItemString(keyword_annotations, "arg", type) == 0;
4492
15
        Py_DECREF(type);
4493
15
        if (!cond) {
4494
0
            Py_DECREF(keyword_annotations);
4495
0
            return 0;
4496
0
        }
4497
15
    }
4498
15
    {
4499
15
        PyObject *type = state->expr_type;
4500
15
        Py_INCREF(type);
4501
15
        cond = PyDict_SetItemString(keyword_annotations, "value", type) == 0;
4502
15
        Py_DECREF(type);
4503
15
        if (!cond) {
4504
0
            Py_DECREF(keyword_annotations);
4505
0
            return 0;
4506
0
        }
4507
15
    }
4508
15
    cond = PyObject_SetAttrString(state->keyword_type, "_field_types",
4509
15
                                  keyword_annotations) == 0;
4510
15
    if (!cond) {
4511
0
        Py_DECREF(keyword_annotations);
4512
0
        return 0;
4513
0
    }
4514
15
    cond = PyObject_SetAttrString(state->keyword_type, "__annotations__",
4515
15
                                  keyword_annotations) == 0;
4516
15
    if (!cond) {
4517
0
        Py_DECREF(keyword_annotations);
4518
0
        return 0;
4519
0
    }
4520
15
    Py_DECREF(keyword_annotations);
4521
15
    PyObject *alias_annotations = PyDict_New();
4522
15
    if (!alias_annotations) return 0;
4523
15
    {
4524
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4525
15
        Py_INCREF(type);
4526
15
        cond = PyDict_SetItemString(alias_annotations, "name", type) == 0;
4527
15
        Py_DECREF(type);
4528
15
        if (!cond) {
4529
0
            Py_DECREF(alias_annotations);
4530
0
            return 0;
4531
0
        }
4532
15
    }
4533
15
    {
4534
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4535
15
        type = _Py_union_type_or(type, Py_None);
4536
15
        cond = type != NULL;
4537
15
        if (!cond) {
4538
0
            Py_DECREF(alias_annotations);
4539
0
            return 0;
4540
0
        }
4541
15
        cond = PyDict_SetItemString(alias_annotations, "asname", type) == 0;
4542
15
        Py_DECREF(type);
4543
15
        if (!cond) {
4544
0
            Py_DECREF(alias_annotations);
4545
0
            return 0;
4546
0
        }
4547
15
    }
4548
15
    cond = PyObject_SetAttrString(state->alias_type, "_field_types",
4549
15
                                  alias_annotations) == 0;
4550
15
    if (!cond) {
4551
0
        Py_DECREF(alias_annotations);
4552
0
        return 0;
4553
0
    }
4554
15
    cond = PyObject_SetAttrString(state->alias_type, "__annotations__",
4555
15
                                  alias_annotations) == 0;
4556
15
    if (!cond) {
4557
0
        Py_DECREF(alias_annotations);
4558
0
        return 0;
4559
0
    }
4560
15
    Py_DECREF(alias_annotations);
4561
15
    PyObject *withitem_annotations = PyDict_New();
4562
15
    if (!withitem_annotations) return 0;
4563
15
    {
4564
15
        PyObject *type = state->expr_type;
4565
15
        Py_INCREF(type);
4566
15
        cond = PyDict_SetItemString(withitem_annotations, "context_expr", type)
4567
15
                                    == 0;
4568
15
        Py_DECREF(type);
4569
15
        if (!cond) {
4570
0
            Py_DECREF(withitem_annotations);
4571
0
            return 0;
4572
0
        }
4573
15
    }
4574
15
    {
4575
15
        PyObject *type = state->expr_type;
4576
15
        type = _Py_union_type_or(type, Py_None);
4577
15
        cond = type != NULL;
4578
15
        if (!cond) {
4579
0
            Py_DECREF(withitem_annotations);
4580
0
            return 0;
4581
0
        }
4582
15
        cond = PyDict_SetItemString(withitem_annotations, "optional_vars",
4583
15
                                    type) == 0;
4584
15
        Py_DECREF(type);
4585
15
        if (!cond) {
4586
0
            Py_DECREF(withitem_annotations);
4587
0
            return 0;
4588
0
        }
4589
15
    }
4590
15
    cond = PyObject_SetAttrString(state->withitem_type, "_field_types",
4591
15
                                  withitem_annotations) == 0;
4592
15
    if (!cond) {
4593
0
        Py_DECREF(withitem_annotations);
4594
0
        return 0;
4595
0
    }
4596
15
    cond = PyObject_SetAttrString(state->withitem_type, "__annotations__",
4597
15
                                  withitem_annotations) == 0;
4598
15
    if (!cond) {
4599
0
        Py_DECREF(withitem_annotations);
4600
0
        return 0;
4601
0
    }
4602
15
    Py_DECREF(withitem_annotations);
4603
15
    PyObject *match_case_annotations = PyDict_New();
4604
15
    if (!match_case_annotations) return 0;
4605
15
    {
4606
15
        PyObject *type = state->pattern_type;
4607
15
        Py_INCREF(type);
4608
15
        cond = PyDict_SetItemString(match_case_annotations, "pattern", type) ==
4609
15
                                    0;
4610
15
        Py_DECREF(type);
4611
15
        if (!cond) {
4612
0
            Py_DECREF(match_case_annotations);
4613
0
            return 0;
4614
0
        }
4615
15
    }
4616
15
    {
4617
15
        PyObject *type = state->expr_type;
4618
15
        type = _Py_union_type_or(type, Py_None);
4619
15
        cond = type != NULL;
4620
15
        if (!cond) {
4621
0
            Py_DECREF(match_case_annotations);
4622
0
            return 0;
4623
0
        }
4624
15
        cond = PyDict_SetItemString(match_case_annotations, "guard", type) == 0;
4625
15
        Py_DECREF(type);
4626
15
        if (!cond) {
4627
0
            Py_DECREF(match_case_annotations);
4628
0
            return 0;
4629
0
        }
4630
15
    }
4631
15
    {
4632
15
        PyObject *type = state->stmt_type;
4633
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4634
15
        cond = type != NULL;
4635
15
        if (!cond) {
4636
0
            Py_DECREF(match_case_annotations);
4637
0
            return 0;
4638
0
        }
4639
15
        cond = PyDict_SetItemString(match_case_annotations, "body", type) == 0;
4640
15
        Py_DECREF(type);
4641
15
        if (!cond) {
4642
0
            Py_DECREF(match_case_annotations);
4643
0
            return 0;
4644
0
        }
4645
15
    }
4646
15
    cond = PyObject_SetAttrString(state->match_case_type, "_field_types",
4647
15
                                  match_case_annotations) == 0;
4648
15
    if (!cond) {
4649
0
        Py_DECREF(match_case_annotations);
4650
0
        return 0;
4651
0
    }
4652
15
    cond = PyObject_SetAttrString(state->match_case_type, "__annotations__",
4653
15
                                  match_case_annotations) == 0;
4654
15
    if (!cond) {
4655
0
        Py_DECREF(match_case_annotations);
4656
0
        return 0;
4657
0
    }
4658
15
    Py_DECREF(match_case_annotations);
4659
15
    PyObject *MatchValue_annotations = PyDict_New();
4660
15
    if (!MatchValue_annotations) return 0;
4661
15
    {
4662
15
        PyObject *type = state->expr_type;
4663
15
        Py_INCREF(type);
4664
15
        cond = PyDict_SetItemString(MatchValue_annotations, "value", type) == 0;
4665
15
        Py_DECREF(type);
4666
15
        if (!cond) {
4667
0
            Py_DECREF(MatchValue_annotations);
4668
0
            return 0;
4669
0
        }
4670
15
    }
4671
15
    cond = PyObject_SetAttrString(state->MatchValue_type, "_field_types",
4672
15
                                  MatchValue_annotations) == 0;
4673
15
    if (!cond) {
4674
0
        Py_DECREF(MatchValue_annotations);
4675
0
        return 0;
4676
0
    }
4677
15
    cond = PyObject_SetAttrString(state->MatchValue_type, "__annotations__",
4678
15
                                  MatchValue_annotations) == 0;
4679
15
    if (!cond) {
4680
0
        Py_DECREF(MatchValue_annotations);
4681
0
        return 0;
4682
0
    }
4683
15
    Py_DECREF(MatchValue_annotations);
4684
15
    PyObject *MatchSingleton_annotations = PyDict_New();
4685
15
    if (!MatchSingleton_annotations) return 0;
4686
15
    {
4687
15
        PyObject *type = (PyObject *)&PyBaseObject_Type;
4688
15
        Py_INCREF(type);
4689
15
        cond = PyDict_SetItemString(MatchSingleton_annotations, "value", type)
4690
15
                                    == 0;
4691
15
        Py_DECREF(type);
4692
15
        if (!cond) {
4693
0
            Py_DECREF(MatchSingleton_annotations);
4694
0
            return 0;
4695
0
        }
4696
15
    }
4697
15
    cond = PyObject_SetAttrString(state->MatchSingleton_type, "_field_types",
4698
15
                                  MatchSingleton_annotations) == 0;
4699
15
    if (!cond) {
4700
0
        Py_DECREF(MatchSingleton_annotations);
4701
0
        return 0;
4702
0
    }
4703
15
    cond = PyObject_SetAttrString(state->MatchSingleton_type,
4704
15
                                  "__annotations__",
4705
15
                                  MatchSingleton_annotations) == 0;
4706
15
    if (!cond) {
4707
0
        Py_DECREF(MatchSingleton_annotations);
4708
0
        return 0;
4709
0
    }
4710
15
    Py_DECREF(MatchSingleton_annotations);
4711
15
    PyObject *MatchSequence_annotations = PyDict_New();
4712
15
    if (!MatchSequence_annotations) return 0;
4713
15
    {
4714
15
        PyObject *type = state->pattern_type;
4715
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4716
15
        cond = type != NULL;
4717
15
        if (!cond) {
4718
0
            Py_DECREF(MatchSequence_annotations);
4719
0
            return 0;
4720
0
        }
4721
15
        cond = PyDict_SetItemString(MatchSequence_annotations, "patterns",
4722
15
                                    type) == 0;
4723
15
        Py_DECREF(type);
4724
15
        if (!cond) {
4725
0
            Py_DECREF(MatchSequence_annotations);
4726
0
            return 0;
4727
0
        }
4728
15
    }
4729
15
    cond = PyObject_SetAttrString(state->MatchSequence_type, "_field_types",
4730
15
                                  MatchSequence_annotations) == 0;
4731
15
    if (!cond) {
4732
0
        Py_DECREF(MatchSequence_annotations);
4733
0
        return 0;
4734
0
    }
4735
15
    cond = PyObject_SetAttrString(state->MatchSequence_type, "__annotations__",
4736
15
                                  MatchSequence_annotations) == 0;
4737
15
    if (!cond) {
4738
0
        Py_DECREF(MatchSequence_annotations);
4739
0
        return 0;
4740
0
    }
4741
15
    Py_DECREF(MatchSequence_annotations);
4742
15
    PyObject *MatchMapping_annotations = PyDict_New();
4743
15
    if (!MatchMapping_annotations) return 0;
4744
15
    {
4745
15
        PyObject *type = state->expr_type;
4746
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4747
15
        cond = type != NULL;
4748
15
        if (!cond) {
4749
0
            Py_DECREF(MatchMapping_annotations);
4750
0
            return 0;
4751
0
        }
4752
15
        cond = PyDict_SetItemString(MatchMapping_annotations, "keys", type) ==
4753
15
                                    0;
4754
15
        Py_DECREF(type);
4755
15
        if (!cond) {
4756
0
            Py_DECREF(MatchMapping_annotations);
4757
0
            return 0;
4758
0
        }
4759
15
    }
4760
15
    {
4761
15
        PyObject *type = state->pattern_type;
4762
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4763
15
        cond = type != NULL;
4764
15
        if (!cond) {
4765
0
            Py_DECREF(MatchMapping_annotations);
4766
0
            return 0;
4767
0
        }
4768
15
        cond = PyDict_SetItemString(MatchMapping_annotations, "patterns", type)
4769
15
                                    == 0;
4770
15
        Py_DECREF(type);
4771
15
        if (!cond) {
4772
0
            Py_DECREF(MatchMapping_annotations);
4773
0
            return 0;
4774
0
        }
4775
15
    }
4776
15
    {
4777
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4778
15
        type = _Py_union_type_or(type, Py_None);
4779
15
        cond = type != NULL;
4780
15
        if (!cond) {
4781
0
            Py_DECREF(MatchMapping_annotations);
4782
0
            return 0;
4783
0
        }
4784
15
        cond = PyDict_SetItemString(MatchMapping_annotations, "rest", type) ==
4785
15
                                    0;
4786
15
        Py_DECREF(type);
4787
15
        if (!cond) {
4788
0
            Py_DECREF(MatchMapping_annotations);
4789
0
            return 0;
4790
0
        }
4791
15
    }
4792
15
    cond = PyObject_SetAttrString(state->MatchMapping_type, "_field_types",
4793
15
                                  MatchMapping_annotations) == 0;
4794
15
    if (!cond) {
4795
0
        Py_DECREF(MatchMapping_annotations);
4796
0
        return 0;
4797
0
    }
4798
15
    cond = PyObject_SetAttrString(state->MatchMapping_type, "__annotations__",
4799
15
                                  MatchMapping_annotations) == 0;
4800
15
    if (!cond) {
4801
0
        Py_DECREF(MatchMapping_annotations);
4802
0
        return 0;
4803
0
    }
4804
15
    Py_DECREF(MatchMapping_annotations);
4805
15
    PyObject *MatchClass_annotations = PyDict_New();
4806
15
    if (!MatchClass_annotations) return 0;
4807
15
    {
4808
15
        PyObject *type = state->expr_type;
4809
15
        Py_INCREF(type);
4810
15
        cond = PyDict_SetItemString(MatchClass_annotations, "cls", type) == 0;
4811
15
        Py_DECREF(type);
4812
15
        if (!cond) {
4813
0
            Py_DECREF(MatchClass_annotations);
4814
0
            return 0;
4815
0
        }
4816
15
    }
4817
15
    {
4818
15
        PyObject *type = state->pattern_type;
4819
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4820
15
        cond = type != NULL;
4821
15
        if (!cond) {
4822
0
            Py_DECREF(MatchClass_annotations);
4823
0
            return 0;
4824
0
        }
4825
15
        cond = PyDict_SetItemString(MatchClass_annotations, "patterns", type)
4826
15
                                    == 0;
4827
15
        Py_DECREF(type);
4828
15
        if (!cond) {
4829
0
            Py_DECREF(MatchClass_annotations);
4830
0
            return 0;
4831
0
        }
4832
15
    }
4833
15
    {
4834
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4835
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4836
15
        cond = type != NULL;
4837
15
        if (!cond) {
4838
0
            Py_DECREF(MatchClass_annotations);
4839
0
            return 0;
4840
0
        }
4841
15
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_attrs", type)
4842
15
                                    == 0;
4843
15
        Py_DECREF(type);
4844
15
        if (!cond) {
4845
0
            Py_DECREF(MatchClass_annotations);
4846
0
            return 0;
4847
0
        }
4848
15
    }
4849
15
    {
4850
15
        PyObject *type = state->pattern_type;
4851
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4852
15
        cond = type != NULL;
4853
15
        if (!cond) {
4854
0
            Py_DECREF(MatchClass_annotations);
4855
0
            return 0;
4856
0
        }
4857
15
        cond = PyDict_SetItemString(MatchClass_annotations, "kwd_patterns",
4858
15
                                    type) == 0;
4859
15
        Py_DECREF(type);
4860
15
        if (!cond) {
4861
0
            Py_DECREF(MatchClass_annotations);
4862
0
            return 0;
4863
0
        }
4864
15
    }
4865
15
    cond = PyObject_SetAttrString(state->MatchClass_type, "_field_types",
4866
15
                                  MatchClass_annotations) == 0;
4867
15
    if (!cond) {
4868
0
        Py_DECREF(MatchClass_annotations);
4869
0
        return 0;
4870
0
    }
4871
15
    cond = PyObject_SetAttrString(state->MatchClass_type, "__annotations__",
4872
15
                                  MatchClass_annotations) == 0;
4873
15
    if (!cond) {
4874
0
        Py_DECREF(MatchClass_annotations);
4875
0
        return 0;
4876
0
    }
4877
15
    Py_DECREF(MatchClass_annotations);
4878
15
    PyObject *MatchStar_annotations = PyDict_New();
4879
15
    if (!MatchStar_annotations) return 0;
4880
15
    {
4881
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4882
15
        type = _Py_union_type_or(type, Py_None);
4883
15
        cond = type != NULL;
4884
15
        if (!cond) {
4885
0
            Py_DECREF(MatchStar_annotations);
4886
0
            return 0;
4887
0
        }
4888
15
        cond = PyDict_SetItemString(MatchStar_annotations, "name", type) == 0;
4889
15
        Py_DECREF(type);
4890
15
        if (!cond) {
4891
0
            Py_DECREF(MatchStar_annotations);
4892
0
            return 0;
4893
0
        }
4894
15
    }
4895
15
    cond = PyObject_SetAttrString(state->MatchStar_type, "_field_types",
4896
15
                                  MatchStar_annotations) == 0;
4897
15
    if (!cond) {
4898
0
        Py_DECREF(MatchStar_annotations);
4899
0
        return 0;
4900
0
    }
4901
15
    cond = PyObject_SetAttrString(state->MatchStar_type, "__annotations__",
4902
15
                                  MatchStar_annotations) == 0;
4903
15
    if (!cond) {
4904
0
        Py_DECREF(MatchStar_annotations);
4905
0
        return 0;
4906
0
    }
4907
15
    Py_DECREF(MatchStar_annotations);
4908
15
    PyObject *MatchAs_annotations = PyDict_New();
4909
15
    if (!MatchAs_annotations) return 0;
4910
15
    {
4911
15
        PyObject *type = state->pattern_type;
4912
15
        type = _Py_union_type_or(type, Py_None);
4913
15
        cond = type != NULL;
4914
15
        if (!cond) {
4915
0
            Py_DECREF(MatchAs_annotations);
4916
0
            return 0;
4917
0
        }
4918
15
        cond = PyDict_SetItemString(MatchAs_annotations, "pattern", type) == 0;
4919
15
        Py_DECREF(type);
4920
15
        if (!cond) {
4921
0
            Py_DECREF(MatchAs_annotations);
4922
0
            return 0;
4923
0
        }
4924
15
    }
4925
15
    {
4926
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4927
15
        type = _Py_union_type_or(type, Py_None);
4928
15
        cond = type != NULL;
4929
15
        if (!cond) {
4930
0
            Py_DECREF(MatchAs_annotations);
4931
0
            return 0;
4932
0
        }
4933
15
        cond = PyDict_SetItemString(MatchAs_annotations, "name", type) == 0;
4934
15
        Py_DECREF(type);
4935
15
        if (!cond) {
4936
0
            Py_DECREF(MatchAs_annotations);
4937
0
            return 0;
4938
0
        }
4939
15
    }
4940
15
    cond = PyObject_SetAttrString(state->MatchAs_type, "_field_types",
4941
15
                                  MatchAs_annotations) == 0;
4942
15
    if (!cond) {
4943
0
        Py_DECREF(MatchAs_annotations);
4944
0
        return 0;
4945
0
    }
4946
15
    cond = PyObject_SetAttrString(state->MatchAs_type, "__annotations__",
4947
15
                                  MatchAs_annotations) == 0;
4948
15
    if (!cond) {
4949
0
        Py_DECREF(MatchAs_annotations);
4950
0
        return 0;
4951
0
    }
4952
15
    Py_DECREF(MatchAs_annotations);
4953
15
    PyObject *MatchOr_annotations = PyDict_New();
4954
15
    if (!MatchOr_annotations) return 0;
4955
15
    {
4956
15
        PyObject *type = state->pattern_type;
4957
15
        type = Py_GenericAlias((PyObject *)&PyList_Type, type);
4958
15
        cond = type != NULL;
4959
15
        if (!cond) {
4960
0
            Py_DECREF(MatchOr_annotations);
4961
0
            return 0;
4962
0
        }
4963
15
        cond = PyDict_SetItemString(MatchOr_annotations, "patterns", type) == 0;
4964
15
        Py_DECREF(type);
4965
15
        if (!cond) {
4966
0
            Py_DECREF(MatchOr_annotations);
4967
0
            return 0;
4968
0
        }
4969
15
    }
4970
15
    cond = PyObject_SetAttrString(state->MatchOr_type, "_field_types",
4971
15
                                  MatchOr_annotations) == 0;
4972
15
    if (!cond) {
4973
0
        Py_DECREF(MatchOr_annotations);
4974
0
        return 0;
4975
0
    }
4976
15
    cond = PyObject_SetAttrString(state->MatchOr_type, "__annotations__",
4977
15
                                  MatchOr_annotations) == 0;
4978
15
    if (!cond) {
4979
0
        Py_DECREF(MatchOr_annotations);
4980
0
        return 0;
4981
0
    }
4982
15
    Py_DECREF(MatchOr_annotations);
4983
15
    PyObject *TypeIgnore_annotations = PyDict_New();
4984
15
    if (!TypeIgnore_annotations) return 0;
4985
15
    {
4986
15
        PyObject *type = (PyObject *)&PyLong_Type;
4987
15
        Py_INCREF(type);
4988
15
        cond = PyDict_SetItemString(TypeIgnore_annotations, "lineno", type) ==
4989
15
                                    0;
4990
15
        Py_DECREF(type);
4991
15
        if (!cond) {
4992
0
            Py_DECREF(TypeIgnore_annotations);
4993
0
            return 0;
4994
0
        }
4995
15
    }
4996
15
    {
4997
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
4998
15
        Py_INCREF(type);
4999
15
        cond = PyDict_SetItemString(TypeIgnore_annotations, "tag", type) == 0;
5000
15
        Py_DECREF(type);
5001
15
        if (!cond) {
5002
0
            Py_DECREF(TypeIgnore_annotations);
5003
0
            return 0;
5004
0
        }
5005
15
    }
5006
15
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "_field_types",
5007
15
                                  TypeIgnore_annotations) == 0;
5008
15
    if (!cond) {
5009
0
        Py_DECREF(TypeIgnore_annotations);
5010
0
        return 0;
5011
0
    }
5012
15
    cond = PyObject_SetAttrString(state->TypeIgnore_type, "__annotations__",
5013
15
                                  TypeIgnore_annotations) == 0;
5014
15
    if (!cond) {
5015
0
        Py_DECREF(TypeIgnore_annotations);
5016
0
        return 0;
5017
0
    }
5018
15
    Py_DECREF(TypeIgnore_annotations);
5019
15
    PyObject *TypeVar_annotations = PyDict_New();
5020
15
    if (!TypeVar_annotations) return 0;
5021
15
    {
5022
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
5023
15
        Py_INCREF(type);
5024
15
        cond = PyDict_SetItemString(TypeVar_annotations, "name", type) == 0;
5025
15
        Py_DECREF(type);
5026
15
        if (!cond) {
5027
0
            Py_DECREF(TypeVar_annotations);
5028
0
            return 0;
5029
0
        }
5030
15
    }
5031
15
    {
5032
15
        PyObject *type = state->expr_type;
5033
15
        type = _Py_union_type_or(type, Py_None);
5034
15
        cond = type != NULL;
5035
15
        if (!cond) {
5036
0
            Py_DECREF(TypeVar_annotations);
5037
0
            return 0;
5038
0
        }
5039
15
        cond = PyDict_SetItemString(TypeVar_annotations, "bound", type) == 0;
5040
15
        Py_DECREF(type);
5041
15
        if (!cond) {
5042
0
            Py_DECREF(TypeVar_annotations);
5043
0
            return 0;
5044
0
        }
5045
15
    }
5046
15
    {
5047
15
        PyObject *type = state->expr_type;
5048
15
        type = _Py_union_type_or(type, Py_None);
5049
15
        cond = type != NULL;
5050
15
        if (!cond) {
5051
0
            Py_DECREF(TypeVar_annotations);
5052
0
            return 0;
5053
0
        }
5054
15
        cond = PyDict_SetItemString(TypeVar_annotations, "default_value", type)
5055
15
                                    == 0;
5056
15
        Py_DECREF(type);
5057
15
        if (!cond) {
5058
0
            Py_DECREF(TypeVar_annotations);
5059
0
            return 0;
5060
0
        }
5061
15
    }
5062
15
    cond = PyObject_SetAttrString(state->TypeVar_type, "_field_types",
5063
15
                                  TypeVar_annotations) == 0;
5064
15
    if (!cond) {
5065
0
        Py_DECREF(TypeVar_annotations);
5066
0
        return 0;
5067
0
    }
5068
15
    cond = PyObject_SetAttrString(state->TypeVar_type, "__annotations__",
5069
15
                                  TypeVar_annotations) == 0;
5070
15
    if (!cond) {
5071
0
        Py_DECREF(TypeVar_annotations);
5072
0
        return 0;
5073
0
    }
5074
15
    Py_DECREF(TypeVar_annotations);
5075
15
    PyObject *ParamSpec_annotations = PyDict_New();
5076
15
    if (!ParamSpec_annotations) return 0;
5077
15
    {
5078
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
5079
15
        Py_INCREF(type);
5080
15
        cond = PyDict_SetItemString(ParamSpec_annotations, "name", type) == 0;
5081
15
        Py_DECREF(type);
5082
15
        if (!cond) {
5083
0
            Py_DECREF(ParamSpec_annotations);
5084
0
            return 0;
5085
0
        }
5086
15
    }
5087
15
    {
5088
15
        PyObject *type = state->expr_type;
5089
15
        type = _Py_union_type_or(type, Py_None);
5090
15
        cond = type != NULL;
5091
15
        if (!cond) {
5092
0
            Py_DECREF(ParamSpec_annotations);
5093
0
            return 0;
5094
0
        }
5095
15
        cond = PyDict_SetItemString(ParamSpec_annotations, "default_value",
5096
15
                                    type) == 0;
5097
15
        Py_DECREF(type);
5098
15
        if (!cond) {
5099
0
            Py_DECREF(ParamSpec_annotations);
5100
0
            return 0;
5101
0
        }
5102
15
    }
5103
15
    cond = PyObject_SetAttrString(state->ParamSpec_type, "_field_types",
5104
15
                                  ParamSpec_annotations) == 0;
5105
15
    if (!cond) {
5106
0
        Py_DECREF(ParamSpec_annotations);
5107
0
        return 0;
5108
0
    }
5109
15
    cond = PyObject_SetAttrString(state->ParamSpec_type, "__annotations__",
5110
15
                                  ParamSpec_annotations) == 0;
5111
15
    if (!cond) {
5112
0
        Py_DECREF(ParamSpec_annotations);
5113
0
        return 0;
5114
0
    }
5115
15
    Py_DECREF(ParamSpec_annotations);
5116
15
    PyObject *TypeVarTuple_annotations = PyDict_New();
5117
15
    if (!TypeVarTuple_annotations) return 0;
5118
15
    {
5119
15
        PyObject *type = (PyObject *)&PyUnicode_Type;
5120
15
        Py_INCREF(type);
5121
15
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "name", type) ==
5122
15
                                    0;
5123
15
        Py_DECREF(type);
5124
15
        if (!cond) {
5125
0
            Py_DECREF(TypeVarTuple_annotations);
5126
0
            return 0;
5127
0
        }
5128
15
    }
5129
15
    {
5130
15
        PyObject *type = state->expr_type;
5131
15
        type = _Py_union_type_or(type, Py_None);
5132
15
        cond = type != NULL;
5133
15
        if (!cond) {
5134
0
            Py_DECREF(TypeVarTuple_annotations);
5135
0
            return 0;
5136
0
        }
5137
15
        cond = PyDict_SetItemString(TypeVarTuple_annotations, "default_value",
5138
15
                                    type) == 0;
5139
15
        Py_DECREF(type);
5140
15
        if (!cond) {
5141
0
            Py_DECREF(TypeVarTuple_annotations);
5142
0
            return 0;
5143
0
        }
5144
15
    }
5145
15
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "_field_types",
5146
15
                                  TypeVarTuple_annotations) == 0;
5147
15
    if (!cond) {
5148
0
        Py_DECREF(TypeVarTuple_annotations);
5149
0
        return 0;
5150
0
    }
5151
15
    cond = PyObject_SetAttrString(state->TypeVarTuple_type, "__annotations__",
5152
15
                                  TypeVarTuple_annotations) == 0;
5153
15
    if (!cond) {
5154
0
        Py_DECREF(TypeVarTuple_annotations);
5155
0
        return 0;
5156
0
    }
5157
15
    Py_DECREF(TypeVarTuple_annotations);
5158
5159
15
    return 1;
5160
15
}
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
380k
{
5172
380k
    AST_object *self = (AST_object*)op;
5173
    /* bpo-31095: UnTrack is needed before calling any callbacks */
5174
380k
    PyTypeObject *tp = Py_TYPE(self);
5175
380k
    PyObject_GC_UnTrack(self);
5176
380k
    Py_CLEAR(self->dict);
5177
380k
    freefunc free_func = PyType_GetSlot(tp, Py_tp_free);
5178
380k
    assert(free_func != NULL);
5179
380k
    free_func(self);
5180
380k
    Py_DECREF(tp);
5181
380k
}
5182
5183
static int
5184
ast_traverse(PyObject *op, visitproc visit, void *arg)
5185
120k
{
5186
120k
    AST_object *self = (AST_object*)op;
5187
120k
    Py_VISIT(Py_TYPE(self));
5188
120k
    Py_VISIT(self->dict);
5189
120k
    return 0;
5190
120k
}
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
312
{
5203
312
    struct ast_state *state = get_ast_state();
5204
312
    if (state == NULL) {
5205
0
        return -1;
5206
0
    }
5207
5208
312
    Py_ssize_t i, numfields = 0;
5209
312
    int res = -1;
5210
312
    PyObject *key, *value, *fields, *attributes = NULL, *remaining_fields = NULL;
5211
5212
312
    fields = PyObject_GetAttr((PyObject*)Py_TYPE(self), state->_fields);
5213
312
    if (fields == NULL) {
5214
0
        goto cleanup;
5215
0
    }
5216
5217
312
    numfields = PySequence_Size(fields);
5218
312
    if (numfields == -1) {
5219
0
        goto cleanup;
5220
0
    }
5221
312
    remaining_fields = PySet_New(fields);
5222
312
    if (remaining_fields == NULL) {
5223
0
        goto cleanup;
5224
0
    }
5225
5226
312
    res = 0; /* if no error occurs, this stays 0 to the end */
5227
312
    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
378
    for (i = 0; i < PyTuple_GET_SIZE(args); i++) {
5236
        /* cannot be reached when fields is NULL */
5237
66
        PyObject *name = PySequence_GetItem(fields, i);
5238
66
        if (!name) {
5239
0
            res = -1;
5240
0
            goto cleanup;
5241
0
        }
5242
66
        res = PyObject_SetAttr(self, name, PyTuple_GET_ITEM(args, i));
5243
66
        if (PySet_Discard(remaining_fields, name) < 0) {
5244
0
            res = -1;
5245
0
            Py_DECREF(name);
5246
0
            goto cleanup;
5247
0
        }
5248
66
        Py_DECREF(name);
5249
66
        if (res < 0) {
5250
0
            goto cleanup;
5251
0
        }
5252
66
    }
5253
312
    if (kw) {
5254
66
        i = 0;  /* needed by PyDict_Next */
5255
132
        while (PyDict_Next(kw, &i, &key, &value)) {
5256
66
            int contains = PySequence_Contains(fields, key);
5257
66
            if (contains == -1) {
5258
0
                res = -1;
5259
0
                goto cleanup;
5260
0
            }
5261
66
            else if (contains == 1) {
5262
66
                int p = PySet_Discard(remaining_fields, key);
5263
66
                if (p == -1) {
5264
0
                    res = -1;
5265
0
                    goto cleanup;
5266
0
                }
5267
66
                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
66
            }
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
66
            res = PyObject_SetAttr(self, key, value);
5303
66
            if (res < 0) {
5304
0
                goto cleanup;
5305
0
            }
5306
66
        }
5307
66
    }
5308
312
    Py_ssize_t size = PySet_Size(remaining_fields);
5309
312
    PyObject *field_types = NULL, *remaining_list = NULL;
5310
312
    if (size > 0) {
5311
102
        if (PyObject_GetOptionalAttr((PyObject*)Py_TYPE(self), &_Py_ID(_field_types),
5312
102
                                     &field_types) < 0) {
5313
0
            res = -1;
5314
0
            goto cleanup;
5315
0
        }
5316
102
        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
102
        remaining_list = PySequence_List(remaining_fields);
5323
102
        if (!remaining_list) {
5324
0
            goto set_remaining_cleanup;
5325
0
        }
5326
204
        for (Py_ssize_t i = 0; i < size; i++) {
5327
102
            PyObject *name = PyList_GET_ITEM(remaining_list, i);
5328
102
            PyObject *type = PyDict_GetItemWithError(field_types, name);
5329
102
            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
102
            else if (_PyUnion_Check(type)) {
5345
                // optional field
5346
                // do nothing, we'll have set a None default on the class
5347
12
            }
5348
90
            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
90
            else if (type == state->expr_context_type) {
5361
                // special case for expr_context: default to Load()
5362
90
                res = PyObject_SetAttr(self, name, state->Load_singleton);
5363
90
                if (res < 0) {
5364
0
                    goto set_remaining_cleanup;
5365
0
                }
5366
90
            }
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
102
        }
5379
102
        Py_DECREF(remaining_list);
5380
102
        Py_DECREF(field_types);
5381
102
    }
5382
312
  cleanup:
5383
312
    Py_XDECREF(attributes);
5384
312
    Py_XDECREF(fields);
5385
312
    Py_XDECREF(remaining_fields);
5386
312
    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
312
}
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.87k
{
6042
1.87k
    PyObject *fnames, *result;
6043
1.87k
    int i;
6044
1.87k
    fnames = PyTuple_New(num_fields);
6045
1.87k
    if (!fnames) return NULL;
6046
4.84k
    for (i = 0; i < num_fields; i++) {
6047
2.97k
        PyObject *field = PyUnicode_InternFromString(fields[i]);
6048
2.97k
        if (!field) {
6049
0
            Py_DECREF(fnames);
6050
0
            return NULL;
6051
0
        }
6052
2.97k
        PyTuple_SET_ITEM(fnames, i, field);
6053
2.97k
    }
6054
1.87k
    result = PyObject_CallFunction((PyObject*)&PyType_Type, "s(O){OOOOOOOs}",
6055
1.87k
                    type, base,
6056
1.87k
                    state->_fields, fnames,
6057
1.87k
                    state->__match_args__, fnames,
6058
1.87k
                    state->__module__,
6059
1.87k
                    state->ast,
6060
1.87k
                    state->__doc__, doc);
6061
1.87k
    Py_DECREF(fnames);
6062
1.87k
    return result;
6063
1.87k
}
6064
6065
static int
6066
add_attributes(struct ast_state *state, PyObject *type, const char * const *attrs, int num_fields)
6067
285
{
6068
285
    int i, result;
6069
285
    PyObject *s, *l = PyTuple_New(num_fields);
6070
285
    if (!l)
6071
0
        return -1;
6072
765
    for (i = 0; i < num_fields; i++) {
6073
480
        s = PyUnicode_InternFromString(attrs[i]);
6074
480
        if (!s) {
6075
0
            Py_DECREF(l);
6076
0
            return -1;
6077
0
        }
6078
480
        PyTuple_SET_ITEM(l, i, s);
6079
480
    }
6080
285
    result = PyObject_SetAttr(type, state->_attributes, l);
6081
285
    Py_DECREF(l);
6082
285
    return result;
6083
285
}
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
88.2k
{
6090
88.2k
    Py_ssize_t i, n = asdl_seq_LEN(seq);
6091
88.2k
    PyObject *result = PyList_New(n);
6092
88.2k
    PyObject *value;
6093
88.2k
    if (!result)
6094
0
        return NULL;
6095
228k
    for (i = 0; i < n; i++) {
6096
140k
        value = func(state, asdl_seq_GET_UNTYPED(seq, i));
6097
140k
        if (!value) {
6098
0
            Py_DECREF(result);
6099
0
            return NULL;
6100
0
        }
6101
140k
        PyList_SET_ITEM(result, i, value);
6102
140k
    }
6103
88.2k
    return result;
6104
88.2k
}
6105
6106
static PyObject* ast2obj_object(struct ast_state *Py_UNUSED(state), void *o)
6107
228k
{
6108
228k
    PyObject *op = (PyObject*)o;
6109
228k
    if (!op) {
6110
79.6k
        op = Py_None;
6111
79.6k
    }
6112
228k
    return Py_NewRef(op);
6113
228k
}
6114
54.2k
#define ast2obj_constant ast2obj_object
6115
103k
#define ast2obj_identifier ast2obj_object
6116
70.4k
#define ast2obj_string ast2obj_object
6117
6118
static PyObject* ast2obj_int(struct ast_state *Py_UNUSED(state), long b)
6119
1.49M
{
6120
1.49M
    return PyLong_FromLong(b);
6121
1.49M
}
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
15
{
6187
15
    PyObject *empty_tuple;
6188
15
    empty_tuple = PyTuple_New(0);
6189
15
    if (!empty_tuple ||
6190
15
        PyObject_SetAttrString(state->AST_type, "_fields", empty_tuple) < 0 ||
6191
15
        PyObject_SetAttrString(state->AST_type, "__match_args__", empty_tuple) < 0 ||
6192
15
        PyObject_SetAttrString(state->AST_type, "_attributes", empty_tuple) < 0) {
6193
0
        Py_XDECREF(empty_tuple);
6194
0
        return -1;
6195
0
    }
6196
15
    Py_DECREF(empty_tuple);
6197
15
    return 0;
6198
15
}
6199
6200
6201
6202
static int
6203
init_types(void *arg)
6204
15
{
6205
15
    struct ast_state *state = arg;
6206
15
    if (init_identifiers(state) < 0) {
6207
0
        return -1;
6208
0
    }
6209
15
    state->AST_type = PyType_FromSpec(&AST_type_spec);
6210
15
    if (!state->AST_type) {
6211
0
        return -1;
6212
0
    }
6213
15
    if (add_ast_fields(state) < 0) {
6214
0
        return -1;
6215
0
    }
6216
15
    state->mod_type = make_type(state, "mod", state->AST_type, NULL, 0,
6217
15
        "mod = Module(stmt* body, type_ignore* type_ignores)\n"
6218
15
        "    | Interactive(stmt* body)\n"
6219
15
        "    | Expression(expr body)\n"
6220
15
        "    | FunctionType(expr* argtypes, expr returns)");
6221
15
    if (!state->mod_type) return -1;
6222
15
    if (add_attributes(state, state->mod_type, NULL, 0) < 0) return -1;
6223
15
    state->Module_type = make_type(state, "Module", state->mod_type,
6224
15
                                   Module_fields, 2,
6225
15
        "Module(stmt* body, type_ignore* type_ignores)");
6226
15
    if (!state->Module_type) return -1;
6227
15
    state->Interactive_type = make_type(state, "Interactive", state->mod_type,
6228
15
                                        Interactive_fields, 1,
6229
15
        "Interactive(stmt* body)");
6230
15
    if (!state->Interactive_type) return -1;
6231
15
    state->Expression_type = make_type(state, "Expression", state->mod_type,
6232
15
                                       Expression_fields, 1,
6233
15
        "Expression(expr body)");
6234
15
    if (!state->Expression_type) return -1;
6235
15
    state->FunctionType_type = make_type(state, "FunctionType",
6236
15
                                         state->mod_type, FunctionType_fields,
6237
15
                                         2,
6238
15
        "FunctionType(expr* argtypes, expr returns)");
6239
15
    if (!state->FunctionType_type) return -1;
6240
15
    state->stmt_type = make_type(state, "stmt", state->AST_type, NULL, 0,
6241
15
        "stmt = FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6242
15
        "     | AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)\n"
6243
15
        "     | ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)\n"
6244
15
        "     | Return(expr? value)\n"
6245
15
        "     | Delete(expr* targets)\n"
6246
15
        "     | Assign(expr* targets, expr value, string? type_comment)\n"
6247
15
        "     | TypeAlias(expr name, type_param* type_params, expr value)\n"
6248
15
        "     | AugAssign(expr target, operator op, expr value)\n"
6249
15
        "     | AnnAssign(expr target, expr annotation, expr? value, int simple)\n"
6250
15
        "     | For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6251
15
        "     | AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)\n"
6252
15
        "     | While(expr test, stmt* body, stmt* orelse)\n"
6253
15
        "     | If(expr test, stmt* body, stmt* orelse)\n"
6254
15
        "     | With(withitem* items, stmt* body, string? type_comment)\n"
6255
15
        "     | AsyncWith(withitem* items, stmt* body, string? type_comment)\n"
6256
15
        "     | Match(expr subject, match_case* cases)\n"
6257
15
        "     | Raise(expr? exc, expr? cause)\n"
6258
15
        "     | Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6259
15
        "     | TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)\n"
6260
15
        "     | Assert(expr test, expr? msg)\n"
6261
15
        "     | Import(alias* names, int? is_lazy)\n"
6262
15
        "     | ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)\n"
6263
15
        "     | Global(identifier* names)\n"
6264
15
        "     | Nonlocal(identifier* names)\n"
6265
15
        "     | Expr(expr value)\n"
6266
15
        "     | Pass\n"
6267
15
        "     | Break\n"
6268
15
        "     | Continue");
6269
15
    if (!state->stmt_type) return -1;
6270
15
    if (add_attributes(state, state->stmt_type, stmt_attributes, 4) < 0) return
6271
0
        -1;
6272
15
    if (PyObject_SetAttr(state->stmt_type, state->end_lineno, Py_None) == -1)
6273
0
        return -1;
6274
15
    if (PyObject_SetAttr(state->stmt_type, state->end_col_offset, Py_None) ==
6275
15
        -1)
6276
0
        return -1;
6277
15
    state->FunctionDef_type = make_type(state, "FunctionDef", state->stmt_type,
6278
15
                                        FunctionDef_fields, 7,
6279
15
        "FunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6280
15
    if (!state->FunctionDef_type) return -1;
6281
15
    if (PyObject_SetAttr(state->FunctionDef_type, state->returns, Py_None) ==
6282
15
        -1)
6283
0
        return -1;
6284
15
    if (PyObject_SetAttr(state->FunctionDef_type, state->type_comment, Py_None)
6285
15
        == -1)
6286
0
        return -1;
6287
15
    state->AsyncFunctionDef_type = make_type(state, "AsyncFunctionDef",
6288
15
                                             state->stmt_type,
6289
15
                                             AsyncFunctionDef_fields, 7,
6290
15
        "AsyncFunctionDef(identifier name, arguments args, stmt* body, expr* decorator_list, expr? returns, string? type_comment, type_param* type_params)");
6291
15
    if (!state->AsyncFunctionDef_type) return -1;
6292
15
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->returns, Py_None)
6293
15
        == -1)
6294
0
        return -1;
6295
15
    if (PyObject_SetAttr(state->AsyncFunctionDef_type, state->type_comment,
6296
15
        Py_None) == -1)
6297
0
        return -1;
6298
15
    state->ClassDef_type = make_type(state, "ClassDef", state->stmt_type,
6299
15
                                     ClassDef_fields, 6,
6300
15
        "ClassDef(identifier name, expr* bases, keyword* keywords, stmt* body, expr* decorator_list, type_param* type_params)");
6301
15
    if (!state->ClassDef_type) return -1;
6302
15
    state->Return_type = make_type(state, "Return", state->stmt_type,
6303
15
                                   Return_fields, 1,
6304
15
        "Return(expr? value)");
6305
15
    if (!state->Return_type) return -1;
6306
15
    if (PyObject_SetAttr(state->Return_type, state->value, Py_None) == -1)
6307
0
        return -1;
6308
15
    state->Delete_type = make_type(state, "Delete", state->stmt_type,
6309
15
                                   Delete_fields, 1,
6310
15
        "Delete(expr* targets)");
6311
15
    if (!state->Delete_type) return -1;
6312
15
    state->Assign_type = make_type(state, "Assign", state->stmt_type,
6313
15
                                   Assign_fields, 3,
6314
15
        "Assign(expr* targets, expr value, string? type_comment)");
6315
15
    if (!state->Assign_type) return -1;
6316
15
    if (PyObject_SetAttr(state->Assign_type, state->type_comment, Py_None) ==
6317
15
        -1)
6318
0
        return -1;
6319
15
    state->TypeAlias_type = make_type(state, "TypeAlias", state->stmt_type,
6320
15
                                      TypeAlias_fields, 3,
6321
15
        "TypeAlias(expr name, type_param* type_params, expr value)");
6322
15
    if (!state->TypeAlias_type) return -1;
6323
15
    state->AugAssign_type = make_type(state, "AugAssign", state->stmt_type,
6324
15
                                      AugAssign_fields, 3,
6325
15
        "AugAssign(expr target, operator op, expr value)");
6326
15
    if (!state->AugAssign_type) return -1;
6327
15
    state->AnnAssign_type = make_type(state, "AnnAssign", state->stmt_type,
6328
15
                                      AnnAssign_fields, 4,
6329
15
        "AnnAssign(expr target, expr annotation, expr? value, int simple)");
6330
15
    if (!state->AnnAssign_type) return -1;
6331
15
    if (PyObject_SetAttr(state->AnnAssign_type, state->value, Py_None) == -1)
6332
0
        return -1;
6333
15
    state->For_type = make_type(state, "For", state->stmt_type, For_fields, 5,
6334
15
        "For(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6335
15
    if (!state->For_type) return -1;
6336
15
    if (PyObject_SetAttr(state->For_type, state->type_comment, Py_None) == -1)
6337
0
        return -1;
6338
15
    state->AsyncFor_type = make_type(state, "AsyncFor", state->stmt_type,
6339
15
                                     AsyncFor_fields, 5,
6340
15
        "AsyncFor(expr target, expr iter, stmt* body, stmt* orelse, string? type_comment)");
6341
15
    if (!state->AsyncFor_type) return -1;
6342
15
    if (PyObject_SetAttr(state->AsyncFor_type, state->type_comment, Py_None) ==
6343
15
        -1)
6344
0
        return -1;
6345
15
    state->While_type = make_type(state, "While", state->stmt_type,
6346
15
                                  While_fields, 3,
6347
15
        "While(expr test, stmt* body, stmt* orelse)");
6348
15
    if (!state->While_type) return -1;
6349
15
    state->If_type = make_type(state, "If", state->stmt_type, If_fields, 3,
6350
15
        "If(expr test, stmt* body, stmt* orelse)");
6351
15
    if (!state->If_type) return -1;
6352
15
    state->With_type = make_type(state, "With", state->stmt_type, With_fields,
6353
15
                                 3,
6354
15
        "With(withitem* items, stmt* body, string? type_comment)");
6355
15
    if (!state->With_type) return -1;
6356
15
    if (PyObject_SetAttr(state->With_type, state->type_comment, Py_None) == -1)
6357
0
        return -1;
6358
15
    state->AsyncWith_type = make_type(state, "AsyncWith", state->stmt_type,
6359
15
                                      AsyncWith_fields, 3,
6360
15
        "AsyncWith(withitem* items, stmt* body, string? type_comment)");
6361
15
    if (!state->AsyncWith_type) return -1;
6362
15
    if (PyObject_SetAttr(state->AsyncWith_type, state->type_comment, Py_None)
6363
15
        == -1)
6364
0
        return -1;
6365
15
    state->Match_type = make_type(state, "Match", state->stmt_type,
6366
15
                                  Match_fields, 2,
6367
15
        "Match(expr subject, match_case* cases)");
6368
15
    if (!state->Match_type) return -1;
6369
15
    state->Raise_type = make_type(state, "Raise", state->stmt_type,
6370
15
                                  Raise_fields, 2,
6371
15
        "Raise(expr? exc, expr? cause)");
6372
15
    if (!state->Raise_type) return -1;
6373
15
    if (PyObject_SetAttr(state->Raise_type, state->exc, Py_None) == -1)
6374
0
        return -1;
6375
15
    if (PyObject_SetAttr(state->Raise_type, state->cause, Py_None) == -1)
6376
0
        return -1;
6377
15
    state->Try_type = make_type(state, "Try", state->stmt_type, Try_fields, 4,
6378
15
        "Try(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6379
15
    if (!state->Try_type) return -1;
6380
15
    state->TryStar_type = make_type(state, "TryStar", state->stmt_type,
6381
15
                                    TryStar_fields, 4,
6382
15
        "TryStar(stmt* body, excepthandler* handlers, stmt* orelse, stmt* finalbody)");
6383
15
    if (!state->TryStar_type) return -1;
6384
15
    state->Assert_type = make_type(state, "Assert", state->stmt_type,
6385
15
                                   Assert_fields, 2,
6386
15
        "Assert(expr test, expr? msg)");
6387
15
    if (!state->Assert_type) return -1;
6388
15
    if (PyObject_SetAttr(state->Assert_type, state->msg, Py_None) == -1)
6389
0
        return -1;
6390
15
    state->Import_type = make_type(state, "Import", state->stmt_type,
6391
15
                                   Import_fields, 2,
6392
15
        "Import(alias* names, int? is_lazy)");
6393
15
    if (!state->Import_type) return -1;
6394
15
    if (PyObject_SetAttr(state->Import_type, state->is_lazy, Py_None) == -1)
6395
0
        return -1;
6396
15
    state->ImportFrom_type = make_type(state, "ImportFrom", state->stmt_type,
6397
15
                                       ImportFrom_fields, 4,
6398
15
        "ImportFrom(identifier? module, alias* names, int? level, int? is_lazy)");
6399
15
    if (!state->ImportFrom_type) return -1;
6400
15
    if (PyObject_SetAttr(state->ImportFrom_type, state->module, Py_None) == -1)
6401
0
        return -1;
6402
15
    if (PyObject_SetAttr(state->ImportFrom_type, state->level, Py_None) == -1)
6403
0
        return -1;
6404
15
    if (PyObject_SetAttr(state->ImportFrom_type, state->is_lazy, Py_None) == -1)
6405
0
        return -1;
6406
15
    state->Global_type = make_type(state, "Global", state->stmt_type,
6407
15
                                   Global_fields, 1,
6408
15
        "Global(identifier* names)");
6409
15
    if (!state->Global_type) return -1;
6410
15
    state->Nonlocal_type = make_type(state, "Nonlocal", state->stmt_type,
6411
15
                                     Nonlocal_fields, 1,
6412
15
        "Nonlocal(identifier* names)");
6413
15
    if (!state->Nonlocal_type) return -1;
6414
15
    state->Expr_type = make_type(state, "Expr", state->stmt_type, Expr_fields,
6415
15
                                 1,
6416
15
        "Expr(expr value)");
6417
15
    if (!state->Expr_type) return -1;
6418
15
    state->Pass_type = make_type(state, "Pass", state->stmt_type, NULL, 0,
6419
15
        "Pass");
6420
15
    if (!state->Pass_type) return -1;
6421
15
    state->Break_type = make_type(state, "Break", state->stmt_type, NULL, 0,
6422
15
        "Break");
6423
15
    if (!state->Break_type) return -1;
6424
15
    state->Continue_type = make_type(state, "Continue", state->stmt_type, NULL,
6425
15
                                     0,
6426
15
        "Continue");
6427
15
    if (!state->Continue_type) return -1;
6428
15
    state->expr_type = make_type(state, "expr", state->AST_type, NULL, 0,
6429
15
        "expr = BoolOp(boolop op, expr* values)\n"
6430
15
        "     | NamedExpr(expr target, expr value)\n"
6431
15
        "     | BinOp(expr left, operator op, expr right)\n"
6432
15
        "     | UnaryOp(unaryop op, expr operand)\n"
6433
15
        "     | Lambda(arguments args, expr body)\n"
6434
15
        "     | IfExp(expr test, expr body, expr orelse)\n"
6435
15
        "     | Dict(expr?* keys, expr* values)\n"
6436
15
        "     | Set(expr* elts)\n"
6437
15
        "     | ListComp(expr elt, comprehension* generators)\n"
6438
15
        "     | SetComp(expr elt, comprehension* generators)\n"
6439
15
        "     | DictComp(expr key, expr? value, comprehension* generators)\n"
6440
15
        "     | GeneratorExp(expr elt, comprehension* generators)\n"
6441
15
        "     | Await(expr value)\n"
6442
15
        "     | Yield(expr? value)\n"
6443
15
        "     | YieldFrom(expr value)\n"
6444
15
        "     | Compare(expr left, cmpop* ops, expr* comparators)\n"
6445
15
        "     | Call(expr func, expr* args, keyword* keywords)\n"
6446
15
        "     | FormattedValue(expr value, int conversion, expr? format_spec)\n"
6447
15
        "     | Interpolation(expr value, constant str, int conversion, expr? format_spec)\n"
6448
15
        "     | JoinedStr(expr* values)\n"
6449
15
        "     | TemplateStr(expr* values)\n"
6450
15
        "     | Constant(constant value, string? kind)\n"
6451
15
        "     | Attribute(expr value, identifier attr, expr_context ctx)\n"
6452
15
        "     | Subscript(expr value, expr slice, expr_context ctx)\n"
6453
15
        "     | Starred(expr value, expr_context ctx)\n"
6454
15
        "     | Name(identifier id, expr_context ctx)\n"
6455
15
        "     | List(expr* elts, expr_context ctx)\n"
6456
15
        "     | Tuple(expr* elts, expr_context ctx)\n"
6457
15
        "     | Slice(expr? lower, expr? upper, expr? step)");
6458
15
    if (!state->expr_type) return -1;
6459
15
    if (add_attributes(state, state->expr_type, expr_attributes, 4) < 0) return
6460
0
        -1;
6461
15
    if (PyObject_SetAttr(state->expr_type, state->end_lineno, Py_None) == -1)
6462
0
        return -1;
6463
15
    if (PyObject_SetAttr(state->expr_type, state->end_col_offset, Py_None) ==
6464
15
        -1)
6465
0
        return -1;
6466
15
    state->BoolOp_type = make_type(state, "BoolOp", state->expr_type,
6467
15
                                   BoolOp_fields, 2,
6468
15
        "BoolOp(boolop op, expr* values)");
6469
15
    if (!state->BoolOp_type) return -1;
6470
15
    state->NamedExpr_type = make_type(state, "NamedExpr", state->expr_type,
6471
15
                                      NamedExpr_fields, 2,
6472
15
        "NamedExpr(expr target, expr value)");
6473
15
    if (!state->NamedExpr_type) return -1;
6474
15
    state->BinOp_type = make_type(state, "BinOp", state->expr_type,
6475
15
                                  BinOp_fields, 3,
6476
15
        "BinOp(expr left, operator op, expr right)");
6477
15
    if (!state->BinOp_type) return -1;
6478
15
    state->UnaryOp_type = make_type(state, "UnaryOp", state->expr_type,
6479
15
                                    UnaryOp_fields, 2,
6480
15
        "UnaryOp(unaryop op, expr operand)");
6481
15
    if (!state->UnaryOp_type) return -1;
6482
15
    state->Lambda_type = make_type(state, "Lambda", state->expr_type,
6483
15
                                   Lambda_fields, 2,
6484
15
        "Lambda(arguments args, expr body)");
6485
15
    if (!state->Lambda_type) return -1;
6486
15
    state->IfExp_type = make_type(state, "IfExp", state->expr_type,
6487
15
                                  IfExp_fields, 3,
6488
15
        "IfExp(expr test, expr body, expr orelse)");
6489
15
    if (!state->IfExp_type) return -1;
6490
15
    state->Dict_type = make_type(state, "Dict", state->expr_type, Dict_fields,
6491
15
                                 2,
6492
15
        "Dict(expr?* keys, expr* values)");
6493
15
    if (!state->Dict_type) return -1;
6494
15
    state->Set_type = make_type(state, "Set", state->expr_type, Set_fields, 1,
6495
15
        "Set(expr* elts)");
6496
15
    if (!state->Set_type) return -1;
6497
15
    state->ListComp_type = make_type(state, "ListComp", state->expr_type,
6498
15
                                     ListComp_fields, 2,
6499
15
        "ListComp(expr elt, comprehension* generators)");
6500
15
    if (!state->ListComp_type) return -1;
6501
15
    state->SetComp_type = make_type(state, "SetComp", state->expr_type,
6502
15
                                    SetComp_fields, 2,
6503
15
        "SetComp(expr elt, comprehension* generators)");
6504
15
    if (!state->SetComp_type) return -1;
6505
15
    state->DictComp_type = make_type(state, "DictComp", state->expr_type,
6506
15
                                     DictComp_fields, 3,
6507
15
        "DictComp(expr key, expr? value, comprehension* generators)");
6508
15
    if (!state->DictComp_type) return -1;
6509
15
    if (PyObject_SetAttr(state->DictComp_type, state->value, Py_None) == -1)
6510
0
        return -1;
6511
15
    state->GeneratorExp_type = make_type(state, "GeneratorExp",
6512
15
                                         state->expr_type, GeneratorExp_fields,
6513
15
                                         2,
6514
15
        "GeneratorExp(expr elt, comprehension* generators)");
6515
15
    if (!state->GeneratorExp_type) return -1;
6516
15
    state->Await_type = make_type(state, "Await", state->expr_type,
6517
15
                                  Await_fields, 1,
6518
15
        "Await(expr value)");
6519
15
    if (!state->Await_type) return -1;
6520
15
    state->Yield_type = make_type(state, "Yield", state->expr_type,
6521
15
                                  Yield_fields, 1,
6522
15
        "Yield(expr? value)");
6523
15
    if (!state->Yield_type) return -1;
6524
15
    if (PyObject_SetAttr(state->Yield_type, state->value, Py_None) == -1)
6525
0
        return -1;
6526
15
    state->YieldFrom_type = make_type(state, "YieldFrom", state->expr_type,
6527
15
                                      YieldFrom_fields, 1,
6528
15
        "YieldFrom(expr value)");
6529
15
    if (!state->YieldFrom_type) return -1;
6530
15
    state->Compare_type = make_type(state, "Compare", state->expr_type,
6531
15
                                    Compare_fields, 3,
6532
15
        "Compare(expr left, cmpop* ops, expr* comparators)");
6533
15
    if (!state->Compare_type) return -1;
6534
15
    state->Call_type = make_type(state, "Call", state->expr_type, Call_fields,
6535
15
                                 3,
6536
15
        "Call(expr func, expr* args, keyword* keywords)");
6537
15
    if (!state->Call_type) return -1;
6538
15
    state->FormattedValue_type = make_type(state, "FormattedValue",
6539
15
                                           state->expr_type,
6540
15
                                           FormattedValue_fields, 3,
6541
15
        "FormattedValue(expr value, int conversion, expr? format_spec)");
6542
15
    if (!state->FormattedValue_type) return -1;
6543
15
    if (PyObject_SetAttr(state->FormattedValue_type, state->format_spec,
6544
15
        Py_None) == -1)
6545
0
        return -1;
6546
15
    state->Interpolation_type = make_type(state, "Interpolation",
6547
15
                                          state->expr_type,
6548
15
                                          Interpolation_fields, 4,
6549
15
        "Interpolation(expr value, constant str, int conversion, expr? format_spec)");
6550
15
    if (!state->Interpolation_type) return -1;
6551
15
    if (PyObject_SetAttr(state->Interpolation_type, state->format_spec,
6552
15
        Py_None) == -1)
6553
0
        return -1;
6554
15
    state->JoinedStr_type = make_type(state, "JoinedStr", state->expr_type,
6555
15
                                      JoinedStr_fields, 1,
6556
15
        "JoinedStr(expr* values)");
6557
15
    if (!state->JoinedStr_type) return -1;
6558
15
    state->TemplateStr_type = make_type(state, "TemplateStr", state->expr_type,
6559
15
                                        TemplateStr_fields, 1,
6560
15
        "TemplateStr(expr* values)");
6561
15
    if (!state->TemplateStr_type) return -1;
6562
15
    state->Constant_type = make_type(state, "Constant", state->expr_type,
6563
15
                                     Constant_fields, 2,
6564
15
        "Constant(constant value, string? kind)");
6565
15
    if (!state->Constant_type) return -1;
6566
15
    if (PyObject_SetAttr(state->Constant_type, state->kind, Py_None) == -1)
6567
0
        return -1;
6568
15
    state->Attribute_type = make_type(state, "Attribute", state->expr_type,
6569
15
                                      Attribute_fields, 3,
6570
15
        "Attribute(expr value, identifier attr, expr_context ctx)");
6571
15
    if (!state->Attribute_type) return -1;
6572
15
    state->Subscript_type = make_type(state, "Subscript", state->expr_type,
6573
15
                                      Subscript_fields, 3,
6574
15
        "Subscript(expr value, expr slice, expr_context ctx)");
6575
15
    if (!state->Subscript_type) return -1;
6576
15
    state->Starred_type = make_type(state, "Starred", state->expr_type,
6577
15
                                    Starred_fields, 2,
6578
15
        "Starred(expr value, expr_context ctx)");
6579
15
    if (!state->Starred_type) return -1;
6580
15
    state->Name_type = make_type(state, "Name", state->expr_type, Name_fields,
6581
15
                                 2,
6582
15
        "Name(identifier id, expr_context ctx)");
6583
15
    if (!state->Name_type) return -1;
6584
15
    state->List_type = make_type(state, "List", state->expr_type, List_fields,
6585
15
                                 2,
6586
15
        "List(expr* elts, expr_context ctx)");
6587
15
    if (!state->List_type) return -1;
6588
15
    state->Tuple_type = make_type(state, "Tuple", state->expr_type,
6589
15
                                  Tuple_fields, 2,
6590
15
        "Tuple(expr* elts, expr_context ctx)");
6591
15
    if (!state->Tuple_type) return -1;
6592
15
    state->Slice_type = make_type(state, "Slice", state->expr_type,
6593
15
                                  Slice_fields, 3,
6594
15
        "Slice(expr? lower, expr? upper, expr? step)");
6595
15
    if (!state->Slice_type) return -1;
6596
15
    if (PyObject_SetAttr(state->Slice_type, state->lower, Py_None) == -1)
6597
0
        return -1;
6598
15
    if (PyObject_SetAttr(state->Slice_type, state->upper, Py_None) == -1)
6599
0
        return -1;
6600
15
    if (PyObject_SetAttr(state->Slice_type, state->step, Py_None) == -1)
6601
0
        return -1;
6602
15
    state->expr_context_type = make_type(state, "expr_context",
6603
15
                                         state->AST_type, NULL, 0,
6604
15
        "expr_context = Load | Store | Del");
6605
15
    if (!state->expr_context_type) return -1;
6606
15
    if (add_attributes(state, state->expr_context_type, NULL, 0) < 0) return -1;
6607
15
    state->Load_type = make_type(state, "Load", state->expr_context_type, NULL,
6608
15
                                 0,
6609
15
        "Load");
6610
15
    if (!state->Load_type) return -1;
6611
15
    state->Load_singleton = PyType_GenericNew((PyTypeObject *)state->Load_type,
6612
15
                                              NULL, NULL);
6613
15
    if (!state->Load_singleton) return -1;
6614
15
    state->Store_type = make_type(state, "Store", state->expr_context_type,
6615
15
                                  NULL, 0,
6616
15
        "Store");
6617
15
    if (!state->Store_type) return -1;
6618
15
    state->Store_singleton = PyType_GenericNew((PyTypeObject
6619
15
                                               *)state->Store_type, NULL, NULL);
6620
15
    if (!state->Store_singleton) return -1;
6621
15
    state->Del_type = make_type(state, "Del", state->expr_context_type, NULL, 0,
6622
15
        "Del");
6623
15
    if (!state->Del_type) return -1;
6624
15
    state->Del_singleton = PyType_GenericNew((PyTypeObject *)state->Del_type,
6625
15
                                             NULL, NULL);
6626
15
    if (!state->Del_singleton) return -1;
6627
15
    state->boolop_type = make_type(state, "boolop", state->AST_type, NULL, 0,
6628
15
        "boolop = And | Or");
6629
15
    if (!state->boolop_type) return -1;
6630
15
    if (add_attributes(state, state->boolop_type, NULL, 0) < 0) return -1;
6631
15
    state->And_type = make_type(state, "And", state->boolop_type, NULL, 0,
6632
15
        "And");
6633
15
    if (!state->And_type) return -1;
6634
15
    state->And_singleton = PyType_GenericNew((PyTypeObject *)state->And_type,
6635
15
                                             NULL, NULL);
6636
15
    if (!state->And_singleton) return -1;
6637
15
    state->Or_type = make_type(state, "Or", state->boolop_type, NULL, 0,
6638
15
        "Or");
6639
15
    if (!state->Or_type) return -1;
6640
15
    state->Or_singleton = PyType_GenericNew((PyTypeObject *)state->Or_type,
6641
15
                                            NULL, NULL);
6642
15
    if (!state->Or_singleton) return -1;
6643
15
    state->operator_type = make_type(state, "operator", state->AST_type, NULL,
6644
15
                                     0,
6645
15
        "operator = Add | Sub | Mult | MatMult | Div | Mod | Pow | LShift | RShift | BitOr | BitXor | BitAnd | FloorDiv");
6646
15
    if (!state->operator_type) return -1;
6647
15
    if (add_attributes(state, state->operator_type, NULL, 0) < 0) return -1;
6648
15
    state->Add_type = make_type(state, "Add", state->operator_type, NULL, 0,
6649
15
        "Add");
6650
15
    if (!state->Add_type) return -1;
6651
15
    state->Add_singleton = PyType_GenericNew((PyTypeObject *)state->Add_type,
6652
15
                                             NULL, NULL);
6653
15
    if (!state->Add_singleton) return -1;
6654
15
    state->Sub_type = make_type(state, "Sub", state->operator_type, NULL, 0,
6655
15
        "Sub");
6656
15
    if (!state->Sub_type) return -1;
6657
15
    state->Sub_singleton = PyType_GenericNew((PyTypeObject *)state->Sub_type,
6658
15
                                             NULL, NULL);
6659
15
    if (!state->Sub_singleton) return -1;
6660
15
    state->Mult_type = make_type(state, "Mult", state->operator_type, NULL, 0,
6661
15
        "Mult");
6662
15
    if (!state->Mult_type) return -1;
6663
15
    state->Mult_singleton = PyType_GenericNew((PyTypeObject *)state->Mult_type,
6664
15
                                              NULL, NULL);
6665
15
    if (!state->Mult_singleton) return -1;
6666
15
    state->MatMult_type = make_type(state, "MatMult", state->operator_type,
6667
15
                                    NULL, 0,
6668
15
        "MatMult");
6669
15
    if (!state->MatMult_type) return -1;
6670
15
    state->MatMult_singleton = PyType_GenericNew((PyTypeObject
6671
15
                                                 *)state->MatMult_type, NULL,
6672
15
                                                 NULL);
6673
15
    if (!state->MatMult_singleton) return -1;
6674
15
    state->Div_type = make_type(state, "Div", state->operator_type, NULL, 0,
6675
15
        "Div");
6676
15
    if (!state->Div_type) return -1;
6677
15
    state->Div_singleton = PyType_GenericNew((PyTypeObject *)state->Div_type,
6678
15
                                             NULL, NULL);
6679
15
    if (!state->Div_singleton) return -1;
6680
15
    state->Mod_type = make_type(state, "Mod", state->operator_type, NULL, 0,
6681
15
        "Mod");
6682
15
    if (!state->Mod_type) return -1;
6683
15
    state->Mod_singleton = PyType_GenericNew((PyTypeObject *)state->Mod_type,
6684
15
                                             NULL, NULL);
6685
15
    if (!state->Mod_singleton) return -1;
6686
15
    state->Pow_type = make_type(state, "Pow", state->operator_type, NULL, 0,
6687
15
        "Pow");
6688
15
    if (!state->Pow_type) return -1;
6689
15
    state->Pow_singleton = PyType_GenericNew((PyTypeObject *)state->Pow_type,
6690
15
                                             NULL, NULL);
6691
15
    if (!state->Pow_singleton) return -1;
6692
15
    state->LShift_type = make_type(state, "LShift", state->operator_type, NULL,
6693
15
                                   0,
6694
15
        "LShift");
6695
15
    if (!state->LShift_type) return -1;
6696
15
    state->LShift_singleton = PyType_GenericNew((PyTypeObject
6697
15
                                                *)state->LShift_type, NULL,
6698
15
                                                NULL);
6699
15
    if (!state->LShift_singleton) return -1;
6700
15
    state->RShift_type = make_type(state, "RShift", state->operator_type, NULL,
6701
15
                                   0,
6702
15
        "RShift");
6703
15
    if (!state->RShift_type) return -1;
6704
15
    state->RShift_singleton = PyType_GenericNew((PyTypeObject
6705
15
                                                *)state->RShift_type, NULL,
6706
15
                                                NULL);
6707
15
    if (!state->RShift_singleton) return -1;
6708
15
    state->BitOr_type = make_type(state, "BitOr", state->operator_type, NULL, 0,
6709
15
        "BitOr");
6710
15
    if (!state->BitOr_type) return -1;
6711
15
    state->BitOr_singleton = PyType_GenericNew((PyTypeObject
6712
15
                                               *)state->BitOr_type, NULL, NULL);
6713
15
    if (!state->BitOr_singleton) return -1;
6714
15
    state->BitXor_type = make_type(state, "BitXor", state->operator_type, NULL,
6715
15
                                   0,
6716
15
        "BitXor");
6717
15
    if (!state->BitXor_type) return -1;
6718
15
    state->BitXor_singleton = PyType_GenericNew((PyTypeObject
6719
15
                                                *)state->BitXor_type, NULL,
6720
15
                                                NULL);
6721
15
    if (!state->BitXor_singleton) return -1;
6722
15
    state->BitAnd_type = make_type(state, "BitAnd", state->operator_type, NULL,
6723
15
                                   0,
6724
15
        "BitAnd");
6725
15
    if (!state->BitAnd_type) return -1;
6726
15
    state->BitAnd_singleton = PyType_GenericNew((PyTypeObject
6727
15
                                                *)state->BitAnd_type, NULL,
6728
15
                                                NULL);
6729
15
    if (!state->BitAnd_singleton) return -1;
6730
15
    state->FloorDiv_type = make_type(state, "FloorDiv", state->operator_type,
6731
15
                                     NULL, 0,
6732
15
        "FloorDiv");
6733
15
    if (!state->FloorDiv_type) return -1;
6734
15
    state->FloorDiv_singleton = PyType_GenericNew((PyTypeObject
6735
15
                                                  *)state->FloorDiv_type, NULL,
6736
15
                                                  NULL);
6737
15
    if (!state->FloorDiv_singleton) return -1;
6738
15
    state->unaryop_type = make_type(state, "unaryop", state->AST_type, NULL, 0,
6739
15
        "unaryop = Invert | Not | UAdd | USub");
6740
15
    if (!state->unaryop_type) return -1;
6741
15
    if (add_attributes(state, state->unaryop_type, NULL, 0) < 0) return -1;
6742
15
    state->Invert_type = make_type(state, "Invert", state->unaryop_type, NULL,
6743
15
                                   0,
6744
15
        "Invert");
6745
15
    if (!state->Invert_type) return -1;
6746
15
    state->Invert_singleton = PyType_GenericNew((PyTypeObject
6747
15
                                                *)state->Invert_type, NULL,
6748
15
                                                NULL);
6749
15
    if (!state->Invert_singleton) return -1;
6750
15
    state->Not_type = make_type(state, "Not", state->unaryop_type, NULL, 0,
6751
15
        "Not");
6752
15
    if (!state->Not_type) return -1;
6753
15
    state->Not_singleton = PyType_GenericNew((PyTypeObject *)state->Not_type,
6754
15
                                             NULL, NULL);
6755
15
    if (!state->Not_singleton) return -1;
6756
15
    state->UAdd_type = make_type(state, "UAdd", state->unaryop_type, NULL, 0,
6757
15
        "UAdd");
6758
15
    if (!state->UAdd_type) return -1;
6759
15
    state->UAdd_singleton = PyType_GenericNew((PyTypeObject *)state->UAdd_type,
6760
15
                                              NULL, NULL);
6761
15
    if (!state->UAdd_singleton) return -1;
6762
15
    state->USub_type = make_type(state, "USub", state->unaryop_type, NULL, 0,
6763
15
        "USub");
6764
15
    if (!state->USub_type) return -1;
6765
15
    state->USub_singleton = PyType_GenericNew((PyTypeObject *)state->USub_type,
6766
15
                                              NULL, NULL);
6767
15
    if (!state->USub_singleton) return -1;
6768
15
    state->cmpop_type = make_type(state, "cmpop", state->AST_type, NULL, 0,
6769
15
        "cmpop = Eq | NotEq | Lt | LtE | Gt | GtE | Is | IsNot | In | NotIn");
6770
15
    if (!state->cmpop_type) return -1;
6771
15
    if (add_attributes(state, state->cmpop_type, NULL, 0) < 0) return -1;
6772
15
    state->Eq_type = make_type(state, "Eq", state->cmpop_type, NULL, 0,
6773
15
        "Eq");
6774
15
    if (!state->Eq_type) return -1;
6775
15
    state->Eq_singleton = PyType_GenericNew((PyTypeObject *)state->Eq_type,
6776
15
                                            NULL, NULL);
6777
15
    if (!state->Eq_singleton) return -1;
6778
15
    state->NotEq_type = make_type(state, "NotEq", state->cmpop_type, NULL, 0,
6779
15
        "NotEq");
6780
15
    if (!state->NotEq_type) return -1;
6781
15
    state->NotEq_singleton = PyType_GenericNew((PyTypeObject
6782
15
                                               *)state->NotEq_type, NULL, NULL);
6783
15
    if (!state->NotEq_singleton) return -1;
6784
15
    state->Lt_type = make_type(state, "Lt", state->cmpop_type, NULL, 0,
6785
15
        "Lt");
6786
15
    if (!state->Lt_type) return -1;
6787
15
    state->Lt_singleton = PyType_GenericNew((PyTypeObject *)state->Lt_type,
6788
15
                                            NULL, NULL);
6789
15
    if (!state->Lt_singleton) return -1;
6790
15
    state->LtE_type = make_type(state, "LtE", state->cmpop_type, NULL, 0,
6791
15
        "LtE");
6792
15
    if (!state->LtE_type) return -1;
6793
15
    state->LtE_singleton = PyType_GenericNew((PyTypeObject *)state->LtE_type,
6794
15
                                             NULL, NULL);
6795
15
    if (!state->LtE_singleton) return -1;
6796
15
    state->Gt_type = make_type(state, "Gt", state->cmpop_type, NULL, 0,
6797
15
        "Gt");
6798
15
    if (!state->Gt_type) return -1;
6799
15
    state->Gt_singleton = PyType_GenericNew((PyTypeObject *)state->Gt_type,
6800
15
                                            NULL, NULL);
6801
15
    if (!state->Gt_singleton) return -1;
6802
15
    state->GtE_type = make_type(state, "GtE", state->cmpop_type, NULL, 0,
6803
15
        "GtE");
6804
15
    if (!state->GtE_type) return -1;
6805
15
    state->GtE_singleton = PyType_GenericNew((PyTypeObject *)state->GtE_type,
6806
15
                                             NULL, NULL);
6807
15
    if (!state->GtE_singleton) return -1;
6808
15
    state->Is_type = make_type(state, "Is", state->cmpop_type, NULL, 0,
6809
15
        "Is");
6810
15
    if (!state->Is_type) return -1;
6811
15
    state->Is_singleton = PyType_GenericNew((PyTypeObject *)state->Is_type,
6812
15
                                            NULL, NULL);
6813
15
    if (!state->Is_singleton) return -1;
6814
15
    state->IsNot_type = make_type(state, "IsNot", state->cmpop_type, NULL, 0,
6815
15
        "IsNot");
6816
15
    if (!state->IsNot_type) return -1;
6817
15
    state->IsNot_singleton = PyType_GenericNew((PyTypeObject
6818
15
                                               *)state->IsNot_type, NULL, NULL);
6819
15
    if (!state->IsNot_singleton) return -1;
6820
15
    state->In_type = make_type(state, "In", state->cmpop_type, NULL, 0,
6821
15
        "In");
6822
15
    if (!state->In_type) return -1;
6823
15
    state->In_singleton = PyType_GenericNew((PyTypeObject *)state->In_type,
6824
15
                                            NULL, NULL);
6825
15
    if (!state->In_singleton) return -1;
6826
15
    state->NotIn_type = make_type(state, "NotIn", state->cmpop_type, NULL, 0,
6827
15
        "NotIn");
6828
15
    if (!state->NotIn_type) return -1;
6829
15
    state->NotIn_singleton = PyType_GenericNew((PyTypeObject
6830
15
                                               *)state->NotIn_type, NULL, NULL);
6831
15
    if (!state->NotIn_singleton) return -1;
6832
15
    state->comprehension_type = make_type(state, "comprehension",
6833
15
                                          state->AST_type,
6834
15
                                          comprehension_fields, 4,
6835
15
        "comprehension(expr target, expr iter, expr* ifs, int is_async)");
6836
15
    if (!state->comprehension_type) return -1;
6837
15
    if (add_attributes(state, state->comprehension_type, NULL, 0) < 0) return
6838
0
        -1;
6839
15
    state->excepthandler_type = make_type(state, "excepthandler",
6840
15
                                          state->AST_type, NULL, 0,
6841
15
        "excepthandler = ExceptHandler(expr? type, identifier? name, stmt* body)");
6842
15
    if (!state->excepthandler_type) return -1;
6843
15
    if (add_attributes(state, state->excepthandler_type,
6844
15
        excepthandler_attributes, 4) < 0) return -1;
6845
15
    if (PyObject_SetAttr(state->excepthandler_type, state->end_lineno, Py_None)
6846
15
        == -1)
6847
0
        return -1;
6848
15
    if (PyObject_SetAttr(state->excepthandler_type, state->end_col_offset,
6849
15
        Py_None) == -1)
6850
0
        return -1;
6851
15
    state->ExceptHandler_type = make_type(state, "ExceptHandler",
6852
15
                                          state->excepthandler_type,
6853
15
                                          ExceptHandler_fields, 3,
6854
15
        "ExceptHandler(expr? type, identifier? name, stmt* body)");
6855
15
    if (!state->ExceptHandler_type) return -1;
6856
15
    if (PyObject_SetAttr(state->ExceptHandler_type, state->type, Py_None) == -1)
6857
0
        return -1;
6858
15
    if (PyObject_SetAttr(state->ExceptHandler_type, state->name, Py_None) == -1)
6859
0
        return -1;
6860
15
    state->arguments_type = make_type(state, "arguments", state->AST_type,
6861
15
                                      arguments_fields, 7,
6862
15
        "arguments(arg* posonlyargs, arg* args, arg? vararg, arg* kwonlyargs, expr?* kw_defaults, arg? kwarg, expr* defaults)");
6863
15
    if (!state->arguments_type) return -1;
6864
15
    if (add_attributes(state, state->arguments_type, NULL, 0) < 0) return -1;
6865
15
    if (PyObject_SetAttr(state->arguments_type, state->vararg, Py_None) == -1)
6866
0
        return -1;
6867
15
    if (PyObject_SetAttr(state->arguments_type, state->kwarg, Py_None) == -1)
6868
0
        return -1;
6869
15
    state->arg_type = make_type(state, "arg", state->AST_type, arg_fields, 3,
6870
15
        "arg(identifier arg, expr? annotation, string? type_comment)");
6871
15
    if (!state->arg_type) return -1;
6872
15
    if (add_attributes(state, state->arg_type, arg_attributes, 4) < 0) return
6873
0
        -1;
6874
15
    if (PyObject_SetAttr(state->arg_type, state->annotation, Py_None) == -1)
6875
0
        return -1;
6876
15
    if (PyObject_SetAttr(state->arg_type, state->type_comment, Py_None) == -1)
6877
0
        return -1;
6878
15
    if (PyObject_SetAttr(state->arg_type, state->end_lineno, Py_None) == -1)
6879
0
        return -1;
6880
15
    if (PyObject_SetAttr(state->arg_type, state->end_col_offset, Py_None) == -1)
6881
0
        return -1;
6882
15
    state->keyword_type = make_type(state, "keyword", state->AST_type,
6883
15
                                    keyword_fields, 2,
6884
15
        "keyword(identifier? arg, expr value)");
6885
15
    if (!state->keyword_type) return -1;
6886
15
    if (add_attributes(state, state->keyword_type, keyword_attributes, 4) < 0)
6887
0
        return -1;
6888
15
    if (PyObject_SetAttr(state->keyword_type, state->arg, Py_None) == -1)
6889
0
        return -1;
6890
15
    if (PyObject_SetAttr(state->keyword_type, state->end_lineno, Py_None) == -1)
6891
0
        return -1;
6892
15
    if (PyObject_SetAttr(state->keyword_type, state->end_col_offset, Py_None)
6893
15
        == -1)
6894
0
        return -1;
6895
15
    state->alias_type = make_type(state, "alias", state->AST_type,
6896
15
                                  alias_fields, 2,
6897
15
        "alias(identifier name, identifier? asname)");
6898
15
    if (!state->alias_type) return -1;
6899
15
    if (add_attributes(state, state->alias_type, alias_attributes, 4) < 0)
6900
0
        return -1;
6901
15
    if (PyObject_SetAttr(state->alias_type, state->asname, Py_None) == -1)
6902
0
        return -1;
6903
15
    if (PyObject_SetAttr(state->alias_type, state->end_lineno, Py_None) == -1)
6904
0
        return -1;
6905
15
    if (PyObject_SetAttr(state->alias_type, state->end_col_offset, Py_None) ==
6906
15
        -1)
6907
0
        return -1;
6908
15
    state->withitem_type = make_type(state, "withitem", state->AST_type,
6909
15
                                     withitem_fields, 2,
6910
15
        "withitem(expr context_expr, expr? optional_vars)");
6911
15
    if (!state->withitem_type) return -1;
6912
15
    if (add_attributes(state, state->withitem_type, NULL, 0) < 0) return -1;
6913
15
    if (PyObject_SetAttr(state->withitem_type, state->optional_vars, Py_None)
6914
15
        == -1)
6915
0
        return -1;
6916
15
    state->match_case_type = make_type(state, "match_case", state->AST_type,
6917
15
                                       match_case_fields, 3,
6918
15
        "match_case(pattern pattern, expr? guard, stmt* body)");
6919
15
    if (!state->match_case_type) return -1;
6920
15
    if (add_attributes(state, state->match_case_type, NULL, 0) < 0) return -1;
6921
15
    if (PyObject_SetAttr(state->match_case_type, state->guard, Py_None) == -1)
6922
0
        return -1;
6923
15
    state->pattern_type = make_type(state, "pattern", state->AST_type, NULL, 0,
6924
15
        "pattern = MatchValue(expr value)\n"
6925
15
        "        | MatchSingleton(constant value)\n"
6926
15
        "        | MatchSequence(pattern* patterns)\n"
6927
15
        "        | MatchMapping(expr* keys, pattern* patterns, identifier? rest)\n"
6928
15
        "        | MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)\n"
6929
15
        "        | MatchStar(identifier? name)\n"
6930
15
        "        | MatchAs(pattern? pattern, identifier? name)\n"
6931
15
        "        | MatchOr(pattern* patterns)");
6932
15
    if (!state->pattern_type) return -1;
6933
15
    if (add_attributes(state, state->pattern_type, pattern_attributes, 4) < 0)
6934
0
        return -1;
6935
15
    state->MatchValue_type = make_type(state, "MatchValue",
6936
15
                                       state->pattern_type, MatchValue_fields,
6937
15
                                       1,
6938
15
        "MatchValue(expr value)");
6939
15
    if (!state->MatchValue_type) return -1;
6940
15
    state->MatchSingleton_type = make_type(state, "MatchSingleton",
6941
15
                                           state->pattern_type,
6942
15
                                           MatchSingleton_fields, 1,
6943
15
        "MatchSingleton(constant value)");
6944
15
    if (!state->MatchSingleton_type) return -1;
6945
15
    state->MatchSequence_type = make_type(state, "MatchSequence",
6946
15
                                          state->pattern_type,
6947
15
                                          MatchSequence_fields, 1,
6948
15
        "MatchSequence(pattern* patterns)");
6949
15
    if (!state->MatchSequence_type) return -1;
6950
15
    state->MatchMapping_type = make_type(state, "MatchMapping",
6951
15
                                         state->pattern_type,
6952
15
                                         MatchMapping_fields, 3,
6953
15
        "MatchMapping(expr* keys, pattern* patterns, identifier? rest)");
6954
15
    if (!state->MatchMapping_type) return -1;
6955
15
    if (PyObject_SetAttr(state->MatchMapping_type, state->rest, Py_None) == -1)
6956
0
        return -1;
6957
15
    state->MatchClass_type = make_type(state, "MatchClass",
6958
15
                                       state->pattern_type, MatchClass_fields,
6959
15
                                       4,
6960
15
        "MatchClass(expr cls, pattern* patterns, identifier* kwd_attrs, pattern* kwd_patterns)");
6961
15
    if (!state->MatchClass_type) return -1;
6962
15
    state->MatchStar_type = make_type(state, "MatchStar", state->pattern_type,
6963
15
                                      MatchStar_fields, 1,
6964
15
        "MatchStar(identifier? name)");
6965
15
    if (!state->MatchStar_type) return -1;
6966
15
    if (PyObject_SetAttr(state->MatchStar_type, state->name, Py_None) == -1)
6967
0
        return -1;
6968
15
    state->MatchAs_type = make_type(state, "MatchAs", state->pattern_type,
6969
15
                                    MatchAs_fields, 2,
6970
15
        "MatchAs(pattern? pattern, identifier? name)");
6971
15
    if (!state->MatchAs_type) return -1;
6972
15
    if (PyObject_SetAttr(state->MatchAs_type, state->pattern, Py_None) == -1)
6973
0
        return -1;
6974
15
    if (PyObject_SetAttr(state->MatchAs_type, state->name, Py_None) == -1)
6975
0
        return -1;
6976
15
    state->MatchOr_type = make_type(state, "MatchOr", state->pattern_type,
6977
15
                                    MatchOr_fields, 1,
6978
15
        "MatchOr(pattern* patterns)");
6979
15
    if (!state->MatchOr_type) return -1;
6980
15
    state->type_ignore_type = make_type(state, "type_ignore", state->AST_type,
6981
15
                                        NULL, 0,
6982
15
        "type_ignore = TypeIgnore(int lineno, string tag)");
6983
15
    if (!state->type_ignore_type) return -1;
6984
15
    if (add_attributes(state, state->type_ignore_type, NULL, 0) < 0) return -1;
6985
15
    state->TypeIgnore_type = make_type(state, "TypeIgnore",
6986
15
                                       state->type_ignore_type,
6987
15
                                       TypeIgnore_fields, 2,
6988
15
        "TypeIgnore(int lineno, string tag)");
6989
15
    if (!state->TypeIgnore_type) return -1;
6990
15
    state->type_param_type = make_type(state, "type_param", state->AST_type,
6991
15
                                       NULL, 0,
6992
15
        "type_param = TypeVar(identifier name, expr? bound, expr? default_value)\n"
6993
15
        "           | ParamSpec(identifier name, expr? default_value)\n"
6994
15
        "           | TypeVarTuple(identifier name, expr? default_value)");
6995
15
    if (!state->type_param_type) return -1;
6996
15
    if (add_attributes(state, state->type_param_type, type_param_attributes, 4)
6997
15
        < 0) return -1;
6998
15
    state->TypeVar_type = make_type(state, "TypeVar", state->type_param_type,
6999
15
                                    TypeVar_fields, 3,
7000
15
        "TypeVar(identifier name, expr? bound, expr? default_value)");
7001
15
    if (!state->TypeVar_type) return -1;
7002
15
    if (PyObject_SetAttr(state->TypeVar_type, state->bound, Py_None) == -1)
7003
0
        return -1;
7004
15
    if (PyObject_SetAttr(state->TypeVar_type, state->default_value, Py_None) ==
7005
15
        -1)
7006
0
        return -1;
7007
15
    state->ParamSpec_type = make_type(state, "ParamSpec",
7008
15
                                      state->type_param_type, ParamSpec_fields,
7009
15
                                      2,
7010
15
        "ParamSpec(identifier name, expr? default_value)");
7011
15
    if (!state->ParamSpec_type) return -1;
7012
15
    if (PyObject_SetAttr(state->ParamSpec_type, state->default_value, Py_None)
7013
15
        == -1)
7014
0
        return -1;
7015
15
    state->TypeVarTuple_type = make_type(state, "TypeVarTuple",
7016
15
                                         state->type_param_type,
7017
15
                                         TypeVarTuple_fields, 2,
7018
15
        "TypeVarTuple(identifier name, expr? default_value)");
7019
15
    if (!state->TypeVarTuple_type) return -1;
7020
15
    if (PyObject_SetAttr(state->TypeVarTuple_type, state->default_value,
7021
15
        Py_None) == -1)
7022
0
        return -1;
7023
7024
15
    if (!add_ast_annotations(state)) {
7025
0
        return -1;
7026
0
    }
7027
15
    return 0;
7028
15
}
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
6.18k
{
7073
6.18k
    mod_ty p;
7074
6.18k
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7075
6.18k
    if (!p)
7076
0
        return NULL;
7077
6.18k
    p->kind = Module_kind;
7078
6.18k
    p->v.Module.body = body;
7079
6.18k
    p->v.Module.type_ignores = type_ignores;
7080
6.18k
    return p;
7081
6.18k
}
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
242
{
7098
242
    mod_ty p;
7099
242
    if (!body) {
7100
0
        PyErr_SetString(PyExc_ValueError,
7101
0
                        "field 'body' is required for Expression");
7102
0
        return NULL;
7103
0
    }
7104
242
    p = (mod_ty)_PyArena_Malloc(arena, sizeof(*p));
7105
242
    if (!p)
7106
0
        return NULL;
7107
242
    p->kind = Expression_kind;
7108
242
    p->v.Expression.body = body;
7109
242
    return p;
7110
242
}
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.73k
{
7137
6.73k
    stmt_ty p;
7138
6.73k
    if (!name) {
7139
0
        PyErr_SetString(PyExc_ValueError,
7140
0
                        "field 'name' is required for FunctionDef");
7141
0
        return NULL;
7142
0
    }
7143
6.73k
    if (!args) {
7144
0
        PyErr_SetString(PyExc_ValueError,
7145
0
                        "field 'args' is required for FunctionDef");
7146
0
        return NULL;
7147
0
    }
7148
6.73k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7149
6.73k
    if (!p)
7150
0
        return NULL;
7151
6.73k
    p->kind = FunctionDef_kind;
7152
6.73k
    p->v.FunctionDef.name = name;
7153
6.73k
    p->v.FunctionDef.args = args;
7154
6.73k
    p->v.FunctionDef.body = body;
7155
6.73k
    p->v.FunctionDef.decorator_list = decorator_list;
7156
6.73k
    p->v.FunctionDef.returns = returns;
7157
6.73k
    p->v.FunctionDef.type_comment = type_comment;
7158
6.73k
    p->v.FunctionDef.type_params = type_params;
7159
6.73k
    p->lineno = lineno;
7160
6.73k
    p->col_offset = col_offset;
7161
6.73k
    p->end_lineno = end_lineno;
7162
6.73k
    p->end_col_offset = end_col_offset;
7163
6.73k
    return p;
7164
6.73k
}
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
480
{
7173
480
    stmt_ty p;
7174
480
    if (!name) {
7175
0
        PyErr_SetString(PyExc_ValueError,
7176
0
                        "field 'name' is required for AsyncFunctionDef");
7177
0
        return NULL;
7178
0
    }
7179
480
    if (!args) {
7180
0
        PyErr_SetString(PyExc_ValueError,
7181
0
                        "field 'args' is required for AsyncFunctionDef");
7182
0
        return NULL;
7183
0
    }
7184
480
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7185
480
    if (!p)
7186
0
        return NULL;
7187
480
    p->kind = AsyncFunctionDef_kind;
7188
480
    p->v.AsyncFunctionDef.name = name;
7189
480
    p->v.AsyncFunctionDef.args = args;
7190
480
    p->v.AsyncFunctionDef.body = body;
7191
480
    p->v.AsyncFunctionDef.decorator_list = decorator_list;
7192
480
    p->v.AsyncFunctionDef.returns = returns;
7193
480
    p->v.AsyncFunctionDef.type_comment = type_comment;
7194
480
    p->v.AsyncFunctionDef.type_params = type_params;
7195
480
    p->lineno = lineno;
7196
480
    p->col_offset = col_offset;
7197
480
    p->end_lineno = end_lineno;
7198
480
    p->end_col_offset = end_col_offset;
7199
480
    return p;
7200
480
}
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.42k
{
7208
3.42k
    stmt_ty p;
7209
3.42k
    if (!name) {
7210
0
        PyErr_SetString(PyExc_ValueError,
7211
0
                        "field 'name' is required for ClassDef");
7212
0
        return NULL;
7213
0
    }
7214
3.42k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7215
3.42k
    if (!p)
7216
0
        return NULL;
7217
3.42k
    p->kind = ClassDef_kind;
7218
3.42k
    p->v.ClassDef.name = name;
7219
3.42k
    p->v.ClassDef.bases = bases;
7220
3.42k
    p->v.ClassDef.keywords = keywords;
7221
3.42k
    p->v.ClassDef.body = body;
7222
3.42k
    p->v.ClassDef.decorator_list = decorator_list;
7223
3.42k
    p->v.ClassDef.type_params = type_params;
7224
3.42k
    p->lineno = lineno;
7225
3.42k
    p->col_offset = col_offset;
7226
3.42k
    p->end_lineno = end_lineno;
7227
3.42k
    p->end_col_offset = end_col_offset;
7228
3.42k
    return p;
7229
3.42k
}
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.51k
{
7235
3.51k
    stmt_ty p;
7236
3.51k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7237
3.51k
    if (!p)
7238
0
        return NULL;
7239
3.51k
    p->kind = Return_kind;
7240
3.51k
    p->v.Return.value = value;
7241
3.51k
    p->lineno = lineno;
7242
3.51k
    p->col_offset = col_offset;
7243
3.51k
    p->end_lineno = end_lineno;
7244
3.51k
    p->end_col_offset = end_col_offset;
7245
3.51k
    return p;
7246
3.51k
}
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
534
{
7252
534
    stmt_ty p;
7253
534
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7254
534
    if (!p)
7255
0
        return NULL;
7256
534
    p->kind = Delete_kind;
7257
534
    p->v.Delete.targets = targets;
7258
534
    p->lineno = lineno;
7259
534
    p->col_offset = col_offset;
7260
534
    p->end_lineno = end_lineno;
7261
534
    p->end_col_offset = end_col_offset;
7262
534
    return p;
7263
534
}
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.28k
{
7270
6.28k
    stmt_ty p;
7271
6.28k
    if (!value) {
7272
0
        PyErr_SetString(PyExc_ValueError,
7273
0
                        "field 'value' is required for Assign");
7274
0
        return NULL;
7275
0
    }
7276
6.28k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7277
6.28k
    if (!p)
7278
0
        return NULL;
7279
6.28k
    p->kind = Assign_kind;
7280
6.28k
    p->v.Assign.targets = targets;
7281
6.28k
    p->v.Assign.value = value;
7282
6.28k
    p->v.Assign.type_comment = type_comment;
7283
6.28k
    p->lineno = lineno;
7284
6.28k
    p->col_offset = col_offset;
7285
6.28k
    p->end_lineno = end_lineno;
7286
6.28k
    p->end_col_offset = end_col_offset;
7287
6.28k
    return p;
7288
6.28k
}
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.27k
{
7324
2.27k
    stmt_ty p;
7325
2.27k
    if (!target) {
7326
0
        PyErr_SetString(PyExc_ValueError,
7327
0
                        "field 'target' is required for AugAssign");
7328
0
        return NULL;
7329
0
    }
7330
2.27k
    if (!op) {
7331
0
        PyErr_SetString(PyExc_ValueError,
7332
0
                        "field 'op' is required for AugAssign");
7333
0
        return NULL;
7334
0
    }
7335
2.27k
    if (!value) {
7336
0
        PyErr_SetString(PyExc_ValueError,
7337
0
                        "field 'value' is required for AugAssign");
7338
0
        return NULL;
7339
0
    }
7340
2.27k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7341
2.27k
    if (!p)
7342
0
        return NULL;
7343
2.27k
    p->kind = AugAssign_kind;
7344
2.27k
    p->v.AugAssign.target = target;
7345
2.27k
    p->v.AugAssign.op = op;
7346
2.27k
    p->v.AugAssign.value = value;
7347
2.27k
    p->lineno = lineno;
7348
2.27k
    p->col_offset = col_offset;
7349
2.27k
    p->end_lineno = end_lineno;
7350
2.27k
    p->end_col_offset = end_col_offset;
7351
2.27k
    return p;
7352
2.27k
}
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
3.16k
{
7359
3.16k
    stmt_ty p;
7360
3.16k
    if (!target) {
7361
0
        PyErr_SetString(PyExc_ValueError,
7362
0
                        "field 'target' is required for AnnAssign");
7363
0
        return NULL;
7364
0
    }
7365
3.16k
    if (!annotation) {
7366
0
        PyErr_SetString(PyExc_ValueError,
7367
0
                        "field 'annotation' is required for AnnAssign");
7368
0
        return NULL;
7369
0
    }
7370
3.16k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7371
3.16k
    if (!p)
7372
0
        return NULL;
7373
3.16k
    p->kind = AnnAssign_kind;
7374
3.16k
    p->v.AnnAssign.target = target;
7375
3.16k
    p->v.AnnAssign.annotation = annotation;
7376
3.16k
    p->v.AnnAssign.value = value;
7377
3.16k
    p->v.AnnAssign.simple = simple;
7378
3.16k
    p->lineno = lineno;
7379
3.16k
    p->col_offset = col_offset;
7380
3.16k
    p->end_lineno = end_lineno;
7381
3.16k
    p->end_col_offset = end_col_offset;
7382
3.16k
    return p;
7383
3.16k
}
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.12k
{
7390
1.12k
    stmt_ty p;
7391
1.12k
    if (!target) {
7392
0
        PyErr_SetString(PyExc_ValueError,
7393
0
                        "field 'target' is required for For");
7394
0
        return NULL;
7395
0
    }
7396
1.12k
    if (!iter) {
7397
0
        PyErr_SetString(PyExc_ValueError,
7398
0
                        "field 'iter' is required for For");
7399
0
        return NULL;
7400
0
    }
7401
1.12k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7402
1.12k
    if (!p)
7403
0
        return NULL;
7404
1.12k
    p->kind = For_kind;
7405
1.12k
    p->v.For.target = target;
7406
1.12k
    p->v.For.iter = iter;
7407
1.12k
    p->v.For.body = body;
7408
1.12k
    p->v.For.orelse = orelse;
7409
1.12k
    p->v.For.type_comment = type_comment;
7410
1.12k
    p->lineno = lineno;
7411
1.12k
    p->col_offset = col_offset;
7412
1.12k
    p->end_lineno = end_lineno;
7413
1.12k
    p->end_col_offset = end_col_offset;
7414
1.12k
    return p;
7415
1.12k
}
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
428
{
7422
428
    stmt_ty p;
7423
428
    if (!target) {
7424
0
        PyErr_SetString(PyExc_ValueError,
7425
0
                        "field 'target' is required for AsyncFor");
7426
0
        return NULL;
7427
0
    }
7428
428
    if (!iter) {
7429
0
        PyErr_SetString(PyExc_ValueError,
7430
0
                        "field 'iter' is required for AsyncFor");
7431
0
        return NULL;
7432
0
    }
7433
428
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7434
428
    if (!p)
7435
0
        return NULL;
7436
428
    p->kind = AsyncFor_kind;
7437
428
    p->v.AsyncFor.target = target;
7438
428
    p->v.AsyncFor.iter = iter;
7439
428
    p->v.AsyncFor.body = body;
7440
428
    p->v.AsyncFor.orelse = orelse;
7441
428
    p->v.AsyncFor.type_comment = type_comment;
7442
428
    p->lineno = lineno;
7443
428
    p->col_offset = col_offset;
7444
428
    p->end_lineno = end_lineno;
7445
428
    p->end_col_offset = end_col_offset;
7446
428
    return p;
7447
428
}
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
763
{
7454
763
    stmt_ty p;
7455
763
    if (!test) {
7456
0
        PyErr_SetString(PyExc_ValueError,
7457
0
                        "field 'test' is required for While");
7458
0
        return NULL;
7459
0
    }
7460
763
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7461
763
    if (!p)
7462
0
        return NULL;
7463
763
    p->kind = While_kind;
7464
763
    p->v.While.test = test;
7465
763
    p->v.While.body = body;
7466
763
    p->v.While.orelse = orelse;
7467
763
    p->lineno = lineno;
7468
763
    p->col_offset = col_offset;
7469
763
    p->end_lineno = end_lineno;
7470
763
    p->end_col_offset = end_col_offset;
7471
763
    return p;
7472
763
}
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.97k
{
7479
4.97k
    stmt_ty p;
7480
4.97k
    if (!test) {
7481
0
        PyErr_SetString(PyExc_ValueError,
7482
0
                        "field 'test' is required for If");
7483
0
        return NULL;
7484
0
    }
7485
4.97k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7486
4.97k
    if (!p)
7487
0
        return NULL;
7488
4.97k
    p->kind = If_kind;
7489
4.97k
    p->v.If.test = test;
7490
4.97k
    p->v.If.body = body;
7491
4.97k
    p->v.If.orelse = orelse;
7492
4.97k
    p->lineno = lineno;
7493
4.97k
    p->col_offset = col_offset;
7494
4.97k
    p->end_lineno = end_lineno;
7495
4.97k
    p->end_col_offset = end_col_offset;
7496
4.97k
    return p;
7497
4.97k
}
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.14k
{
7504
1.14k
    stmt_ty p;
7505
1.14k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7506
1.14k
    if (!p)
7507
0
        return NULL;
7508
1.14k
    p->kind = With_kind;
7509
1.14k
    p->v.With.items = items;
7510
1.14k
    p->v.With.body = body;
7511
1.14k
    p->v.With.type_comment = type_comment;
7512
1.14k
    p->lineno = lineno;
7513
1.14k
    p->col_offset = col_offset;
7514
1.14k
    p->end_lineno = end_lineno;
7515
1.14k
    p->end_col_offset = end_col_offset;
7516
1.14k
    return p;
7517
1.14k
}
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
658
{
7524
658
    stmt_ty p;
7525
658
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7526
658
    if (!p)
7527
0
        return NULL;
7528
658
    p->kind = AsyncWith_kind;
7529
658
    p->v.AsyncWith.items = items;
7530
658
    p->v.AsyncWith.body = body;
7531
658
    p->v.AsyncWith.type_comment = type_comment;
7532
658
    p->lineno = lineno;
7533
658
    p->col_offset = col_offset;
7534
658
    p->end_lineno = end_lineno;
7535
658
    p->end_col_offset = end_col_offset;
7536
658
    return p;
7537
658
}
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
456
{
7543
456
    stmt_ty p;
7544
456
    if (!subject) {
7545
0
        PyErr_SetString(PyExc_ValueError,
7546
0
                        "field 'subject' is required for Match");
7547
0
        return NULL;
7548
0
    }
7549
456
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7550
456
    if (!p)
7551
0
        return NULL;
7552
456
    p->kind = Match_kind;
7553
456
    p->v.Match.subject = subject;
7554
456
    p->v.Match.cases = cases;
7555
456
    p->lineno = lineno;
7556
456
    p->col_offset = col_offset;
7557
456
    p->end_lineno = end_lineno;
7558
456
    p->end_col_offset = end_col_offset;
7559
456
    return p;
7560
456
}
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.04k
{
7566
2.04k
    stmt_ty p;
7567
2.04k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7568
2.04k
    if (!p)
7569
0
        return NULL;
7570
2.04k
    p->kind = Raise_kind;
7571
2.04k
    p->v.Raise.exc = exc;
7572
2.04k
    p->v.Raise.cause = cause;
7573
2.04k
    p->lineno = lineno;
7574
2.04k
    p->col_offset = col_offset;
7575
2.04k
    p->end_lineno = end_lineno;
7576
2.04k
    p->end_col_offset = end_col_offset;
7577
2.04k
    return p;
7578
2.04k
}
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
2.41k
{
7585
2.41k
    stmt_ty p;
7586
2.41k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7587
2.41k
    if (!p)
7588
0
        return NULL;
7589
2.41k
    p->kind = Try_kind;
7590
2.41k
    p->v.Try.body = body;
7591
2.41k
    p->v.Try.handlers = handlers;
7592
2.41k
    p->v.Try.orelse = orelse;
7593
2.41k
    p->v.Try.finalbody = finalbody;
7594
2.41k
    p->lineno = lineno;
7595
2.41k
    p->col_offset = col_offset;
7596
2.41k
    p->end_lineno = end_lineno;
7597
2.41k
    p->end_col_offset = end_col_offset;
7598
2.41k
    return p;
7599
2.41k
}
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.40k
{
7607
1.40k
    stmt_ty p;
7608
1.40k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7609
1.40k
    if (!p)
7610
0
        return NULL;
7611
1.40k
    p->kind = TryStar_kind;
7612
1.40k
    p->v.TryStar.body = body;
7613
1.40k
    p->v.TryStar.handlers = handlers;
7614
1.40k
    p->v.TryStar.orelse = orelse;
7615
1.40k
    p->v.TryStar.finalbody = finalbody;
7616
1.40k
    p->lineno = lineno;
7617
1.40k
    p->col_offset = col_offset;
7618
1.40k
    p->end_lineno = end_lineno;
7619
1.40k
    p->end_col_offset = end_col_offset;
7620
1.40k
    return p;
7621
1.40k
}
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.15k
{
7627
1.15k
    stmt_ty p;
7628
1.15k
    if (!test) {
7629
0
        PyErr_SetString(PyExc_ValueError,
7630
0
                        "field 'test' is required for Assert");
7631
0
        return NULL;
7632
0
    }
7633
1.15k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7634
1.15k
    if (!p)
7635
0
        return NULL;
7636
1.15k
    p->kind = Assert_kind;
7637
1.15k
    p->v.Assert.test = test;
7638
1.15k
    p->v.Assert.msg = msg;
7639
1.15k
    p->lineno = lineno;
7640
1.15k
    p->col_offset = col_offset;
7641
1.15k
    p->end_lineno = end_lineno;
7642
1.15k
    p->end_col_offset = end_col_offset;
7643
1.15k
    return p;
7644
1.15k
}
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.30k
{
7650
2.30k
    stmt_ty p;
7651
2.30k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7652
2.30k
    if (!p)
7653
0
        return NULL;
7654
2.30k
    p->kind = Import_kind;
7655
2.30k
    p->v.Import.names = names;
7656
2.30k
    p->v.Import.is_lazy = is_lazy;
7657
2.30k
    p->lineno = lineno;
7658
2.30k
    p->col_offset = col_offset;
7659
2.30k
    p->end_lineno = end_lineno;
7660
2.30k
    p->end_col_offset = end_col_offset;
7661
2.30k
    return p;
7662
2.30k
}
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.85k
{
7669
2.85k
    stmt_ty p;
7670
2.85k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7671
2.85k
    if (!p)
7672
0
        return NULL;
7673
2.85k
    p->kind = ImportFrom_kind;
7674
2.85k
    p->v.ImportFrom.module = module;
7675
2.85k
    p->v.ImportFrom.names = names;
7676
2.85k
    p->v.ImportFrom.level = level;
7677
2.85k
    p->v.ImportFrom.is_lazy = is_lazy;
7678
2.85k
    p->lineno = lineno;
7679
2.85k
    p->col_offset = col_offset;
7680
2.85k
    p->end_lineno = end_lineno;
7681
2.85k
    p->end_col_offset = end_col_offset;
7682
2.85k
    return p;
7683
2.85k
}
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
637
{
7689
637
    stmt_ty p;
7690
637
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7691
637
    if (!p)
7692
0
        return NULL;
7693
637
    p->kind = Global_kind;
7694
637
    p->v.Global.names = names;
7695
637
    p->lineno = lineno;
7696
637
    p->col_offset = col_offset;
7697
637
    p->end_lineno = end_lineno;
7698
637
    p->end_col_offset = end_col_offset;
7699
637
    return p;
7700
637
}
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
113
{
7706
113
    stmt_ty p;
7707
113
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7708
113
    if (!p)
7709
0
        return NULL;
7710
113
    p->kind = Nonlocal_kind;
7711
113
    p->v.Nonlocal.names = names;
7712
113
    p->lineno = lineno;
7713
113
    p->col_offset = col_offset;
7714
113
    p->end_lineno = end_lineno;
7715
113
    p->end_col_offset = end_col_offset;
7716
113
    return p;
7717
113
}
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
73.5k
{
7723
73.5k
    stmt_ty p;
7724
73.5k
    if (!value) {
7725
0
        PyErr_SetString(PyExc_ValueError,
7726
0
                        "field 'value' is required for Expr");
7727
0
        return NULL;
7728
0
    }
7729
73.5k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7730
73.5k
    if (!p)
7731
0
        return NULL;
7732
73.5k
    p->kind = Expr_kind;
7733
73.5k
    p->v.Expr.value = value;
7734
73.5k
    p->lineno = lineno;
7735
73.5k
    p->col_offset = col_offset;
7736
73.5k
    p->end_lineno = end_lineno;
7737
73.5k
    p->end_col_offset = end_col_offset;
7738
73.5k
    return p;
7739
73.5k
}
7740
7741
stmt_ty
7742
_PyAST_Pass(int lineno, int col_offset, int end_lineno, int end_col_offset,
7743
            PyArena *arena)
7744
1.67k
{
7745
1.67k
    stmt_ty p;
7746
1.67k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7747
1.67k
    if (!p)
7748
0
        return NULL;
7749
1.67k
    p->kind = Pass_kind;
7750
1.67k
    p->lineno = lineno;
7751
1.67k
    p->col_offset = col_offset;
7752
1.67k
    p->end_lineno = end_lineno;
7753
1.67k
    p->end_col_offset = end_col_offset;
7754
1.67k
    return p;
7755
1.67k
}
7756
7757
stmt_ty
7758
_PyAST_Break(int lineno, int col_offset, int end_lineno, int end_col_offset,
7759
             PyArena *arena)
7760
1.40k
{
7761
1.40k
    stmt_ty p;
7762
1.40k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7763
1.40k
    if (!p)
7764
0
        return NULL;
7765
1.40k
    p->kind = Break_kind;
7766
1.40k
    p->lineno = lineno;
7767
1.40k
    p->col_offset = col_offset;
7768
1.40k
    p->end_lineno = end_lineno;
7769
1.40k
    p->end_col_offset = end_col_offset;
7770
1.40k
    return p;
7771
1.40k
}
7772
7773
stmt_ty
7774
_PyAST_Continue(int lineno, int col_offset, int end_lineno, int end_col_offset,
7775
                PyArena *arena)
7776
1.65k
{
7777
1.65k
    stmt_ty p;
7778
1.65k
    p = (stmt_ty)_PyArena_Malloc(arena, sizeof(*p));
7779
1.65k
    if (!p)
7780
0
        return NULL;
7781
1.65k
    p->kind = Continue_kind;
7782
1.65k
    p->lineno = lineno;
7783
1.65k
    p->col_offset = col_offset;
7784
1.65k
    p->end_lineno = end_lineno;
7785
1.65k
    p->end_col_offset = end_col_offset;
7786
1.65k
    return p;
7787
1.65k
}
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
2.02k
{
7793
2.02k
    expr_ty p;
7794
2.02k
    if (!op) {
7795
0
        PyErr_SetString(PyExc_ValueError,
7796
0
                        "field 'op' is required for BoolOp");
7797
0
        return NULL;
7798
0
    }
7799
2.02k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7800
2.02k
    if (!p)
7801
0
        return NULL;
7802
2.02k
    p->kind = BoolOp_kind;
7803
2.02k
    p->v.BoolOp.op = op;
7804
2.02k
    p->v.BoolOp.values = values;
7805
2.02k
    p->lineno = lineno;
7806
2.02k
    p->col_offset = col_offset;
7807
2.02k
    p->end_lineno = end_lineno;
7808
2.02k
    p->end_col_offset = end_col_offset;
7809
2.02k
    return p;
7810
2.02k
}
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.55k
{
7816
1.55k
    expr_ty p;
7817
1.55k
    if (!target) {
7818
0
        PyErr_SetString(PyExc_ValueError,
7819
0
                        "field 'target' is required for NamedExpr");
7820
0
        return NULL;
7821
0
    }
7822
1.55k
    if (!value) {
7823
0
        PyErr_SetString(PyExc_ValueError,
7824
0
                        "field 'value' is required for NamedExpr");
7825
0
        return NULL;
7826
0
    }
7827
1.55k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7828
1.55k
    if (!p)
7829
0
        return NULL;
7830
1.55k
    p->kind = NamedExpr_kind;
7831
1.55k
    p->v.NamedExpr.target = target;
7832
1.55k
    p->v.NamedExpr.value = value;
7833
1.55k
    p->lineno = lineno;
7834
1.55k
    p->col_offset = col_offset;
7835
1.55k
    p->end_lineno = end_lineno;
7836
1.55k
    p->end_col_offset = end_col_offset;
7837
1.55k
    return p;
7838
1.55k
}
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
37.6k
{
7844
37.6k
    expr_ty p;
7845
37.6k
    if (!left) {
7846
0
        PyErr_SetString(PyExc_ValueError,
7847
0
                        "field 'left' is required for BinOp");
7848
0
        return NULL;
7849
0
    }
7850
37.6k
    if (!op) {
7851
0
        PyErr_SetString(PyExc_ValueError,
7852
0
                        "field 'op' is required for BinOp");
7853
0
        return NULL;
7854
0
    }
7855
37.6k
    if (!right) {
7856
0
        PyErr_SetString(PyExc_ValueError,
7857
0
                        "field 'right' is required for BinOp");
7858
0
        return NULL;
7859
0
    }
7860
37.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7861
37.6k
    if (!p)
7862
0
        return NULL;
7863
37.6k
    p->kind = BinOp_kind;
7864
37.6k
    p->v.BinOp.left = left;
7865
37.6k
    p->v.BinOp.op = op;
7866
37.6k
    p->v.BinOp.right = right;
7867
37.6k
    p->lineno = lineno;
7868
37.6k
    p->col_offset = col_offset;
7869
37.6k
    p->end_lineno = end_lineno;
7870
37.6k
    p->end_col_offset = end_col_offset;
7871
37.6k
    return p;
7872
37.6k
}
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
127k
{
7878
127k
    expr_ty p;
7879
127k
    if (!op) {
7880
0
        PyErr_SetString(PyExc_ValueError,
7881
0
                        "field 'op' is required for UnaryOp");
7882
0
        return NULL;
7883
0
    }
7884
127k
    if (!operand) {
7885
0
        PyErr_SetString(PyExc_ValueError,
7886
0
                        "field 'operand' is required for UnaryOp");
7887
0
        return NULL;
7888
0
    }
7889
127k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7890
127k
    if (!p)
7891
0
        return NULL;
7892
127k
    p->kind = UnaryOp_kind;
7893
127k
    p->v.UnaryOp.op = op;
7894
127k
    p->v.UnaryOp.operand = operand;
7895
127k
    p->lineno = lineno;
7896
127k
    p->col_offset = col_offset;
7897
127k
    p->end_lineno = end_lineno;
7898
127k
    p->end_col_offset = end_col_offset;
7899
127k
    return p;
7900
127k
}
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.51k
{
7906
2.51k
    expr_ty p;
7907
2.51k
    if (!args) {
7908
0
        PyErr_SetString(PyExc_ValueError,
7909
0
                        "field 'args' is required for Lambda");
7910
0
        return NULL;
7911
0
    }
7912
2.51k
    if (!body) {
7913
0
        PyErr_SetString(PyExc_ValueError,
7914
0
                        "field 'body' is required for Lambda");
7915
0
        return NULL;
7916
0
    }
7917
2.51k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7918
2.51k
    if (!p)
7919
0
        return NULL;
7920
2.51k
    p->kind = Lambda_kind;
7921
2.51k
    p->v.Lambda.args = args;
7922
2.51k
    p->v.Lambda.body = body;
7923
2.51k
    p->lineno = lineno;
7924
2.51k
    p->col_offset = col_offset;
7925
2.51k
    p->end_lineno = end_lineno;
7926
2.51k
    p->end_col_offset = end_col_offset;
7927
2.51k
    return p;
7928
2.51k
}
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
1.04k
{
7934
1.04k
    expr_ty p;
7935
1.04k
    if (!test) {
7936
0
        PyErr_SetString(PyExc_ValueError,
7937
0
                        "field 'test' is required for IfExp");
7938
0
        return NULL;
7939
0
    }
7940
1.04k
    if (!body) {
7941
0
        PyErr_SetString(PyExc_ValueError,
7942
0
                        "field 'body' is required for IfExp");
7943
0
        return NULL;
7944
0
    }
7945
1.04k
    if (!orelse) {
7946
0
        PyErr_SetString(PyExc_ValueError,
7947
0
                        "field 'orelse' is required for IfExp");
7948
0
        return NULL;
7949
0
    }
7950
1.04k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7951
1.04k
    if (!p)
7952
0
        return NULL;
7953
1.04k
    p->kind = IfExp_kind;
7954
1.04k
    p->v.IfExp.test = test;
7955
1.04k
    p->v.IfExp.body = body;
7956
1.04k
    p->v.IfExp.orelse = orelse;
7957
1.04k
    p->lineno = lineno;
7958
1.04k
    p->col_offset = col_offset;
7959
1.04k
    p->end_lineno = end_lineno;
7960
1.04k
    p->end_col_offset = end_col_offset;
7961
1.04k
    return p;
7962
1.04k
}
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.74k
{
7968
4.74k
    expr_ty p;
7969
4.74k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7970
4.74k
    if (!p)
7971
0
        return NULL;
7972
4.74k
    p->kind = Dict_kind;
7973
4.74k
    p->v.Dict.keys = keys;
7974
4.74k
    p->v.Dict.values = values;
7975
4.74k
    p->lineno = lineno;
7976
4.74k
    p->col_offset = col_offset;
7977
4.74k
    p->end_lineno = end_lineno;
7978
4.74k
    p->end_col_offset = end_col_offset;
7979
4.74k
    return p;
7980
4.74k
}
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.91k
{
7986
1.91k
    expr_ty p;
7987
1.91k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
7988
1.91k
    if (!p)
7989
0
        return NULL;
7990
1.91k
    p->kind = Set_kind;
7991
1.91k
    p->v.Set.elts = elts;
7992
1.91k
    p->lineno = lineno;
7993
1.91k
    p->col_offset = col_offset;
7994
1.91k
    p->end_lineno = end_lineno;
7995
1.91k
    p->end_col_offset = end_col_offset;
7996
1.91k
    return p;
7997
1.91k
}
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
994
{
8004
994
    expr_ty p;
8005
994
    if (!elt) {
8006
0
        PyErr_SetString(PyExc_ValueError,
8007
0
                        "field 'elt' is required for ListComp");
8008
0
        return NULL;
8009
0
    }
8010
994
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8011
994
    if (!p)
8012
0
        return NULL;
8013
994
    p->kind = ListComp_kind;
8014
994
    p->v.ListComp.elt = elt;
8015
994
    p->v.ListComp.generators = generators;
8016
994
    p->lineno = lineno;
8017
994
    p->col_offset = col_offset;
8018
994
    p->end_lineno = end_lineno;
8019
994
    p->end_col_offset = end_col_offset;
8020
994
    return p;
8021
994
}
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
918
{
8028
918
    expr_ty p;
8029
918
    if (!elt) {
8030
0
        PyErr_SetString(PyExc_ValueError,
8031
0
                        "field 'elt' is required for SetComp");
8032
0
        return NULL;
8033
0
    }
8034
918
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8035
918
    if (!p)
8036
0
        return NULL;
8037
918
    p->kind = SetComp_kind;
8038
918
    p->v.SetComp.elt = elt;
8039
918
    p->v.SetComp.generators = generators;
8040
918
    p->lineno = lineno;
8041
918
    p->col_offset = col_offset;
8042
918
    p->end_lineno = end_lineno;
8043
918
    p->end_col_offset = end_col_offset;
8044
918
    return p;
8045
918
}
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
631
{
8052
631
    expr_ty p;
8053
631
    if (!key) {
8054
0
        PyErr_SetString(PyExc_ValueError,
8055
0
                        "field 'key' is required for DictComp");
8056
0
        return NULL;
8057
0
    }
8058
631
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8059
631
    if (!p)
8060
0
        return NULL;
8061
631
    p->kind = DictComp_kind;
8062
631
    p->v.DictComp.key = key;
8063
631
    p->v.DictComp.value = value;
8064
631
    p->v.DictComp.generators = generators;
8065
631
    p->lineno = lineno;
8066
631
    p->col_offset = col_offset;
8067
631
    p->end_lineno = end_lineno;
8068
631
    p->end_col_offset = end_col_offset;
8069
631
    return p;
8070
631
}
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.53k
{
8077
3.53k
    expr_ty p;
8078
3.53k
    if (!elt) {
8079
0
        PyErr_SetString(PyExc_ValueError,
8080
0
                        "field 'elt' is required for GeneratorExp");
8081
0
        return NULL;
8082
0
    }
8083
3.53k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8084
3.53k
    if (!p)
8085
0
        return NULL;
8086
3.53k
    p->kind = GeneratorExp_kind;
8087
3.53k
    p->v.GeneratorExp.elt = elt;
8088
3.53k
    p->v.GeneratorExp.generators = generators;
8089
3.53k
    p->lineno = lineno;
8090
3.53k
    p->col_offset = col_offset;
8091
3.53k
    p->end_lineno = end_lineno;
8092
3.53k
    p->end_col_offset = end_col_offset;
8093
3.53k
    return p;
8094
3.53k
}
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
378
{
8100
378
    expr_ty p;
8101
378
    if (!value) {
8102
0
        PyErr_SetString(PyExc_ValueError,
8103
0
                        "field 'value' is required for Await");
8104
0
        return NULL;
8105
0
    }
8106
378
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8107
378
    if (!p)
8108
0
        return NULL;
8109
378
    p->kind = Await_kind;
8110
378
    p->v.Await.value = value;
8111
378
    p->lineno = lineno;
8112
378
    p->col_offset = col_offset;
8113
378
    p->end_lineno = end_lineno;
8114
378
    p->end_col_offset = end_col_offset;
8115
378
    return p;
8116
378
}
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.75k
{
8122
2.75k
    expr_ty p;
8123
2.75k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8124
2.75k
    if (!p)
8125
0
        return NULL;
8126
2.75k
    p->kind = Yield_kind;
8127
2.75k
    p->v.Yield.value = value;
8128
2.75k
    p->lineno = lineno;
8129
2.75k
    p->col_offset = col_offset;
8130
2.75k
    p->end_lineno = end_lineno;
8131
2.75k
    p->end_col_offset = end_col_offset;
8132
2.75k
    return p;
8133
2.75k
}
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
313
{
8139
313
    expr_ty p;
8140
313
    if (!value) {
8141
0
        PyErr_SetString(PyExc_ValueError,
8142
0
                        "field 'value' is required for YieldFrom");
8143
0
        return NULL;
8144
0
    }
8145
313
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8146
313
    if (!p)
8147
0
        return NULL;
8148
313
    p->kind = YieldFrom_kind;
8149
313
    p->v.YieldFrom.value = value;
8150
313
    p->lineno = lineno;
8151
313
    p->col_offset = col_offset;
8152
313
    p->end_lineno = end_lineno;
8153
313
    p->end_col_offset = end_col_offset;
8154
313
    return p;
8155
313
}
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
5.75k
{
8162
5.75k
    expr_ty p;
8163
5.75k
    if (!left) {
8164
0
        PyErr_SetString(PyExc_ValueError,
8165
0
                        "field 'left' is required for Compare");
8166
0
        return NULL;
8167
0
    }
8168
5.75k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8169
5.75k
    if (!p)
8170
0
        return NULL;
8171
5.75k
    p->kind = Compare_kind;
8172
5.75k
    p->v.Compare.left = left;
8173
5.75k
    p->v.Compare.ops = ops;
8174
5.75k
    p->v.Compare.comparators = comparators;
8175
5.75k
    p->lineno = lineno;
8176
5.75k
    p->col_offset = col_offset;
8177
5.75k
    p->end_lineno = end_lineno;
8178
5.75k
    p->end_col_offset = end_col_offset;
8179
5.75k
    return p;
8180
5.75k
}
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
60.7k
{
8187
60.7k
    expr_ty p;
8188
60.7k
    if (!func) {
8189
0
        PyErr_SetString(PyExc_ValueError,
8190
0
                        "field 'func' is required for Call");
8191
0
        return NULL;
8192
0
    }
8193
60.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8194
60.7k
    if (!p)
8195
0
        return NULL;
8196
60.7k
    p->kind = Call_kind;
8197
60.7k
    p->v.Call.func = func;
8198
60.7k
    p->v.Call.args = args;
8199
60.7k
    p->v.Call.keywords = keywords;
8200
60.7k
    p->lineno = lineno;
8201
60.7k
    p->col_offset = col_offset;
8202
60.7k
    p->end_lineno = end_lineno;
8203
60.7k
    p->end_col_offset = end_col_offset;
8204
60.7k
    return p;
8205
60.7k
}
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
22.7k
{
8212
22.7k
    expr_ty p;
8213
22.7k
    if (!value) {
8214
0
        PyErr_SetString(PyExc_ValueError,
8215
0
                        "field 'value' is required for FormattedValue");
8216
0
        return NULL;
8217
0
    }
8218
22.7k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8219
22.7k
    if (!p)
8220
0
        return NULL;
8221
22.7k
    p->kind = FormattedValue_kind;
8222
22.7k
    p->v.FormattedValue.value = value;
8223
22.7k
    p->v.FormattedValue.conversion = conversion;
8224
22.7k
    p->v.FormattedValue.format_spec = format_spec;
8225
22.7k
    p->lineno = lineno;
8226
22.7k
    p->col_offset = col_offset;
8227
22.7k
    p->end_lineno = end_lineno;
8228
22.7k
    p->end_col_offset = end_col_offset;
8229
22.7k
    return p;
8230
22.7k
}
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
5.24k
{
8237
5.24k
    expr_ty p;
8238
5.24k
    if (!value) {
8239
0
        PyErr_SetString(PyExc_ValueError,
8240
0
                        "field 'value' is required for Interpolation");
8241
0
        return NULL;
8242
0
    }
8243
5.24k
    if (!str) {
8244
0
        PyErr_SetString(PyExc_ValueError,
8245
0
                        "field 'str' is required for Interpolation");
8246
0
        return NULL;
8247
0
    }
8248
5.24k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8249
5.24k
    if (!p)
8250
0
        return NULL;
8251
5.24k
    p->kind = Interpolation_kind;
8252
5.24k
    p->v.Interpolation.value = value;
8253
5.24k
    p->v.Interpolation.str = str;
8254
5.24k
    p->v.Interpolation.conversion = conversion;
8255
5.24k
    p->v.Interpolation.format_spec = format_spec;
8256
5.24k
    p->lineno = lineno;
8257
5.24k
    p->col_offset = col_offset;
8258
5.24k
    p->end_lineno = end_lineno;
8259
5.24k
    p->end_col_offset = end_col_offset;
8260
5.24k
    return p;
8261
5.24k
}
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
37.4k
{
8267
37.4k
    expr_ty p;
8268
37.4k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8269
37.4k
    if (!p)
8270
0
        return NULL;
8271
37.4k
    p->kind = JoinedStr_kind;
8272
37.4k
    p->v.JoinedStr.values = values;
8273
37.4k
    p->lineno = lineno;
8274
37.4k
    p->col_offset = col_offset;
8275
37.4k
    p->end_lineno = end_lineno;
8276
37.4k
    p->end_col_offset = end_col_offset;
8277
37.4k
    return p;
8278
37.4k
}
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
7.54k
{
8284
7.54k
    expr_ty p;
8285
7.54k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8286
7.54k
    if (!p)
8287
0
        return NULL;
8288
7.54k
    p->kind = TemplateStr_kind;
8289
7.54k
    p->v.TemplateStr.values = values;
8290
7.54k
    p->lineno = lineno;
8291
7.54k
    p->col_offset = col_offset;
8292
7.54k
    p->end_lineno = end_lineno;
8293
7.54k
    p->end_col_offset = end_col_offset;
8294
7.54k
    return p;
8295
7.54k
}
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
340k
{
8301
340k
    expr_ty p;
8302
340k
    if (!value) {
8303
2
        PyErr_SetString(PyExc_ValueError,
8304
2
                        "field 'value' is required for Constant");
8305
2
        return NULL;
8306
2
    }
8307
340k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8308
340k
    if (!p)
8309
0
        return NULL;
8310
340k
    p->kind = Constant_kind;
8311
340k
    p->v.Constant.value = value;
8312
340k
    p->v.Constant.kind = kind;
8313
340k
    p->lineno = lineno;
8314
340k
    p->col_offset = col_offset;
8315
340k
    p->end_lineno = end_lineno;
8316
340k
    p->end_col_offset = end_col_offset;
8317
340k
    return p;
8318
340k
}
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
36.6k
{
8325
36.6k
    expr_ty p;
8326
36.6k
    if (!value) {
8327
0
        PyErr_SetString(PyExc_ValueError,
8328
0
                        "field 'value' is required for Attribute");
8329
0
        return NULL;
8330
0
    }
8331
36.6k
    if (!attr) {
8332
0
        PyErr_SetString(PyExc_ValueError,
8333
0
                        "field 'attr' is required for Attribute");
8334
0
        return NULL;
8335
0
    }
8336
36.6k
    if (!ctx) {
8337
0
        PyErr_SetString(PyExc_ValueError,
8338
0
                        "field 'ctx' is required for Attribute");
8339
0
        return NULL;
8340
0
    }
8341
36.6k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8342
36.6k
    if (!p)
8343
0
        return NULL;
8344
36.6k
    p->kind = Attribute_kind;
8345
36.6k
    p->v.Attribute.value = value;
8346
36.6k
    p->v.Attribute.attr = attr;
8347
36.6k
    p->v.Attribute.ctx = ctx;
8348
36.6k
    p->lineno = lineno;
8349
36.6k
    p->col_offset = col_offset;
8350
36.6k
    p->end_lineno = end_lineno;
8351
36.6k
    p->end_col_offset = end_col_offset;
8352
36.6k
    return p;
8353
36.6k
}
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
3.92k
{
8360
3.92k
    expr_ty p;
8361
3.92k
    if (!value) {
8362
0
        PyErr_SetString(PyExc_ValueError,
8363
0
                        "field 'value' is required for Subscript");
8364
0
        return NULL;
8365
0
    }
8366
3.92k
    if (!slice) {
8367
0
        PyErr_SetString(PyExc_ValueError,
8368
0
                        "field 'slice' is required for Subscript");
8369
0
        return NULL;
8370
0
    }
8371
3.92k
    if (!ctx) {
8372
0
        PyErr_SetString(PyExc_ValueError,
8373
0
                        "field 'ctx' is required for Subscript");
8374
0
        return NULL;
8375
0
    }
8376
3.92k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8377
3.92k
    if (!p)
8378
0
        return NULL;
8379
3.92k
    p->kind = Subscript_kind;
8380
3.92k
    p->v.Subscript.value = value;
8381
3.92k
    p->v.Subscript.slice = slice;
8382
3.92k
    p->v.Subscript.ctx = ctx;
8383
3.92k
    p->lineno = lineno;
8384
3.92k
    p->col_offset = col_offset;
8385
3.92k
    p->end_lineno = end_lineno;
8386
3.92k
    p->end_col_offset = end_col_offset;
8387
3.92k
    return p;
8388
3.92k
}
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
17.5k
{
8394
17.5k
    expr_ty p;
8395
17.5k
    if (!value) {
8396
0
        PyErr_SetString(PyExc_ValueError,
8397
0
                        "field 'value' is required for Starred");
8398
0
        return NULL;
8399
0
    }
8400
17.5k
    if (!ctx) {
8401
0
        PyErr_SetString(PyExc_ValueError,
8402
0
                        "field 'ctx' is required for Starred");
8403
0
        return NULL;
8404
0
    }
8405
17.5k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8406
17.5k
    if (!p)
8407
0
        return NULL;
8408
17.5k
    p->kind = Starred_kind;
8409
17.5k
    p->v.Starred.value = value;
8410
17.5k
    p->v.Starred.ctx = ctx;
8411
17.5k
    p->lineno = lineno;
8412
17.5k
    p->col_offset = col_offset;
8413
17.5k
    p->end_lineno = end_lineno;
8414
17.5k
    p->end_col_offset = end_col_offset;
8415
17.5k
    return p;
8416
17.5k
}
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
11.1M
{
8422
11.1M
    expr_ty p;
8423
11.1M
    if (!id) {
8424
0
        PyErr_SetString(PyExc_ValueError,
8425
0
                        "field 'id' is required for Name");
8426
0
        return NULL;
8427
0
    }
8428
11.1M
    if (!ctx) {
8429
0
        PyErr_SetString(PyExc_ValueError,
8430
0
                        "field 'ctx' is required for Name");
8431
0
        return NULL;
8432
0
    }
8433
11.1M
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8434
11.1M
    if (!p)
8435
0
        return NULL;
8436
11.1M
    p->kind = Name_kind;
8437
11.1M
    p->v.Name.id = id;
8438
11.1M
    p->v.Name.ctx = ctx;
8439
11.1M
    p->lineno = lineno;
8440
11.1M
    p->col_offset = col_offset;
8441
11.1M
    p->end_lineno = end_lineno;
8442
11.1M
    p->end_col_offset = end_col_offset;
8443
11.1M
    return p;
8444
11.1M
}
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
16.3k
{
8450
16.3k
    expr_ty p;
8451
16.3k
    if (!ctx) {
8452
0
        PyErr_SetString(PyExc_ValueError,
8453
0
                        "field 'ctx' is required for List");
8454
0
        return NULL;
8455
0
    }
8456
16.3k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8457
16.3k
    if (!p)
8458
0
        return NULL;
8459
16.3k
    p->kind = List_kind;
8460
16.3k
    p->v.List.elts = elts;
8461
16.3k
    p->v.List.ctx = ctx;
8462
16.3k
    p->lineno = lineno;
8463
16.3k
    p->col_offset = col_offset;
8464
16.3k
    p->end_lineno = end_lineno;
8465
16.3k
    p->end_col_offset = end_col_offset;
8466
16.3k
    return p;
8467
16.3k
}
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
11.1k
{
8496
11.1k
    expr_ty p;
8497
11.1k
    p = (expr_ty)_PyArena_Malloc(arena, sizeof(*p));
8498
11.1k
    if (!p)
8499
0
        return NULL;
8500
11.1k
    p->kind = Slice_kind;
8501
11.1k
    p->v.Slice.lower = lower;
8502
11.1k
    p->v.Slice.upper = upper;
8503
11.1k
    p->v.Slice.step = step;
8504
11.1k
    p->lineno = lineno;
8505
11.1k
    p->col_offset = col_offset;
8506
11.1k
    p->end_lineno = end_lineno;
8507
11.1k
    p->end_col_offset = end_col_offset;
8508
11.1k
    return p;
8509
11.1k
}
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.56k
{
8515
8.56k
    comprehension_ty p;
8516
8.56k
    if (!target) {
8517
0
        PyErr_SetString(PyExc_ValueError,
8518
0
                        "field 'target' is required for comprehension");
8519
0
        return NULL;
8520
0
    }
8521
8.56k
    if (!iter) {
8522
0
        PyErr_SetString(PyExc_ValueError,
8523
0
                        "field 'iter' is required for comprehension");
8524
0
        return NULL;
8525
0
    }
8526
8.56k
    p = (comprehension_ty)_PyArena_Malloc(arena, sizeof(*p));
8527
8.56k
    if (!p)
8528
0
        return NULL;
8529
8.56k
    p->target = target;
8530
8.56k
    p->iter = iter;
8531
8.56k
    p->ifs = ifs;
8532
8.56k
    p->is_async = is_async;
8533
8.56k
    return p;
8534
8.56k
}
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
8.07k
{
8541
8.07k
    excepthandler_ty p;
8542
8.07k
    p = (excepthandler_ty)_PyArena_Malloc(arena, sizeof(*p));
8543
8.07k
    if (!p)
8544
0
        return NULL;
8545
8.07k
    p->kind = ExceptHandler_kind;
8546
8.07k
    p->v.ExceptHandler.type = type;
8547
8.07k
    p->v.ExceptHandler.name = name;
8548
8.07k
    p->v.ExceptHandler.body = body;
8549
8.07k
    p->lineno = lineno;
8550
8.07k
    p->col_offset = col_offset;
8551
8.07k
    p->end_lineno = end_lineno;
8552
8.07k
    p->end_col_offset = end_col_offset;
8553
8.07k
    return p;
8554
8.07k
}
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
310k
{
8562
310k
    arguments_ty p;
8563
310k
    p = (arguments_ty)_PyArena_Malloc(arena, sizeof(*p));
8564
310k
    if (!p)
8565
0
        return NULL;
8566
310k
    p->posonlyargs = posonlyargs;
8567
310k
    p->args = args;
8568
310k
    p->vararg = vararg;
8569
310k
    p->kwonlyargs = kwonlyargs;
8570
310k
    p->kw_defaults = kw_defaults;
8571
310k
    p->kwarg = kwarg;
8572
310k
    p->defaults = defaults;
8573
310k
    return p;
8574
310k
}
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
9.58M
{
8580
9.58M
    arg_ty p;
8581
9.58M
    if (!arg) {
8582
0
        PyErr_SetString(PyExc_ValueError,
8583
0
                        "field 'arg' is required for arg");
8584
0
        return NULL;
8585
0
    }
8586
9.58M
    p = (arg_ty)_PyArena_Malloc(arena, sizeof(*p));
8587
9.58M
    if (!p)
8588
0
        return NULL;
8589
9.58M
    p->arg = arg;
8590
9.58M
    p->annotation = annotation;
8591
9.58M
    p->type_comment = type_comment;
8592
9.58M
    p->lineno = lineno;
8593
9.58M
    p->col_offset = col_offset;
8594
9.58M
    p->end_lineno = end_lineno;
8595
9.58M
    p->end_col_offset = end_col_offset;
8596
9.58M
    return p;
8597
9.58M
}
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
30.7k
{
8603
30.7k
    keyword_ty p;
8604
30.7k
    if (!value) {
8605
0
        PyErr_SetString(PyExc_ValueError,
8606
0
                        "field 'value' is required for keyword");
8607
0
        return NULL;
8608
0
    }
8609
30.7k
    p = (keyword_ty)_PyArena_Malloc(arena, sizeof(*p));
8610
30.7k
    if (!p)
8611
0
        return NULL;
8612
30.7k
    p->arg = arg;
8613
30.7k
    p->value = value;
8614
30.7k
    p->lineno = lineno;
8615
30.7k
    p->col_offset = col_offset;
8616
30.7k
    p->end_lineno = end_lineno;
8617
30.7k
    p->end_col_offset = end_col_offset;
8618
30.7k
    return p;
8619
30.7k
}
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.7k
{
8625
12.7k
    alias_ty p;
8626
12.7k
    if (!name) {
8627
0
        PyErr_SetString(PyExc_ValueError,
8628
0
                        "field 'name' is required for alias");
8629
0
        return NULL;
8630
0
    }
8631
12.7k
    p = (alias_ty)_PyArena_Malloc(arena, sizeof(*p));
8632
12.7k
    if (!p)
8633
0
        return NULL;
8634
12.7k
    p->name = name;
8635
12.7k
    p->asname = asname;
8636
12.7k
    p->lineno = lineno;
8637
12.7k
    p->col_offset = col_offset;
8638
12.7k
    p->end_lineno = end_lineno;
8639
12.7k
    p->end_col_offset = end_col_offset;
8640
12.7k
    return p;
8641
12.7k
}
8642
8643
withitem_ty
8644
_PyAST_withitem(expr_ty context_expr, expr_ty optional_vars, PyArena *arena)
8645
6.17k
{
8646
6.17k
    withitem_ty p;
8647
6.17k
    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
6.17k
    p = (withitem_ty)_PyArena_Malloc(arena, sizeof(*p));
8653
6.17k
    if (!p)
8654
0
        return NULL;
8655
6.17k
    p->context_expr = context_expr;
8656
6.17k
    p->optional_vars = optional_vars;
8657
6.17k
    return p;
8658
6.17k
}
8659
8660
match_case_ty
8661
_PyAST_match_case(pattern_ty pattern, expr_ty guard, asdl_stmt_seq * body,
8662
                  PyArena *arena)
8663
2.54k
{
8664
2.54k
    match_case_ty p;
8665
2.54k
    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.54k
    p = (match_case_ty)_PyArena_Malloc(arena, sizeof(*p));
8671
2.54k
    if (!p)
8672
0
        return NULL;
8673
2.54k
    p->pattern = pattern;
8674
2.54k
    p->guard = guard;
8675
2.54k
    p->body = body;
8676
2.54k
    return p;
8677
2.54k
}
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
3.04k
{
8683
3.04k
    pattern_ty p;
8684
3.04k
    if (!value) {
8685
0
        PyErr_SetString(PyExc_ValueError,
8686
0
                        "field 'value' is required for MatchValue");
8687
0
        return NULL;
8688
0
    }
8689
3.04k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8690
3.04k
    if (!p)
8691
0
        return NULL;
8692
3.04k
    p->kind = MatchValue_kind;
8693
3.04k
    p->v.MatchValue.value = value;
8694
3.04k
    p->lineno = lineno;
8695
3.04k
    p->col_offset = col_offset;
8696
3.04k
    p->end_lineno = end_lineno;
8697
3.04k
    p->end_col_offset = end_col_offset;
8698
3.04k
    return p;
8699
3.04k
}
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
844
{
8705
844
    pattern_ty p;
8706
844
    if (!value) {
8707
0
        PyErr_SetString(PyExc_ValueError,
8708
0
                        "field 'value' is required for MatchSingleton");
8709
0
        return NULL;
8710
0
    }
8711
844
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8712
844
    if (!p)
8713
0
        return NULL;
8714
844
    p->kind = MatchSingleton_kind;
8715
844
    p->v.MatchSingleton.value = value;
8716
844
    p->lineno = lineno;
8717
844
    p->col_offset = col_offset;
8718
844
    p->end_lineno = end_lineno;
8719
844
    p->end_col_offset = end_col_offset;
8720
844
    return p;
8721
844
}
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.59k
{
8727
2.59k
    pattern_ty p;
8728
2.59k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8729
2.59k
    if (!p)
8730
0
        return NULL;
8731
2.59k
    p->kind = MatchSequence_kind;
8732
2.59k
    p->v.MatchSequence.patterns = patterns;
8733
2.59k
    p->lineno = lineno;
8734
2.59k
    p->col_offset = col_offset;
8735
2.59k
    p->end_lineno = end_lineno;
8736
2.59k
    p->end_col_offset = end_col_offset;
8737
2.59k
    return p;
8738
2.59k
}
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
1.08k
{
8745
1.08k
    pattern_ty p;
8746
1.08k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8747
1.08k
    if (!p)
8748
0
        return NULL;
8749
1.08k
    p->kind = MatchMapping_kind;
8750
1.08k
    p->v.MatchMapping.keys = keys;
8751
1.08k
    p->v.MatchMapping.patterns = patterns;
8752
1.08k
    p->v.MatchMapping.rest = rest;
8753
1.08k
    p->lineno = lineno;
8754
1.08k
    p->col_offset = col_offset;
8755
1.08k
    p->end_lineno = end_lineno;
8756
1.08k
    p->end_col_offset = end_col_offset;
8757
1.08k
    return p;
8758
1.08k
}
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
1.95k
{
8766
1.95k
    pattern_ty p;
8767
1.95k
    if (!cls) {
8768
0
        PyErr_SetString(PyExc_ValueError,
8769
0
                        "field 'cls' is required for MatchClass");
8770
0
        return NULL;
8771
0
    }
8772
1.95k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8773
1.95k
    if (!p)
8774
0
        return NULL;
8775
1.95k
    p->kind = MatchClass_kind;
8776
1.95k
    p->v.MatchClass.cls = cls;
8777
1.95k
    p->v.MatchClass.patterns = patterns;
8778
1.95k
    p->v.MatchClass.kwd_attrs = kwd_attrs;
8779
1.95k
    p->v.MatchClass.kwd_patterns = kwd_patterns;
8780
1.95k
    p->lineno = lineno;
8781
1.95k
    p->col_offset = col_offset;
8782
1.95k
    p->end_lineno = end_lineno;
8783
1.95k
    p->end_col_offset = end_col_offset;
8784
1.95k
    return p;
8785
1.95k
}
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.29k
{
8791
1.29k
    pattern_ty p;
8792
1.29k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8793
1.29k
    if (!p)
8794
0
        return NULL;
8795
1.29k
    p->kind = MatchStar_kind;
8796
1.29k
    p->v.MatchStar.name = name;
8797
1.29k
    p->lineno = lineno;
8798
1.29k
    p->col_offset = col_offset;
8799
1.29k
    p->end_lineno = end_lineno;
8800
1.29k
    p->end_col_offset = end_col_offset;
8801
1.29k
    return p;
8802
1.29k
}
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
20.3k
{
8808
20.3k
    pattern_ty p;
8809
20.3k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8810
20.3k
    if (!p)
8811
0
        return NULL;
8812
20.3k
    p->kind = MatchAs_kind;
8813
20.3k
    p->v.MatchAs.pattern = pattern;
8814
20.3k
    p->v.MatchAs.name = name;
8815
20.3k
    p->lineno = lineno;
8816
20.3k
    p->col_offset = col_offset;
8817
20.3k
    p->end_lineno = end_lineno;
8818
20.3k
    p->end_col_offset = end_col_offset;
8819
20.3k
    return p;
8820
20.3k
}
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
6.70k
{
8826
6.70k
    pattern_ty p;
8827
6.70k
    p = (pattern_ty)_PyArena_Malloc(arena, sizeof(*p));
8828
6.70k
    if (!p)
8829
0
        return NULL;
8830
6.70k
    p->kind = MatchOr_kind;
8831
6.70k
    p->v.MatchOr.patterns = patterns;
8832
6.70k
    p->lineno = lineno;
8833
6.70k
    p->col_offset = col_offset;
8834
6.70k
    p->end_lineno = end_lineno;
8835
6.70k
    p->end_col_offset = end_col_offset;
8836
6.70k
    return p;
8837
6.70k
}
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
6.68k
{
8862
6.68k
    type_param_ty p;
8863
6.68k
    if (!name) {
8864
0
        PyErr_SetString(PyExc_ValueError,
8865
0
                        "field 'name' is required for TypeVar");
8866
0
        return NULL;
8867
0
    }
8868
6.68k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8869
6.68k
    if (!p)
8870
0
        return NULL;
8871
6.68k
    p->kind = TypeVar_kind;
8872
6.68k
    p->v.TypeVar.name = name;
8873
6.68k
    p->v.TypeVar.bound = bound;
8874
6.68k
    p->v.TypeVar.default_value = default_value;
8875
6.68k
    p->lineno = lineno;
8876
6.68k
    p->col_offset = col_offset;
8877
6.68k
    p->end_lineno = end_lineno;
8878
6.68k
    p->end_col_offset = end_col_offset;
8879
6.68k
    return p;
8880
6.68k
}
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
955
{
8886
955
    type_param_ty p;
8887
955
    if (!name) {
8888
0
        PyErr_SetString(PyExc_ValueError,
8889
0
                        "field 'name' is required for ParamSpec");
8890
0
        return NULL;
8891
0
    }
8892
955
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8893
955
    if (!p)
8894
0
        return NULL;
8895
955
    p->kind = ParamSpec_kind;
8896
955
    p->v.ParamSpec.name = name;
8897
955
    p->v.ParamSpec.default_value = default_value;
8898
955
    p->lineno = lineno;
8899
955
    p->col_offset = col_offset;
8900
955
    p->end_lineno = end_lineno;
8901
955
    p->end_col_offset = end_col_offset;
8902
955
    return p;
8903
955
}
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.68k
{
8910
1.68k
    type_param_ty p;
8911
1.68k
    if (!name) {
8912
0
        PyErr_SetString(PyExc_ValueError,
8913
0
                        "field 'name' is required for TypeVarTuple");
8914
0
        return NULL;
8915
0
    }
8916
1.68k
    p = (type_param_ty)_PyArena_Malloc(arena, sizeof(*p));
8917
1.68k
    if (!p)
8918
0
        return NULL;
8919
1.68k
    p->kind = TypeVarTuple_kind;
8920
1.68k
    p->v.TypeVarTuple.name = name;
8921
1.68k
    p->v.TypeVarTuple.default_value = default_value;
8922
1.68k
    p->lineno = lineno;
8923
1.68k
    p->col_offset = col_offset;
8924
1.68k
    p->end_lineno = end_lineno;
8925
1.68k
    p->end_col_offset = end_col_offset;
8926
1.68k
    return p;
8927
1.68k
}
8928
8929
8930
PyObject*
8931
ast2obj_mod(struct ast_state *state, void* _o)
8932
5.58k
{
8933
5.58k
    mod_ty o = (mod_ty)_o;
8934
5.58k
    PyObject *result = NULL, *value = NULL;
8935
5.58k
    PyTypeObject *tp;
8936
5.58k
    if (!o) {
8937
0
        Py_RETURN_NONE;
8938
0
    }
8939
5.58k
    if (Py_EnterRecursiveCall("during  ast construction")) {
8940
0
        return NULL;
8941
0
    }
8942
5.58k
    switch (o->kind) {
8943
5.58k
    case Module_kind:
8944
5.58k
        tp = (PyTypeObject *)state->Module_type;
8945
5.58k
        result = PyType_GenericNew(tp, NULL, NULL);
8946
5.58k
        if (!result) goto failed;
8947
5.58k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.body, ast2obj_stmt);
8948
5.58k
        if (!value) goto failed;
8949
5.58k
        if (PyObject_SetAttr(result, state->body, value) == -1)
8950
0
            goto failed;
8951
5.58k
        Py_DECREF(value);
8952
5.58k
        value = ast2obj_list(state, (asdl_seq*)o->v.Module.type_ignores,
8953
5.58k
                             ast2obj_type_ignore);
8954
5.58k
        if (!value) goto failed;
8955
5.58k
        if (PyObject_SetAttr(result, state->type_ignores, value) == -1)
8956
0
            goto failed;
8957
5.58k
        Py_DECREF(value);
8958
5.58k
        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
5.58k
    }
8997
5.58k
    Py_LeaveRecursiveCall();
8998
5.58k
    return result;
8999
0
failed:
9000
0
    Py_LeaveRecursiveCall();
9001
0
    Py_XDECREF(value);
9002
0
    Py_XDECREF(result);
9003
0
    return NULL;
9004
5.58k
}
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.48k
    case FunctionDef_kind:
9020
1.48k
        tp = (PyTypeObject *)state->FunctionDef_type;
9021
1.48k
        result = PyType_GenericNew(tp, NULL, NULL);
9022
1.48k
        if (!result) goto failed;
9023
1.48k
        value = ast2obj_identifier(state, o->v.FunctionDef.name);
9024
1.48k
        if (!value) goto failed;
9025
1.48k
        if (PyObject_SetAttr(result, state->name, value) == -1)
9026
0
            goto failed;
9027
1.48k
        Py_DECREF(value);
9028
1.48k
        value = ast2obj_arguments(state, o->v.FunctionDef.args);
9029
1.48k
        if (!value) goto failed;
9030
1.48k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9031
0
            goto failed;
9032
1.48k
        Py_DECREF(value);
9033
1.48k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.body,
9034
1.48k
                             ast2obj_stmt);
9035
1.48k
        if (!value) goto failed;
9036
1.48k
        if (PyObject_SetAttr(result, state->body, value) == -1)
9037
0
            goto failed;
9038
1.48k
        Py_DECREF(value);
9039
1.48k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.decorator_list,
9040
1.48k
                             ast2obj_expr);
9041
1.48k
        if (!value) goto failed;
9042
1.48k
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9043
0
            goto failed;
9044
1.48k
        Py_DECREF(value);
9045
1.48k
        value = ast2obj_expr(state, o->v.FunctionDef.returns);
9046
1.48k
        if (!value) goto failed;
9047
1.48k
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9048
0
            goto failed;
9049
1.48k
        Py_DECREF(value);
9050
1.48k
        value = ast2obj_string(state, o->v.FunctionDef.type_comment);
9051
1.48k
        if (!value) goto failed;
9052
1.48k
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9053
0
            goto failed;
9054
1.48k
        Py_DECREF(value);
9055
1.48k
        value = ast2obj_list(state, (asdl_seq*)o->v.FunctionDef.type_params,
9056
1.48k
                             ast2obj_type_param);
9057
1.48k
        if (!value) goto failed;
9058
1.48k
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9059
0
            goto failed;
9060
1.48k
        Py_DECREF(value);
9061
1.48k
        break;
9062
208
    case AsyncFunctionDef_kind:
9063
208
        tp = (PyTypeObject *)state->AsyncFunctionDef_type;
9064
208
        result = PyType_GenericNew(tp, NULL, NULL);
9065
208
        if (!result) goto failed;
9066
208
        value = ast2obj_identifier(state, o->v.AsyncFunctionDef.name);
9067
208
        if (!value) goto failed;
9068
208
        if (PyObject_SetAttr(result, state->name, value) == -1)
9069
0
            goto failed;
9070
208
        Py_DECREF(value);
9071
208
        value = ast2obj_arguments(state, o->v.AsyncFunctionDef.args);
9072
208
        if (!value) goto failed;
9073
208
        if (PyObject_SetAttr(result, state->args, value) == -1)
9074
0
            goto failed;
9075
208
        Py_DECREF(value);
9076
208
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFunctionDef.body,
9077
208
                             ast2obj_stmt);
9078
208
        if (!value) goto failed;
9079
208
        if (PyObject_SetAttr(result, state->body, value) == -1)
9080
0
            goto failed;
9081
208
        Py_DECREF(value);
9082
208
        value = ast2obj_list(state,
9083
208
                             (asdl_seq*)o->v.AsyncFunctionDef.decorator_list,
9084
208
                             ast2obj_expr);
9085
208
        if (!value) goto failed;
9086
208
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9087
0
            goto failed;
9088
208
        Py_DECREF(value);
9089
208
        value = ast2obj_expr(state, o->v.AsyncFunctionDef.returns);
9090
208
        if (!value) goto failed;
9091
208
        if (PyObject_SetAttr(result, state->returns, value) == -1)
9092
0
            goto failed;
9093
208
        Py_DECREF(value);
9094
208
        value = ast2obj_string(state, o->v.AsyncFunctionDef.type_comment);
9095
208
        if (!value) goto failed;
9096
208
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9097
0
            goto failed;
9098
208
        Py_DECREF(value);
9099
208
        value = ast2obj_list(state,
9100
208
                             (asdl_seq*)o->v.AsyncFunctionDef.type_params,
9101
208
                             ast2obj_type_param);
9102
208
        if (!value) goto failed;
9103
208
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9104
0
            goto failed;
9105
208
        Py_DECREF(value);
9106
208
        break;
9107
532
    case ClassDef_kind:
9108
532
        tp = (PyTypeObject *)state->ClassDef_type;
9109
532
        result = PyType_GenericNew(tp, NULL, NULL);
9110
532
        if (!result) goto failed;
9111
532
        value = ast2obj_identifier(state, o->v.ClassDef.name);
9112
532
        if (!value) goto failed;
9113
532
        if (PyObject_SetAttr(result, state->name, value) == -1)
9114
0
            goto failed;
9115
532
        Py_DECREF(value);
9116
532
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.bases,
9117
532
                             ast2obj_expr);
9118
532
        if (!value) goto failed;
9119
532
        if (PyObject_SetAttr(result, state->bases, value) == -1)
9120
0
            goto failed;
9121
532
        Py_DECREF(value);
9122
532
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.keywords,
9123
532
                             ast2obj_keyword);
9124
532
        if (!value) goto failed;
9125
532
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9126
0
            goto failed;
9127
532
        Py_DECREF(value);
9128
532
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.body,
9129
532
                             ast2obj_stmt);
9130
532
        if (!value) goto failed;
9131
532
        if (PyObject_SetAttr(result, state->body, value) == -1)
9132
0
            goto failed;
9133
532
        Py_DECREF(value);
9134
532
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.decorator_list,
9135
532
                             ast2obj_expr);
9136
532
        if (!value) goto failed;
9137
532
        if (PyObject_SetAttr(result, state->decorator_list, value) == -1)
9138
0
            goto failed;
9139
532
        Py_DECREF(value);
9140
532
        value = ast2obj_list(state, (asdl_seq*)o->v.ClassDef.type_params,
9141
532
                             ast2obj_type_param);
9142
532
        if (!value) goto failed;
9143
532
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9144
0
            goto failed;
9145
532
        Py_DECREF(value);
9146
532
        break;
9147
418
    case Return_kind:
9148
418
        tp = (PyTypeObject *)state->Return_type;
9149
418
        result = PyType_GenericNew(tp, NULL, NULL);
9150
418
        if (!result) goto failed;
9151
418
        value = ast2obj_expr(state, o->v.Return.value);
9152
418
        if (!value) goto failed;
9153
418
        if (PyObject_SetAttr(result, state->value, value) == -1)
9154
0
            goto failed;
9155
418
        Py_DECREF(value);
9156
418
        break;
9157
163
    case Delete_kind:
9158
163
        tp = (PyTypeObject *)state->Delete_type;
9159
163
        result = PyType_GenericNew(tp, NULL, NULL);
9160
163
        if (!result) goto failed;
9161
163
        value = ast2obj_list(state, (asdl_seq*)o->v.Delete.targets,
9162
163
                             ast2obj_expr);
9163
163
        if (!value) goto failed;
9164
163
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9165
0
            goto failed;
9166
163
        Py_DECREF(value);
9167
163
        break;
9168
730
    case Assign_kind:
9169
730
        tp = (PyTypeObject *)state->Assign_type;
9170
730
        result = PyType_GenericNew(tp, NULL, NULL);
9171
730
        if (!result) goto failed;
9172
730
        value = ast2obj_list(state, (asdl_seq*)o->v.Assign.targets,
9173
730
                             ast2obj_expr);
9174
730
        if (!value) goto failed;
9175
730
        if (PyObject_SetAttr(result, state->targets, value) == -1)
9176
0
            goto failed;
9177
730
        Py_DECREF(value);
9178
730
        value = ast2obj_expr(state, o->v.Assign.value);
9179
730
        if (!value) goto failed;
9180
730
        if (PyObject_SetAttr(result, state->value, value) == -1)
9181
0
            goto failed;
9182
730
        Py_DECREF(value);
9183
730
        value = ast2obj_string(state, o->v.Assign.type_comment);
9184
730
        if (!value) goto failed;
9185
730
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9186
0
            goto failed;
9187
730
        Py_DECREF(value);
9188
730
        break;
9189
43
    case TypeAlias_kind:
9190
43
        tp = (PyTypeObject *)state->TypeAlias_type;
9191
43
        result = PyType_GenericNew(tp, NULL, NULL);
9192
43
        if (!result) goto failed;
9193
43
        value = ast2obj_expr(state, o->v.TypeAlias.name);
9194
43
        if (!value) goto failed;
9195
43
        if (PyObject_SetAttr(result, state->name, value) == -1)
9196
0
            goto failed;
9197
43
        Py_DECREF(value);
9198
43
        value = ast2obj_list(state, (asdl_seq*)o->v.TypeAlias.type_params,
9199
43
                             ast2obj_type_param);
9200
43
        if (!value) goto failed;
9201
43
        if (PyObject_SetAttr(result, state->type_params, value) == -1)
9202
0
            goto failed;
9203
43
        Py_DECREF(value);
9204
43
        value = ast2obj_expr(state, o->v.TypeAlias.value);
9205
43
        if (!value) goto failed;
9206
43
        if (PyObject_SetAttr(result, state->value, value) == -1)
9207
0
            goto failed;
9208
43
        Py_DECREF(value);
9209
43
        break;
9210
355
    case AugAssign_kind:
9211
355
        tp = (PyTypeObject *)state->AugAssign_type;
9212
355
        result = PyType_GenericNew(tp, NULL, NULL);
9213
355
        if (!result) goto failed;
9214
355
        value = ast2obj_expr(state, o->v.AugAssign.target);
9215
355
        if (!value) goto failed;
9216
355
        if (PyObject_SetAttr(result, state->target, value) == -1)
9217
0
            goto failed;
9218
355
        Py_DECREF(value);
9219
355
        value = ast2obj_operator(state, o->v.AugAssign.op);
9220
355
        if (!value) goto failed;
9221
355
        if (PyObject_SetAttr(result, state->op, value) == -1)
9222
0
            goto failed;
9223
355
        Py_DECREF(value);
9224
355
        value = ast2obj_expr(state, o->v.AugAssign.value);
9225
355
        if (!value) goto failed;
9226
355
        if (PyObject_SetAttr(result, state->value, value) == -1)
9227
0
            goto failed;
9228
355
        Py_DECREF(value);
9229
355
        break;
9230
1.25k
    case AnnAssign_kind:
9231
1.25k
        tp = (PyTypeObject *)state->AnnAssign_type;
9232
1.25k
        result = PyType_GenericNew(tp, NULL, NULL);
9233
1.25k
        if (!result) goto failed;
9234
1.25k
        value = ast2obj_expr(state, o->v.AnnAssign.target);
9235
1.25k
        if (!value) goto failed;
9236
1.25k
        if (PyObject_SetAttr(result, state->target, value) == -1)
9237
0
            goto failed;
9238
1.25k
        Py_DECREF(value);
9239
1.25k
        value = ast2obj_expr(state, o->v.AnnAssign.annotation);
9240
1.25k
        if (!value) goto failed;
9241
1.25k
        if (PyObject_SetAttr(result, state->annotation, value) == -1)
9242
0
            goto failed;
9243
1.25k
        Py_DECREF(value);
9244
1.25k
        value = ast2obj_expr(state, o->v.AnnAssign.value);
9245
1.25k
        if (!value) goto failed;
9246
1.25k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9247
0
            goto failed;
9248
1.25k
        Py_DECREF(value);
9249
1.25k
        value = ast2obj_int(state, o->v.AnnAssign.simple);
9250
1.25k
        if (!value) goto failed;
9251
1.25k
        if (PyObject_SetAttr(result, state->simple, value) == -1)
9252
0
            goto failed;
9253
1.25k
        Py_DECREF(value);
9254
1.25k
        break;
9255
304
    case For_kind:
9256
304
        tp = (PyTypeObject *)state->For_type;
9257
304
        result = PyType_GenericNew(tp, NULL, NULL);
9258
304
        if (!result) goto failed;
9259
304
        value = ast2obj_expr(state, o->v.For.target);
9260
304
        if (!value) goto failed;
9261
304
        if (PyObject_SetAttr(result, state->target, value) == -1)
9262
0
            goto failed;
9263
304
        Py_DECREF(value);
9264
304
        value = ast2obj_expr(state, o->v.For.iter);
9265
304
        if (!value) goto failed;
9266
304
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9267
0
            goto failed;
9268
304
        Py_DECREF(value);
9269
304
        value = ast2obj_list(state, (asdl_seq*)o->v.For.body, ast2obj_stmt);
9270
304
        if (!value) goto failed;
9271
304
        if (PyObject_SetAttr(result, state->body, value) == -1)
9272
0
            goto failed;
9273
304
        Py_DECREF(value);
9274
304
        value = ast2obj_list(state, (asdl_seq*)o->v.For.orelse, ast2obj_stmt);
9275
304
        if (!value) goto failed;
9276
304
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9277
0
            goto failed;
9278
304
        Py_DECREF(value);
9279
304
        value = ast2obj_string(state, o->v.For.type_comment);
9280
304
        if (!value) goto failed;
9281
304
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9282
0
            goto failed;
9283
304
        Py_DECREF(value);
9284
304
        break;
9285
140
    case AsyncFor_kind:
9286
140
        tp = (PyTypeObject *)state->AsyncFor_type;
9287
140
        result = PyType_GenericNew(tp, NULL, NULL);
9288
140
        if (!result) goto failed;
9289
140
        value = ast2obj_expr(state, o->v.AsyncFor.target);
9290
140
        if (!value) goto failed;
9291
140
        if (PyObject_SetAttr(result, state->target, value) == -1)
9292
0
            goto failed;
9293
140
        Py_DECREF(value);
9294
140
        value = ast2obj_expr(state, o->v.AsyncFor.iter);
9295
140
        if (!value) goto failed;
9296
140
        if (PyObject_SetAttr(result, state->iter, value) == -1)
9297
0
            goto failed;
9298
140
        Py_DECREF(value);
9299
140
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.body,
9300
140
                             ast2obj_stmt);
9301
140
        if (!value) goto failed;
9302
140
        if (PyObject_SetAttr(result, state->body, value) == -1)
9303
0
            goto failed;
9304
140
        Py_DECREF(value);
9305
140
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncFor.orelse,
9306
140
                             ast2obj_stmt);
9307
140
        if (!value) goto failed;
9308
140
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9309
0
            goto failed;
9310
140
        Py_DECREF(value);
9311
140
        value = ast2obj_string(state, o->v.AsyncFor.type_comment);
9312
140
        if (!value) goto failed;
9313
140
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9314
0
            goto failed;
9315
140
        Py_DECREF(value);
9316
140
        break;
9317
211
    case While_kind:
9318
211
        tp = (PyTypeObject *)state->While_type;
9319
211
        result = PyType_GenericNew(tp, NULL, NULL);
9320
211
        if (!result) goto failed;
9321
211
        value = ast2obj_expr(state, o->v.While.test);
9322
211
        if (!value) goto failed;
9323
211
        if (PyObject_SetAttr(result, state->test, value) == -1)
9324
0
            goto failed;
9325
211
        Py_DECREF(value);
9326
211
        value = ast2obj_list(state, (asdl_seq*)o->v.While.body, ast2obj_stmt);
9327
211
        if (!value) goto failed;
9328
211
        if (PyObject_SetAttr(result, state->body, value) == -1)
9329
0
            goto failed;
9330
211
        Py_DECREF(value);
9331
211
        value = ast2obj_list(state, (asdl_seq*)o->v.While.orelse, ast2obj_stmt);
9332
211
        if (!value) goto failed;
9333
211
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9334
0
            goto failed;
9335
211
        Py_DECREF(value);
9336
211
        break;
9337
393
    case If_kind:
9338
393
        tp = (PyTypeObject *)state->If_type;
9339
393
        result = PyType_GenericNew(tp, NULL, NULL);
9340
393
        if (!result) goto failed;
9341
393
        value = ast2obj_expr(state, o->v.If.test);
9342
393
        if (!value) goto failed;
9343
393
        if (PyObject_SetAttr(result, state->test, value) == -1)
9344
0
            goto failed;
9345
393
        Py_DECREF(value);
9346
393
        value = ast2obj_list(state, (asdl_seq*)o->v.If.body, ast2obj_stmt);
9347
393
        if (!value) goto failed;
9348
393
        if (PyObject_SetAttr(result, state->body, value) == -1)
9349
0
            goto failed;
9350
393
        Py_DECREF(value);
9351
393
        value = ast2obj_list(state, (asdl_seq*)o->v.If.orelse, ast2obj_stmt);
9352
393
        if (!value) goto failed;
9353
393
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9354
0
            goto failed;
9355
393
        Py_DECREF(value);
9356
393
        break;
9357
124
    case With_kind:
9358
124
        tp = (PyTypeObject *)state->With_type;
9359
124
        result = PyType_GenericNew(tp, NULL, NULL);
9360
124
        if (!result) goto failed;
9361
124
        value = ast2obj_list(state, (asdl_seq*)o->v.With.items,
9362
124
                             ast2obj_withitem);
9363
124
        if (!value) goto failed;
9364
124
        if (PyObject_SetAttr(result, state->items, value) == -1)
9365
0
            goto failed;
9366
124
        Py_DECREF(value);
9367
124
        value = ast2obj_list(state, (asdl_seq*)o->v.With.body, ast2obj_stmt);
9368
124
        if (!value) goto failed;
9369
124
        if (PyObject_SetAttr(result, state->body, value) == -1)
9370
0
            goto failed;
9371
124
        Py_DECREF(value);
9372
124
        value = ast2obj_string(state, o->v.With.type_comment);
9373
124
        if (!value) goto failed;
9374
124
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9375
0
            goto failed;
9376
124
        Py_DECREF(value);
9377
124
        break;
9378
154
    case AsyncWith_kind:
9379
154
        tp = (PyTypeObject *)state->AsyncWith_type;
9380
154
        result = PyType_GenericNew(tp, NULL, NULL);
9381
154
        if (!result) goto failed;
9382
154
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.items,
9383
154
                             ast2obj_withitem);
9384
154
        if (!value) goto failed;
9385
154
        if (PyObject_SetAttr(result, state->items, value) == -1)
9386
0
            goto failed;
9387
154
        Py_DECREF(value);
9388
154
        value = ast2obj_list(state, (asdl_seq*)o->v.AsyncWith.body,
9389
154
                             ast2obj_stmt);
9390
154
        if (!value) goto failed;
9391
154
        if (PyObject_SetAttr(result, state->body, value) == -1)
9392
0
            goto failed;
9393
154
        Py_DECREF(value);
9394
154
        value = ast2obj_string(state, o->v.AsyncWith.type_comment);
9395
154
        if (!value) goto failed;
9396
154
        if (PyObject_SetAttr(result, state->type_comment, value) == -1)
9397
0
            goto failed;
9398
154
        Py_DECREF(value);
9399
154
        break;
9400
245
    case Match_kind:
9401
245
        tp = (PyTypeObject *)state->Match_type;
9402
245
        result = PyType_GenericNew(tp, NULL, NULL);
9403
245
        if (!result) goto failed;
9404
245
        value = ast2obj_expr(state, o->v.Match.subject);
9405
245
        if (!value) goto failed;
9406
245
        if (PyObject_SetAttr(result, state->subject, value) == -1)
9407
0
            goto failed;
9408
245
        Py_DECREF(value);
9409
245
        value = ast2obj_list(state, (asdl_seq*)o->v.Match.cases,
9410
245
                             ast2obj_match_case);
9411
245
        if (!value) goto failed;
9412
245
        if (PyObject_SetAttr(result, state->cases, value) == -1)
9413
0
            goto failed;
9414
245
        Py_DECREF(value);
9415
245
        break;
9416
338
    case Raise_kind:
9417
338
        tp = (PyTypeObject *)state->Raise_type;
9418
338
        result = PyType_GenericNew(tp, NULL, NULL);
9419
338
        if (!result) goto failed;
9420
338
        value = ast2obj_expr(state, o->v.Raise.exc);
9421
338
        if (!value) goto failed;
9422
338
        if (PyObject_SetAttr(result, state->exc, value) == -1)
9423
0
            goto failed;
9424
338
        Py_DECREF(value);
9425
338
        value = ast2obj_expr(state, o->v.Raise.cause);
9426
338
        if (!value) goto failed;
9427
338
        if (PyObject_SetAttr(result, state->cause, value) == -1)
9428
0
            goto failed;
9429
338
        Py_DECREF(value);
9430
338
        break;
9431
287
    case Try_kind:
9432
287
        tp = (PyTypeObject *)state->Try_type;
9433
287
        result = PyType_GenericNew(tp, NULL, NULL);
9434
287
        if (!result) goto failed;
9435
287
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.body, ast2obj_stmt);
9436
287
        if (!value) goto failed;
9437
287
        if (PyObject_SetAttr(result, state->body, value) == -1)
9438
0
            goto failed;
9439
287
        Py_DECREF(value);
9440
287
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.handlers,
9441
287
                             ast2obj_excepthandler);
9442
287
        if (!value) goto failed;
9443
287
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9444
0
            goto failed;
9445
287
        Py_DECREF(value);
9446
287
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.orelse, ast2obj_stmt);
9447
287
        if (!value) goto failed;
9448
287
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9449
0
            goto failed;
9450
287
        Py_DECREF(value);
9451
287
        value = ast2obj_list(state, (asdl_seq*)o->v.Try.finalbody,
9452
287
                             ast2obj_stmt);
9453
287
        if (!value) goto failed;
9454
287
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9455
0
            goto failed;
9456
287
        Py_DECREF(value);
9457
287
        break;
9458
328
    case TryStar_kind:
9459
328
        tp = (PyTypeObject *)state->TryStar_type;
9460
328
        result = PyType_GenericNew(tp, NULL, NULL);
9461
328
        if (!result) goto failed;
9462
328
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.body, ast2obj_stmt);
9463
328
        if (!value) goto failed;
9464
328
        if (PyObject_SetAttr(result, state->body, value) == -1)
9465
0
            goto failed;
9466
328
        Py_DECREF(value);
9467
328
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.handlers,
9468
328
                             ast2obj_excepthandler);
9469
328
        if (!value) goto failed;
9470
328
        if (PyObject_SetAttr(result, state->handlers, value) == -1)
9471
0
            goto failed;
9472
328
        Py_DECREF(value);
9473
328
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.orelse,
9474
328
                             ast2obj_stmt);
9475
328
        if (!value) goto failed;
9476
328
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9477
0
            goto failed;
9478
328
        Py_DECREF(value);
9479
328
        value = ast2obj_list(state, (asdl_seq*)o->v.TryStar.finalbody,
9480
328
                             ast2obj_stmt);
9481
328
        if (!value) goto failed;
9482
328
        if (PyObject_SetAttr(result, state->finalbody, value) == -1)
9483
0
            goto failed;
9484
328
        Py_DECREF(value);
9485
328
        break;
9486
294
    case Assert_kind:
9487
294
        tp = (PyTypeObject *)state->Assert_type;
9488
294
        result = PyType_GenericNew(tp, NULL, NULL);
9489
294
        if (!result) goto failed;
9490
294
        value = ast2obj_expr(state, o->v.Assert.test);
9491
294
        if (!value) goto failed;
9492
294
        if (PyObject_SetAttr(result, state->test, value) == -1)
9493
0
            goto failed;
9494
294
        Py_DECREF(value);
9495
294
        value = ast2obj_expr(state, o->v.Assert.msg);
9496
294
        if (!value) goto failed;
9497
294
        if (PyObject_SetAttr(result, state->msg, value) == -1)
9498
0
            goto failed;
9499
294
        Py_DECREF(value);
9500
294
        break;
9501
756
    case Import_kind:
9502
756
        tp = (PyTypeObject *)state->Import_type;
9503
756
        result = PyType_GenericNew(tp, NULL, NULL);
9504
756
        if (!result) goto failed;
9505
756
        value = ast2obj_list(state, (asdl_seq*)o->v.Import.names,
9506
756
                             ast2obj_alias);
9507
756
        if (!value) goto failed;
9508
756
        if (PyObject_SetAttr(result, state->names, value) == -1)
9509
0
            goto failed;
9510
756
        Py_DECREF(value);
9511
756
        value = ast2obj_int(state, o->v.Import.is_lazy);
9512
756
        if (!value) goto failed;
9513
756
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9514
0
            goto failed;
9515
756
        Py_DECREF(value);
9516
756
        break;
9517
814
    case ImportFrom_kind:
9518
814
        tp = (PyTypeObject *)state->ImportFrom_type;
9519
814
        result = PyType_GenericNew(tp, NULL, NULL);
9520
814
        if (!result) goto failed;
9521
814
        value = ast2obj_identifier(state, o->v.ImportFrom.module);
9522
814
        if (!value) goto failed;
9523
814
        if (PyObject_SetAttr(result, state->module, value) == -1)
9524
0
            goto failed;
9525
814
        Py_DECREF(value);
9526
814
        value = ast2obj_list(state, (asdl_seq*)o->v.ImportFrom.names,
9527
814
                             ast2obj_alias);
9528
814
        if (!value) goto failed;
9529
814
        if (PyObject_SetAttr(result, state->names, value) == -1)
9530
0
            goto failed;
9531
814
        Py_DECREF(value);
9532
814
        value = ast2obj_int(state, o->v.ImportFrom.level);
9533
814
        if (!value) goto failed;
9534
814
        if (PyObject_SetAttr(result, state->level, value) == -1)
9535
0
            goto failed;
9536
814
        Py_DECREF(value);
9537
814
        value = ast2obj_int(state, o->v.ImportFrom.is_lazy);
9538
814
        if (!value) goto failed;
9539
814
        if (PyObject_SetAttr(result, state->is_lazy, value) == -1)
9540
0
            goto failed;
9541
814
        Py_DECREF(value);
9542
814
        break;
9543
115
    case Global_kind:
9544
115
        tp = (PyTypeObject *)state->Global_type;
9545
115
        result = PyType_GenericNew(tp, NULL, NULL);
9546
115
        if (!result) goto failed;
9547
115
        value = ast2obj_list(state, (asdl_seq*)o->v.Global.names,
9548
115
                             ast2obj_identifier);
9549
115
        if (!value) goto failed;
9550
115
        if (PyObject_SetAttr(result, state->names, value) == -1)
9551
0
            goto failed;
9552
115
        Py_DECREF(value);
9553
115
        break;
9554
71
    case Nonlocal_kind:
9555
71
        tp = (PyTypeObject *)state->Nonlocal_type;
9556
71
        result = PyType_GenericNew(tp, NULL, NULL);
9557
71
        if (!result) goto failed;
9558
71
        value = ast2obj_list(state, (asdl_seq*)o->v.Nonlocal.names,
9559
71
                             ast2obj_identifier);
9560
71
        if (!value) goto failed;
9561
71
        if (PyObject_SetAttr(result, state->names, value) == -1)
9562
0
            goto failed;
9563
71
        Py_DECREF(value);
9564
71
        break;
9565
24.4k
    case Expr_kind:
9566
24.4k
        tp = (PyTypeObject *)state->Expr_type;
9567
24.4k
        result = PyType_GenericNew(tp, NULL, NULL);
9568
24.4k
        if (!result) goto failed;
9569
24.4k
        value = ast2obj_expr(state, o->v.Expr.value);
9570
24.4k
        if (!value) goto failed;
9571
24.4k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9572
0
            goto failed;
9573
24.4k
        Py_DECREF(value);
9574
24.4k
        break;
9575
239
    case Pass_kind:
9576
239
        tp = (PyTypeObject *)state->Pass_type;
9577
239
        result = PyType_GenericNew(tp, NULL, NULL);
9578
239
        if (!result) goto failed;
9579
239
        break;
9580
304
    case Break_kind:
9581
304
        tp = (PyTypeObject *)state->Break_type;
9582
304
        result = PyType_GenericNew(tp, NULL, NULL);
9583
304
        if (!result) goto failed;
9584
304
        break;
9585
304
    case Continue_kind:
9586
67
        tp = (PyTypeObject *)state->Continue_type;
9587
67
        result = PyType_GenericNew(tp, NULL, NULL);
9588
67
        if (!result) goto failed;
9589
67
        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
339k
{
9623
339k
    expr_ty o = (expr_ty)_o;
9624
339k
    PyObject *result = NULL, *value = NULL;
9625
339k
    PyTypeObject *tp;
9626
339k
    if (!o) {
9627
45.9k
        Py_RETURN_NONE;
9628
45.9k
    }
9629
293k
    if (Py_EnterRecursiveCall("during  ast construction")) {
9630
0
        return NULL;
9631
0
    }
9632
293k
    switch (o->kind) {
9633
573
    case BoolOp_kind:
9634
573
        tp = (PyTypeObject *)state->BoolOp_type;
9635
573
        result = PyType_GenericNew(tp, NULL, NULL);
9636
573
        if (!result) goto failed;
9637
573
        value = ast2obj_boolop(state, o->v.BoolOp.op);
9638
573
        if (!value) goto failed;
9639
573
        if (PyObject_SetAttr(result, state->op, value) == -1)
9640
0
            goto failed;
9641
573
        Py_DECREF(value);
9642
573
        value = ast2obj_list(state, (asdl_seq*)o->v.BoolOp.values,
9643
573
                             ast2obj_expr);
9644
573
        if (!value) goto failed;
9645
573
        if (PyObject_SetAttr(result, state->values, value) == -1)
9646
0
            goto failed;
9647
573
        Py_DECREF(value);
9648
573
        break;
9649
41
    case NamedExpr_kind:
9650
41
        tp = (PyTypeObject *)state->NamedExpr_type;
9651
41
        result = PyType_GenericNew(tp, NULL, NULL);
9652
41
        if (!result) goto failed;
9653
41
        value = ast2obj_expr(state, o->v.NamedExpr.target);
9654
41
        if (!value) goto failed;
9655
41
        if (PyObject_SetAttr(result, state->target, value) == -1)
9656
0
            goto failed;
9657
41
        Py_DECREF(value);
9658
41
        value = ast2obj_expr(state, o->v.NamedExpr.value);
9659
41
        if (!value) goto failed;
9660
41
        if (PyObject_SetAttr(result, state->value, value) == -1)
9661
0
            goto failed;
9662
41
        Py_DECREF(value);
9663
41
        break;
9664
20.2k
    case BinOp_kind:
9665
20.2k
        tp = (PyTypeObject *)state->BinOp_type;
9666
20.2k
        result = PyType_GenericNew(tp, NULL, NULL);
9667
20.2k
        if (!result) goto failed;
9668
20.2k
        value = ast2obj_expr(state, o->v.BinOp.left);
9669
20.2k
        if (!value) goto failed;
9670
20.2k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9671
0
            goto failed;
9672
20.2k
        Py_DECREF(value);
9673
20.2k
        value = ast2obj_operator(state, o->v.BinOp.op);
9674
20.2k
        if (!value) goto failed;
9675
20.2k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9676
0
            goto failed;
9677
20.2k
        Py_DECREF(value);
9678
20.2k
        value = ast2obj_expr(state, o->v.BinOp.right);
9679
20.2k
        if (!value) goto failed;
9680
20.2k
        if (PyObject_SetAttr(result, state->right, value) == -1)
9681
0
            goto failed;
9682
20.2k
        Py_DECREF(value);
9683
20.2k
        break;
9684
113k
    case UnaryOp_kind:
9685
113k
        tp = (PyTypeObject *)state->UnaryOp_type;
9686
113k
        result = PyType_GenericNew(tp, NULL, NULL);
9687
113k
        if (!result) goto failed;
9688
113k
        value = ast2obj_unaryop(state, o->v.UnaryOp.op);
9689
113k
        if (!value) goto failed;
9690
113k
        if (PyObject_SetAttr(result, state->op, value) == -1)
9691
0
            goto failed;
9692
113k
        Py_DECREF(value);
9693
113k
        value = ast2obj_expr(state, o->v.UnaryOp.operand);
9694
113k
        if (!value) goto failed;
9695
113k
        if (PyObject_SetAttr(result, state->operand, value) == -1)
9696
0
            goto failed;
9697
113k
        Py_DECREF(value);
9698
113k
        break;
9699
808
    case Lambda_kind:
9700
808
        tp = (PyTypeObject *)state->Lambda_type;
9701
808
        result = PyType_GenericNew(tp, NULL, NULL);
9702
808
        if (!result) goto failed;
9703
808
        value = ast2obj_arguments(state, o->v.Lambda.args);
9704
808
        if (!value) goto failed;
9705
808
        if (PyObject_SetAttr(result, state->args, value) == -1)
9706
0
            goto failed;
9707
808
        Py_DECREF(value);
9708
808
        value = ast2obj_expr(state, o->v.Lambda.body);
9709
808
        if (!value) goto failed;
9710
808
        if (PyObject_SetAttr(result, state->body, value) == -1)
9711
0
            goto failed;
9712
808
        Py_DECREF(value);
9713
808
        break;
9714
215
    case IfExp_kind:
9715
215
        tp = (PyTypeObject *)state->IfExp_type;
9716
215
        result = PyType_GenericNew(tp, NULL, NULL);
9717
215
        if (!result) goto failed;
9718
215
        value = ast2obj_expr(state, o->v.IfExp.test);
9719
215
        if (!value) goto failed;
9720
215
        if (PyObject_SetAttr(result, state->test, value) == -1)
9721
0
            goto failed;
9722
215
        Py_DECREF(value);
9723
215
        value = ast2obj_expr(state, o->v.IfExp.body);
9724
215
        if (!value) goto failed;
9725
215
        if (PyObject_SetAttr(result, state->body, value) == -1)
9726
0
            goto failed;
9727
215
        Py_DECREF(value);
9728
215
        value = ast2obj_expr(state, o->v.IfExp.orelse);
9729
215
        if (!value) goto failed;
9730
215
        if (PyObject_SetAttr(result, state->orelse, value) == -1)
9731
0
            goto failed;
9732
215
        Py_DECREF(value);
9733
215
        break;
9734
1.72k
    case Dict_kind:
9735
1.72k
        tp = (PyTypeObject *)state->Dict_type;
9736
1.72k
        result = PyType_GenericNew(tp, NULL, NULL);
9737
1.72k
        if (!result) goto failed;
9738
1.72k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.keys, ast2obj_expr);
9739
1.72k
        if (!value) goto failed;
9740
1.72k
        if (PyObject_SetAttr(result, state->keys, value) == -1)
9741
0
            goto failed;
9742
1.72k
        Py_DECREF(value);
9743
1.72k
        value = ast2obj_list(state, (asdl_seq*)o->v.Dict.values, ast2obj_expr);
9744
1.72k
        if (!value) goto failed;
9745
1.72k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9746
0
            goto failed;
9747
1.72k
        Py_DECREF(value);
9748
1.72k
        break;
9749
493
    case Set_kind:
9750
493
        tp = (PyTypeObject *)state->Set_type;
9751
493
        result = PyType_GenericNew(tp, NULL, NULL);
9752
493
        if (!result) goto failed;
9753
493
        value = ast2obj_list(state, (asdl_seq*)o->v.Set.elts, ast2obj_expr);
9754
493
        if (!value) goto failed;
9755
493
        if (PyObject_SetAttr(result, state->elts, value) == -1)
9756
0
            goto failed;
9757
493
        Py_DECREF(value);
9758
493
        break;
9759
347
    case ListComp_kind:
9760
347
        tp = (PyTypeObject *)state->ListComp_type;
9761
347
        result = PyType_GenericNew(tp, NULL, NULL);
9762
347
        if (!result) goto failed;
9763
347
        value = ast2obj_expr(state, o->v.ListComp.elt);
9764
347
        if (!value) goto failed;
9765
347
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9766
0
            goto failed;
9767
347
        Py_DECREF(value);
9768
347
        value = ast2obj_list(state, (asdl_seq*)o->v.ListComp.generators,
9769
347
                             ast2obj_comprehension);
9770
347
        if (!value) goto failed;
9771
347
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9772
0
            goto failed;
9773
347
        Py_DECREF(value);
9774
347
        break;
9775
345
    case SetComp_kind:
9776
345
        tp = (PyTypeObject *)state->SetComp_type;
9777
345
        result = PyType_GenericNew(tp, NULL, NULL);
9778
345
        if (!result) goto failed;
9779
345
        value = ast2obj_expr(state, o->v.SetComp.elt);
9780
345
        if (!value) goto failed;
9781
345
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9782
0
            goto failed;
9783
345
        Py_DECREF(value);
9784
345
        value = ast2obj_list(state, (asdl_seq*)o->v.SetComp.generators,
9785
345
                             ast2obj_comprehension);
9786
345
        if (!value) goto failed;
9787
345
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9788
0
            goto failed;
9789
345
        Py_DECREF(value);
9790
345
        break;
9791
251
    case DictComp_kind:
9792
251
        tp = (PyTypeObject *)state->DictComp_type;
9793
251
        result = PyType_GenericNew(tp, NULL, NULL);
9794
251
        if (!result) goto failed;
9795
251
        value = ast2obj_expr(state, o->v.DictComp.key);
9796
251
        if (!value) goto failed;
9797
251
        if (PyObject_SetAttr(result, state->key, value) == -1)
9798
0
            goto failed;
9799
251
        Py_DECREF(value);
9800
251
        value = ast2obj_expr(state, o->v.DictComp.value);
9801
251
        if (!value) goto failed;
9802
251
        if (PyObject_SetAttr(result, state->value, value) == -1)
9803
0
            goto failed;
9804
251
        Py_DECREF(value);
9805
251
        value = ast2obj_list(state, (asdl_seq*)o->v.DictComp.generators,
9806
251
                             ast2obj_comprehension);
9807
251
        if (!value) goto failed;
9808
251
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9809
0
            goto failed;
9810
251
        Py_DECREF(value);
9811
251
        break;
9812
420
    case GeneratorExp_kind:
9813
420
        tp = (PyTypeObject *)state->GeneratorExp_type;
9814
420
        result = PyType_GenericNew(tp, NULL, NULL);
9815
420
        if (!result) goto failed;
9816
420
        value = ast2obj_expr(state, o->v.GeneratorExp.elt);
9817
420
        if (!value) goto failed;
9818
420
        if (PyObject_SetAttr(result, state->elt, value) == -1)
9819
0
            goto failed;
9820
420
        Py_DECREF(value);
9821
420
        value = ast2obj_list(state, (asdl_seq*)o->v.GeneratorExp.generators,
9822
420
                             ast2obj_comprehension);
9823
420
        if (!value) goto failed;
9824
420
        if (PyObject_SetAttr(result, state->generators, value) == -1)
9825
0
            goto failed;
9826
420
        Py_DECREF(value);
9827
420
        break;
9828
70
    case Await_kind:
9829
70
        tp = (PyTypeObject *)state->Await_type;
9830
70
        result = PyType_GenericNew(tp, NULL, NULL);
9831
70
        if (!result) goto failed;
9832
70
        value = ast2obj_expr(state, o->v.Await.value);
9833
70
        if (!value) goto failed;
9834
70
        if (PyObject_SetAttr(result, state->value, value) == -1)
9835
0
            goto failed;
9836
70
        Py_DECREF(value);
9837
70
        break;
9838
776
    case Yield_kind:
9839
776
        tp = (PyTypeObject *)state->Yield_type;
9840
776
        result = PyType_GenericNew(tp, NULL, NULL);
9841
776
        if (!result) goto failed;
9842
776
        value = ast2obj_expr(state, o->v.Yield.value);
9843
776
        if (!value) goto failed;
9844
776
        if (PyObject_SetAttr(result, state->value, value) == -1)
9845
0
            goto failed;
9846
776
        Py_DECREF(value);
9847
776
        break;
9848
96
    case YieldFrom_kind:
9849
96
        tp = (PyTypeObject *)state->YieldFrom_type;
9850
96
        result = PyType_GenericNew(tp, NULL, NULL);
9851
96
        if (!result) goto failed;
9852
96
        value = ast2obj_expr(state, o->v.YieldFrom.value);
9853
96
        if (!value) goto failed;
9854
96
        if (PyObject_SetAttr(result, state->value, value) == -1)
9855
0
            goto failed;
9856
96
        Py_DECREF(value);
9857
96
        break;
9858
1.06k
    case Compare_kind:
9859
1.06k
        tp = (PyTypeObject *)state->Compare_type;
9860
1.06k
        result = PyType_GenericNew(tp, NULL, NULL);
9861
1.06k
        if (!result) goto failed;
9862
1.06k
        value = ast2obj_expr(state, o->v.Compare.left);
9863
1.06k
        if (!value) goto failed;
9864
1.06k
        if (PyObject_SetAttr(result, state->left, value) == -1)
9865
0
            goto failed;
9866
1.06k
        Py_DECREF(value);
9867
1.06k
        {
9868
1.06k
            Py_ssize_t i, n = asdl_seq_LEN(o->v.Compare.ops);
9869
1.06k
            value = PyList_New(n);
9870
1.06k
            if (!value) goto failed;
9871
6.10k
            for(i = 0; i < n; i++)
9872
5.04k
                PyList_SET_ITEM(value, i, ast2obj_cmpop(state, (cmpop_ty)asdl_seq_GET(o->v.Compare.ops, i)));
9873
1.06k
        }
9874
1.06k
        if (!value) goto failed;
9875
1.06k
        if (PyObject_SetAttr(result, state->ops, value) == -1)
9876
0
            goto failed;
9877
1.06k
        Py_DECREF(value);
9878
1.06k
        value = ast2obj_list(state, (asdl_seq*)o->v.Compare.comparators,
9879
1.06k
                             ast2obj_expr);
9880
1.06k
        if (!value) goto failed;
9881
1.06k
        if (PyObject_SetAttr(result, state->comparators, value) == -1)
9882
0
            goto failed;
9883
1.06k
        Py_DECREF(value);
9884
1.06k
        break;
9885
9.71k
    case Call_kind:
9886
9.71k
        tp = (PyTypeObject *)state->Call_type;
9887
9.71k
        result = PyType_GenericNew(tp, NULL, NULL);
9888
9.71k
        if (!result) goto failed;
9889
9.71k
        value = ast2obj_expr(state, o->v.Call.func);
9890
9.71k
        if (!value) goto failed;
9891
9.71k
        if (PyObject_SetAttr(result, state->func, value) == -1)
9892
0
            goto failed;
9893
9.71k
        Py_DECREF(value);
9894
9.71k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.args, ast2obj_expr);
9895
9.71k
        if (!value) goto failed;
9896
9.71k
        if (PyObject_SetAttr(result, state->args, value) == -1)
9897
0
            goto failed;
9898
9.71k
        Py_DECREF(value);
9899
9.71k
        value = ast2obj_list(state, (asdl_seq*)o->v.Call.keywords,
9900
9.71k
                             ast2obj_keyword);
9901
9.71k
        if (!value) goto failed;
9902
9.71k
        if (PyObject_SetAttr(result, state->keywords, value) == -1)
9903
0
            goto failed;
9904
9.71k
        Py_DECREF(value);
9905
9.71k
        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.07k
    case Interpolation_kind:
9927
1.07k
        tp = (PyTypeObject *)state->Interpolation_type;
9928
1.07k
        result = PyType_GenericNew(tp, NULL, NULL);
9929
1.07k
        if (!result) goto failed;
9930
1.07k
        value = ast2obj_expr(state, o->v.Interpolation.value);
9931
1.07k
        if (!value) goto failed;
9932
1.07k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9933
0
            goto failed;
9934
1.07k
        Py_DECREF(value);
9935
1.07k
        value = ast2obj_constant(state, o->v.Interpolation.str);
9936
1.07k
        if (!value) goto failed;
9937
1.07k
        if (PyObject_SetAttr(result, state->str, value) == -1)
9938
0
            goto failed;
9939
1.07k
        Py_DECREF(value);
9940
1.07k
        value = ast2obj_int(state, o->v.Interpolation.conversion);
9941
1.07k
        if (!value) goto failed;
9942
1.07k
        if (PyObject_SetAttr(result, state->conversion, value) == -1)
9943
0
            goto failed;
9944
1.07k
        Py_DECREF(value);
9945
1.07k
        value = ast2obj_expr(state, o->v.Interpolation.format_spec);
9946
1.07k
        if (!value) goto failed;
9947
1.07k
        if (PyObject_SetAttr(result, state->format_spec, value) == -1)
9948
0
            goto failed;
9949
1.07k
        Py_DECREF(value);
9950
1.07k
        break;
9951
6.75k
    case JoinedStr_kind:
9952
6.75k
        tp = (PyTypeObject *)state->JoinedStr_type;
9953
6.75k
        result = PyType_GenericNew(tp, NULL, NULL);
9954
6.75k
        if (!result) goto failed;
9955
6.75k
        value = ast2obj_list(state, (asdl_seq*)o->v.JoinedStr.values,
9956
6.75k
                             ast2obj_expr);
9957
6.75k
        if (!value) goto failed;
9958
6.75k
        if (PyObject_SetAttr(result, state->values, value) == -1)
9959
0
            goto failed;
9960
6.75k
        Py_DECREF(value);
9961
6.75k
        break;
9962
178
    case TemplateStr_kind:
9963
178
        tp = (PyTypeObject *)state->TemplateStr_type;
9964
178
        result = PyType_GenericNew(tp, NULL, NULL);
9965
178
        if (!result) goto failed;
9966
178
        value = ast2obj_list(state, (asdl_seq*)o->v.TemplateStr.values,
9967
178
                             ast2obj_expr);
9968
178
        if (!value) goto failed;
9969
178
        if (PyObject_SetAttr(result, state->values, value) == -1)
9970
0
            goto failed;
9971
178
        Py_DECREF(value);
9972
178
        break;
9973
52.9k
    case Constant_kind:
9974
52.9k
        tp = (PyTypeObject *)state->Constant_type;
9975
52.9k
        result = PyType_GenericNew(tp, NULL, NULL);
9976
52.9k
        if (!result) goto failed;
9977
52.9k
        value = ast2obj_constant(state, o->v.Constant.value);
9978
52.9k
        if (!value) goto failed;
9979
52.9k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9980
0
            goto failed;
9981
52.9k
        Py_DECREF(value);
9982
52.9k
        value = ast2obj_string(state, o->v.Constant.kind);
9983
52.9k
        if (!value) goto failed;
9984
52.9k
        if (PyObject_SetAttr(result, state->kind, value) == -1)
9985
0
            goto failed;
9986
52.9k
        Py_DECREF(value);
9987
52.9k
        break;
9988
2.00k
    case Attribute_kind:
9989
2.00k
        tp = (PyTypeObject *)state->Attribute_type;
9990
2.00k
        result = PyType_GenericNew(tp, NULL, NULL);
9991
2.00k
        if (!result) goto failed;
9992
2.00k
        value = ast2obj_expr(state, o->v.Attribute.value);
9993
2.00k
        if (!value) goto failed;
9994
2.00k
        if (PyObject_SetAttr(result, state->value, value) == -1)
9995
0
            goto failed;
9996
2.00k
        Py_DECREF(value);
9997
2.00k
        value = ast2obj_identifier(state, o->v.Attribute.attr);
9998
2.00k
        if (!value) goto failed;
9999
2.00k
        if (PyObject_SetAttr(result, state->attr, value) == -1)
10000
0
            goto failed;
10001
2.00k
        Py_DECREF(value);
10002
2.00k
        value = ast2obj_expr_context(state, o->v.Attribute.ctx);
10003
2.00k
        if (!value) goto failed;
10004
2.00k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10005
0
            goto failed;
10006
2.00k
        Py_DECREF(value);
10007
2.00k
        break;
10008
365
    case Subscript_kind:
10009
365
        tp = (PyTypeObject *)state->Subscript_type;
10010
365
        result = PyType_GenericNew(tp, NULL, NULL);
10011
365
        if (!result) goto failed;
10012
365
        value = ast2obj_expr(state, o->v.Subscript.value);
10013
365
        if (!value) goto failed;
10014
365
        if (PyObject_SetAttr(result, state->value, value) == -1)
10015
0
            goto failed;
10016
365
        Py_DECREF(value);
10017
365
        value = ast2obj_expr(state, o->v.Subscript.slice);
10018
365
        if (!value) goto failed;
10019
365
        if (PyObject_SetAttr(result, state->slice, value) == -1)
10020
0
            goto failed;
10021
365
        Py_DECREF(value);
10022
365
        value = ast2obj_expr_context(state, o->v.Subscript.ctx);
10023
365
        if (!value) goto failed;
10024
365
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10025
0
            goto failed;
10026
365
        Py_DECREF(value);
10027
365
        break;
10028
512
    case Starred_kind:
10029
512
        tp = (PyTypeObject *)state->Starred_type;
10030
512
        result = PyType_GenericNew(tp, NULL, NULL);
10031
512
        if (!result) goto failed;
10032
512
        value = ast2obj_expr(state, o->v.Starred.value);
10033
512
        if (!value) goto failed;
10034
512
        if (PyObject_SetAttr(result, state->value, value) == -1)
10035
0
            goto failed;
10036
512
        Py_DECREF(value);
10037
512
        value = ast2obj_expr_context(state, o->v.Starred.ctx);
10038
512
        if (!value) goto failed;
10039
512
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10040
0
            goto failed;
10041
512
        Py_DECREF(value);
10042
512
        break;
10043
56.8k
    case Name_kind:
10044
56.8k
        tp = (PyTypeObject *)state->Name_type;
10045
56.8k
        result = PyType_GenericNew(tp, NULL, NULL);
10046
56.8k
        if (!result) goto failed;
10047
56.8k
        value = ast2obj_identifier(state, o->v.Name.id);
10048
56.8k
        if (!value) goto failed;
10049
56.8k
        if (PyObject_SetAttr(result, state->id, value) == -1)
10050
0
            goto failed;
10051
56.8k
        Py_DECREF(value);
10052
56.8k
        value = ast2obj_expr_context(state, o->v.Name.ctx);
10053
56.8k
        if (!value) goto failed;
10054
56.8k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10055
0
            goto failed;
10056
56.8k
        Py_DECREF(value);
10057
56.8k
        break;
10058
1.24k
    case List_kind:
10059
1.24k
        tp = (PyTypeObject *)state->List_type;
10060
1.24k
        result = PyType_GenericNew(tp, NULL, NULL);
10061
1.24k
        if (!result) goto failed;
10062
1.24k
        value = ast2obj_list(state, (asdl_seq*)o->v.List.elts, ast2obj_expr);
10063
1.24k
        if (!value) goto failed;
10064
1.24k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10065
0
            goto failed;
10066
1.24k
        Py_DECREF(value);
10067
1.24k
        value = ast2obj_expr_context(state, o->v.List.ctx);
10068
1.24k
        if (!value) goto failed;
10069
1.24k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10070
0
            goto failed;
10071
1.24k
        Py_DECREF(value);
10072
1.24k
        break;
10073
4.99k
    case Tuple_kind:
10074
4.99k
        tp = (PyTypeObject *)state->Tuple_type;
10075
4.99k
        result = PyType_GenericNew(tp, NULL, NULL);
10076
4.99k
        if (!result) goto failed;
10077
4.99k
        value = ast2obj_list(state, (asdl_seq*)o->v.Tuple.elts, ast2obj_expr);
10078
4.99k
        if (!value) goto failed;
10079
4.99k
        if (PyObject_SetAttr(result, state->elts, value) == -1)
10080
0
            goto failed;
10081
4.99k
        Py_DECREF(value);
10082
4.99k
        value = ast2obj_expr_context(state, o->v.Tuple.ctx);
10083
4.99k
        if (!value) goto failed;
10084
4.99k
        if (PyObject_SetAttr(result, state->ctx, value) == -1)
10085
0
            goto failed;
10086
4.99k
        Py_DECREF(value);
10087
4.99k
        break;
10088
1.97k
    case Slice_kind:
10089
1.97k
        tp = (PyTypeObject *)state->Slice_type;
10090
1.97k
        result = PyType_GenericNew(tp, NULL, NULL);
10091
1.97k
        if (!result) goto failed;
10092
1.97k
        value = ast2obj_expr(state, o->v.Slice.lower);
10093
1.97k
        if (!value) goto failed;
10094
1.97k
        if (PyObject_SetAttr(result, state->lower, value) == -1)
10095
0
            goto failed;
10096
1.97k
        Py_DECREF(value);
10097
1.97k
        value = ast2obj_expr(state, o->v.Slice.upper);
10098
1.97k
        if (!value) goto failed;
10099
1.97k
        if (PyObject_SetAttr(result, state->upper, value) == -1)
10100
0
            goto failed;
10101
1.97k
        Py_DECREF(value);
10102
1.97k
        value = ast2obj_expr(state, o->v.Slice.step);
10103
1.97k
        if (!value) goto failed;
10104
1.97k
        if (PyObject_SetAttr(result, state->step, value) == -1)
10105
0
            goto failed;
10106
1.97k
        Py_DECREF(value);
10107
1.97k
        break;
10108
293k
    }
10109
293k
    value = ast2obj_int(state, o->lineno);
10110
293k
    if (!value) goto failed;
10111
293k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10112
0
        goto failed;
10113
293k
    Py_DECREF(value);
10114
293k
    value = ast2obj_int(state, o->col_offset);
10115
293k
    if (!value) goto failed;
10116
293k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10117
0
        goto failed;
10118
293k
    Py_DECREF(value);
10119
293k
    value = ast2obj_int(state, o->end_lineno);
10120
293k
    if (!value) goto failed;
10121
293k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10122
0
        goto failed;
10123
293k
    Py_DECREF(value);
10124
293k
    value = ast2obj_int(state, o->end_col_offset);
10125
293k
    if (!value) goto failed;
10126
293k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10127
0
        goto failed;
10128
293k
    Py_DECREF(value);
10129
293k
    Py_LeaveRecursiveCall();
10130
293k
    return result;
10131
0
failed:
10132
0
    Py_LeaveRecursiveCall();
10133
0
    Py_XDECREF(value);
10134
0
    Py_XDECREF(result);
10135
0
    return NULL;
10136
293k
}
10137
10138
PyObject* ast2obj_expr_context(struct ast_state *state, expr_context_ty o)
10139
65.9k
{
10140
65.9k
    switch(o) {
10141
60.2k
        case Load:
10142
60.2k
            return Py_NewRef(state->Load_singleton);
10143
5.28k
        case Store:
10144
5.28k
            return Py_NewRef(state->Store_singleton);
10145
374
        case Del:
10146
374
            return Py_NewRef(state->Del_singleton);
10147
65.9k
    }
10148
65.9k
    Py_UNREACHABLE();
10149
65.9k
}
10150
PyObject* ast2obj_boolop(struct ast_state *state, boolop_ty o)
10151
573
{
10152
573
    switch(o) {
10153
338
        case And:
10154
338
            return Py_NewRef(state->And_singleton);
10155
235
        case Or:
10156
235
            return Py_NewRef(state->Or_singleton);
10157
573
    }
10158
573
    Py_UNREACHABLE();
10159
573
}
10160
PyObject* ast2obj_operator(struct ast_state *state, operator_ty o)
10161
20.6k
{
10162
20.6k
    switch(o) {
10163
3.48k
        case Add:
10164
3.48k
            return Py_NewRef(state->Add_singleton);
10165
6.06k
        case Sub:
10166
6.06k
            return Py_NewRef(state->Sub_singleton);
10167
4.06k
        case Mult:
10168
4.06k
            return Py_NewRef(state->Mult_singleton);
10169
847
        case MatMult:
10170
847
            return Py_NewRef(state->MatMult_singleton);
10171
1.12k
        case Div:
10172
1.12k
            return Py_NewRef(state->Div_singleton);
10173
1.30k
        case Mod:
10174
1.30k
            return Py_NewRef(state->Mod_singleton);
10175
871
        case Pow:
10176
871
            return Py_NewRef(state->Pow_singleton);
10177
125
        case LShift:
10178
125
            return Py_NewRef(state->LShift_singleton);
10179
241
        case RShift:
10180
241
            return Py_NewRef(state->RShift_singleton);
10181
612
        case BitOr:
10182
612
            return Py_NewRef(state->BitOr_singleton);
10183
417
        case BitXor:
10184
417
            return Py_NewRef(state->BitXor_singleton);
10185
1.23k
        case BitAnd:
10186
1.23k
            return Py_NewRef(state->BitAnd_singleton);
10187
256
        case FloorDiv:
10188
256
            return Py_NewRef(state->FloorDiv_singleton);
10189
20.6k
    }
10190
20.6k
    Py_UNREACHABLE();
10191
20.6k
}
10192
PyObject* ast2obj_unaryop(struct ast_state *state, unaryop_ty o)
10193
113k
{
10194
113k
    switch(o) {
10195
21.9k
        case Invert:
10196
21.9k
            return Py_NewRef(state->Invert_singleton);
10197
99
        case Not:
10198
99
            return Py_NewRef(state->Not_singleton);
10199
41.8k
        case UAdd:
10200
41.8k
            return Py_NewRef(state->UAdd_singleton);
10201
49.4k
        case USub:
10202
49.4k
            return Py_NewRef(state->USub_singleton);
10203
113k
    }
10204
113k
    Py_UNREACHABLE();
10205
113k
}
10206
PyObject* ast2obj_cmpop(struct ast_state *state, cmpop_ty o)
10207
5.04k
{
10208
5.04k
    switch(o) {
10209
666
        case Eq:
10210
666
            return Py_NewRef(state->Eq_singleton);
10211
211
        case NotEq:
10212
211
            return Py_NewRef(state->NotEq_singleton);
10213
1.24k
        case Lt:
10214
1.24k
            return Py_NewRef(state->Lt_singleton);
10215
206
        case LtE:
10216
206
            return Py_NewRef(state->LtE_singleton);
10217
2.02k
        case Gt:
10218
2.02k
            return Py_NewRef(state->Gt_singleton);
10219
210
        case GtE:
10220
210
            return Py_NewRef(state->GtE_singleton);
10221
128
        case Is:
10222
128
            return Py_NewRef(state->Is_singleton);
10223
80
        case IsNot:
10224
80
            return Py_NewRef(state->IsNot_singleton);
10225
201
        case In:
10226
201
            return Py_NewRef(state->In_singleton);
10227
67
        case NotIn:
10228
67
            return Py_NewRef(state->NotIn_singleton);
10229
5.04k
    }
10230
5.04k
    Py_UNREACHABLE();
10231
5.04k
}
10232
PyObject*
10233
ast2obj_comprehension(struct ast_state *state, void* _o)
10234
1.46k
{
10235
1.46k
    comprehension_ty o = (comprehension_ty)_o;
10236
1.46k
    PyObject *result = NULL, *value = NULL;
10237
1.46k
    PyTypeObject *tp;
10238
1.46k
    if (!o) {
10239
0
        Py_RETURN_NONE;
10240
0
    }
10241
1.46k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10242
0
        return NULL;
10243
0
    }
10244
1.46k
    tp = (PyTypeObject *)state->comprehension_type;
10245
1.46k
    result = PyType_GenericNew(tp, NULL, NULL);
10246
1.46k
    if (!result) return NULL;
10247
1.46k
    value = ast2obj_expr(state, o->target);
10248
1.46k
    if (!value) goto failed;
10249
1.46k
    if (PyObject_SetAttr(result, state->target, value) == -1)
10250
0
        goto failed;
10251
1.46k
    Py_DECREF(value);
10252
1.46k
    value = ast2obj_expr(state, o->iter);
10253
1.46k
    if (!value) goto failed;
10254
1.46k
    if (PyObject_SetAttr(result, state->iter, value) == -1)
10255
0
        goto failed;
10256
1.46k
    Py_DECREF(value);
10257
1.46k
    value = ast2obj_list(state, (asdl_seq*)o->ifs, ast2obj_expr);
10258
1.46k
    if (!value) goto failed;
10259
1.46k
    if (PyObject_SetAttr(result, state->ifs, value) == -1)
10260
0
        goto failed;
10261
1.46k
    Py_DECREF(value);
10262
1.46k
    value = ast2obj_int(state, o->is_async);
10263
1.46k
    if (!value) goto failed;
10264
1.46k
    if (PyObject_SetAttr(result, state->is_async, value) == -1)
10265
0
        goto failed;
10266
1.46k
    Py_DECREF(value);
10267
1.46k
    Py_LeaveRecursiveCall();
10268
1.46k
    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.46k
}
10275
10276
PyObject*
10277
ast2obj_excepthandler(struct ast_state *state, void* _o)
10278
748
{
10279
748
    excepthandler_ty o = (excepthandler_ty)_o;
10280
748
    PyObject *result = NULL, *value = NULL;
10281
748
    PyTypeObject *tp;
10282
748
    if (!o) {
10283
0
        Py_RETURN_NONE;
10284
0
    }
10285
748
    if (Py_EnterRecursiveCall("during  ast construction")) {
10286
0
        return NULL;
10287
0
    }
10288
748
    switch (o->kind) {
10289
748
    case ExceptHandler_kind:
10290
748
        tp = (PyTypeObject *)state->ExceptHandler_type;
10291
748
        result = PyType_GenericNew(tp, NULL, NULL);
10292
748
        if (!result) goto failed;
10293
748
        value = ast2obj_expr(state, o->v.ExceptHandler.type);
10294
748
        if (!value) goto failed;
10295
748
        if (PyObject_SetAttr(result, state->type, value) == -1)
10296
0
            goto failed;
10297
748
        Py_DECREF(value);
10298
748
        value = ast2obj_identifier(state, o->v.ExceptHandler.name);
10299
748
        if (!value) goto failed;
10300
748
        if (PyObject_SetAttr(result, state->name, value) == -1)
10301
0
            goto failed;
10302
748
        Py_DECREF(value);
10303
748
        value = ast2obj_list(state, (asdl_seq*)o->v.ExceptHandler.body,
10304
748
                             ast2obj_stmt);
10305
748
        if (!value) goto failed;
10306
748
        if (PyObject_SetAttr(result, state->body, value) == -1)
10307
0
            goto failed;
10308
748
        Py_DECREF(value);
10309
748
        break;
10310
748
    }
10311
748
    value = ast2obj_int(state, o->lineno);
10312
748
    if (!value) goto failed;
10313
748
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10314
0
        goto failed;
10315
748
    Py_DECREF(value);
10316
748
    value = ast2obj_int(state, o->col_offset);
10317
748
    if (!value) goto failed;
10318
748
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10319
0
        goto failed;
10320
748
    Py_DECREF(value);
10321
748
    value = ast2obj_int(state, o->end_lineno);
10322
748
    if (!value) goto failed;
10323
748
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10324
0
        goto failed;
10325
748
    Py_DECREF(value);
10326
748
    value = ast2obj_int(state, o->end_col_offset);
10327
748
    if (!value) goto failed;
10328
748
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10329
0
        goto failed;
10330
748
    Py_DECREF(value);
10331
748
    Py_LeaveRecursiveCall();
10332
748
    return result;
10333
0
failed:
10334
0
    Py_LeaveRecursiveCall();
10335
0
    Py_XDECREF(value);
10336
0
    Py_XDECREF(result);
10337
0
    return NULL;
10338
748
}
10339
10340
PyObject*
10341
ast2obj_arguments(struct ast_state *state, void* _o)
10342
2.50k
{
10343
2.50k
    arguments_ty o = (arguments_ty)_o;
10344
2.50k
    PyObject *result = NULL, *value = NULL;
10345
2.50k
    PyTypeObject *tp;
10346
2.50k
    if (!o) {
10347
0
        Py_RETURN_NONE;
10348
0
    }
10349
2.50k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10350
0
        return NULL;
10351
0
    }
10352
2.50k
    tp = (PyTypeObject *)state->arguments_type;
10353
2.50k
    result = PyType_GenericNew(tp, NULL, NULL);
10354
2.50k
    if (!result) return NULL;
10355
2.50k
    value = ast2obj_list(state, (asdl_seq*)o->posonlyargs, ast2obj_arg);
10356
2.50k
    if (!value) goto failed;
10357
2.50k
    if (PyObject_SetAttr(result, state->posonlyargs, value) == -1)
10358
0
        goto failed;
10359
2.50k
    Py_DECREF(value);
10360
2.50k
    value = ast2obj_list(state, (asdl_seq*)o->args, ast2obj_arg);
10361
2.50k
    if (!value) goto failed;
10362
2.50k
    if (PyObject_SetAttr(result, state->args, value) == -1)
10363
0
        goto failed;
10364
2.50k
    Py_DECREF(value);
10365
2.50k
    value = ast2obj_arg(state, o->vararg);
10366
2.50k
    if (!value) goto failed;
10367
2.50k
    if (PyObject_SetAttr(result, state->vararg, value) == -1)
10368
0
        goto failed;
10369
2.50k
    Py_DECREF(value);
10370
2.50k
    value = ast2obj_list(state, (asdl_seq*)o->kwonlyargs, ast2obj_arg);
10371
2.50k
    if (!value) goto failed;
10372
2.50k
    if (PyObject_SetAttr(result, state->kwonlyargs, value) == -1)
10373
0
        goto failed;
10374
2.50k
    Py_DECREF(value);
10375
2.50k
    value = ast2obj_list(state, (asdl_seq*)o->kw_defaults, ast2obj_expr);
10376
2.50k
    if (!value) goto failed;
10377
2.50k
    if (PyObject_SetAttr(result, state->kw_defaults, value) == -1)
10378
0
        goto failed;
10379
2.50k
    Py_DECREF(value);
10380
2.50k
    value = ast2obj_arg(state, o->kwarg);
10381
2.50k
    if (!value) goto failed;
10382
2.50k
    if (PyObject_SetAttr(result, state->kwarg, value) == -1)
10383
0
        goto failed;
10384
2.50k
    Py_DECREF(value);
10385
2.50k
    value = ast2obj_list(state, (asdl_seq*)o->defaults, ast2obj_expr);
10386
2.50k
    if (!value) goto failed;
10387
2.50k
    if (PyObject_SetAttr(result, state->defaults, value) == -1)
10388
0
        goto failed;
10389
2.50k
    Py_DECREF(value);
10390
2.50k
    Py_LeaveRecursiveCall();
10391
2.50k
    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.50k
}
10398
10399
PyObject*
10400
ast2obj_arg(struct ast_state *state, void* _o)
10401
18.6k
{
10402
18.6k
    arg_ty o = (arg_ty)_o;
10403
18.6k
    PyObject *result = NULL, *value = NULL;
10404
18.6k
    PyTypeObject *tp;
10405
18.6k
    if (!o) {
10406
4.34k
        Py_RETURN_NONE;
10407
4.34k
    }
10408
14.3k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10409
0
        return NULL;
10410
0
    }
10411
14.3k
    tp = (PyTypeObject *)state->arg_type;
10412
14.3k
    result = PyType_GenericNew(tp, NULL, NULL);
10413
14.3k
    if (!result) return NULL;
10414
14.3k
    value = ast2obj_identifier(state, o->arg);
10415
14.3k
    if (!value) goto failed;
10416
14.3k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10417
0
        goto failed;
10418
14.3k
    Py_DECREF(value);
10419
14.3k
    value = ast2obj_expr(state, o->annotation);
10420
14.3k
    if (!value) goto failed;
10421
14.3k
    if (PyObject_SetAttr(result, state->annotation, value) == -1)
10422
0
        goto failed;
10423
14.3k
    Py_DECREF(value);
10424
14.3k
    value = ast2obj_string(state, o->type_comment);
10425
14.3k
    if (!value) goto failed;
10426
14.3k
    if (PyObject_SetAttr(result, state->type_comment, value) == -1)
10427
0
        goto failed;
10428
14.3k
    Py_DECREF(value);
10429
14.3k
    value = ast2obj_int(state, o->lineno);
10430
14.3k
    if (!value) goto failed;
10431
14.3k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10432
0
        goto failed;
10433
14.3k
    Py_DECREF(value);
10434
14.3k
    value = ast2obj_int(state, o->col_offset);
10435
14.3k
    if (!value) goto failed;
10436
14.3k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10437
0
        goto failed;
10438
14.3k
    Py_DECREF(value);
10439
14.3k
    value = ast2obj_int(state, o->end_lineno);
10440
14.3k
    if (!value) goto failed;
10441
14.3k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10442
0
        goto failed;
10443
14.3k
    Py_DECREF(value);
10444
14.3k
    value = ast2obj_int(state, o->end_col_offset);
10445
14.3k
    if (!value) goto failed;
10446
14.3k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10447
0
        goto failed;
10448
14.3k
    Py_DECREF(value);
10449
14.3k
    Py_LeaveRecursiveCall();
10450
14.3k
    return result;
10451
0
failed:
10452
0
    Py_LeaveRecursiveCall();
10453
0
    Py_XDECREF(value);
10454
0
    Py_XDECREF(result);
10455
0
    return NULL;
10456
14.3k
}
10457
10458
PyObject*
10459
ast2obj_keyword(struct ast_state *state, void* _o)
10460
2.30k
{
10461
2.30k
    keyword_ty o = (keyword_ty)_o;
10462
2.30k
    PyObject *result = NULL, *value = NULL;
10463
2.30k
    PyTypeObject *tp;
10464
2.30k
    if (!o) {
10465
0
        Py_RETURN_NONE;
10466
0
    }
10467
2.30k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10468
0
        return NULL;
10469
0
    }
10470
2.30k
    tp = (PyTypeObject *)state->keyword_type;
10471
2.30k
    result = PyType_GenericNew(tp, NULL, NULL);
10472
2.30k
    if (!result) return NULL;
10473
2.30k
    value = ast2obj_identifier(state, o->arg);
10474
2.30k
    if (!value) goto failed;
10475
2.30k
    if (PyObject_SetAttr(result, state->arg, value) == -1)
10476
0
        goto failed;
10477
2.30k
    Py_DECREF(value);
10478
2.30k
    value = ast2obj_expr(state, o->value);
10479
2.30k
    if (!value) goto failed;
10480
2.30k
    if (PyObject_SetAttr(result, state->value, value) == -1)
10481
0
        goto failed;
10482
2.30k
    Py_DECREF(value);
10483
2.30k
    value = ast2obj_int(state, o->lineno);
10484
2.30k
    if (!value) goto failed;
10485
2.30k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10486
0
        goto failed;
10487
2.30k
    Py_DECREF(value);
10488
2.30k
    value = ast2obj_int(state, o->col_offset);
10489
2.30k
    if (!value) goto failed;
10490
2.30k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10491
0
        goto failed;
10492
2.30k
    Py_DECREF(value);
10493
2.30k
    value = ast2obj_int(state, o->end_lineno);
10494
2.30k
    if (!value) goto failed;
10495
2.30k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10496
0
        goto failed;
10497
2.30k
    Py_DECREF(value);
10498
2.30k
    value = ast2obj_int(state, o->end_col_offset);
10499
2.30k
    if (!value) goto failed;
10500
2.30k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10501
0
        goto failed;
10502
2.30k
    Py_DECREF(value);
10503
2.30k
    Py_LeaveRecursiveCall();
10504
2.30k
    return result;
10505
0
failed:
10506
0
    Py_LeaveRecursiveCall();
10507
0
    Py_XDECREF(value);
10508
0
    Py_XDECREF(result);
10509
0
    return NULL;
10510
2.30k
}
10511
10512
PyObject*
10513
ast2obj_alias(struct ast_state *state, void* _o)
10514
3.86k
{
10515
3.86k
    alias_ty o = (alias_ty)_o;
10516
3.86k
    PyObject *result = NULL, *value = NULL;
10517
3.86k
    PyTypeObject *tp;
10518
3.86k
    if (!o) {
10519
0
        Py_RETURN_NONE;
10520
0
    }
10521
3.86k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10522
0
        return NULL;
10523
0
    }
10524
3.86k
    tp = (PyTypeObject *)state->alias_type;
10525
3.86k
    result = PyType_GenericNew(tp, NULL, NULL);
10526
3.86k
    if (!result) return NULL;
10527
3.86k
    value = ast2obj_identifier(state, o->name);
10528
3.86k
    if (!value) goto failed;
10529
3.86k
    if (PyObject_SetAttr(result, state->name, value) == -1)
10530
0
        goto failed;
10531
3.86k
    Py_DECREF(value);
10532
3.86k
    value = ast2obj_identifier(state, o->asname);
10533
3.86k
    if (!value) goto failed;
10534
3.86k
    if (PyObject_SetAttr(result, state->asname, value) == -1)
10535
0
        goto failed;
10536
3.86k
    Py_DECREF(value);
10537
3.86k
    value = ast2obj_int(state, o->lineno);
10538
3.86k
    if (!value) goto failed;
10539
3.86k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10540
0
        goto failed;
10541
3.86k
    Py_DECREF(value);
10542
3.86k
    value = ast2obj_int(state, o->col_offset);
10543
3.86k
    if (!value) goto failed;
10544
3.86k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10545
0
        goto failed;
10546
3.86k
    Py_DECREF(value);
10547
3.86k
    value = ast2obj_int(state, o->end_lineno);
10548
3.86k
    if (!value) goto failed;
10549
3.86k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10550
0
        goto failed;
10551
3.86k
    Py_DECREF(value);
10552
3.86k
    value = ast2obj_int(state, o->end_col_offset);
10553
3.86k
    if (!value) goto failed;
10554
3.86k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10555
0
        goto failed;
10556
3.86k
    Py_DECREF(value);
10557
3.86k
    Py_LeaveRecursiveCall();
10558
3.86k
    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.86k
}
10565
10566
PyObject*
10567
ast2obj_withitem(struct ast_state *state, void* _o)
10568
1.15k
{
10569
1.15k
    withitem_ty o = (withitem_ty)_o;
10570
1.15k
    PyObject *result = NULL, *value = NULL;
10571
1.15k
    PyTypeObject *tp;
10572
1.15k
    if (!o) {
10573
0
        Py_RETURN_NONE;
10574
0
    }
10575
1.15k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10576
0
        return NULL;
10577
0
    }
10578
1.15k
    tp = (PyTypeObject *)state->withitem_type;
10579
1.15k
    result = PyType_GenericNew(tp, NULL, NULL);
10580
1.15k
    if (!result) return NULL;
10581
1.15k
    value = ast2obj_expr(state, o->context_expr);
10582
1.15k
    if (!value) goto failed;
10583
1.15k
    if (PyObject_SetAttr(result, state->context_expr, value) == -1)
10584
0
        goto failed;
10585
1.15k
    Py_DECREF(value);
10586
1.15k
    value = ast2obj_expr(state, o->optional_vars);
10587
1.15k
    if (!value) goto failed;
10588
1.15k
    if (PyObject_SetAttr(result, state->optional_vars, value) == -1)
10589
0
        goto failed;
10590
1.15k
    Py_DECREF(value);
10591
1.15k
    Py_LeaveRecursiveCall();
10592
1.15k
    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.15k
}
10599
10600
PyObject*
10601
ast2obj_match_case(struct ast_state *state, void* _o)
10602
680
{
10603
680
    match_case_ty o = (match_case_ty)_o;
10604
680
    PyObject *result = NULL, *value = NULL;
10605
680
    PyTypeObject *tp;
10606
680
    if (!o) {
10607
0
        Py_RETURN_NONE;
10608
0
    }
10609
680
    if (Py_EnterRecursiveCall("during  ast construction")) {
10610
0
        return NULL;
10611
0
    }
10612
680
    tp = (PyTypeObject *)state->match_case_type;
10613
680
    result = PyType_GenericNew(tp, NULL, NULL);
10614
680
    if (!result) return NULL;
10615
680
    value = ast2obj_pattern(state, o->pattern);
10616
680
    if (!value) goto failed;
10617
680
    if (PyObject_SetAttr(result, state->pattern, value) == -1)
10618
0
        goto failed;
10619
680
    Py_DECREF(value);
10620
680
    value = ast2obj_expr(state, o->guard);
10621
680
    if (!value) goto failed;
10622
680
    if (PyObject_SetAttr(result, state->guard, value) == -1)
10623
0
        goto failed;
10624
680
    Py_DECREF(value);
10625
680
    value = ast2obj_list(state, (asdl_seq*)o->body, ast2obj_stmt);
10626
680
    if (!value) goto failed;
10627
680
    if (PyObject_SetAttr(result, state->body, value) == -1)
10628
0
        goto failed;
10629
680
    Py_DECREF(value);
10630
680
    Py_LeaveRecursiveCall();
10631
680
    return result;
10632
0
failed:
10633
0
    Py_LeaveRecursiveCall();
10634
0
    Py_XDECREF(value);
10635
0
    Py_XDECREF(result);
10636
0
    return NULL;
10637
680
}
10638
10639
PyObject*
10640
ast2obj_pattern(struct ast_state *state, void* _o)
10641
22.2k
{
10642
22.2k
    pattern_ty o = (pattern_ty)_o;
10643
22.2k
    PyObject *result = NULL, *value = NULL;
10644
22.2k
    PyTypeObject *tp;
10645
22.2k
    if (!o) {
10646
8.59k
        Py_RETURN_NONE;
10647
8.59k
    }
10648
13.6k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10649
0
        return NULL;
10650
0
    }
10651
13.6k
    switch (o->kind) {
10652
369
    case MatchValue_kind:
10653
369
        tp = (PyTypeObject *)state->MatchValue_type;
10654
369
        result = PyType_GenericNew(tp, NULL, NULL);
10655
369
        if (!result) goto failed;
10656
369
        value = ast2obj_expr(state, o->v.MatchValue.value);
10657
369
        if (!value) goto failed;
10658
369
        if (PyObject_SetAttr(result, state->value, value) == -1)
10659
0
            goto failed;
10660
369
        Py_DECREF(value);
10661
369
        break;
10662
202
    case MatchSingleton_kind:
10663
202
        tp = (PyTypeObject *)state->MatchSingleton_type;
10664
202
        result = PyType_GenericNew(tp, NULL, NULL);
10665
202
        if (!result) goto failed;
10666
202
        value = ast2obj_constant(state, o->v.MatchSingleton.value);
10667
202
        if (!value) goto failed;
10668
202
        if (PyObject_SetAttr(result, state->value, value) == -1)
10669
0
            goto failed;
10670
202
        Py_DECREF(value);
10671
202
        break;
10672
455
    case MatchSequence_kind:
10673
455
        tp = (PyTypeObject *)state->MatchSequence_type;
10674
455
        result = PyType_GenericNew(tp, NULL, NULL);
10675
455
        if (!result) goto failed;
10676
455
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchSequence.patterns,
10677
455
                             ast2obj_pattern);
10678
455
        if (!value) goto failed;
10679
455
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10680
0
            goto failed;
10681
455
        Py_DECREF(value);
10682
455
        break;
10683
246
    case MatchMapping_kind:
10684
246
        tp = (PyTypeObject *)state->MatchMapping_type;
10685
246
        result = PyType_GenericNew(tp, NULL, NULL);
10686
246
        if (!result) goto failed;
10687
246
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.keys,
10688
246
                             ast2obj_expr);
10689
246
        if (!value) goto failed;
10690
246
        if (PyObject_SetAttr(result, state->keys, value) == -1)
10691
0
            goto failed;
10692
246
        Py_DECREF(value);
10693
246
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchMapping.patterns,
10694
246
                             ast2obj_pattern);
10695
246
        if (!value) goto failed;
10696
246
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10697
0
            goto failed;
10698
246
        Py_DECREF(value);
10699
246
        value = ast2obj_identifier(state, o->v.MatchMapping.rest);
10700
246
        if (!value) goto failed;
10701
246
        if (PyObject_SetAttr(result, state->rest, value) == -1)
10702
0
            goto failed;
10703
246
        Py_DECREF(value);
10704
246
        break;
10705
913
    case MatchClass_kind:
10706
913
        tp = (PyTypeObject *)state->MatchClass_type;
10707
913
        result = PyType_GenericNew(tp, NULL, NULL);
10708
913
        if (!result) goto failed;
10709
913
        value = ast2obj_expr(state, o->v.MatchClass.cls);
10710
913
        if (!value) goto failed;
10711
913
        if (PyObject_SetAttr(result, state->cls, value) == -1)
10712
0
            goto failed;
10713
913
        Py_DECREF(value);
10714
913
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.patterns,
10715
913
                             ast2obj_pattern);
10716
913
        if (!value) goto failed;
10717
913
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10718
0
            goto failed;
10719
913
        Py_DECREF(value);
10720
913
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_attrs,
10721
913
                             ast2obj_identifier);
10722
913
        if (!value) goto failed;
10723
913
        if (PyObject_SetAttr(result, state->kwd_attrs, value) == -1)
10724
0
            goto failed;
10725
913
        Py_DECREF(value);
10726
913
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchClass.kwd_patterns,
10727
913
                             ast2obj_pattern);
10728
913
        if (!value) goto failed;
10729
913
        if (PyObject_SetAttr(result, state->kwd_patterns, value) == -1)
10730
0
            goto failed;
10731
913
        Py_DECREF(value);
10732
913
        break;
10733
261
    case MatchStar_kind:
10734
261
        tp = (PyTypeObject *)state->MatchStar_type;
10735
261
        result = PyType_GenericNew(tp, NULL, NULL);
10736
261
        if (!result) goto failed;
10737
261
        value = ast2obj_identifier(state, o->v.MatchStar.name);
10738
261
        if (!value) goto failed;
10739
261
        if (PyObject_SetAttr(result, state->name, value) == -1)
10740
0
            goto failed;
10741
261
        Py_DECREF(value);
10742
261
        break;
10743
8.65k
    case MatchAs_kind:
10744
8.65k
        tp = (PyTypeObject *)state->MatchAs_type;
10745
8.65k
        result = PyType_GenericNew(tp, NULL, NULL);
10746
8.65k
        if (!result) goto failed;
10747
8.65k
        value = ast2obj_pattern(state, o->v.MatchAs.pattern);
10748
8.65k
        if (!value) goto failed;
10749
8.65k
        if (PyObject_SetAttr(result, state->pattern, value) == -1)
10750
0
            goto failed;
10751
8.65k
        Py_DECREF(value);
10752
8.65k
        value = ast2obj_identifier(state, o->v.MatchAs.name);
10753
8.65k
        if (!value) goto failed;
10754
8.65k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10755
0
            goto failed;
10756
8.65k
        Py_DECREF(value);
10757
8.65k
        break;
10758
2.60k
    case MatchOr_kind:
10759
2.60k
        tp = (PyTypeObject *)state->MatchOr_type;
10760
2.60k
        result = PyType_GenericNew(tp, NULL, NULL);
10761
2.60k
        if (!result) goto failed;
10762
2.60k
        value = ast2obj_list(state, (asdl_seq*)o->v.MatchOr.patterns,
10763
2.60k
                             ast2obj_pattern);
10764
2.60k
        if (!value) goto failed;
10765
2.60k
        if (PyObject_SetAttr(result, state->patterns, value) == -1)
10766
0
            goto failed;
10767
2.60k
        Py_DECREF(value);
10768
2.60k
        break;
10769
13.6k
    }
10770
13.6k
    value = ast2obj_int(state, o->lineno);
10771
13.6k
    if (!value) goto failed;
10772
13.6k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10773
0
        goto failed;
10774
13.6k
    Py_DECREF(value);
10775
13.6k
    value = ast2obj_int(state, o->col_offset);
10776
13.6k
    if (!value) goto failed;
10777
13.6k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10778
0
        goto failed;
10779
13.6k
    Py_DECREF(value);
10780
13.6k
    value = ast2obj_int(state, o->end_lineno);
10781
13.6k
    if (!value) goto failed;
10782
13.6k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10783
0
        goto failed;
10784
13.6k
    Py_DECREF(value);
10785
13.6k
    value = ast2obj_int(state, o->end_col_offset);
10786
13.6k
    if (!value) goto failed;
10787
13.6k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10788
0
        goto failed;
10789
13.6k
    Py_DECREF(value);
10790
13.6k
    Py_LeaveRecursiveCall();
10791
13.6k
    return result;
10792
0
failed:
10793
0
    Py_LeaveRecursiveCall();
10794
0
    Py_XDECREF(value);
10795
0
    Py_XDECREF(result);
10796
0
    return NULL;
10797
13.6k
}
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
5.92k
{
10840
5.92k
    type_param_ty o = (type_param_ty)_o;
10841
5.92k
    PyObject *result = NULL, *value = NULL;
10842
5.92k
    PyTypeObject *tp;
10843
5.92k
    if (!o) {
10844
0
        Py_RETURN_NONE;
10845
0
    }
10846
5.92k
    if (Py_EnterRecursiveCall("during  ast construction")) {
10847
0
        return NULL;
10848
0
    }
10849
5.92k
    switch (o->kind) {
10850
4.61k
    case TypeVar_kind:
10851
4.61k
        tp = (PyTypeObject *)state->TypeVar_type;
10852
4.61k
        result = PyType_GenericNew(tp, NULL, NULL);
10853
4.61k
        if (!result) goto failed;
10854
4.61k
        value = ast2obj_identifier(state, o->v.TypeVar.name);
10855
4.61k
        if (!value) goto failed;
10856
4.61k
        if (PyObject_SetAttr(result, state->name, value) == -1)
10857
0
            goto failed;
10858
4.61k
        Py_DECREF(value);
10859
4.61k
        value = ast2obj_expr(state, o->v.TypeVar.bound);
10860
4.61k
        if (!value) goto failed;
10861
4.61k
        if (PyObject_SetAttr(result, state->bound, value) == -1)
10862
0
            goto failed;
10863
4.61k
        Py_DECREF(value);
10864
4.61k
        value = ast2obj_expr(state, o->v.TypeVar.default_value);
10865
4.61k
        if (!value) goto failed;
10866
4.61k
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10867
0
            goto failed;
10868
4.61k
        Py_DECREF(value);
10869
4.61k
        break;
10870
410
    case ParamSpec_kind:
10871
410
        tp = (PyTypeObject *)state->ParamSpec_type;
10872
410
        result = PyType_GenericNew(tp, NULL, NULL);
10873
410
        if (!result) goto failed;
10874
410
        value = ast2obj_identifier(state, o->v.ParamSpec.name);
10875
410
        if (!value) goto failed;
10876
410
        if (PyObject_SetAttr(result, state->name, value) == -1)
10877
0
            goto failed;
10878
410
        Py_DECREF(value);
10879
410
        value = ast2obj_expr(state, o->v.ParamSpec.default_value);
10880
410
        if (!value) goto failed;
10881
410
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10882
0
            goto failed;
10883
410
        Py_DECREF(value);
10884
410
        break;
10885
904
    case TypeVarTuple_kind:
10886
904
        tp = (PyTypeObject *)state->TypeVarTuple_type;
10887
904
        result = PyType_GenericNew(tp, NULL, NULL);
10888
904
        if (!result) goto failed;
10889
904
        value = ast2obj_identifier(state, o->v.TypeVarTuple.name);
10890
904
        if (!value) goto failed;
10891
904
        if (PyObject_SetAttr(result, state->name, value) == -1)
10892
0
            goto failed;
10893
904
        Py_DECREF(value);
10894
904
        value = ast2obj_expr(state, o->v.TypeVarTuple.default_value);
10895
904
        if (!value) goto failed;
10896
904
        if (PyObject_SetAttr(result, state->default_value, value) == -1)
10897
0
            goto failed;
10898
904
        Py_DECREF(value);
10899
904
        break;
10900
5.92k
    }
10901
5.92k
    value = ast2obj_int(state, o->lineno);
10902
5.92k
    if (!value) goto failed;
10903
5.92k
    if (PyObject_SetAttr(result, state->lineno, value) < 0)
10904
0
        goto failed;
10905
5.92k
    Py_DECREF(value);
10906
5.92k
    value = ast2obj_int(state, o->col_offset);
10907
5.92k
    if (!value) goto failed;
10908
5.92k
    if (PyObject_SetAttr(result, state->col_offset, value) < 0)
10909
0
        goto failed;
10910
5.92k
    Py_DECREF(value);
10911
5.92k
    value = ast2obj_int(state, o->end_lineno);
10912
5.92k
    if (!value) goto failed;
10913
5.92k
    if (PyObject_SetAttr(result, state->end_lineno, value) < 0)
10914
0
        goto failed;
10915
5.92k
    Py_DECREF(value);
10916
5.92k
    value = ast2obj_int(state, o->end_col_offset);
10917
5.92k
    if (!value) goto failed;
10918
5.92k
    if (PyObject_SetAttr(result, state->end_col_offset, value) < 0)
10919
0
        goto failed;
10920
5.92k
    Py_DECREF(value);
10921
5.92k
    Py_LeaveRecursiveCall();
10922
5.92k
    return result;
10923
0
failed:
10924
0
    Py_LeaveRecursiveCall();
10925
0
    Py_XDECREF(value);
10926
0
    Py_XDECREF(result);
10927
0
    return NULL;
10928
5.92k
}
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
8
{
18072
8
    struct ast_state *state = get_ast_state();
18073
8
    if (state == NULL) {
18074
0
        return -1;
18075
0
    }
18076
8
    if (PyModule_AddObjectRef(m, "AST", state->AST_type) < 0) {
18077
0
        return -1;
18078
0
    }
18079
8
    if (PyModule_AddIntMacro(m, PyCF_ALLOW_TOP_LEVEL_AWAIT) < 0) {
18080
0
        return -1;
18081
0
    }
18082
8
    if (PyModule_AddIntMacro(m, PyCF_ONLY_AST) < 0) {
18083
0
        return -1;
18084
0
    }
18085
8
    if (PyModule_AddIntMacro(m, PyCF_TYPE_COMMENTS) < 0) {
18086
0
        return -1;
18087
0
    }
18088
8
    if (PyModule_AddIntMacro(m, PyCF_OPTIMIZED_AST) < 0) {
18089
0
        return -1;
18090
0
    }
18091
8
    if (PyModule_AddObjectRef(m, "mod", state->mod_type) < 0) {
18092
0
        return -1;
18093
0
    }
18094
8
    if (PyModule_AddObjectRef(m, "Module", state->Module_type) < 0) {
18095
0
        return -1;
18096
0
    }
18097
8
    if (PyModule_AddObjectRef(m, "Interactive", state->Interactive_type) < 0) {
18098
0
        return -1;
18099
0
    }
18100
8
    if (PyModule_AddObjectRef(m, "Expression", state->Expression_type) < 0) {
18101
0
        return -1;
18102
0
    }
18103
8
    if (PyModule_AddObjectRef(m, "FunctionType", state->FunctionType_type) < 0)
18104
0
        {
18105
0
        return -1;
18106
0
    }
18107
8
    if (PyModule_AddObjectRef(m, "stmt", state->stmt_type) < 0) {
18108
0
        return -1;
18109
0
    }
18110
8
    if (PyModule_AddObjectRef(m, "FunctionDef", state->FunctionDef_type) < 0) {
18111
0
        return -1;
18112
0
    }
18113
8
    if (PyModule_AddObjectRef(m, "AsyncFunctionDef",
18114
8
        state->AsyncFunctionDef_type) < 0) {
18115
0
        return -1;
18116
0
    }
18117
8
    if (PyModule_AddObjectRef(m, "ClassDef", state->ClassDef_type) < 0) {
18118
0
        return -1;
18119
0
    }
18120
8
    if (PyModule_AddObjectRef(m, "Return", state->Return_type) < 0) {
18121
0
        return -1;
18122
0
    }
18123
8
    if (PyModule_AddObjectRef(m, "Delete", state->Delete_type) < 0) {
18124
0
        return -1;
18125
0
    }
18126
8
    if (PyModule_AddObjectRef(m, "Assign", state->Assign_type) < 0) {
18127
0
        return -1;
18128
0
    }
18129
8
    if (PyModule_AddObjectRef(m, "TypeAlias", state->TypeAlias_type) < 0) {
18130
0
        return -1;
18131
0
    }
18132
8
    if (PyModule_AddObjectRef(m, "AugAssign", state->AugAssign_type) < 0) {
18133
0
        return -1;
18134
0
    }
18135
8
    if (PyModule_AddObjectRef(m, "AnnAssign", state->AnnAssign_type) < 0) {
18136
0
        return -1;
18137
0
    }
18138
8
    if (PyModule_AddObjectRef(m, "For", state->For_type) < 0) {
18139
0
        return -1;
18140
0
    }
18141
8
    if (PyModule_AddObjectRef(m, "AsyncFor", state->AsyncFor_type) < 0) {
18142
0
        return -1;
18143
0
    }
18144
8
    if (PyModule_AddObjectRef(m, "While", state->While_type) < 0) {
18145
0
        return -1;
18146
0
    }
18147
8
    if (PyModule_AddObjectRef(m, "If", state->If_type) < 0) {
18148
0
        return -1;
18149
0
    }
18150
8
    if (PyModule_AddObjectRef(m, "With", state->With_type) < 0) {
18151
0
        return -1;
18152
0
    }
18153
8
    if (PyModule_AddObjectRef(m, "AsyncWith", state->AsyncWith_type) < 0) {
18154
0
        return -1;
18155
0
    }
18156
8
    if (PyModule_AddObjectRef(m, "Match", state->Match_type) < 0) {
18157
0
        return -1;
18158
0
    }
18159
8
    if (PyModule_AddObjectRef(m, "Raise", state->Raise_type) < 0) {
18160
0
        return -1;
18161
0
    }
18162
8
    if (PyModule_AddObjectRef(m, "Try", state->Try_type) < 0) {
18163
0
        return -1;
18164
0
    }
18165
8
    if (PyModule_AddObjectRef(m, "TryStar", state->TryStar_type) < 0) {
18166
0
        return -1;
18167
0
    }
18168
8
    if (PyModule_AddObjectRef(m, "Assert", state->Assert_type) < 0) {
18169
0
        return -1;
18170
0
    }
18171
8
    if (PyModule_AddObjectRef(m, "Import", state->Import_type) < 0) {
18172
0
        return -1;
18173
0
    }
18174
8
    if (PyModule_AddObjectRef(m, "ImportFrom", state->ImportFrom_type) < 0) {
18175
0
        return -1;
18176
0
    }
18177
8
    if (PyModule_AddObjectRef(m, "Global", state->Global_type) < 0) {
18178
0
        return -1;
18179
0
    }
18180
8
    if (PyModule_AddObjectRef(m, "Nonlocal", state->Nonlocal_type) < 0) {
18181
0
        return -1;
18182
0
    }
18183
8
    if (PyModule_AddObjectRef(m, "Expr", state->Expr_type) < 0) {
18184
0
        return -1;
18185
0
    }
18186
8
    if (PyModule_AddObjectRef(m, "Pass", state->Pass_type) < 0) {
18187
0
        return -1;
18188
0
    }
18189
8
    if (PyModule_AddObjectRef(m, "Break", state->Break_type) < 0) {
18190
0
        return -1;
18191
0
    }
18192
8
    if (PyModule_AddObjectRef(m, "Continue", state->Continue_type) < 0) {
18193
0
        return -1;
18194
0
    }
18195
8
    if (PyModule_AddObjectRef(m, "expr", state->expr_type) < 0) {
18196
0
        return -1;
18197
0
    }
18198
8
    if (PyModule_AddObjectRef(m, "BoolOp", state->BoolOp_type) < 0) {
18199
0
        return -1;
18200
0
    }
18201
8
    if (PyModule_AddObjectRef(m, "NamedExpr", state->NamedExpr_type) < 0) {
18202
0
        return -1;
18203
0
    }
18204
8
    if (PyModule_AddObjectRef(m, "BinOp", state->BinOp_type) < 0) {
18205
0
        return -1;
18206
0
    }
18207
8
    if (PyModule_AddObjectRef(m, "UnaryOp", state->UnaryOp_type) < 0) {
18208
0
        return -1;
18209
0
    }
18210
8
    if (PyModule_AddObjectRef(m, "Lambda", state->Lambda_type) < 0) {
18211
0
        return -1;
18212
0
    }
18213
8
    if (PyModule_AddObjectRef(m, "IfExp", state->IfExp_type) < 0) {
18214
0
        return -1;
18215
0
    }
18216
8
    if (PyModule_AddObjectRef(m, "Dict", state->Dict_type) < 0) {
18217
0
        return -1;
18218
0
    }
18219
8
    if (PyModule_AddObjectRef(m, "Set", state->Set_type) < 0) {
18220
0
        return -1;
18221
0
    }
18222
8
    if (PyModule_AddObjectRef(m, "ListComp", state->ListComp_type) < 0) {
18223
0
        return -1;
18224
0
    }
18225
8
    if (PyModule_AddObjectRef(m, "SetComp", state->SetComp_type) < 0) {
18226
0
        return -1;
18227
0
    }
18228
8
    if (PyModule_AddObjectRef(m, "DictComp", state->DictComp_type) < 0) {
18229
0
        return -1;
18230
0
    }
18231
8
    if (PyModule_AddObjectRef(m, "GeneratorExp", state->GeneratorExp_type) < 0)
18232
0
        {
18233
0
        return -1;
18234
0
    }
18235
8
    if (PyModule_AddObjectRef(m, "Await", state->Await_type) < 0) {
18236
0
        return -1;
18237
0
    }
18238
8
    if (PyModule_AddObjectRef(m, "Yield", state->Yield_type) < 0) {
18239
0
        return -1;
18240
0
    }
18241
8
    if (PyModule_AddObjectRef(m, "YieldFrom", state->YieldFrom_type) < 0) {
18242
0
        return -1;
18243
0
    }
18244
8
    if (PyModule_AddObjectRef(m, "Compare", state->Compare_type) < 0) {
18245
0
        return -1;
18246
0
    }
18247
8
    if (PyModule_AddObjectRef(m, "Call", state->Call_type) < 0) {
18248
0
        return -1;
18249
0
    }
18250
8
    if (PyModule_AddObjectRef(m, "FormattedValue", state->FormattedValue_type)
18251
8
        < 0) {
18252
0
        return -1;
18253
0
    }
18254
8
    if (PyModule_AddObjectRef(m, "Interpolation", state->Interpolation_type) <
18255
8
        0) {
18256
0
        return -1;
18257
0
    }
18258
8
    if (PyModule_AddObjectRef(m, "JoinedStr", state->JoinedStr_type) < 0) {
18259
0
        return -1;
18260
0
    }
18261
8
    if (PyModule_AddObjectRef(m, "TemplateStr", state->TemplateStr_type) < 0) {
18262
0
        return -1;
18263
0
    }
18264
8
    if (PyModule_AddObjectRef(m, "Constant", state->Constant_type) < 0) {
18265
0
        return -1;
18266
0
    }
18267
8
    if (PyModule_AddObjectRef(m, "Attribute", state->Attribute_type) < 0) {
18268
0
        return -1;
18269
0
    }
18270
8
    if (PyModule_AddObjectRef(m, "Subscript", state->Subscript_type) < 0) {
18271
0
        return -1;
18272
0
    }
18273
8
    if (PyModule_AddObjectRef(m, "Starred", state->Starred_type) < 0) {
18274
0
        return -1;
18275
0
    }
18276
8
    if (PyModule_AddObjectRef(m, "Name", state->Name_type) < 0) {
18277
0
        return -1;
18278
0
    }
18279
8
    if (PyModule_AddObjectRef(m, "List", state->List_type) < 0) {
18280
0
        return -1;
18281
0
    }
18282
8
    if (PyModule_AddObjectRef(m, "Tuple", state->Tuple_type) < 0) {
18283
0
        return -1;
18284
0
    }
18285
8
    if (PyModule_AddObjectRef(m, "Slice", state->Slice_type) < 0) {
18286
0
        return -1;
18287
0
    }
18288
8
    if (PyModule_AddObjectRef(m, "expr_context", state->expr_context_type) < 0)
18289
0
        {
18290
0
        return -1;
18291
0
    }
18292
8
    if (PyModule_AddObjectRef(m, "Load", state->Load_type) < 0) {
18293
0
        return -1;
18294
0
    }
18295
8
    if (PyModule_AddObjectRef(m, "Store", state->Store_type) < 0) {
18296
0
        return -1;
18297
0
    }
18298
8
    if (PyModule_AddObjectRef(m, "Del", state->Del_type) < 0) {
18299
0
        return -1;
18300
0
    }
18301
8
    if (PyModule_AddObjectRef(m, "boolop", state->boolop_type) < 0) {
18302
0
        return -1;
18303
0
    }
18304
8
    if (PyModule_AddObjectRef(m, "And", state->And_type) < 0) {
18305
0
        return -1;
18306
0
    }
18307
8
    if (PyModule_AddObjectRef(m, "Or", state->Or_type) < 0) {
18308
0
        return -1;
18309
0
    }
18310
8
    if (PyModule_AddObjectRef(m, "operator", state->operator_type) < 0) {
18311
0
        return -1;
18312
0
    }
18313
8
    if (PyModule_AddObjectRef(m, "Add", state->Add_type) < 0) {
18314
0
        return -1;
18315
0
    }
18316
8
    if (PyModule_AddObjectRef(m, "Sub", state->Sub_type) < 0) {
18317
0
        return -1;
18318
0
    }
18319
8
    if (PyModule_AddObjectRef(m, "Mult", state->Mult_type) < 0) {
18320
0
        return -1;
18321
0
    }
18322
8
    if (PyModule_AddObjectRef(m, "MatMult", state->MatMult_type) < 0) {
18323
0
        return -1;
18324
0
    }
18325
8
    if (PyModule_AddObjectRef(m, "Div", state->Div_type) < 0) {
18326
0
        return -1;
18327
0
    }
18328
8
    if (PyModule_AddObjectRef(m, "Mod", state->Mod_type) < 0) {
18329
0
        return -1;
18330
0
    }
18331
8
    if (PyModule_AddObjectRef(m, "Pow", state->Pow_type) < 0) {
18332
0
        return -1;
18333
0
    }
18334
8
    if (PyModule_AddObjectRef(m, "LShift", state->LShift_type) < 0) {
18335
0
        return -1;
18336
0
    }
18337
8
    if (PyModule_AddObjectRef(m, "RShift", state->RShift_type) < 0) {
18338
0
        return -1;
18339
0
    }
18340
8
    if (PyModule_AddObjectRef(m, "BitOr", state->BitOr_type) < 0) {
18341
0
        return -1;
18342
0
    }
18343
8
    if (PyModule_AddObjectRef(m, "BitXor", state->BitXor_type) < 0) {
18344
0
        return -1;
18345
0
    }
18346
8
    if (PyModule_AddObjectRef(m, "BitAnd", state->BitAnd_type) < 0) {
18347
0
        return -1;
18348
0
    }
18349
8
    if (PyModule_AddObjectRef(m, "FloorDiv", state->FloorDiv_type) < 0) {
18350
0
        return -1;
18351
0
    }
18352
8
    if (PyModule_AddObjectRef(m, "unaryop", state->unaryop_type) < 0) {
18353
0
        return -1;
18354
0
    }
18355
8
    if (PyModule_AddObjectRef(m, "Invert", state->Invert_type) < 0) {
18356
0
        return -1;
18357
0
    }
18358
8
    if (PyModule_AddObjectRef(m, "Not", state->Not_type) < 0) {
18359
0
        return -1;
18360
0
    }
18361
8
    if (PyModule_AddObjectRef(m, "UAdd", state->UAdd_type) < 0) {
18362
0
        return -1;
18363
0
    }
18364
8
    if (PyModule_AddObjectRef(m, "USub", state->USub_type) < 0) {
18365
0
        return -1;
18366
0
    }
18367
8
    if (PyModule_AddObjectRef(m, "cmpop", state->cmpop_type) < 0) {
18368
0
        return -1;
18369
0
    }
18370
8
    if (PyModule_AddObjectRef(m, "Eq", state->Eq_type) < 0) {
18371
0
        return -1;
18372
0
    }
18373
8
    if (PyModule_AddObjectRef(m, "NotEq", state->NotEq_type) < 0) {
18374
0
        return -1;
18375
0
    }
18376
8
    if (PyModule_AddObjectRef(m, "Lt", state->Lt_type) < 0) {
18377
0
        return -1;
18378
0
    }
18379
8
    if (PyModule_AddObjectRef(m, "LtE", state->LtE_type) < 0) {
18380
0
        return -1;
18381
0
    }
18382
8
    if (PyModule_AddObjectRef(m, "Gt", state->Gt_type) < 0) {
18383
0
        return -1;
18384
0
    }
18385
8
    if (PyModule_AddObjectRef(m, "GtE", state->GtE_type) < 0) {
18386
0
        return -1;
18387
0
    }
18388
8
    if (PyModule_AddObjectRef(m, "Is", state->Is_type) < 0) {
18389
0
        return -1;
18390
0
    }
18391
8
    if (PyModule_AddObjectRef(m, "IsNot", state->IsNot_type) < 0) {
18392
0
        return -1;
18393
0
    }
18394
8
    if (PyModule_AddObjectRef(m, "In", state->In_type) < 0) {
18395
0
        return -1;
18396
0
    }
18397
8
    if (PyModule_AddObjectRef(m, "NotIn", state->NotIn_type) < 0) {
18398
0
        return -1;
18399
0
    }
18400
8
    if (PyModule_AddObjectRef(m, "comprehension", state->comprehension_type) <
18401
8
        0) {
18402
0
        return -1;
18403
0
    }
18404
8
    if (PyModule_AddObjectRef(m, "excepthandler", state->excepthandler_type) <
18405
8
        0) {
18406
0
        return -1;
18407
0
    }
18408
8
    if (PyModule_AddObjectRef(m, "ExceptHandler", state->ExceptHandler_type) <
18409
8
        0) {
18410
0
        return -1;
18411
0
    }
18412
8
    if (PyModule_AddObjectRef(m, "arguments", state->arguments_type) < 0) {
18413
0
        return -1;
18414
0
    }
18415
8
    if (PyModule_AddObjectRef(m, "arg", state->arg_type) < 0) {
18416
0
        return -1;
18417
0
    }
18418
8
    if (PyModule_AddObjectRef(m, "keyword", state->keyword_type) < 0) {
18419
0
        return -1;
18420
0
    }
18421
8
    if (PyModule_AddObjectRef(m, "alias", state->alias_type) < 0) {
18422
0
        return -1;
18423
0
    }
18424
8
    if (PyModule_AddObjectRef(m, "withitem", state->withitem_type) < 0) {
18425
0
        return -1;
18426
0
    }
18427
8
    if (PyModule_AddObjectRef(m, "match_case", state->match_case_type) < 0) {
18428
0
        return -1;
18429
0
    }
18430
8
    if (PyModule_AddObjectRef(m, "pattern", state->pattern_type) < 0) {
18431
0
        return -1;
18432
0
    }
18433
8
    if (PyModule_AddObjectRef(m, "MatchValue", state->MatchValue_type) < 0) {
18434
0
        return -1;
18435
0
    }
18436
8
    if (PyModule_AddObjectRef(m, "MatchSingleton", state->MatchSingleton_type)
18437
8
        < 0) {
18438
0
        return -1;
18439
0
    }
18440
8
    if (PyModule_AddObjectRef(m, "MatchSequence", state->MatchSequence_type) <
18441
8
        0) {
18442
0
        return -1;
18443
0
    }
18444
8
    if (PyModule_AddObjectRef(m, "MatchMapping", state->MatchMapping_type) < 0)
18445
0
        {
18446
0
        return -1;
18447
0
    }
18448
8
    if (PyModule_AddObjectRef(m, "MatchClass", state->MatchClass_type) < 0) {
18449
0
        return -1;
18450
0
    }
18451
8
    if (PyModule_AddObjectRef(m, "MatchStar", state->MatchStar_type) < 0) {
18452
0
        return -1;
18453
0
    }
18454
8
    if (PyModule_AddObjectRef(m, "MatchAs", state->MatchAs_type) < 0) {
18455
0
        return -1;
18456
0
    }
18457
8
    if (PyModule_AddObjectRef(m, "MatchOr", state->MatchOr_type) < 0) {
18458
0
        return -1;
18459
0
    }
18460
8
    if (PyModule_AddObjectRef(m, "type_ignore", state->type_ignore_type) < 0) {
18461
0
        return -1;
18462
0
    }
18463
8
    if (PyModule_AddObjectRef(m, "TypeIgnore", state->TypeIgnore_type) < 0) {
18464
0
        return -1;
18465
0
    }
18466
8
    if (PyModule_AddObjectRef(m, "type_param", state->type_param_type) < 0) {
18467
0
        return -1;
18468
0
    }
18469
8
    if (PyModule_AddObjectRef(m, "TypeVar", state->TypeVar_type) < 0) {
18470
0
        return -1;
18471
0
    }
18472
8
    if (PyModule_AddObjectRef(m, "ParamSpec", state->ParamSpec_type) < 0) {
18473
0
        return -1;
18474
0
    }
18475
8
    if (PyModule_AddObjectRef(m, "TypeVarTuple", state->TypeVarTuple_type) < 0)
18476
0
        {
18477
0
        return -1;
18478
0
    }
18479
8
    return 0;
18480
8
}
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
8
{
18500
8
    return PyModuleDef_Init(&_astmodule);
18501
8
}
18502
18503
18504
PyObject* PyAST_mod2obj(mod_ty t)
18505
5.58k
{
18506
5.58k
    struct ast_state *state = get_ast_state();
18507
5.58k
    if (state == NULL) {
18508
0
        return NULL;
18509
0
    }
18510
5.58k
    PyObject *result = ast2obj_mod(state, t);
18511
18512
5.58k
    return result;
18513
5.58k
}
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
92.1k
{
18567
92.1k
    struct ast_state *state = get_ast_state();
18568
92.1k
    if (state == NULL) {
18569
0
        return -1;
18570
0
    }
18571
92.1k
    return PyObject_IsInstance(obj, state->AST_type);
18572
92.1k
}
18573
18574