Coverage Report

Created: 2026-03-08 06:40

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